blob: 28a63381aaf495623eb50e873897379da85167a5 [file] [log] [blame]
Ratan Gupta3e84ec62017-10-06 21:37:01 +05301#pragma once
2
3#include "sdbusplus.hpp"
4#include "xyz/openbmc_project/Logging/Event/server.hpp"
5
6#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
Andrew Geisslerae4c95c2020-05-16 13:58:53 -05008#include <string>
Ratan Gupta3e84ec62017-10-06 21:37:01 +05309
10namespace phosphor
11{
12namespace events
13{
14
15using namespace phosphor::dbus::monitoring;
16
Brad Bishopd1eac882018-03-29 10:34:05 -040017using EntryIface = sdbusplus::server::object::object<
18 sdbusplus::xyz::openbmc_project::Logging::server::Event>;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053019
20/** @class Entry
21 * @brief OpenBMC Event entry implementation.
22 * @details A concrete implementation for the
23 * xyz.openbmc_project.Event.Entry.
24 */
25class Entry : public EntryIface
26{
Brad Bishopd1eac882018-03-29 10:34:05 -040027 public:
28 Entry() = delete;
29 Entry(const Entry&) = delete;
30 Entry& operator=(const Entry&) = delete;
31 Entry(Entry&&) = delete;
32 Entry& operator=(Entry&&) = delete;
33 virtual ~Entry() = default;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053034
Brad Bishopd1eac882018-03-29 10:34:05 -040035 /** @brief Constructor to put object onto bus at a dbus path.
36 * @param[in] path - Path to attach at.
37 * @param[in] eventId - The event entry id.
38 * @param[in] timestamp - timestamp when the event created.
39 * @param[in] msg - The message of the event.
40 * @param[in] metaData - The event metadata.
41 */
42 Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg,
43 std::vector<std::string>&& metaData) :
44 EntryIface(SDBusPlus::getBus(), path.c_str(), true),
45 objectPath(path)
46 {
47 timestamp(eventTimestamp);
48 message(msg);
49 additionalData(metaData);
50 // Emit deferred signal.
51 this->emit_object_added();
52 }
Ratan Gupta3e84ec62017-10-06 21:37:01 +053053
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050054 /** @brief Constructor to create an empty event object with only
55 * timestamp, caller should make a call to emit added signal.
56 * @param[in] path - Path to attach at.
57 * @param[in] timestamp - timestamp when the event created.
58 */
59 Entry(const std::string& path, uint64_t eventTimestamp) :
60 EntryIface(SDBusPlus::getBus(), path.c_str(), true), objectPath(path)
61 {
62 timestamp(eventTimestamp);
63 }
64
Brad Bishopd1eac882018-03-29 10:34:05 -040065 /** @brief Path of Object. */
66 std::string objectPath;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053067};
68
69} // namespace events
70} // namespace phosphor