blob: ffff8af76239f750179c8816085cbfbe7bc59575 [file] [log] [blame]
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include "xyz/openbmc_project/Logging/Entry/server.hpp"
Deepak Kodihalli36db46c2017-03-31 06:28:44 -05006#include "xyz/openbmc_project/Object/Delete/server.hpp"
Deepak Kodihallib388da62017-02-27 00:47:12 -06007#include "org/openbmc/Associations/server.hpp"
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06008
9namespace phosphor
10{
11namespace logging
12{
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060013
Deepak Kodihallib388da62017-02-27 00:47:12 -060014using EntryIfaces = sdbusplus::server::object::object<
15 sdbusplus::xyz::openbmc_project::Logging::server::Entry,
Deepak Kodihalli36db46c2017-03-31 06:28:44 -050016 sdbusplus::xyz::openbmc_project::Object::server::Delete,
Deepak Kodihallib388da62017-02-27 00:47:12 -060017 sdbusplus::org::openbmc::server::Associations>;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060018
Deepak Kodihalli35b46372017-02-27 04:58:18 -060019using AssociationList =
20 std::vector<std::tuple<std::string, std::string, std::string>>;
21
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050022class Manager;
23
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060024/** @class Entry
25 * @brief OpenBMC logging entry implementation.
26 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060027 * xyz.openbmc_project.Logging.Entry and
28 * org.openbmc.Associations DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060029 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060030class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060031{
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
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060040 /** @brief Constructor to put object onto bus at a dbus path.
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060041 * Defer signal registration (pass true for deferSignal to the
42 * base class) until after the properties are set.
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060043 * @param[in] bus - Bus to attach to.
44 * @param[in] path - Path to attach at.
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060045 * @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.
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050050 * @param[in] parent - The error's parent.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060051 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060052 Entry(sdbusplus::bus::bus& bus,
53 const std::string& path,
54 uint32_t idErr,
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060055 uint64_t timestampErr,
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060056 Level severityErr,
57 std::string&& msgErr,
Deepak Kodihalli35b46372017-02-27 04:58:18 -060058 std::vector<std::string>&& additionalDataErr,
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050059 AssociationList&& objects,
60 Manager& parent) :
61 EntryIfaces(bus, path.c_str(), true),
62 parent(parent)
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060063 {
64 id(idErr);
65 severity(severityErr);
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060066 timestamp(timestampErr);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060067 message(std::move(msgErr));
68 additionalData(std::move(additionalDataErr));
Deepak Kodihalli35b46372017-02-27 04:58:18 -060069 associations(std::move(objects));
Deepak Kodihalli16aed112017-03-31 00:11:46 -050070 // Store a copy of associations in case we need to recreate
71 assocs = associations();
Deepak Kodihalli1c9f16e2017-03-27 03:50:01 -050072 resolved(false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060073
74 // Emit deferred signal.
75 this->emit_object_added();
76 };
77
Deepak Kodihalli72654f12017-06-12 04:33:29 -050078 /** @brief Constructor that puts an "empty" error object on the bus,
79 * with only the id property populated. Rest of the properties
80 * to be set by the caller. Caller should emit the added signal.
81 * @param[in] bus - Bus to attach to.
82 * @param[in] path - Path to attach at.
83 * @param[in] id - The error entry id.
84 * @param[in] parent - The error's parent.
85 */
86 Entry(sdbusplus::bus::bus& bus,
87 const std::string& path,
88 uint32_t entryId,
89 Manager& parent) :
90 EntryIfaces(bus, path.c_str(), true),
91 parent(parent)
92 {
93 id(entryId);
94 };
95
Deepak Kodihalli90abed62017-03-27 03:56:44 -050096 /** @brief Set resolution status of the error.
97 * @param[in] value - boolean indicating resolution
98 * status (true = resolved)
99 * @returns value of 'Resolved' property
100 */
101 bool resolved(bool value) override
102 {
103 value ?
104 associations({}) :
105 associations(assocs);
106
107 return sdbusplus::xyz::openbmc_project::
108 Logging::server::Entry::resolved(value);
109 }
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500110 using sdbusplus::xyz::openbmc_project::
111 Logging::server::Entry::resolved;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500112
Deepak Kodihalli36db46c2017-03-31 06:28:44 -0500113 /** @brief Delete this d-bus object.
114 */
115 void delete_() override;
116
Deepak Kodihalli16aed112017-03-31 00:11:46 -0500117 private:
118 /** @brief This entry's associations */
119 AssociationList assocs = {};
Deepak Kodihalli8110ca62017-04-10 02:11:54 -0500120
121 /** @brief This entry's parent */
122 Manager& parent;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -0600123};
124
125} // namespace logging
126} // namespace phosphor