1 #pragma once 2 3 #include "types.hpp" 4 5 namespace phosphor 6 { 7 namespace inventory 8 { 9 namespace manager 10 { 11 12 class Manager; 13 14 /** @struct Event 15 * @brief Event object interface. 16 * 17 * The event base is an association of an event type 18 * and an array of filter callbacks. 19 */ 20 struct Event : public std::vector<Filter> 21 { 22 enum class Type 23 { 24 DBUS_SIGNAL, 25 STARTUP, 26 }; 27 28 virtual ~Event() = default; 29 Event(const Event&) = delete; 30 Event& operator=(const Event&) = delete; 31 Event(Event&&) = default; 32 Event& operator=(Event&&) = default; 33 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( 40 const std::vector<Filter>& filters, Type t = Type::STARTUP) : 41 std::vector<Filter>(filters), 42 type(t) {} 43 44 /** @brief event class enumeration. */ 45 Type type; 46 }; 47 48 using StartupEvent = Event; 49 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 */ 58 struct DbusSignal final : public Event 59 { 60 ~DbusSignal() = default; 61 DbusSignal(const DbusSignal&) = delete; 62 DbusSignal& operator=(const DbusSignal&) = delete; 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. 69 * @param[in] filter - An array of DBus signal 70 * match callback filtering functions. 71 */ 72 DbusSignal(const char* sig, const std::vector<Filter>& filters) : 73 Event(filters, Type::DBUS_SIGNAL), 74 signature(sig) {} 75 76 const char* signature; 77 }; 78 79 } // namespace manager 80 } // namespace inventory 81 } // namespace phosphor 82 83 // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 84