1 #pragma once 2 3 #include "xyz/openbmc_project/Dump/Entry/server.hpp" 4 #include "xyz/openbmc_project/Object/Delete/server.hpp" 5 #include "xyz/openbmc_project/Time/EpochTime/server.hpp" 6 7 #include <experimental/filesystem> 8 #include <sdbusplus/bus.hpp> 9 #include <sdbusplus/server/object.hpp> 10 11 namespace phosphor 12 { 13 namespace dump 14 { 15 16 template <typename T> 17 using ServerObject = typename sdbusplus::server::object::object<T>; 18 19 using EntryIfaces = sdbusplus::server::object::object< 20 sdbusplus::xyz::openbmc_project::Dump::server::Entry, 21 sdbusplus::xyz::openbmc_project::Object::server::Delete, 22 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>; 23 24 namespace fs = std::experimental::filesystem; 25 26 class Manager; 27 28 /** @class Entry 29 * @brief OpenBMC Dump Entry implementation. 30 * @details A concrete implementation for the 31 * xyz.openbmc_project.Dump.Entry DBus API 32 */ 33 class Entry : public EntryIfaces 34 { 35 public: 36 Entry() = delete; 37 Entry(const Entry&) = delete; 38 Entry& operator=(const Entry&) = delete; 39 Entry(Entry&&) = delete; 40 Entry& operator=(Entry&&) = delete; 41 ~Entry() = default; 42 43 /** @brief Constructor for the Dump Entry Object 44 * @param[in] bus - Bus to attach to. 45 * @param[in] objPath - Object path to attach to 46 * @param[in] dumpId - Dump id. 47 * @param[in] timeStamp - Dump creation timestamp 48 * since the epoch. 49 * @param[in] fileSize - Dump file size in bytes. 50 * @param[in] file - Dump file name. 51 * @param[in] parent - The dump entry's parent. 52 */ 53 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, 54 uint64_t timeStamp, uint64_t fileSize, const fs::path& file, 55 Manager& parent) : 56 EntryIfaces(bus, objPath.c_str(), true), 57 file(file), parent(parent), id(dumpId) 58 { 59 size(fileSize); 60 elapsed(timeStamp); 61 // Emit deferred signal. 62 this->emit_object_added(); 63 }; 64 65 /** @brief Delete this d-bus object. 66 */ 67 void delete_() override; 68 69 private: 70 /** @Dump file name */ 71 fs::path file; 72 73 /** @brief This entry's parent */ 74 Manager& parent; 75 76 /** @brief This entry's id */ 77 uint32_t id; 78 }; 79 80 } // namespace dump 81 } // namespace phosphor 82