blob: 7bf97c64ddb28fcef976cb3614b64b3067060878 [file] [log] [blame]
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05301#pragma once
2
Patrick Venture91ac8d32018-11-01 17:03:22 -07003#include "manager.hpp"
George Liu2098aa62020-05-09 11:26:35 +08004#include "serialize.hpp"
Patrick Venture91ac8d32018-11-01 17:03:22 -07005
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05306#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
Vishwanatha Subbanna55ef5b02017-03-10 13:32:08 +05308#include <xyz/openbmc_project/Led/Group/server.hpp>
Andrew Geisslerd02c3cb2020-05-16 10:28:02 -05009
George Liua6c18f82020-06-22 10:50:04 +080010#include <string>
11
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053012namespace phosphor
13{
14namespace led
15{
16
17/** @class Group
18 * @brief Manages group of LEDs and applies action on the elements of group
19 */
George Liua6c18f82020-06-22 10:50:04 +080020class Group :
21 sdbusplus::server::object::object<
22 sdbusplus::xyz::openbmc_project::Led::server::Group>
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053023{
Patrick Venture91ac8d32018-11-01 17:03:22 -070024 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 Subbanna4c8c72b2016-11-29 23:02:06 +053031
Patrick Venture91ac8d32018-11-01 17:03:22 -070032 /** @brief Constructs LED Group
33 *
34 * @param[in] bus - Handle to system dbus
George Liu2098aa62020-05-09 11:26:35 +080035 * @param[in] objPath - The D-Bus path that hosts LED group
Patrick Venture91ac8d32018-11-01 17:03:22 -070036 * @param[in] manager - Reference to Manager
George Liu2098aa62020-05-09 11:26:35 +080037 * @param[in] serialize - Serialize object
Patrick Venture91ac8d32018-11-01 17:03:22 -070038 */
39 Group(sdbusplus::bus::bus& bus, const std::string& objPath,
George Liu2098aa62020-05-09 11:26:35 +080040 Manager& manager, Serialize& serialize) :
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053041
Patrick Venture91ac8d32018-11-01 17:03:22 -070042 sdbusplus::server::object::object<
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053043 sdbusplus::xyz::openbmc_project::Led::server::Group>(
George Liu2098aa62020-05-09 11:26:35 +080044 bus, objPath.c_str(), true),
45 path(objPath), manager(manager), serialize(serialize)
Patrick Venture91ac8d32018-11-01 17:03:22 -070046 {
George Liu2098aa62020-05-09 11:26:35 +080047 // Initialize Asserted property value
48 if (serialize.getGroupSavedState(objPath))
49 {
50 asserted(true);
51 }
52
53 // Emit deferred signal.
54 emit_object_added();
Patrick Venture91ac8d32018-11-01 17:03:22 -070055 }
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053056
Patrick Venture91ac8d32018-11-01 17:03:22 -070057 /** @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 Subbanna4c8c72b2016-11-29 23:02:06 +053063
Patrick Venture91ac8d32018-11-01 17:03:22 -070064 private:
65 /** @brief Path of the group instance */
66 std::string path;
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053067
Patrick Venture91ac8d32018-11-01 17:03:22 -070068 /** @brief Reference to Manager object */
69 Manager& manager;
George Liu2098aa62020-05-09 11:26:35 +080070
71 /** @brief The serialize class for storing and restoring groups of LEDs */
72 Serialize& serialize;
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053073};
74
75} // namespace led
76} // namespace phosphor