blob: b36f880c24c5a4152ebf33ea189a4493a98eaecf [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
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060029 * @brief Base Dump Entry implementation.
Jayanth Othayoth224882b2017-05-04 05:46:45 -050030 * @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
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060068 * @param[in] uri - URI to offload dump
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060069 */
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060070 void initiateOffload(std::string uri) override
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060071 {
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060072 offloadUri(uri);
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060073 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050074
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060075 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050076 /** @brief This entry's parent */
77 Manager& parent;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050078
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050079 /** @brief This entry's id */
80 uint32_t id;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050081};
82
83} // namespace dump
84} // namespace phosphor