blob: 29427045fe62324a4f6a99175e6a35db5912494f [file] [log] [blame]
Jayanth Othayoth224882b2017-05-04 05:46:45 -05001#pragma once
2
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05003#include <experimental/filesystem>
4
5#include <sdbusplus/bus.hpp>
Jayanth Othayoth224882b2017-05-04 05:46:45 -05006#include <sdbusplus/server/object.hpp>
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05007
Jayanth Othayoth224882b2017-05-04 05:46:45 -05008#include "xyz/openbmc_project/Dump/Entry/server.hpp"
9#include "xyz/openbmc_project/Object/Delete/server.hpp"
10#include "xyz/openbmc_project/Time/EpochTime/server.hpp"
11
12namespace phosphor
13{
14namespace dump
15{
16
17template <typename T>
18using ServerObject = typename sdbusplus::server::object::object<T>;
19
20using EntryIfaces = sdbusplus::server::object::object<
21 sdbusplus::xyz::openbmc_project::Dump::server::Entry,
22 sdbusplus::xyz::openbmc_project::Object::server::Delete,
23 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>;
24
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050025namespace fs = std::experimental::filesystem;
26
27class Manager;
28
Jayanth Othayoth224882b2017-05-04 05:46:45 -050029/** @class Entry
30 * @brief OpenBMC Dump Entry implementation.
31 * @details A concrete implementation for the
32 * xyz.openbmc_project.Dump.Entry DBus API
33 */
34class Entry : public EntryIfaces
35{
36 public:
37 Entry() = delete;
38 Entry(const Entry&) = delete;
39 Entry& operator=(const Entry&) = delete;
40 Entry(Entry&&) = delete;
41 Entry& operator=(Entry&&) = delete;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050042 ~Entry() = default;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050043
44 /** @brief Constructor for the Dump Entry Object
45 * @param[in] bus - Bus to attach to.
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050046 * @param[in] objPath - Object path to attach to
47 * @param[in] dumpId - Dump id.
48 * @param[in] timeStamp - Dump creation timestamp
49 * since the epoch.
50 * @param[in] fileSize - Dump file size in bytes.
51 * @param[in] file - Dump file name.
52 * @param[in] parent - The dump entry's parent.
Jayanth Othayoth224882b2017-05-04 05:46:45 -050053 */
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050054 Entry(sdbusplus::bus::bus& bus,
55 const std::string& objPath,
56 uint32_t dumpId,
57 uint64_t timeStamp,
58 uint64_t fileSize,
59 const fs::path& file,
60 Manager& parent):
61 EntryIfaces(bus, objPath.c_str(), true),
62 file(file),
63 parent(parent),
64 id(dumpId)
65 {
66 size(fileSize);
67 elapsed(timeStamp);
68 // Emit deferred signal.
69 this->emit_object_added();
70 };
Jayanth Othayoth224882b2017-05-04 05:46:45 -050071
72 /** @brief Delete this d-bus object.
73 */
74 void delete_() override ;
75
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050076 private:
77 /** @Dump file name */
78 fs::path file;
79
80 /** @brief This entry's parent */
81 Manager& parent;
82
83 /** @brief This entry's id */
84 uint32_t id;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050085};
86
87} // namespace dump
88} // namespace phosphor