1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include <sdbusplus/server/object.hpp> 5 #include "xyz/openbmc_project/Logging/Entry/server.hpp" 6 #include "xyz/openbmc_project/Object/Delete/server.hpp" 7 #include "org/openbmc/Associations/server.hpp" 8 9 namespace phosphor 10 { 11 namespace logging 12 { 13 14 using EntryIfaces = sdbusplus::server::object::object< 15 sdbusplus::xyz::openbmc_project::Logging::server::Entry, 16 sdbusplus::xyz::openbmc_project::Object::server::Delete, 17 sdbusplus::org::openbmc::server::Associations>; 18 19 using AssociationList = 20 std::vector<std::tuple<std::string, std::string, std::string>>; 21 22 class Manager; 23 24 /** @class Entry 25 * @brief OpenBMC logging entry implementation. 26 * @details A concrete implementation for the 27 * xyz.openbmc_project.Logging.Entry and 28 * org.openbmc.Associations DBus APIs. 29 */ 30 class Entry : public EntryIfaces 31 { 32 public: 33 Entry() = delete; 34 Entry(const Entry&) = delete; 35 Entry& operator=(const Entry&) = delete; 36 Entry(Entry&&) = delete; 37 Entry& operator=(Entry&&) = delete; 38 virtual ~Entry() = default; 39 40 /** @brief Constructor to put object onto bus at a dbus path. 41 * Defer signal registration (pass true for deferSignal to the 42 * base class) until after the properties are set. 43 * @param[in] bus - Bus to attach to. 44 * @param[in] path - Path to attach at. 45 * @param[in] idErr - The error entry id. 46 * @param[in] timestampErr - The commit timestamp. 47 * @param[in] severityErr - The severity of the error. 48 * @param[in] msgErr - The message of the error. 49 * @param[in] additionalDataErr - The error metadata. 50 * @param[in] parent - The error's parent. 51 */ 52 Entry(sdbusplus::bus::bus& bus, 53 const std::string& path, 54 uint32_t idErr, 55 uint64_t timestampErr, 56 Level severityErr, 57 std::string&& msgErr, 58 std::vector<std::string>&& additionalDataErr, 59 AssociationList&& objects, 60 Manager& parent) : 61 EntryIfaces(bus, path.c_str(), true), 62 parent(parent) 63 { 64 id(idErr); 65 severity(severityErr); 66 timestamp(timestampErr); 67 message(std::move(msgErr)); 68 additionalData(std::move(additionalDataErr)); 69 associations(std::move(objects)); 70 // Store a copy of associations in case we need to recreate 71 assocs = associations(); 72 resolved(false); 73 74 // Emit deferred signal. 75 this->emit_object_added(); 76 }; 77 78 /** @brief Set resolution status of the error. 79 * @param[in] value - boolean indicating resolution 80 * status (true = resolved) 81 * @returns value of 'Resolved' property 82 */ 83 bool resolved(bool value) override 84 { 85 value ? 86 associations({}) : 87 associations(assocs); 88 89 return sdbusplus::xyz::openbmc_project:: 90 Logging::server::Entry::resolved(value); 91 } 92 93 /** @brief Delete this d-bus object. 94 */ 95 void delete_() override; 96 97 private: 98 /** @brief This entry's associations */ 99 AssociationList assocs = {}; 100 101 /** @brief This entry's parent */ 102 Manager& parent; 103 }; 104 105 } // namespace logging 106 } // namespace phosphor 107