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