13e84ec66SRatan Gupta #pragma once 23e84ec66SRatan Gupta 33e84ec66SRatan Gupta #include "sdbusplus.hpp" 43e84ec66SRatan Gupta #include "xyz/openbmc_project/Logging/Event/server.hpp" 53e84ec66SRatan Gupta 63e84ec66SRatan Gupta #include <sdbusplus/bus.hpp> 73e84ec66SRatan Gupta #include <sdbusplus/server/object.hpp> 83fe976ccSGeorge Liu 9ae4c95c6SAndrew Geissler #include <string> 103e84ec66SRatan Gupta 113e84ec66SRatan Gupta namespace phosphor 123e84ec66SRatan Gupta { 133e84ec66SRatan Gupta namespace events 143e84ec66SRatan Gupta { 153e84ec66SRatan Gupta 163e84ec66SRatan Gupta using namespace phosphor::dbus::monitoring; 173e84ec66SRatan Gupta 18*413a4857SPatrick Williams using EntryIface = sdbusplus::server::object_t< 193e84ec66SRatan Gupta sdbusplus::xyz::openbmc_project::Logging::server::Event>; 203e84ec66SRatan Gupta 213e84ec66SRatan Gupta /** @class Entry 223e84ec66SRatan Gupta * @brief OpenBMC Event entry implementation. 233e84ec66SRatan Gupta * @details A concrete implementation for the 243e84ec66SRatan Gupta * xyz.openbmc_project.Event.Entry. 253e84ec66SRatan Gupta */ 263e84ec66SRatan Gupta class Entry : public EntryIface 273e84ec66SRatan Gupta { 283e84ec66SRatan Gupta public: 293e84ec66SRatan Gupta Entry() = delete; 303e84ec66SRatan Gupta Entry(const Entry&) = delete; 313e84ec66SRatan Gupta Entry& operator=(const Entry&) = delete; 323e84ec66SRatan Gupta Entry(Entry&&) = delete; 333e84ec66SRatan Gupta Entry& operator=(Entry&&) = delete; 343e84ec66SRatan Gupta virtual ~Entry() = default; 353e84ec66SRatan Gupta 363e84ec66SRatan Gupta /** @brief Constructor to put object onto bus at a dbus path. 373e84ec66SRatan Gupta * @param[in] path - Path to attach at. 383e84ec66SRatan Gupta * @param[in] eventId - The event entry id. 393e84ec66SRatan Gupta * @param[in] timestamp - timestamp when the event created. 403e84ec66SRatan Gupta * @param[in] msg - The message of the event. 413e84ec66SRatan Gupta * @param[in] metaData - The event metadata. 423e84ec66SRatan Gupta */ Entry(const std::string & path,uint64_t eventTimestamp,std::string && msg,std::vector<std::string> && metaData)43d1eac88dSBrad Bishop Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg, 443e84ec66SRatan Gupta std::vector<std::string>&& metaData) : 45232f395eSPatrick Williams EntryIface(SDBusPlus::getBus(), path.c_str(), 46232f395eSPatrick Williams EntryIface::action::defer_emit), 473e84ec66SRatan Gupta objectPath(path) 483e84ec66SRatan Gupta { 493e84ec66SRatan Gupta timestamp(eventTimestamp); 503e84ec66SRatan Gupta message(msg); 513e84ec66SRatan Gupta additionalData(metaData); 523e84ec66SRatan Gupta // Emit deferred signal. 533e84ec66SRatan Gupta this->emit_object_added(); 543e84ec66SRatan Gupta } 553e84ec66SRatan Gupta 566524b9d8SDhruvaraj Subhashchandran /** @brief Constructor to create an empty event object with only 576524b9d8SDhruvaraj Subhashchandran * timestamp, caller should make a call to emit added signal. 586524b9d8SDhruvaraj Subhashchandran * @param[in] path - Path to attach at. 596524b9d8SDhruvaraj Subhashchandran * @param[in] timestamp - timestamp when the event created. 606524b9d8SDhruvaraj Subhashchandran */ Entry(const std::string & path,uint64_t eventTimestamp)616524b9d8SDhruvaraj Subhashchandran Entry(const std::string& path, uint64_t eventTimestamp) : 62232f395eSPatrick Williams EntryIface(SDBusPlus::getBus(), path.c_str(), 63232f395eSPatrick Williams EntryIface::action::defer_emit), 64232f395eSPatrick Williams objectPath(path) 656524b9d8SDhruvaraj Subhashchandran { 666524b9d8SDhruvaraj Subhashchandran timestamp(eventTimestamp); 676524b9d8SDhruvaraj Subhashchandran } 686524b9d8SDhruvaraj Subhashchandran 693e84ec66SRatan Gupta /** @brief Path of Object. */ 703e84ec66SRatan Gupta std::string objectPath; 713e84ec66SRatan Gupta }; 723e84ec66SRatan Gupta 733e84ec66SRatan Gupta } // namespace events 743e84ec66SRatan Gupta } // namespace phosphor 75