1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include <sdbusplus/server/object.hpp>
5 #include <org/open_power/OCC/Status/server.hpp>
6 #include "occ_events.hpp"
7 #include "occ_device.hpp"
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 
29         /** @brief Constructs the Status object and
30          *         the underlying device object
31          *
32          *  @param[in] bus  - DBus bus to attach to
33          *  @param[in] path - DBus object path
34          */
35         Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path)
36             : Interface(bus, path),
37               path(path),
38               device(event,
39                      name + std::to_string((this->path.back() - '0') + 1),
40                      std::bind(&Status::deviceErrorHandler, this))
41         {
42             // Nothing to do here
43         }
44 
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 
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;
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;
68 
69         /** @brief Callback handler when device errors are detected */
70         void deviceErrorHandler();
71 };
72 
73 } // namespace occ
74 } // namespace open_power
75