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> |
Andrew Geissler | ae4c95c | 2020-05-16 13:58:53 -0500 | [diff] [blame] | 8 | #include <string> |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace events |
| 13 | { |
| 14 | |
| 15 | using namespace phosphor::dbus::monitoring; |
| 16 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 17 | using EntryIface = sdbusplus::server::object::object< |
| 18 | sdbusplus::xyz::openbmc_project::Logging::server::Event>; |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 19 | |
| 20 | /** @class Entry |
| 21 | * @brief OpenBMC Event entry implementation. |
| 22 | * @details A concrete implementation for the |
| 23 | * xyz.openbmc_project.Event.Entry. |
| 24 | */ |
| 25 | class Entry : public EntryIface |
| 26 | { |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 27 | 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 Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 34 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 35 | /** @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 Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 53 | |
Dhruvaraj Subhashchandran | 6524b9d | 2017-10-18 01:41:51 -0500 | [diff] [blame] | 54 | /** @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 Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 65 | /** @brief Path of Object. */ |
| 66 | std::string objectPath; |
Ratan Gupta | 3e84ec6 | 2017-10-06 21:37:01 +0530 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // namespace events |
| 70 | } // namespace phosphor |