Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 3 | #include "manager.hpp" |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 4 | #include "serialize.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 5 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <sdbusplus/server/object.hpp> |
Vishwanatha Subbanna | 55ef5b0 | 2017-03-10 13:32:08 +0530 | [diff] [blame] | 8 | #include <xyz/openbmc_project/Led/Group/server.hpp> |
Andrew Geissler | d02c3cb | 2020-05-16 10:28:02 -0500 | [diff] [blame] | 9 | |
George Liu | a6c18f8 | 2020-06-22 10:50:04 +0800 | [diff] [blame] | 10 | #include <string> |
| 11 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 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 | */ |
George Liu | a6c18f8 | 2020-06-22 10:50:04 +0800 | [diff] [blame] | 20 | class Group : |
| 21 | sdbusplus::server::object::object< |
| 22 | sdbusplus::xyz::openbmc_project::Led::server::Group> |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 23 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 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; |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 31 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 32 | /** @brief Constructs LED Group |
| 33 | * |
| 34 | * @param[in] bus - Handle to system dbus |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 35 | * @param[in] objPath - The D-Bus path that hosts LED group |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 36 | * @param[in] manager - Reference to Manager |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 37 | * @param[in] serialize - Serialize object |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 38 | */ |
| 39 | Group(sdbusplus::bus::bus& bus, const std::string& objPath, |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 40 | Manager& manager, Serialize& serialize) : |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 41 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 42 | sdbusplus::server::object::object< |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 43 | sdbusplus::xyz::openbmc_project::Led::server::Group>( |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 44 | bus, objPath.c_str(), true), |
| 45 | path(objPath), manager(manager), serialize(serialize) |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 46 | { |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 47 | // Initialize Asserted property value |
| 48 | if (serialize.getGroupSavedState(objPath)) |
| 49 | { |
| 50 | asserted(true); |
| 51 | } |
| 52 | |
| 53 | // Emit deferred signal. |
| 54 | emit_object_added(); |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 55 | } |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 56 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 57 | /** @brief Property SET Override function |
| 58 | * |
| 59 | * @param[in] value - True or False |
| 60 | * @return - Success or exception thrown |
| 61 | */ |
| 62 | bool asserted(bool value) override; |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 63 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 64 | private: |
| 65 | /** @brief Path of the group instance */ |
| 66 | std::string path; |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 67 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 68 | /** @brief Reference to Manager object */ |
| 69 | Manager& manager; |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 70 | |
| 71 | /** @brief The serialize class for storing and restoring groups of LEDs */ |
| 72 | Serialize& serialize; |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace led |
| 76 | } // namespace phosphor |