blob: 967813a207e70930fba865588c1d1422dc399002 [file] [log] [blame]
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05001#pragma once
2
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05003#include "dump_entry.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05004#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05005
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05006#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05008
9namespace phosphor
10{
11namespace dump
12{
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050013
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050014using Iface = sdbusplus::server::object::object<
15 sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
Marri Devender Rao0deb2872018-11-12 07:45:54 -060016
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050017/** @class Manager
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050018 * @brief Dump manager base class.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050019 * @details A concrete implementation for the
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050020 * xyz::openbmc_project::Collection::server::DeleteAll.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050021 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050022class Manager : public Iface
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050023{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050024 friend class Entry;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050025
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050026 public:
27 Manager() = delete;
28 Manager(const Manager&) = default;
29 Manager& operator=(const Manager&) = delete;
30 Manager(Manager&&) = delete;
31 Manager& operator=(Manager&&) = delete;
32 virtual ~Manager() = default;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050033
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050034 /** @brief Constructor to put object onto bus at a dbus path.
35 * @param[in] bus - Bus to attach to.
36 * @param[in] event - Dump manager sd_event loop.
37 * @param[in] path - Path to attach at.
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050038 * @param[in] baseEntryPath - Base path of the dump entry.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050039 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050040 Manager(sdbusplus::bus::bus& bus, const char* path,
41 const std::string& baseEntryPath) :
42 Iface(bus, path, true),
43 bus(bus), lastEntryId(0), baseEntryPath(baseEntryPath)
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050044 {
45 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050046
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050047 /** @brief Construct dump d-bus objects from their persisted
48 * representations.
49 */
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050050 virtual void restore() = 0;
Jayanth Othayoth43096592017-07-20 02:17:37 -050051
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050052 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050053 /** @brief Erase specified entry d-bus object
54 *
55 * @param[in] entryId - unique identifier of the entry
56 */
57 void erase(uint32_t entryId);
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050058
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050059 /** @brief Erase all BMC dump entries and Delete all Dump files
60 * from Permanent location
61 *
62 */
63 void deleteAll() override;
Nagaraju Goruganti3c899a42017-09-12 06:14:46 -050064
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050065 /** @brief sdbusplus DBus bus connection. */
66 sdbusplus::bus::bus& bus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050067
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050068 /** @brief Dump Entry dbus objects map based on entry id */
69 std::map<uint32_t, std::unique_ptr<Entry>> entries;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050070
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050071 /** @brief Id of the last Dump entry */
72 uint32_t lastEntryId;
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050073
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050074 /** @bried base object path for the entry object */
75 std::string baseEntryPath;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050076};
77
78} // namespace dump
79} // namespace phosphor