blob: 1f99d811bd0a64a9b7c279d7454887cbb0b34485 [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>
Andrew Geisslerae4c95c2020-05-16 13:58:53 -05008#include <string>
Ratan Gupta3e84ec62017-10-06 21:37:01 +05309
10namespace phosphor
11{
12namespace events
13{
14
15using namespace phosphor::dbus::monitoring;
16
Brad Bishopd1eac882018-03-29 10:34:05 -040017using EntryIface = sdbusplus::server::object::object<
18 sdbusplus::xyz::openbmc_project::Logging::server::Event>;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053019
20/** @class Entry
21 * @brief OpenBMC Event entry implementation.
22 * @details A concrete implementation for the
23 * xyz.openbmc_project.Event.Entry.
24 */
25class Entry : public EntryIface
26{
Brad Bishopd1eac882018-03-29 10:34:05 -040027 public:
28 Entry() = delete;
29 Entry(const Entry&) = delete;
30 Entry& operator=(const Entry&) = delete;
31 Entry(Entry&&) = delete;
32 Entry& operator=(Entry&&) = delete;
33 virtual ~Entry() = default;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053034
Brad Bishopd1eac882018-03-29 10:34:05 -040035 /** @brief Constructor to put object onto bus at a dbus path.
36 * @param[in] path - Path to attach at.
37 * @param[in] eventId - The event entry id.
38 * @param[in] timestamp - timestamp when the event created.
39 * @param[in] msg - The message of the event.
40 * @param[in] metaData - The event metadata.
41 */
42 Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg,
43 std::vector<std::string>&& metaData) :
Patrick Williams232f3952022-04-05 16:26:34 -050044 EntryIface(SDBusPlus::getBus(), path.c_str(),
45 EntryIface::action::defer_emit),
Brad Bishopd1eac882018-03-29 10:34:05 -040046 objectPath(path)
47 {
48 timestamp(eventTimestamp);
49 message(msg);
50 additionalData(metaData);
51 // Emit deferred signal.
52 this->emit_object_added();
53 }
Ratan Gupta3e84ec62017-10-06 21:37:01 +053054
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050055 /** @brief Constructor to create an empty event object with only
56 * timestamp, caller should make a call to emit added signal.
57 * @param[in] path - Path to attach at.
58 * @param[in] timestamp - timestamp when the event created.
59 */
60 Entry(const std::string& path, uint64_t eventTimestamp) :
Patrick Williams232f3952022-04-05 16:26:34 -050061 EntryIface(SDBusPlus::getBus(), path.c_str(),
62 EntryIface::action::defer_emit),
63 objectPath(path)
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050064 {
65 timestamp(eventTimestamp);
66 }
67
Brad Bishopd1eac882018-03-29 10:34:05 -040068 /** @brief Path of Object. */
69 std::string objectPath;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053070};
71
72} // namespace events
73} // namespace phosphor