Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "data_types.hpp" |
| 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace dbus |
| 8 | { |
| 9 | namespace monitoring |
| 10 | { |
| 11 | |
Matthew Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 12 | /** |
| 13 | * @class Event |
| 14 | * @brief An item monitoring triggered event |
| 15 | * @details An event with an associated list of conditions to check |
| 16 | */ |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 17 | class Event : public std::vector<Condition> |
| 18 | { |
| 19 | public: |
Matthew Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 20 | /** |
| 21 | * @brief Types of triggers of the event |
| 22 | */ |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 23 | 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 Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 36 | /** |
| 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 Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 42 | 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 Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 50 | /** @brief Event trigger type */ |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 51 | Trigger trigger; |
| 52 | }; |
| 53 | |
| 54 | class 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 Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 64 | /** |
| 65 | * @brief Constructs a derived application started event |
| 66 | * |
| 67 | * @param[in] conditions - Conditions for the event |
| 68 | */ |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 69 | explicit StartEvent(const std::vector<Condition>& conditions) : |
| 70 | Event(conditions, Trigger::START) |
| 71 | { |
| 72 | // Nothing to do here |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | class 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 Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 86 | /** |
| 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 Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 92 | 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 Barth | c573643 | 2017-04-17 12:22:50 -0500 | [diff] [blame] | 100 | /** @brief Dbus object signature */ |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 101 | const char* signature; |
| 102 | }; |
| 103 | |
| 104 | } // namespace monitoring |
| 105 | } // namespace dbus |
| 106 | } // namespace phosphor |