blob: 735834ac54a1fecf74f9fab6c1c3882fd1871d41 [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)
44 {
45 }
Brad Bishop48547a82017-01-19 15:12:50 -050046
47 /** @brief event class enumeration. */
Brad Bishop4f20a3e2016-11-29 15:21:46 -050048 Type type;
49};
50
Brad Bishop3e4a19a2017-01-21 22:17:09 -050051using StartupEvent = Event;
52
Brad Bishop4f20a3e2016-11-29 15:21:46 -050053using 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 */
Brad Bishop48547a82017-01-19 15:12:50 -050061struct DbusSignal final : public Event
Brad Bishop4f20a3e2016-11-29 15:21:46 -050062{
Brad Bishop48547a82017-01-19 15:12:50 -050063 ~DbusSignal() = default;
64 DbusSignal(const DbusSignal&) = delete;
Brad Bishop7b337772017-01-12 16:11:24 -050065 DbusSignal& operator=(const DbusSignal&) = delete;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050066 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.
Brad Bishop48547a82017-01-19 15:12:50 -050072 * @param[in] filter - An array of DBus signal
73 * match callback filtering functions.
Brad Bishop4f20a3e2016-11-29 15:21:46 -050074 */
Brad Bishop07934a62017-02-08 23:34:59 -050075 DbusSignal(const char* sig, const std::vector<Filter>& filters) :
Brad Bishop615b2a82018-03-29 10:32:41 -040076 Event(filters, Type::DBUS_SIGNAL), signature(sig)
77 {
78 }
Brad Bishop48547a82017-01-19 15:12:50 -050079
80 const char* signature;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050081};
82
Brad Bishop3d57f502016-10-19 12:18:41 -040083} // namespace manager
84} // namespace inventory
85} // namespace phosphor
86
87// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4