blob: 261fa9fe7f29a5dd9f740ac511f102a0b9539ee3 [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
George Liu3fe976c2022-06-21 09:37:04 +08005#include <sdbusplus/bus.hpp>
6
Ratan Gupta3e84ec62017-10-06 21:37:01 +05307#include <map>
8#include <memory>
9#include <queue>
Andrew Geisslerae4c95c2020-05-16 13:58:53 -050010#include <string>
Ratan Guptacd227862017-10-06 21:27:13 +053011
12namespace phosphor
13{
14namespace events
15{
16
17/** @class Manager
18 * @brief OpenBMC Event manager implementation.
19 */
20class Manager
21{
Brad Bishopd1eac882018-03-29 10:34:05 -040022 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;
Ratan Guptacd227862017-10-06 21:27:13 +053029
Brad Bishopd1eac882018-03-29 10:34:05 -040030 /** @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);
Ratan Guptacd227862017-10-06 21:27:13 +053042
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050043 /** @brief Construct event d-bus objects from their persisted
44 * representations.
45 */
46 void restore();
47
Brad Bishopd1eac882018-03-29 10:34:05 -040048 private:
49 using EventName = std::string;
50 /** @brief Queue of events */
51 using EventQueue = std::queue<std::unique_ptr<Entry>>;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053052
Brad Bishopd1eac882018-03-29 10:34:05 -040053 using EventMap = std::map<EventName, EventQueue>;
54 /** @brief Map of event name and the list of events **/
55 EventMap eventMap;
Ratan Guptacd227862017-10-06 21:27:13 +053056};
57
58Manager& getManager();
59
60} // namespace events
61} // namespace phosphor