summaryrefslogtreecommitdiffstats
path: root/src/events.hpp
blob: 684a0a898803d52ec25f98d537f02c5990d40111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once

#include "data_types.hpp"

namespace phosphor
{
namespace dbus
{
namespace monitoring
{

/**
 * @class Event
 * @brief An item monitoring triggered event
 * @details An event with an associated list of conditions to check
 */
class Event : public std::vector<Condition>
{
    public:
        /**
         * @brief Types of triggers of the event
         */
        enum class Trigger
        {
            START,
            SIGNAL
        };

        Event() = delete;
        Event(const Event&) = delete;
        Event(Event&&) = delete;
        Event& operator=(const Event&) = delete;
        Event& operator=(Event&&) = delete;
        virtual ~Event() = default;

        /**
         * @brief Constructs an event with given conditions and trigger
         *
         * @param[in] conditions - Conditions for the event
         * @param[in] t - Type of trigger of the event
         */
        Event(const std::vector<Condition>& conditions,
              Trigger t) :
                  std::vector<Condition>(conditions),
                  trigger(t)
        {
            // Nothing to do here
        }

        /** @brief Event trigger type */
        Trigger trigger;
};

class StartEvent : public Event
{
    public:
        StartEvent() = delete;
        StartEvent(const StartEvent&) = delete;
        StartEvent(StartEvent&&) = delete;
        StartEvent& operator=(const StartEvent&) = delete;
        StartEvent& operator=(StartEvent&&) = delete;
        ~StartEvent() = default;

        /**
         * @brief Constructs a derived application started event
         *
         * @param[in] conditions - Conditions for the event
         */
        explicit StartEvent(const std::vector<Condition>& conditions) :
            Event(conditions, Trigger::START)
        {
            // Nothing to do here
        }
};

class SignalEvent : public Event
{
    public:
        SignalEvent() = delete;
        SignalEvent(const SignalEvent&) = delete;
        SignalEvent(SignalEvent&&) = delete;
        SignalEvent& operator=(const SignalEvent&) = delete;
        SignalEvent& operator=(SignalEvent&&) = delete;
        ~SignalEvent() = default;

        /**
         * @brief Constructs a derived Dbus signal event
         *
         * @param[in] signature - Dbus object signature
         * @param[in] conditions - Conditions for the event
         */
        SignalEvent(const char* signature,
                    const std::vector<Condition>& conditions) :
                        Event(conditions, Trigger::SIGNAL),
                        signature(signature)
        {
            // Nothing to do here
        }

        /** @brief Dbus object signature */
        const char* signature;
};

} // namespace monitoring
} // namespace dbus
} // namespace phosphor
OpenPOWER on IntegriCloud