blob: 899e5ecfb23e63075cb56d35609f0f41b844a437 [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>
8
9namespace phosphor
10{
11namespace events
12{
13
14using namespace phosphor::dbus::monitoring;
15
Brad Bishopd1eac882018-03-29 10:34:05 -040016using EntryIface = sdbusplus::server::object::object<
17 sdbusplus::xyz::openbmc_project::Logging::server::Event>;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053018
19/** @class Entry
20 * @brief OpenBMC Event entry implementation.
21 * @details A concrete implementation for the
22 * xyz.openbmc_project.Event.Entry.
23 */
24class Entry : public EntryIface
25{
Brad Bishopd1eac882018-03-29 10:34:05 -040026 public:
27 Entry() = delete;
28 Entry(const Entry&) = delete;
29 Entry& operator=(const Entry&) = delete;
30 Entry(Entry&&) = delete;
31 Entry& operator=(Entry&&) = delete;
32 virtual ~Entry() = default;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053033
Brad Bishopd1eac882018-03-29 10:34:05 -040034 /** @brief Constructor to put object onto bus at a dbus path.
35 * @param[in] path - Path to attach at.
36 * @param[in] eventId - The event entry id.
37 * @param[in] timestamp - timestamp when the event created.
38 * @param[in] msg - The message of the event.
39 * @param[in] metaData - The event metadata.
40 */
41 Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg,
42 std::vector<std::string>&& metaData) :
43 EntryIface(SDBusPlus::getBus(), path.c_str(), true),
44 objectPath(path)
45 {
46 timestamp(eventTimestamp);
47 message(msg);
48 additionalData(metaData);
49 // Emit deferred signal.
50 this->emit_object_added();
51 }
Ratan Gupta3e84ec62017-10-06 21:37:01 +053052
Dhruvaraj Subhashchandran6524b9d2017-10-18 01:41:51 -050053 /** @brief Constructor to create an empty event object with only
54 * timestamp, caller should make a call to emit added signal.
55 * @param[in] path - Path to attach at.
56 * @param[in] timestamp - timestamp when the event created.
57 */
58 Entry(const std::string& path, uint64_t eventTimestamp) :
59 EntryIface(SDBusPlus::getBus(), path.c_str(), true), objectPath(path)
60 {
61 timestamp(eventTimestamp);
62 }
63
Brad Bishopd1eac882018-03-29 10:34:05 -040064 /** @brief Path of Object. */
65 std::string objectPath;
Ratan Gupta3e84ec62017-10-06 21:37:01 +053066};
67
68} // namespace events
69} // namespace phosphor