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> 8*ae4c95c6SAndrew Geissler #include <string> 93e84ec66SRatan Gupta 103e84ec66SRatan Gupta namespace phosphor 113e84ec66SRatan Gupta { 123e84ec66SRatan Gupta namespace events 133e84ec66SRatan Gupta { 143e84ec66SRatan Gupta 153e84ec66SRatan Gupta using namespace phosphor::dbus::monitoring; 163e84ec66SRatan Gupta 173e84ec66SRatan Gupta using EntryIface = sdbusplus::server::object::object< 183e84ec66SRatan Gupta sdbusplus::xyz::openbmc_project::Logging::server::Event>; 193e84ec66SRatan Gupta 203e84ec66SRatan Gupta /** @class Entry 213e84ec66SRatan Gupta * @brief OpenBMC Event entry implementation. 223e84ec66SRatan Gupta * @details A concrete implementation for the 233e84ec66SRatan Gupta * xyz.openbmc_project.Event.Entry. 243e84ec66SRatan Gupta */ 253e84ec66SRatan Gupta class Entry : public EntryIface 263e84ec66SRatan Gupta { 273e84ec66SRatan Gupta public: 283e84ec66SRatan Gupta Entry() = delete; 293e84ec66SRatan Gupta Entry(const Entry&) = delete; 303e84ec66SRatan Gupta Entry& operator=(const Entry&) = delete; 313e84ec66SRatan Gupta Entry(Entry&&) = delete; 323e84ec66SRatan Gupta Entry& operator=(Entry&&) = delete; 333e84ec66SRatan Gupta virtual ~Entry() = default; 343e84ec66SRatan Gupta 353e84ec66SRatan Gupta /** @brief Constructor to put object onto bus at a dbus path. 363e84ec66SRatan Gupta * @param[in] path - Path to attach at. 373e84ec66SRatan Gupta * @param[in] eventId - The event entry id. 383e84ec66SRatan Gupta * @param[in] timestamp - timestamp when the event created. 393e84ec66SRatan Gupta * @param[in] msg - The message of the event. 403e84ec66SRatan Gupta * @param[in] metaData - The event metadata. 413e84ec66SRatan Gupta */ 42d1eac88dSBrad Bishop Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg, 433e84ec66SRatan Gupta std::vector<std::string>&& metaData) : 443e84ec66SRatan Gupta EntryIface(SDBusPlus::getBus(), path.c_str(), true), 453e84ec66SRatan Gupta objectPath(path) 463e84ec66SRatan Gupta { 473e84ec66SRatan Gupta timestamp(eventTimestamp); 483e84ec66SRatan Gupta message(msg); 493e84ec66SRatan Gupta additionalData(metaData); 503e84ec66SRatan Gupta // Emit deferred signal. 513e84ec66SRatan Gupta this->emit_object_added(); 523e84ec66SRatan Gupta } 533e84ec66SRatan Gupta 546524b9d8SDhruvaraj Subhashchandran /** @brief Constructor to create an empty event object with only 556524b9d8SDhruvaraj Subhashchandran * timestamp, caller should make a call to emit added signal. 566524b9d8SDhruvaraj Subhashchandran * @param[in] path - Path to attach at. 576524b9d8SDhruvaraj Subhashchandran * @param[in] timestamp - timestamp when the event created. 586524b9d8SDhruvaraj Subhashchandran */ 596524b9d8SDhruvaraj Subhashchandran Entry(const std::string& path, uint64_t eventTimestamp) : 606524b9d8SDhruvaraj Subhashchandran EntryIface(SDBusPlus::getBus(), path.c_str(), true), objectPath(path) 616524b9d8SDhruvaraj Subhashchandran { 626524b9d8SDhruvaraj Subhashchandran timestamp(eventTimestamp); 636524b9d8SDhruvaraj Subhashchandran } 646524b9d8SDhruvaraj Subhashchandran 653e84ec66SRatan Gupta /** @brief Path of Object. */ 663e84ec66SRatan Gupta std::string objectPath; 673e84ec66SRatan Gupta }; 683e84ec66SRatan Gupta 693e84ec66SRatan Gupta } // namespace events 703e84ec66SRatan Gupta } // namespace phosphor 71