controller: Heap-allocate LEDs
Do this in preparation for migrating to a single instance of the daemon
whose LED inventory is updated via DBus where the update is triggered by
udev.
Splitting out this work reduces the review complexity of the patch that
rewrites the internals of the daemon.
Signed-off-by: Jayashree Dhanapal <jayashree-d@hcl.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I50e58126413514f7a64153f425629142fa5af6d4
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/physical.hpp b/physical.hpp
index 87bf5b5..14b7655 100644
--- a/physical.hpp
+++ b/physical.hpp
@@ -9,6 +9,8 @@
#include <fstream>
#include <string>
+namespace fs = std::filesystem;
+
namespace phosphor
{
namespace led
@@ -42,11 +44,13 @@
* @param[in] ledPath - sysfs path where this LED is exported
* @param[in] color - led color name
*/
- Physical(sdbusplus::bus_t& bus, const std::string& objPath, SysfsLed& led,
+
+ Physical(sdbusplus::bus_t& bus, const std::string& objPath,
+ std::unique_ptr<phosphor::led::SysfsLed> led,
const std::string& color = "") :
PhysicalIfaces(bus, objPath.c_str(),
PhysicalIfaces::action::defer_emit),
- led(led)
+ led(std::move(led))
{
// Suppose this is getting launched as part of BMC reboot, then we
// need to save what the micro-controller currently has.
@@ -75,7 +79,7 @@
private:
/** @brief Associated LED implementation
*/
- SysfsLed& led;
+ std::unique_ptr<phosphor::led::SysfsLed> led;
/** @brief The value that will assert the LED */
unsigned long assert{};