#pragma once #include "manager.hpp" #include "serialize.hpp" #include #include #include #include namespace phosphor { namespace led { namespace { using GroupInherit = sdbusplus::server::object_t< sdbusplus::xyz::openbmc_project::Led::server::Group>; } /** @class Group * @brief Manages group of LEDs and applies action on the elements of group */ class Group : public GroupInherit { public: Group() = delete; ~Group() = default; Group(const Group&) = delete; Group& operator=(const Group&) = delete; Group(Group&&) = default; Group& operator=(Group&&) = default; /** @brief Constructs LED Group * * @param[in] bus - Handle to system dbus * @param[in] objPath - The D-Bus path that hosts LED group * @param[in] manager - Reference to Manager * @param[in] serializePtr - Serialize object * @param[in] callBack - Custom callback when LED group is asserted */ Group(sdbusplus::bus_t& bus, const std::string& objPath, Manager& manager, std::shared_ptr serializePtr, std::function callBack = nullptr) : GroupInherit(bus, objPath.c_str(), GroupInherit::action::defer_emit), path(objPath), manager(manager), serializePtr(serializePtr), customCallBack(callBack) { // Initialize Asserted property value if (serializePtr && serializePtr->getGroupSavedState(objPath)) { asserted(true); } // Emit deferred signal. emit_object_added(); } /** @brief Property SET Override function * * @param[in] value - True or False * @return - Success or exception thrown */ bool asserted(bool value) override; private: /** @brief Path of the group instance */ std::string path; /** @brief Reference to Manager object */ Manager& manager; /** @brief The serialize class for storing and restoring groups of LEDs */ std::shared_ptr serializePtr; /** @brief Custom callback when LED group is asserted * Callback that holds LED group method which handles lamp test request. * * @param[in] Group object - Pointer to Group object * @param[in] bool - Input value (true/false) * * @return bool which tells if execution succeeds(true) or fails(false). */ std::function customCallBack; }; } // namespace led } // namespace phosphor