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