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(const std::string& path, uint64_t eventTimestamp, std::string&& msg, 42 std::vector<std::string>&& metaData) : 43 EntryIface(SDBusPlus::getBus(), path.c_str(), true), 44 objectPath(path) 45 { 46 timestamp(eventTimestamp); 47 message(msg); 48 additionalData(metaData); 49 // Emit deferred signal. 50 this->emit_object_added(); 51 } 52 53 /** @brief Constructor to create an empty event object with only 54 * timestamp, caller should make a call to emit added signal. 55 * @param[in] path - Path to attach at. 56 * @param[in] timestamp - timestamp when the event created. 57 */ 58 Entry(const std::string& path, uint64_t eventTimestamp) : 59 EntryIface(SDBusPlus::getBus(), path.c_str(), true), objectPath(path) 60 { 61 timestamp(eventTimestamp); 62 } 63 64 /** @brief Path of Object. */ 65 std::string objectPath; 66 }; 67 68 } // namespace events 69 } // namespace phosphor 70