1 #pragma once 2 3 #include "manager.hpp" 4 #include "serialize.hpp" 5 6 #include <sdbusplus/bus.hpp> 7 #include <sdbusplus/server/object.hpp> 8 #include <xyz/openbmc_project/Led/Group/server.hpp> 9 10 #include <string> 11 12 namespace phosphor 13 { 14 namespace led 15 { 16 17 /** @class Group 18 * @brief Manages group of LEDs and applies action on the elements of group 19 */ 20 class Group : 21 sdbusplus::server::object::object< 22 sdbusplus::xyz::openbmc_project::Led::server::Group> 23 { 24 public: 25 Group() = delete; 26 ~Group() = default; 27 Group(const Group&) = delete; 28 Group& operator=(const Group&) = delete; 29 Group(Group&&) = default; 30 Group& operator=(Group&&) = default; 31 32 /** @brief Constructs LED Group 33 * 34 * @param[in] bus - Handle to system dbus 35 * @param[in] objPath - The D-Bus path that hosts LED group 36 * @param[in] manager - Reference to Manager 37 * @param[in] serialize - Serialize object 38 * @param[in] callBack - Custom callback when LED group is asserted 39 */ 40 Group(sdbusplus::bus::bus& bus, const std::string& objPath, 41 Manager& manager, Serialize& serialize, 42 std::function<void(Group*, bool)> callBack = nullptr) : 43 44 sdbusplus::server::object::object< 45 sdbusplus::xyz::openbmc_project::Led::server::Group>( 46 bus, objPath.c_str(), true), 47 path(objPath), manager(manager), serialize(serialize), 48 customCallBack(callBack) 49 { 50 // Initialize Asserted property value 51 if (serialize.getGroupSavedState(objPath)) 52 { 53 asserted(true); 54 } 55 56 // Emit deferred signal. 57 emit_object_added(); 58 } 59 60 /** @brief Property SET Override function 61 * 62 * @param[in] value - True or False 63 * @return - Success or exception thrown 64 */ 65 bool asserted(bool value) override; 66 67 private: 68 /** @brief Path of the group instance */ 69 std::string path; 70 71 /** @brief Reference to Manager object */ 72 Manager& manager; 73 74 /** @brief The serialize class for storing and restoring groups of LEDs */ 75 Serialize& serialize; 76 77 /** @brief Custom callback when LED group is asserted 78 */ 79 std::function<void(Group*, bool)> customCallBack; 80 }; 81 82 } // namespace led 83 } // namespace phosphor 84