Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/server/object.hpp> |
| 5 | #include <org/open_power/OCC/Status/server.hpp> |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 6 | #include "occ_events.hpp" |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 7 | #include "occ_device.hpp" |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 8 | namespace open_power |
| 9 | { |
| 10 | namespace occ |
| 11 | { |
| 12 | |
| 13 | namespace Base = sdbusplus::org::open_power::OCC::server; |
| 14 | using Interface = sdbusplus::server::object::object<Base::Status>; |
| 15 | |
| 16 | /** @class Status |
| 17 | * @brief Implementation of OCC Active Status |
| 18 | */ |
| 19 | class 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 Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 29 | /** @brief Constructs the Status object and |
| 30 | * the underlying device object |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 31 | * |
| 32 | * @param[in] bus - DBus bus to attach to |
| 33 | * @param[in] path - DBus object path |
| 34 | */ |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 35 | Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path) |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 36 | : Interface(bus, path), |
| 37 | path(path), |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 38 | device(event, |
| 39 | name + std::to_string((this->path.back() - '0') + 1), |
| 40 | std::bind(&Status::deviceErrorHandler, this)) |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 41 | { |
| 42 | // Nothing to do here |
| 43 | } |
| 44 | |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 45 | /** @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 Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 51 | /** @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 Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 58 | |
| 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 Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 68 | |
| 69 | /** @brief Callback handler when device errors are detected */ |
| 70 | void deviceErrorHandler(); |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace occ |
| 74 | } // namespace open_power |