blob: 1abf44490d38ed6721e0d539acbf828d9e396046 [file] [log] [blame]
Brad Bishop3d57f502016-10-19 12:18:41 -04001#pragma once
2
Brad Bishopc1f47982017-02-09 01:27:38 -05003#include "types.hpp"
Brad Bishop3d57f502016-10-19 12:18:41 -04004
Brad Bishopb666e532018-12-11 16:36:02 -05005#include <memory>
6#include <vector>
7
Brad Bishop3d57f502016-10-19 12:18:41 -04008namespace phosphor
9{
10namespace inventory
11{
12namespace manager
13{
Brad Bishopc0eae112016-10-19 21:59:47 -040014
15class Manager;
Brad Bishop65ffffa2016-11-29 12:31:31 -050016
Brad Bishop4f20a3e2016-11-29 15:21:46 -050017/** @struct Event
18 * @brief Event object interface.
Brad Bishop48547a82017-01-19 15:12:50 -050019 *
Gunnar Mills33e21792017-10-25 17:15:56 -050020 * The event base is an association of an event type
Brad Bishop48547a82017-01-19 15:12:50 -050021 * and an array of filter callbacks.
Brad Bishop4f20a3e2016-11-29 15:21:46 -050022 */
Brad Bishop07934a62017-02-08 23:34:59 -050023struct Event : public std::vector<Filter>
Brad Bishop4f20a3e2016-11-29 15:21:46 -050024{
25 enum class Type
26 {
27 DBUS_SIGNAL,
Brad Bishop3e4a19a2017-01-21 22:17:09 -050028 STARTUP,
Brad Bishop4f20a3e2016-11-29 15:21:46 -050029 };
30
31 virtual ~Event() = default;
Brad Bishop48547a82017-01-19 15:12:50 -050032 Event(const Event&) = delete;
33 Event& operator=(const Event&) = delete;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050034 Event(Event&&) = default;
35 Event& operator=(Event&&) = default;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050036
Brad Bishop48547a82017-01-19 15:12:50 -050037 /** @brief Event constructor.
38 *
39 * @param[in] filters - An array of filter callbacks.
40 * @param[in] t - The event type.
41 */
Brad Bishop615b2a82018-03-29 10:32:41 -040042 explicit Event(const std::vector<Filter>& filters, Type t = Type::STARTUP) :
43 std::vector<Filter>(filters), type(t)
Brad Bishopa83db302020-12-06 14:51:23 -050044 {}
Brad Bishop48547a82017-01-19 15:12:50 -050045
46 /** @brief event class enumeration. */
Brad Bishop4f20a3e2016-11-29 15:21:46 -050047 Type type;
48};
49
Brad Bishop3e4a19a2017-01-21 22:17:09 -050050using StartupEvent = Event;
51
Brad Bishop4f20a3e2016-11-29 15:21:46 -050052using 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 Bishop48547a82017-01-19 15:12:50 -050060struct DbusSignal final : public Event
Brad Bishop4f20a3e2016-11-29 15:21:46 -050061{
Brad Bishop48547a82017-01-19 15:12:50 -050062 ~DbusSignal() = default;
63 DbusSignal(const DbusSignal&) = delete;
Brad Bishop7b337772017-01-12 16:11:24 -050064 DbusSignal& operator=(const DbusSignal&) = delete;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050065 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 Bishop48547a82017-01-19 15:12:50 -050071 * @param[in] filter - An array of DBus signal
72 * match callback filtering functions.
Brad Bishop4f20a3e2016-11-29 15:21:46 -050073 */
Brad Bishop07934a62017-02-08 23:34:59 -050074 DbusSignal(const char* sig, const std::vector<Filter>& filters) :
Brad Bishop615b2a82018-03-29 10:32:41 -040075 Event(filters, Type::DBUS_SIGNAL), signature(sig)
Brad Bishopa83db302020-12-06 14:51:23 -050076 {}
Brad Bishop48547a82017-01-19 15:12:50 -050077
78 const char* signature;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050079};
80
Brad Bishop3d57f502016-10-19 12:18:41 -040081} // namespace manager
82} // namespace inventory
83} // namespace phosphor
84
85// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4