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