blob: a4ccf18e9e5b3333f190be44ad348c4dc72780cc [file] [log] [blame]
Ratan Guptacd227862017-10-06 21:27:13 +05301#pragma once
2
Ratan Gupta3e84ec62017-10-06 21:37:01 +05303#include "event_entry.hpp"
4
5#include <map>
6#include <memory>
7#include <queue>
Ratan Guptacd227862017-10-06 21:27:13 +05308#include <sdbusplus/bus.hpp>
9
10namespace phosphor
11{
12namespace events
13{
14
15/** @class Manager
16 * @brief OpenBMC Event manager implementation.
17 */
18class Manager
19{
Brad Bishopd1eac882018-03-29 10:34:05 -040020 public:
21 Manager() = default;
22 Manager(const Manager&) = delete;
23 Manager& operator=(const Manager&) = delete;
24 Manager(Manager&&) = default;
25 Manager& operator=(Manager&&) = default;
26 virtual ~Manager() = default;
Ratan Guptacd227862017-10-06 21:27:13 +053027
Brad Bishopd1eac882018-03-29 10:34:05 -040028 /** @brief Create the D-Bus Event object.
29 * @detail Add the objectPath,propertyName, propertyValue
30 * as additional data of the event object.
31 * @param[in] eventName - Name of the event.
32 * @param[in] eventMessage - Message for the event.
33 * @param[in] objectPath - Path of the D-Bus object.
34 * @param[in] propertyName - Name of the property.
35 * @param[in] propertyValue - Value of the property.
36 */
37 void create(const std::string& eventName, const std::string& eventMessage,
38 const std::string& objectPath, const std::string& propertyName,
39 const std::string& propertyValue);
Ratan Guptacd227862017-10-06 21:27:13 +053040
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050041 /** @brief Construct event d-bus objects from their persisted
42 * representations.
43 */
44 void restore();
45
Brad Bishopd1eac882018-03-29 10:34:05 -040046 private:
47 using EventName = std::string;
48 /** @brief Queue of events */
49 using EventQueue = std::queue<std::unique_ptr<Entry>>;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053050
Brad Bishopd1eac882018-03-29 10:34:05 -040051 using EventMap = std::map<EventName, EventQueue>;
52 /** @brief Map of event name and the list of events **/
53 EventMap eventMap;
Ratan Guptacd227862017-10-06 21:27:13 +053054};
55
56Manager& getManager();
57
58} // namespace events
59} // namespace phosphor