blob: e23ba76f5f556bab564d20391e44188703a35f9a [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 Kodihallib388da62017-02-27 00:47:12 -06006#include "org/openbmc/Associations/server.hpp"
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06007
8namespace phosphor
9{
10namespace logging
11{
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060012
Deepak Kodihallib388da62017-02-27 00:47:12 -060013using EntryIfaces = sdbusplus::server::object::object<
14 sdbusplus::xyz::openbmc_project::Logging::server::Entry,
15 sdbusplus::org::openbmc::server::Associations>;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060016
Deepak Kodihalli35b46372017-02-27 04:58:18 -060017using AssociationList =
18 std::vector<std::tuple<std::string, std::string, std::string>>;
19
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060020/** @class Entry
21 * @brief OpenBMC logging entry implementation.
22 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060023 * xyz.openbmc_project.Logging.Entry and
24 * org.openbmc.Associations DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060025 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060026class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060027{
28 public:
29 Entry() = delete;
30 Entry(const Entry&) = delete;
31 Entry& operator=(const Entry&) = delete;
32 Entry(Entry&&) = delete;
33 Entry& operator=(Entry&&) = delete;
34 virtual ~Entry() = default;
35
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060036 /** @brief Constructor to put object onto bus at a dbus path.
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060037 * Defer signal registration (pass true for deferSignal to the
38 * base class) until after the properties are set.
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060039 * @param[in] bus - Bus to attach to.
40 * @param[in] path - Path to attach at.
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060041 * @param[in] idErr - The error entry id.
42 * @param[in] timestampErr - The commit timestamp.
43 * @param[in] severityErr - The severity of the error.
44 * @param[in] msgErr - The message of the error.
45 * @param[in] additionalDataErr - The error metadata.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060046 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060047 Entry(sdbusplus::bus::bus& bus,
48 const std::string& path,
49 uint32_t idErr,
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060050 uint64_t timestampErr,
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060051 Level severityErr,
52 std::string&& msgErr,
Deepak Kodihalli35b46372017-02-27 04:58:18 -060053 std::vector<std::string>&& additionalDataErr,
54 AssociationList&& objects) :
Deepak Kodihallib388da62017-02-27 00:47:12 -060055 EntryIfaces(bus, path.c_str(), true)
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060056 {
57 id(idErr);
58 severity(severityErr);
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060059 timestamp(timestampErr);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060060 message(std::move(msgErr));
61 additionalData(std::move(additionalDataErr));
Deepak Kodihalli35b46372017-02-27 04:58:18 -060062 associations(std::move(objects));
Deepak Kodihalli16aed112017-03-31 00:11:46 -050063 // Store a copy of associations in case we need to recreate
64 assocs = associations();
Deepak Kodihalli1c9f16e2017-03-27 03:50:01 -050065 resolved(false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060066
67 // Emit deferred signal.
68 this->emit_object_added();
69 };
70
Deepak Kodihalli90abed62017-03-27 03:56:44 -050071 /** @brief Set resolution status of the error.
72 * @param[in] value - boolean indicating resolution
73 * status (true = resolved)
74 * @returns value of 'Resolved' property
75 */
76 bool resolved(bool value) override
77 {
78 value ?
79 associations({}) :
80 associations(assocs);
81
82 return sdbusplus::xyz::openbmc_project::
83 Logging::server::Entry::resolved(value);
84 }
85
Deepak Kodihalli16aed112017-03-31 00:11:46 -050086 private:
87 /** @brief This entry's associations */
88 AssociationList assocs = {};
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060089};
90
91} // namespace logging
92} // namespace phosphor