manager: refactor setGroupState
setGroupState used to rely on std::set operations with non-obvious
workings involving std::inserter with custom comparators.
However the logic required seem to be simpler, therefore replacing the
set-based implementation with a map-based one.
The current state of the leds is now stored in a map, replacing the
previous two class members required with only one.
Change-Id: I3a812da4e5632c8258c45511f05ea1966b2f7208
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/manager/manager.hpp b/manager/manager.hpp
index 4e611b8..24a6c17 100644
--- a/manager/manager.hpp
+++ b/manager/manager.hpp
@@ -10,6 +10,9 @@
#include <string>
#include <unordered_map>
+// to better see what the string is representing
+using LedName = std::string;
+
namespace phosphor
{
namespace led
@@ -89,6 +92,10 @@
// Nothing here
}
+ /* create the resulting map from all currently asserted groups */
+ static auto getNewMap(std::set<const ActionSet*> assertedGroups)
+ -> std::map<LedName, Layout::LedAction>;
+
/** @brief Given a group name, applies the action on the group
*
* @param[in] path - dbus path of group
@@ -146,13 +153,8 @@
/** @brief Pointers to groups that are in asserted state */
std::set<const ActionSet*> assertedGroups;
- /** @brief Contains the highest priority actions for all
- * asserted LEDs.
- */
- ActionSet currentState;
-
- /** @brief Contains the set of all actions for asserted LEDs */
- ActionSet combinedState;
+ /** Map of led name to current state */
+ std::map<std::string, Layout::LedAction> ledStateMap;
/** @brief Custom callback when enabled lamp test */
std::function<bool(ActionSet& ledsAssert, ActionSet& ledsDeAssert)>