forked from ibm-openbmc/phosphor-inventory-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.hpp
85 lines (70 loc) · 1.92 KB
/
events.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include "types.hpp"
#include <memory>
#include <vector>
namespace phosphor
{
namespace inventory
{
namespace manager
{
class Manager;
/** @struct Event
* @brief Event object interface.
*
* The event base is an association of an event type
* and an array of filter callbacks.
*/
struct Event : public std::vector<Filter>
{
enum class Type
{
DBUS_SIGNAL,
STARTUP,
};
virtual ~Event() = default;
Event(const Event&) = delete;
Event& operator=(const Event&) = delete;
Event(Event&&) = default;
Event& operator=(Event&&) = default;
/** @brief Event constructor.
*
* @param[in] filters - An array of filter callbacks.
* @param[in] t - The event type.
*/
explicit Event(const std::vector<Filter>& filters, Type t = Type::STARTUP) :
std::vector<Filter>(filters), type(t)
{}
/** @brief event class enumeration. */
Type type;
};
using StartupEvent = Event;
using EventBasePtr = std::shared_ptr<Event>;
/** @struct DbusSignal
* @brief DBus signal event.
*
* DBus signal events are an association of a match signature
* and filtering function object.
*/
struct DbusSignal final : public Event
{
~DbusSignal() = default;
DbusSignal(const DbusSignal&) = delete;
DbusSignal& operator=(const DbusSignal&) = delete;
DbusSignal(DbusSignal&&) = default;
DbusSignal& operator=(DbusSignal&&) = default;
/** @brief Import from signature and filter constructor.
*
* @param[in] sig - The DBus match signature.
* @param[in] filter - An array of DBus signal
* match callback filtering functions.
*/
DbusSignal(const char* sig, const std::vector<Filter>& filters) :
Event(filters, Type::DBUS_SIGNAL), signature(sig)
{}
const char* signature;
};
} // namespace manager
} // namespace inventory
} // namespace phosphor
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4