xref: /openbmc/phosphor-debug-collector/dump_entry.hpp (revision 4a98e8fe86a2423145dea5ac5edc2d5f6ccd2ebc)
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] dumpSize - Dump file size in bytes.
50      *  @param[in] parent - The dump entry's parent.
51      */
52     Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
53           uint64_t timeStamp, uint64_t dumpSize, Manager& parent) :
54         EntryIfaces(bus, objPath.c_str(), true),
55         parent(parent), id(dumpId)
56     {
57         size(dumpSize);
58         elapsed(timeStamp);
59         // Emit deferred signal.
60         this->emit_object_added();
61     };
62 
63     /** @brief Delete this d-bus object.
64      */
65     void delete_() override;
66 
67     /** @brief Method to initiate the offload of dump
68      */
69     void initiateOffload() override
70     {
71     }
72 
73   protected:
74     /** @brief This entry's parent */
75     Manager& parent;
76 
77     /** @brief This entry's id */
78     uint32_t id;
79 };
80 
81 } // namespace dump
82 } // namespace phosphor
83