blob: ac4949a99b4a464ccccb1c360fdef7029c4f5b76 [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
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060022/** @class Entry
23 * @brief OpenBMC logging entry implementation.
24 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060025 * xyz.openbmc_project.Logging.Entry and
26 * org.openbmc.Associations DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060027 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060028class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060029{
30 public:
31 Entry() = delete;
32 Entry(const Entry&) = delete;
33 Entry& operator=(const Entry&) = delete;
34 Entry(Entry&&) = delete;
35 Entry& operator=(Entry&&) = delete;
36 virtual ~Entry() = default;
37
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060038 /** @brief Constructor to put object onto bus at a dbus path.
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060039 * Defer signal registration (pass true for deferSignal to the
40 * base class) until after the properties are set.
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060041 * @param[in] bus - Bus to attach to.
42 * @param[in] path - Path to attach at.
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060043 * @param[in] idErr - The error entry id.
44 * @param[in] timestampErr - The commit timestamp.
45 * @param[in] severityErr - The severity of the error.
46 * @param[in] msgErr - The message of the error.
47 * @param[in] additionalDataErr - The error metadata.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060048 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060049 Entry(sdbusplus::bus::bus& bus,
50 const std::string& path,
51 uint32_t idErr,
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060052 uint64_t timestampErr,
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060053 Level severityErr,
54 std::string&& msgErr,
Deepak Kodihalli35b46372017-02-27 04:58:18 -060055 std::vector<std::string>&& additionalDataErr,
56 AssociationList&& objects) :
Deepak Kodihallib388da62017-02-27 00:47:12 -060057 EntryIfaces(bus, path.c_str(), true)
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060058 {
59 id(idErr);
60 severity(severityErr);
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060061 timestamp(timestampErr);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060062 message(std::move(msgErr));
63 additionalData(std::move(additionalDataErr));
Deepak Kodihalli35b46372017-02-27 04:58:18 -060064 associations(std::move(objects));
Deepak Kodihalli16aed112017-03-31 00:11:46 -050065 // Store a copy of associations in case we need to recreate
66 assocs = associations();
Deepak Kodihalli1c9f16e2017-03-27 03:50:01 -050067 resolved(false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060068
69 // Emit deferred signal.
70 this->emit_object_added();
71 };
72
Deepak Kodihalli90abed62017-03-27 03:56:44 -050073 /** @brief Set resolution status of the error.
74 * @param[in] value - boolean indicating resolution
75 * status (true = resolved)
76 * @returns value of 'Resolved' property
77 */
78 bool resolved(bool value) override
79 {
80 value ?
81 associations({}) :
82 associations(assocs);
83
84 return sdbusplus::xyz::openbmc_project::
85 Logging::server::Entry::resolved(value);
86 }
87
Deepak Kodihalli36db46c2017-03-31 06:28:44 -050088 /** @brief Delete this d-bus object.
89 */
90 void delete_() override;
91
Deepak Kodihalli16aed112017-03-31 00:11:46 -050092 private:
93 /** @brief This entry's associations */
94 AssociationList assocs = {};
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060095};
96
97} // namespace logging
98} // namespace phosphor