1a320c7caSJayanth Othayoth #pragma once
2a320c7caSJayanth Othayoth 
3a320c7caSJayanth Othayoth #include "dump_entry.hpp"
4cb65ffceSJayanth Othayoth #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
5cb65ffceSJayanth Othayoth 
6cb65ffceSJayanth Othayoth #include <sdbusplus/bus.hpp>
7cb65ffceSJayanth Othayoth #include <sdbusplus/server/object.hpp>
8a320c7caSJayanth Othayoth 
9*74a1f39cSAsmitha Karunanithi #define CREATE_DUMP_MAX_PARAMS 2
10*74a1f39cSAsmitha Karunanithi 
11a320c7caSJayanth Othayoth namespace phosphor
12a320c7caSJayanth Othayoth {
13a320c7caSJayanth Othayoth namespace dump
14a320c7caSJayanth Othayoth {
15a320c7caSJayanth Othayoth 
16ddc3366eSDhruvaraj Subhashchandran using DumpCreateParams =
17ddc3366eSDhruvaraj Subhashchandran     std::map<std::string, std::variant<std::string, uint64_t>>;
189b18bf2dSPatrick Williams using Iface = sdbusplus::server::object_t<
19fef66a95SDhruvaraj Subhashchandran     sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
200deb287cSMarri Devender Rao 
21a320c7caSJayanth Othayoth /** @class Manager
22fef66a95SDhruvaraj Subhashchandran  *  @brief Dump  manager base class.
23a320c7caSJayanth Othayoth  *  @details A concrete implementation for the
243c899a4dSNagaraju Goruganti  *  xyz::openbmc_project::Collection::server::DeleteAll.
25a320c7caSJayanth Othayoth  */
26fef66a95SDhruvaraj Subhashchandran class Manager : public Iface
27a320c7caSJayanth Othayoth {
28a320c7caSJayanth Othayoth     friend class Entry;
29a320c7caSJayanth Othayoth 
30a320c7caSJayanth Othayoth   public:
31a320c7caSJayanth Othayoth     Manager() = delete;
32a320c7caSJayanth Othayoth     Manager(const Manager&) = default;
33a320c7caSJayanth Othayoth     Manager& operator=(const Manager&) = delete;
34a320c7caSJayanth Othayoth     Manager(Manager&&) = delete;
35a320c7caSJayanth Othayoth     Manager& operator=(Manager&&) = delete;
36a320c7caSJayanth Othayoth     virtual ~Manager() = default;
37a320c7caSJayanth Othayoth 
38a320c7caSJayanth Othayoth     /** @brief Constructor to put object onto bus at a dbus path.
39a320c7caSJayanth Othayoth      *  @param[in] bus - Bus to attach to.
40a320c7caSJayanth Othayoth      *  @param[in] event - Dump manager sd_event loop.
41a320c7caSJayanth Othayoth      *  @param[in] path - Path to attach at.
42fef66a95SDhruvaraj Subhashchandran      *  @param[in] baseEntryPath - Base path of the dump entry.
43a320c7caSJayanth Othayoth      */
Manager(sdbusplus::bus_t & bus,const char * path,const std::string & baseEntryPath)449b18bf2dSPatrick Williams     Manager(sdbusplus::bus_t& bus, const char* path,
45fef66a95SDhruvaraj Subhashchandran             const std::string& baseEntryPath) :
4673f64076SPatrick Williams         Iface(bus, path, Iface::action::defer_emit),
47fef66a95SDhruvaraj Subhashchandran         bus(bus), lastEntryId(0), baseEntryPath(baseEntryPath)
480af74a5eSJayanth Othayoth     {}
49a320c7caSJayanth Othayoth 
5043096598SJayanth Othayoth     /** @brief Construct dump d-bus objects from their persisted
5143096598SJayanth Othayoth      *        representations.
5243096598SJayanth Othayoth      */
53fef66a95SDhruvaraj Subhashchandran     virtual void restore() = 0;
5443096598SJayanth Othayoth 
55fef66a95SDhruvaraj Subhashchandran   protected:
56a320c7caSJayanth Othayoth     /** @brief Erase specified entry d-bus object
57a320c7caSJayanth Othayoth      *
58a320c7caSJayanth Othayoth      * @param[in] entryId - unique identifier of the entry
59a320c7caSJayanth Othayoth      */
60a320c7caSJayanth Othayoth     void erase(uint32_t entryId);
61a320c7caSJayanth Othayoth 
623c899a4dSNagaraju Goruganti     /** @brief  Erase all BMC dump entries and  Delete all Dump files
633c899a4dSNagaraju Goruganti      * from Permanent location
643c899a4dSNagaraju Goruganti      *
653c899a4dSNagaraju Goruganti      */
663c899a4dSNagaraju Goruganti     void deleteAll() override;
673c899a4dSNagaraju Goruganti 
68a320c7caSJayanth Othayoth     /** @brief sdbusplus DBus bus connection. */
699b18bf2dSPatrick Williams     sdbusplus::bus_t& bus;
70a320c7caSJayanth Othayoth 
71a320c7caSJayanth Othayoth     /** @brief Dump Entry dbus objects map based on entry id */
72a320c7caSJayanth Othayoth     std::map<uint32_t, std::unique_ptr<Entry>> entries;
73a320c7caSJayanth Othayoth 
74a320c7caSJayanth Othayoth     /** @brief Id of the last Dump entry */
75a320c7caSJayanth Othayoth     uint32_t lastEntryId;
76bcb174bdSJayanth Othayoth 
77fef66a95SDhruvaraj Subhashchandran     /** @bried base object path for the entry object */
78fef66a95SDhruvaraj Subhashchandran     std::string baseEntryPath;
79a320c7caSJayanth Othayoth };
80a320c7caSJayanth Othayoth 
81a320c7caSJayanth Othayoth } // namespace dump
82a320c7caSJayanth Othayoth } // namespace phosphor
83