blob: f426048ae5078ae331230391c2882b438cb25b78 [file] [log] [blame]
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05301#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include <org/open_power/OCC/Status/server.hpp>
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +05306#include "occ_events.hpp"
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +05307#include "occ_device.hpp"
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05308namespace open_power
9{
10namespace occ
11{
12
13namespace Base = sdbusplus::org::open_power::OCC::server;
14using Interface = sdbusplus::server::object::object<Base::Status>;
15
16/** @class Status
17 * @brief Implementation of OCC Active Status
18 */
19class Status : public Interface
20{
21 public:
22 Status() = delete;
23 ~Status() = default;
24 Status(const Status&) = delete;
25 Status& operator=(const Status&) = delete;
26 Status(Status&&) = default;
27 Status& operator=(Status&&) = default;
28
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053029 /** @brief Constructs the Status object and
30 * the underlying device object
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053031 *
32 * @param[in] bus - DBus bus to attach to
33 * @param[in] path - DBus object path
34 */
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053035 Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path)
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053036 : Interface(bus, path),
37 path(path),
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053038 device(event,
39 name + std::to_string((this->path.back() - '0') + 1),
40 std::bind(&Status::deviceErrorHandler, this))
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053041 {
42 // Nothing to do here
43 }
44
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053045 /** @brief Since we are overriding the setter-occActive but not the
46 * getter-occActive, we need to have this using in order to
47 * allow passthrough usage of the getter-occActive
48 */
49 using Base::Status::occActive;
50
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053051 /** @brief SET OccActive to True or False
52 *
53 * @param[in] value - Intended value
54 *
55 * @return - Updated value of the property
56 */
57 bool occActive(bool value) override;
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053058
59 private:
60 /** @brief OCC dbus object path */
61 std::string path;
62
63 /** @brief occ name prefix */
64 std::string name = OCC_NAME;
65
66 /** @brief OCC device object to do bind and unbind */
67 Device device;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053068
69 /** @brief Callback handler when device errors are detected */
70 void deviceErrorHandler();
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053071};
72
73} // namespace occ
74} // namespace open_power