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