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      */
42     explicit Event(const std::vector<Filter>& filters, Type t = Type::STARTUP) :
43         std::vector<Filter>(filters), type(t)
44     {
45     }
46 
47     /** @brief event class enumeration. */
48     Type type;
49 };
50 
51 using StartupEvent = Event;
52 
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  */
61 struct DbusSignal final : public Event
62 {
63     ~DbusSignal() = default;
64     DbusSignal(const DbusSignal&) = delete;
65     DbusSignal& operator=(const DbusSignal&) = delete;
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.
72      *  @param[in] filter - An array of DBus signal
73      *     match callback filtering functions.
74      */
75     DbusSignal(const char* sig, const std::vector<Filter>& filters) :
76         Event(filters, Type::DBUS_SIGNAL), signature(sig)
77     {
78     }
79 
80     const char* signature;
81 };
82 
83 } // namespace manager
84 } // namespace inventory
85 } // namespace phosphor
86 
87 // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
88