Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 1 | #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> |
George Liu | 3fe976c | 2022-06-21 09:37:04 +0800 | [diff] [blame] | 8 | |
Andrew Geissler | ae4c95c | 2020-05-16 13:58:53 -0500 | [diff] [blame] | 9 | #include <string> |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 10 | |
| 11 | namespace phosphor |
| 12 | { |
| 13 | namespace events |
| 14 | { |
| 15 | |
| 16 | using namespace phosphor::dbus::monitoring; |
| 17 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 18 | using EntryIface = sdbusplus::server::object::object< |
| 19 | sdbusplus::xyz::openbmc_project::Logging::server::Event>; |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 20 | |
| 21 | /** @class Entry |
| 22 | * @brief OpenBMC Event entry implementation. |
| 23 | * @details A concrete implementation for the |
| 24 | * xyz.openbmc_project.Event.Entry. |
| 25 | */ |
| 26 | class Entry : public EntryIface |
| 27 | { |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 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; |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 35 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 36 | /** @brief Constructor to put object onto bus at a dbus path. |
| 37 | * @param[in] path - Path to attach at. |
| 38 | * @param[in] eventId - The event entry id. |
| 39 | * @param[in] timestamp - timestamp when the event created. |
| 40 | * @param[in] msg - The message of the event. |
| 41 | * @param[in] metaData - The event metadata. |
| 42 | */ |
| 43 | Entry(const std::string& path, uint64_t eventTimestamp, std::string&& msg, |
| 44 | std::vector<std::string>&& metaData) : |
Patrick Williams | 232f395 | 2022-04-05 16:26:34 -0500 | [diff] [blame] | 45 | EntryIface(SDBusPlus::getBus(), path.c_str(), |
| 46 | EntryIface::action::defer_emit), |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 47 | objectPath(path) |
| 48 | { |
| 49 | timestamp(eventTimestamp); |
| 50 | message(msg); |
| 51 | additionalData(metaData); |
| 52 | // Emit deferred signal. |
| 53 | this->emit_object_added(); |
| 54 | } |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 55 | |
Dhruvaraj Subhashchandran | 6524b9d | 2017-10-18 01:41:51 -0500 | [diff] [blame] | 56 | /** @brief Constructor to create an empty event object with only |
| 57 | * timestamp, caller should make a call to emit added signal. |
| 58 | * @param[in] path - Path to attach at. |
| 59 | * @param[in] timestamp - timestamp when the event created. |
| 60 | */ |
| 61 | Entry(const std::string& path, uint64_t eventTimestamp) : |
Patrick Williams | 232f395 | 2022-04-05 16:26:34 -0500 | [diff] [blame] | 62 | EntryIface(SDBusPlus::getBus(), path.c_str(), |
| 63 | EntryIface::action::defer_emit), |
| 64 | objectPath(path) |
Dhruvaraj Subhashchandran | 6524b9d | 2017-10-18 01:41:51 -0500 | [diff] [blame] | 65 | { |
| 66 | timestamp(eventTimestamp); |
| 67 | } |
| 68 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 69 | /** @brief Path of Object. */ |
| 70 | std::string objectPath; |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace events |
| 74 | } // namespace phosphor |