xref: /openbmc/phosphor-dbus-monitor/src/event_entry.hpp (revision 3e84ec6645bcea669805947f1409b58b4b0d9f72)
1 #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>
8 
9 namespace phosphor
10 {
11 namespace events
12 {
13 
14 using namespace phosphor::dbus::monitoring;
15 
16 using EntryIface = sdbusplus::server::object::object <
17                         sdbusplus::xyz::openbmc_project::Logging::server::Event >;
18 
19 /** @class Entry
20  *  @brief OpenBMC Event entry implementation.
21  *  @details A concrete implementation for the
22  *  xyz.openbmc_project.Event.Entry.
23  */
24 class Entry : public EntryIface
25 {
26     public:
27         Entry() = delete;
28         Entry(const Entry&) = delete;
29         Entry& operator=(const Entry&) = delete;
30         Entry(Entry&&) = delete;
31         Entry& operator=(Entry&&) = delete;
32         virtual ~Entry() = default;
33 
34         /** @brief Constructor to put object onto bus at a dbus path.
35          *  @param[in] path - Path to attach at.
36          *  @param[in] eventId - The event entry id.
37          *  @param[in] timestamp - timestamp when the event created.
38          *  @param[in] msg - The message of the event.
39          *  @param[in] metaData - The event metadata.
40          */
41         Entry(
42             const std::string& path,
43             uint64_t eventTimestamp,
44             std::string&& msg,
45             std::vector<std::string>&& metaData) :
46                 EntryIface(SDBusPlus::getBus(), path.c_str(), true),
47                 objectPath(path)
48             {
49                 timestamp(eventTimestamp);
50                 message(msg);
51                 additionalData(metaData);
52                 // Emit deferred signal.
53                 this->emit_object_added();
54             }
55 
56         /** @brief Path of Object. */
57         std::string objectPath;
58 
59 };
60 
61 } // namespace events
62 } // namespace phosphor
63