1 #pragma once
2 
3 #include "dump_entry.hpp"
4 #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
5 
6 #include <sdbusplus/bus.hpp>
7 #include <sdbusplus/server/object.hpp>
8 
9 #define CREATE_DUMP_MAX_PARAMS 2
10 
11 namespace phosphor
12 {
13 namespace dump
14 {
15 
16 using DumpCreateParams =
17     std::map<std::string, std::variant<std::string, uint64_t>>;
18 using Iface = sdbusplus::server::object_t<
19     sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
20 
21 /** @class Manager
22  *  @brief Dump  manager base class.
23  *  @details A concrete implementation for the
24  *  xyz::openbmc_project::Collection::server::DeleteAll.
25  */
26 class Manager : public Iface
27 {
28     friend class Entry;
29 
30   public:
31     Manager() = delete;
32     Manager(const Manager&) = default;
33     Manager& operator=(const Manager&) = delete;
34     Manager(Manager&&) = delete;
35     Manager& operator=(Manager&&) = delete;
36     virtual ~Manager() = default;
37 
38     /** @brief Constructor to put object onto bus at a dbus path.
39      *  @param[in] bus - Bus to attach to.
40      *  @param[in] event - Dump manager sd_event loop.
41      *  @param[in] path - Path to attach at.
42      *  @param[in] baseEntryPath - Base path of the dump entry.
43      */
Manager(sdbusplus::bus_t & bus,const char * path,const std::string & baseEntryPath)44     Manager(sdbusplus::bus_t& bus, const char* path,
45             const std::string& baseEntryPath) :
46         Iface(bus, path, Iface::action::defer_emit),
47         bus(bus), lastEntryId(0), baseEntryPath(baseEntryPath)
48     {}
49 
50     /** @brief Construct dump d-bus objects from their persisted
51      *        representations.
52      */
53     virtual void restore() = 0;
54 
55   protected:
56     /** @brief Erase specified entry d-bus object
57      *
58      * @param[in] entryId - unique identifier of the entry
59      */
60     void erase(uint32_t entryId);
61 
62     /** @brief  Erase all BMC dump entries and  Delete all Dump files
63      * from Permanent location
64      *
65      */
66     void deleteAll() override;
67 
68     /** @brief sdbusplus DBus bus connection. */
69     sdbusplus::bus_t& bus;
70 
71     /** @brief Dump Entry dbus objects map based on entry id */
72     std::map<uint32_t, std::unique_ptr<Entry>> entries;
73 
74     /** @brief Id of the last Dump entry */
75     uint32_t lastEntryId;
76 
77     /** @bried base object path for the entry object */
78     std::string baseEntryPath;
79 };
80 
81 } // namespace dump
82 } // namespace phosphor
83