blob: 0cdcfbc700826ace7194c679d4cc372d340f84eb [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
5namespace phosphor
6{
7namespace inventory
8{
9namespace manager
10{
Brad Bishopc0eae112016-10-19 21:59:47 -040011
12class Manager;
Brad Bishop65ffffa2016-11-29 12:31:31 -050013
Brad Bishop4f20a3e2016-11-29 15:21:46 -050014/** @struct Event
15 * @brief Event object interface.
Brad Bishop48547a82017-01-19 15:12:50 -050016 *
Gunnar Mills33e21792017-10-25 17:15:56 -050017 * The event base is an association of an event type
Brad Bishop48547a82017-01-19 15:12:50 -050018 * and an array of filter callbacks.
Brad Bishop4f20a3e2016-11-29 15:21:46 -050019 */
Brad Bishop07934a62017-02-08 23:34:59 -050020struct Event : public std::vector<Filter>
Brad Bishop4f20a3e2016-11-29 15:21:46 -050021{
22 enum class Type
23 {
24 DBUS_SIGNAL,
Brad Bishop3e4a19a2017-01-21 22:17:09 -050025 STARTUP,
Brad Bishop4f20a3e2016-11-29 15:21:46 -050026 };
27
28 virtual ~Event() = default;
Brad Bishop48547a82017-01-19 15:12:50 -050029 Event(const Event&) = delete;
30 Event& operator=(const Event&) = delete;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050031 Event(Event&&) = default;
32 Event& operator=(Event&&) = default;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050033
Brad Bishop48547a82017-01-19 15:12:50 -050034 /** @brief Event constructor.
35 *
36 * @param[in] filters - An array of filter callbacks.
37 * @param[in] t - The event type.
38 */
Brad Bishop615b2a82018-03-29 10:32:41 -040039 explicit Event(const std::vector<Filter>& filters, Type t = Type::STARTUP) :
40 std::vector<Filter>(filters), type(t)
41 {
42 }
Brad Bishop48547a82017-01-19 15:12:50 -050043
44 /** @brief event class enumeration. */
Brad Bishop4f20a3e2016-11-29 15:21:46 -050045 Type type;
46};
47
Brad Bishop3e4a19a2017-01-21 22:17:09 -050048using StartupEvent = Event;
49
Brad Bishop4f20a3e2016-11-29 15:21:46 -050050using EventBasePtr = std::shared_ptr<Event>;
51
52/** @struct DbusSignal
53 * @brief DBus signal event.
54 *
55 * DBus signal events are an association of a match signature
56 * and filtering function object.
57 */
Brad Bishop48547a82017-01-19 15:12:50 -050058struct DbusSignal final : public Event
Brad Bishop4f20a3e2016-11-29 15:21:46 -050059{
Brad Bishop48547a82017-01-19 15:12:50 -050060 ~DbusSignal() = default;
61 DbusSignal(const DbusSignal&) = delete;
Brad Bishop7b337772017-01-12 16:11:24 -050062 DbusSignal& operator=(const DbusSignal&) = delete;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050063 DbusSignal(DbusSignal&&) = default;
64 DbusSignal& operator=(DbusSignal&&) = default;
65
66 /** @brief Import from signature and filter constructor.
67 *
68 * @param[in] sig - The DBus match signature.
Brad Bishop48547a82017-01-19 15:12:50 -050069 * @param[in] filter - An array of DBus signal
70 * match callback filtering functions.
Brad Bishop4f20a3e2016-11-29 15:21:46 -050071 */
Brad Bishop07934a62017-02-08 23:34:59 -050072 DbusSignal(const char* sig, const std::vector<Filter>& filters) :
Brad Bishop615b2a82018-03-29 10:32:41 -040073 Event(filters, Type::DBUS_SIGNAL), signature(sig)
74 {
75 }
Brad Bishop48547a82017-01-19 15:12:50 -050076
77 const char* signature;
Brad Bishop4f20a3e2016-11-29 15:21:46 -050078};
79
Brad Bishop3d57f502016-10-19 12:18:41 -040080} // namespace manager
81} // namespace inventory
82} // namespace phosphor
83
84// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4