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 #include <string>
10 
11 namespace phosphor
12 {
13 namespace events
14 {
15 
16 using namespace phosphor::dbus::monitoring;
17 
18 using EntryIface = sdbusplus::server::object_t<
19     sdbusplus::xyz::openbmc_project::Logging::server::Event>;
20 
21 /** @class Entry
22  *  @brief OpenBMC Event entry implementation.
23  *  @details A concrete implementation for the
24  *  xyz.openbmc_project.Event.Entry.
25  */
26 class Entry : public EntryIface
27 {
28   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;
35 
36     /** @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) :
45         EntryIface(SDBusPlus::getBus(), path.c_str(),
46                    EntryIface::action::defer_emit),
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 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) :
62         EntryIface(SDBusPlus::getBus(), path.c_str(),
63                    EntryIface::action::defer_emit),
64         objectPath(path)
65     {
66         timestamp(eventTimestamp);
67     }
68 
69     /** @brief Path of Object. */
70     std::string objectPath;
71 };
72 
73 } // namespace events
74 } // namespace phosphor
75