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) |
Brad Bishop | a83db30 | 2020-12-06 14:51:23 -0500 | [diff] [blame] | 44 | {} |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 45 | |
| 46 | /** @brief event class enumeration. */ |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 47 | Type type; |
| 48 | }; |
| 49 | |
Brad Bishop | 3e4a19a | 2017-01-21 22:17:09 -0500 | [diff] [blame] | 50 | using StartupEvent = Event; |
| 51 | |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 52 | using EventBasePtr = std::shared_ptr<Event>; |
| 53 | |
| 54 | /** @struct DbusSignal |
| 55 | * @brief DBus signal event. |
| 56 | * |
| 57 | * DBus signal events are an association of a match signature |
| 58 | * and filtering function object. |
| 59 | */ |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 60 | struct DbusSignal final : public Event |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 61 | { |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 62 | ~DbusSignal() = default; |
| 63 | DbusSignal(const DbusSignal&) = delete; |
Brad Bishop | 7b33777 | 2017-01-12 16:11:24 -0500 | [diff] [blame] | 64 | DbusSignal& operator=(const DbusSignal&) = delete; |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 65 | DbusSignal(DbusSignal&&) = default; |
| 66 | DbusSignal& operator=(DbusSignal&&) = default; |
| 67 | |
| 68 | /** @brief Import from signature and filter constructor. |
| 69 | * |
| 70 | * @param[in] sig - The DBus match signature. |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 71 | * @param[in] filter - An array of DBus signal |
| 72 | * match callback filtering functions. |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 73 | */ |
Brad Bishop | 07934a6 | 2017-02-08 23:34:59 -0500 | [diff] [blame] | 74 | DbusSignal(const char* sig, const std::vector<Filter>& filters) : |
Brad Bishop | 615b2a8 | 2018-03-29 10:32:41 -0400 | [diff] [blame] | 75 | Event(filters, Type::DBUS_SIGNAL), signature(sig) |
Brad Bishop | a83db30 | 2020-12-06 14:51:23 -0500 | [diff] [blame] | 76 | {} |
Brad Bishop | 48547a8 | 2017-01-19 15:12:50 -0500 | [diff] [blame] | 77 | |
| 78 | const char* signature; |
Brad Bishop | 4f20a3e | 2016-11-29 15:21:46 -0500 | [diff] [blame] | 79 | }; |
| 80 | |
Brad Bishop | 3d57f50 | 2016-10-19 12:18:41 -0400 | [diff] [blame] | 81 | } // namespace manager |
| 82 | } // namespace inventory |
| 83 | } // namespace phosphor |
| 84 | |
| 85 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |