blob: 032099df4f9fb9752a08a34bda34c4d4ad5fcf74 [file] [log] [blame]
Ratan Gupta3e84ec62017-10-06 21:37:01 +05301#pragma once
2
3#include "sdbusplus.hpp"
4#include "xyz/openbmc_project/Logging/Event/server.hpp"
5
6#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
George Liu3fe976c2022-06-21 09:37:04 +08008
Andrew Geisslerae4c95c2020-05-16 13:58:53 -05009#include <string>
Ratan Gupta3e84ec62017-10-06 21:37:01 +053010
11namespace phosphor
12{
13namespace events
14{
15
16using namespace phosphor::dbus::monitoring;
17
Brad Bishopd1eac882018-03-29 10:34:05 -040018using EntryIface = sdbusplus::server::object::object<
19 sdbusplus::xyz::openbmc_project::Logging::server::Event>;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053020
21/** @class Entry
22 * @brief OpenBMC Event entry implementation.
23 * @details A concrete implementation for the
24 * xyz.openbmc_project.Event.Entry.
25 */
26class Entry : public EntryIface
27{
Brad Bishopd1eac882018-03-29 10:34:05 -040028 public:
29 Entry() = delete;
30 Entry(const Entry&) = delete;
31 Entry& operator=(const Entry&) = delete;
32 Entry(Entry&&) = delete;
33 Entry& operator=(Entry&&) = delete;
34 virtual ~Entry() = default;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053035
Brad Bishopd1eac882018-03-29 10:34:05 -040036 /** @brief Constructor to put object onto bus at a dbus path.
37 * @param[in] path - Path to attach at.
38 * @param[in] eventId - The event entry id.
39 * @param[in] timestamp - timestamp when the event created.
40 * @param[in] msg - The message of the event.
41 * @param[in] metaData - The event metadata.
42 */
43 Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg,
44 std::vector<std::string>&& metaData) :
Patrick Williams232f3952022-04-05 16:26:34 -050045 EntryIface(SDBusPlus::getBus(), path.c_str(),
46 EntryIface::action::defer_emit),
Brad Bishopd1eac882018-03-29 10:34:05 -040047 objectPath(path)
48 {
49 timestamp(eventTimestamp);
50 message(msg);
51 additionalData(metaData);
52 // Emit deferred signal.
53 this->emit_object_added();
54 }
Ratan Gupta3e84ec62017-10-06 21:37:01 +053055
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050056 /** @brief Constructor to create an empty event object with only
57 * timestamp, caller should make a call to emit added signal.
58 * @param[in] path - Path to attach at.
59 * @param[in] timestamp - timestamp when the event created.
60 */
61 Entry(const std::string& path, uint64_t eventTimestamp) :
Patrick Williams232f3952022-04-05 16:26:34 -050062 EntryIface(SDBusPlus::getBus(), path.c_str(),
63 EntryIface::action::defer_emit),
64 objectPath(path)
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050065 {
66 timestamp(eventTimestamp);
67 }
68
Brad Bishopd1eac882018-03-29 10:34:05 -040069 /** @brief Path of Object. */
70 std::string objectPath;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053071};
72
73} // namespace events
74} // namespace phosphor