blob: 1f5aab89bcf40c79f41699092b9edf66a54a6ba3 [file] [log] [blame]
Jayanth Othayoth224882b2017-05-04 05:46:45 -05001#pragma once
2
Jayanth Othayoth224882b2017-05-04 05:46:45 -05003#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
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05007#include <experimental/filesystem>
8#include <sdbusplus/bus.hpp>
9#include <sdbusplus/server/object.hpp>
10
Jayanth Othayoth224882b2017-05-04 05:46:45 -050011namespace phosphor
12{
13namespace dump
14{
15
16template <typename T>
17using ServerObject = typename sdbusplus::server::object::object<T>;
18
19using EntryIfaces = sdbusplus::server::object::object<
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050020 sdbusplus::xyz::openbmc_project::Dump::server::Entry,
21 sdbusplus::xyz::openbmc_project::Object::server::Delete,
22 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050023
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050024namespace fs = std::experimental::filesystem;
25
26class Manager;
27
Jayanth Othayoth224882b2017-05-04 05:46:45 -050028/** @class Entry
29 * @brief OpenBMC Dump Entry implementation.
30 * @details A concrete implementation for the
31 * xyz.openbmc_project.Dump.Entry DBus API
32 */
33class Entry : public EntryIfaces
34{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050035 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;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050042
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050043 /** @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.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060049 * @param[in] dumpSize - Dump file size in bytes.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050050 * @param[in] parent - The dump entry's parent.
51 */
52 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060053 uint64_t timeStamp, uint64_t dumpSize, Manager& parent) :
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050054 EntryIfaces(bus, objPath.c_str(), true),
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060055 parent(parent), id(dumpId)
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050056 {
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060057 size(dumpSize);
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050058 elapsed(timeStamp);
59 // Emit deferred signal.
60 this->emit_object_added();
61 };
Jayanth Othayoth224882b2017-05-04 05:46:45 -050062
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050063 /** @brief Delete this d-bus object.
64 */
65 void delete_() override;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050066
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060067 /** @brief Method to initiate the offload of dump
68 */
69 void initiateOffload() override
70 {
71 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050072
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060073 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050074 /** @brief This entry's parent */
75 Manager& parent;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050076
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050077 /** @brief This entry's id */
78 uint32_t id;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050079};
80
81} // namespace dump
82} // namespace phosphor