Brad Bishop | 3d57f50 | 2016-10-19 12:18:41 -0400 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brad Bishop | c1f4798 | 2017-02-09 01:27:38 -0500 | [diff] [blame^] | 3 | #include "types.hpp" |
Brad Bishop | 3d57f50 | 2016-10-19 12:18:41 -0400 | [diff] [blame] | 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace inventory |
| 8 | { |
| 9 | namespace manager |
| 10 | { |
Brad Bishop | c0eae11 | 2016-10-19 21:59:47 -0400 | [diff] [blame] | 11 | |
| 12 | class Manager; |
Brad Bishop | 65ffffa | 2016-11-29 12:31:31 -0500 | [diff] [blame] | 13 | |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 14 | /** @struct Event |
| 15 | * @brief Event object interface. |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 16 | * |
| 17 | * The event base is an assocation of an event type |
| 18 | * and an array of filter callbacks. |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 19 | */ |
Brad Bishop | 07934a6 | 2017-02-08 23:34:59 -0500 | [diff] [blame] | 20 | struct Event : public std::vector<Filter> |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 21 | { |
| 22 | enum class Type |
| 23 | { |
| 24 | DBUS_SIGNAL, |
Brad Bishop | 3e4a19a | 2017-01-21 22:17:09 -0500 | [diff] [blame] | 25 | STARTUP, |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | virtual ~Event() = default; |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 29 | Event(const Event&) = delete; |
| 30 | Event& operator=(const Event&) = delete; |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 31 | Event(Event&&) = default; |
| 32 | Event& operator=(Event&&) = default; |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 33 | |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 34 | /** @brief Event constructor. |
| 35 | * |
| 36 | * @param[in] filters - An array of filter callbacks. |
| 37 | * @param[in] t - The event type. |
| 38 | */ |
| 39 | explicit Event( |
Brad Bishop | 07934a6 | 2017-02-08 23:34:59 -0500 | [diff] [blame] | 40 | const std::vector<Filter>& filters, Type t = Type::STARTUP) : |
| 41 | std::vector<Filter>(filters), |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 42 | type(t) {} |
| 43 | |
| 44 | /** @brief event class enumeration. */ |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 45 | Type type; |
| 46 | }; |
| 47 | |
Brad Bishop | 3e4a19a | 2017-01-21 22:17:09 -0500 | [diff] [blame] | 48 | using StartupEvent = Event; |
| 49 | |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 50 | using EventBasePtr = std::shared_ptr<Event>; |
| 51 | |
| 52 | /** @struct DbusSignal |
| 53 | * @brief DBus signal event. |
| 54 | * |
| 55 | * DBus signal events are an association of a match signature |
| 56 | * and filtering function object. |
| 57 | */ |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 58 | struct DbusSignal final : public Event |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 59 | { |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 60 | ~DbusSignal() = default; |
| 61 | DbusSignal(const DbusSignal&) = delete; |
Brad Bishop | 7b33777 | 2017-01-12 16:11:24 -0500 | [diff] [blame] | 62 | DbusSignal& operator=(const DbusSignal&) = delete; |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 63 | DbusSignal(DbusSignal&&) = default; |
| 64 | DbusSignal& operator=(DbusSignal&&) = default; |
| 65 | |
| 66 | /** @brief Import from signature and filter constructor. |
| 67 | * |
| 68 | * @param[in] sig - The DBus match signature. |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 69 | * @param[in] filter - An array of DBus signal |
| 70 | * match callback filtering functions. |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 71 | */ |
Brad Bishop | 07934a6 | 2017-02-08 23:34:59 -0500 | [diff] [blame] | 72 | DbusSignal(const char* sig, const std::vector<Filter>& filters) : |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 73 | Event(filters, Type::DBUS_SIGNAL), |
| 74 | signature(sig) {} |
| 75 | |
| 76 | const char* signature; |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
Brad Bishop | 3d57f50 | 2016-10-19 12:18:41 -0400 | [diff] [blame] | 79 | } // namespace manager |
| 80 | } // namespace inventory |
| 81 | } // namespace phosphor |
| 82 | |
| 83 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |