xref: /openbmc/phosphor-dbus-monitor/src/event_manager.hpp (revision 3fe976cc22e579860f5b1832d920636d93145507)
1 #pragma once
2 
3 #include "event_entry.hpp"
4 
5 #include <sdbusplus/bus.hpp>
6 
7 #include <map>
8 #include <memory>
9 #include <queue>
10 #include <string>
11 
12 namespace phosphor
13 {
14 namespace events
15 {
16 
17 /** @class Manager
18  *  @brief OpenBMC Event manager implementation.
19  */
20 class Manager
21 {
22   public:
23     Manager() = default;
24     Manager(const Manager&) = delete;
25     Manager& operator=(const Manager&) = delete;
26     Manager(Manager&&) = default;
27     Manager& operator=(Manager&&) = default;
28     virtual ~Manager() = default;
29 
30     /** @brief Create the D-Bus Event object.
31      *  @detail Add the objectPath,propertyName, propertyValue
32      *          as additional data of the event object.
33      *  @param[in] eventName - Name of the event.
34      *  @param[in] eventMessage - Message for the event.
35      *  @param[in] objectPath - Path of the D-Bus object.
36      *  @param[in] propertyName - Name of the property.
37      *  @param[in] propertyValue - Value of the property.
38      */
39     void create(const std::string& eventName, const std::string& eventMessage,
40                 const std::string& objectPath, const std::string& propertyName,
41                 const std::string& propertyValue);
42 
43     /** @brief Construct event d-bus objects from their persisted
44      *         representations.
45      */
46     void restore();
47 
48   private:
49     using EventName = std::string;
50     /** @brief Queue of events */
51     using EventQueue = std::queue<std::unique_ptr<Entry>>;
52 
53     using EventMap = std::map<EventName, EventQueue>;
54     /** @brief Map of event name  and the list of events **/
55     EventMap eventMap;
56 };
57 
58 Manager& getManager();
59 
60 } // namespace events
61 } // namespace phosphor
62