1 #pragma once
2 
3 #include "dump_entry.hpp"
4 #include "xyz/openbmc_project/Dump/Entry/System/server.hpp"
5 
6 #include <sdbusplus/bus.hpp>
7 #include <sdbusplus/server/object.hpp>
8 
9 namespace openpower
10 {
11 namespace dump
12 {
13 namespace system
14 {
15 template <typename T>
16 using ServerObject = typename sdbusplus::server::object::object<T>;
17 
18 using EntryIfaces = sdbusplus::server::object::object<
19     sdbusplus::xyz::openbmc_project::Dump::Entry::server::System>;
20 
21 namespace fs = std::experimental::filesystem;
22 
23 class Manager;
24 
25 /** @class Entry
26  *  @brief System Dump Entry implementation.
27  *  @details A concrete implementation for the
28  *  xyz.openbmc_project.Dump.Entry DBus API
29  */
30 class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
31 {
32   public:
33     Entry() = delete;
34     Entry(const Entry&) = delete;
35     Entry& operator=(const Entry&) = delete;
36     Entry(Entry&&) = delete;
37     Entry& operator=(Entry&&) = delete;
38     ~Entry() = default;
39 
40     /** @brief Constructor for the Dump Entry Object
41      *  @param[in] bus - Bus to attach to.
42      *  @param[in] objPath - Object path to attach to
43      *  @param[in] dumpId - Dump id.
44      *  @param[in] timeStamp - Dump creation timestamp
45      *             since the epoch.
46      *  @param[in] dumpSize - Dump size in bytes.
47      *  @param[in] sourceId - DumpId provided by the source.
48      *  @param[in] status - status  of the dump.
49      *  @param[in] parent - The dump entry's parent.
50      */
51     Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
52           uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
53           phosphor::dump::OperationStatus status,
54           phosphor::dump::Manager& parent) :
55         EntryIfaces(bus, objPath.c_str(), true),
56         phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
57                               status, parent)
58     {
59         sourceDumpId(sourceId);
60     };
61 
62     /** @brief Method to initiate the offload of dump
63      *  @param[in] uri - URI to offload dump.
64      */
65     void initiateOffload(std::string uri);
66 
67     /** @brief Method to update an existing dump entry
68      *  @param[in] timeStamp - Dump creation timestamp
69      *  @param[in] dumpSize - Dump size in bytes.
70      *  @param[in] sourceId - DumpId provided by the source.
71      */
72     void update(uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId)
73     {
74         elapsed(timeStamp);
75         size(dumpSize);
76         sourceDumpId(sourceId);
77         // TODO: Handled dump failure case with
78         // #bm-openbmc/2808
79         status(OperationStatus::Completed);
80         completedTime(timeStamp);
81     }
82 
83     /**
84      * @brief Delete host system dump and it entry dbus object
85      */
86     void delete_() override;
87 };
88 
89 } // namespace system
90 } // namespace dump
91 } // namespace openpower
92