blob: 684a0a898803d52ec25f98d537f02c5990d40111 [file] [log] [blame]
Matthew Barthb86374d2017-04-12 10:57:19 -05001#pragma once
2
3#include "data_types.hpp"
4
5namespace phosphor
6{
7namespace dbus
8{
9namespace monitoring
10{
11
Matthew Barthc5736432017-04-17 12:22:50 -050012/**
13 * @class Event
14 * @brief An item monitoring triggered event
15 * @details An event with an associated list of conditions to check
16 */
Matthew Barthb86374d2017-04-12 10:57:19 -050017class Event : public std::vector<Condition>
18{
19 public:
Matthew Barthc5736432017-04-17 12:22:50 -050020 /**
21 * @brief Types of triggers of the event
22 */
Matthew Barthb86374d2017-04-12 10:57:19 -050023 enum class Trigger
24 {
25 START,
26 SIGNAL
27 };
28
29 Event() = delete;
30 Event(const Event&) = delete;
31 Event(Event&&) = delete;
32 Event& operator=(const Event&) = delete;
33 Event& operator=(Event&&) = delete;
34 virtual ~Event() = default;
35
Matthew Barthc5736432017-04-17 12:22:50 -050036 /**
37 * @brief Constructs an event with given conditions and trigger
38 *
39 * @param[in] conditions - Conditions for the event
40 * @param[in] t - Type of trigger of the event
41 */
Matthew Barthb86374d2017-04-12 10:57:19 -050042 Event(const std::vector<Condition>& conditions,
43 Trigger t) :
44 std::vector<Condition>(conditions),
45 trigger(t)
46 {
47 // Nothing to do here
48 }
49
Matthew Barthc5736432017-04-17 12:22:50 -050050 /** @brief Event trigger type */
Matthew Barthb86374d2017-04-12 10:57:19 -050051 Trigger trigger;
52};
53
54class StartEvent : public Event
55{
56 public:
57 StartEvent() = delete;
58 StartEvent(const StartEvent&) = delete;
59 StartEvent(StartEvent&&) = delete;
60 StartEvent& operator=(const StartEvent&) = delete;
61 StartEvent& operator=(StartEvent&&) = delete;
62 ~StartEvent() = default;
63
Matthew Barthc5736432017-04-17 12:22:50 -050064 /**
65 * @brief Constructs a derived application started event
66 *
67 * @param[in] conditions - Conditions for the event
68 */
Matthew Barthb86374d2017-04-12 10:57:19 -050069 explicit StartEvent(const std::vector<Condition>& conditions) :
70 Event(conditions, Trigger::START)
71 {
72 // Nothing to do here
73 }
74};
75
76class SignalEvent : public Event
77{
78 public:
79 SignalEvent() = delete;
80 SignalEvent(const SignalEvent&) = delete;
81 SignalEvent(SignalEvent&&) = delete;
82 SignalEvent& operator=(const SignalEvent&) = delete;
83 SignalEvent& operator=(SignalEvent&&) = delete;
84 ~SignalEvent() = default;
85
Matthew Barthc5736432017-04-17 12:22:50 -050086 /**
87 * @brief Constructs a derived Dbus signal event
88 *
89 * @param[in] signature - Dbus object signature
90 * @param[in] conditions - Conditions for the event
91 */
Matthew Barthb86374d2017-04-12 10:57:19 -050092 SignalEvent(const char* signature,
93 const std::vector<Condition>& conditions) :
94 Event(conditions, Trigger::SIGNAL),
95 signature(signature)
96 {
97 // Nothing to do here
98 }
99
Matthew Barthc5736432017-04-17 12:22:50 -0500100 /** @brief Dbus object signature */
Matthew Barthb86374d2017-04-12 10:57:19 -0500101 const char* signature;
102};
103
104} // namespace monitoring
105} // namespace dbus
106} // namespace phosphor