1*23818bb0SMatt Spinler #pragma once 2*23818bb0SMatt Spinler 3*23818bb0SMatt Spinler #include <experimental/filesystem> 4*23818bb0SMatt Spinler #include "dbus.hpp" 5*23818bb0SMatt Spinler #include "interfaces.hpp" 6*23818bb0SMatt Spinler 7*23818bb0SMatt Spinler namespace ibm 8*23818bb0SMatt Spinler { 9*23818bb0SMatt Spinler namespace logging 10*23818bb0SMatt Spinler { 11*23818bb0SMatt Spinler 12*23818bb0SMatt Spinler namespace fs = std::experimental::filesystem; 13*23818bb0SMatt Spinler 14*23818bb0SMatt Spinler /** 15*23818bb0SMatt Spinler * @class Callout 16*23818bb0SMatt Spinler * 17*23818bb0SMatt Spinler * This class provides information about a callout by utilizing the 18*23818bb0SMatt Spinler * xyz.openbmc_project.Inventory.Decorator.Asset and 19*23818bb0SMatt Spinler * xyz.openbmc_project.Common.ObjectPath interfaces. 20*23818bb0SMatt Spinler * 21*23818bb0SMatt Spinler * It also has the ability to persist and restore its data. 22*23818bb0SMatt Spinler */ 23*23818bb0SMatt Spinler class Callout : public CalloutObject 24*23818bb0SMatt Spinler { 25*23818bb0SMatt Spinler public: 26*23818bb0SMatt Spinler Callout() = delete; 27*23818bb0SMatt Spinler Callout(const Callout&) = delete; 28*23818bb0SMatt Spinler Callout& operator=(const Callout&) = delete; 29*23818bb0SMatt Spinler Callout(Callout&&) = default; 30*23818bb0SMatt Spinler Callout& operator=(Callout&&) = default; 31*23818bb0SMatt Spinler ~Callout() = default; 32*23818bb0SMatt Spinler 33*23818bb0SMatt Spinler /** 34*23818bb0SMatt Spinler * Constructor 35*23818bb0SMatt Spinler * 36*23818bb0SMatt Spinler * Populates the Asset D-Bus properties with data from the property map. 37*23818bb0SMatt Spinler * 38*23818bb0SMatt Spinler * @param[in] bus - D-Bus object 39*23818bb0SMatt Spinler * @param[in] objectPath - object path 40*23818bb0SMatt Spinler * @param[in] inventoryPath - inventory path of the callout 41*23818bb0SMatt Spinler * @param[in] id - which callout this is 42*23818bb0SMatt Spinler * @param[in] timestamp - timestamp when the log was created 43*23818bb0SMatt Spinler * @param[in] properties - the properties for the Asset interface. 44*23818bb0SMatt Spinler */ 45*23818bb0SMatt Spinler Callout(sdbusplus::bus::bus& bus, const std::string& objectPath, 46*23818bb0SMatt Spinler const std::string& inventoryPath, size_t id, uint64_t timestamp, 47*23818bb0SMatt Spinler const DbusPropertyMap& properties); 48*23818bb0SMatt Spinler /** 49*23818bb0SMatt Spinler * Constructor 50*23818bb0SMatt Spinler * 51*23818bb0SMatt Spinler * This version is for when the object is being restored and does 52*23818bb0SMatt Spinler * not take the properties map. 53*23818bb0SMatt Spinler * 54*23818bb0SMatt Spinler * @param[in] bus - D-Bus object 55*23818bb0SMatt Spinler * @param[in] objectPath - object path 56*23818bb0SMatt Spinler * @param[in] id - which callout this is 57*23818bb0SMatt Spinler * @param[in] timestamp - timestamp when the log was created 58*23818bb0SMatt Spinler * @param[in] properties - the properties for the Asset interface. 59*23818bb0SMatt Spinler */ 60*23818bb0SMatt Spinler Callout(sdbusplus::bus::bus& bus, const std::string& objectPath, size_t id, 61*23818bb0SMatt Spinler uint64_t timestamp); 62*23818bb0SMatt Spinler 63*23818bb0SMatt Spinler /** 64*23818bb0SMatt Spinler * Returns the callout ID 65*23818bb0SMatt Spinler * 66*23818bb0SMatt Spinler * @return id - the ID 67*23818bb0SMatt Spinler */ 68*23818bb0SMatt Spinler inline auto id() const 69*23818bb0SMatt Spinler { 70*23818bb0SMatt Spinler return entryID; 71*23818bb0SMatt Spinler } 72*23818bb0SMatt Spinler 73*23818bb0SMatt Spinler /** 74*23818bb0SMatt Spinler * Sets the callout ID 75*23818bb0SMatt Spinler * 76*23818bb0SMatt Spinler * @param[in] id - the ID 77*23818bb0SMatt Spinler */ 78*23818bb0SMatt Spinler inline void id(uint32_t id) 79*23818bb0SMatt Spinler { 80*23818bb0SMatt Spinler entryID = id; 81*23818bb0SMatt Spinler } 82*23818bb0SMatt Spinler 83*23818bb0SMatt Spinler /** 84*23818bb0SMatt Spinler * Returns the timestamp 85*23818bb0SMatt Spinler * 86*23818bb0SMatt Spinler * @return timestamp 87*23818bb0SMatt Spinler */ 88*23818bb0SMatt Spinler inline auto ts() const 89*23818bb0SMatt Spinler { 90*23818bb0SMatt Spinler return timestamp; 91*23818bb0SMatt Spinler } 92*23818bb0SMatt Spinler 93*23818bb0SMatt Spinler /** 94*23818bb0SMatt Spinler * Sets the timestamp 95*23818bb0SMatt Spinler * 96*23818bb0SMatt Spinler * @param[in] ts - the timestamp 97*23818bb0SMatt Spinler */ 98*23818bb0SMatt Spinler inline void ts(uint64_t ts) 99*23818bb0SMatt Spinler { 100*23818bb0SMatt Spinler timestamp = ts; 101*23818bb0SMatt Spinler } 102*23818bb0SMatt Spinler 103*23818bb0SMatt Spinler private: 104*23818bb0SMatt Spinler /** 105*23818bb0SMatt Spinler * The unique identifier for the callout, as error logs can have 106*23818bb0SMatt Spinler * multiple callouts. They start at 0. 107*23818bb0SMatt Spinler */ 108*23818bb0SMatt Spinler size_t entryID; 109*23818bb0SMatt Spinler 110*23818bb0SMatt Spinler /** 111*23818bb0SMatt Spinler * The timestamp of when the error log was created. 112*23818bb0SMatt Spinler * Used for ensuring the callout data is being restored for 113*23818bb0SMatt Spinler * the correct error log. 114*23818bb0SMatt Spinler */ 115*23818bb0SMatt Spinler uint64_t timestamp; 116*23818bb0SMatt Spinler }; 117*23818bb0SMatt Spinler } 118*23818bb0SMatt Spinler } 119