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