led-layout: use common types everywhere
Rather than scattered map and set typedefs, centralize the two common
structures into 'ledlayout.hpp': ActionSet, GroupMap. Use them
everywhere where previous raw maps and sets were used.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I0ed5203146a6486a49caf4000f545ded0088dc15
diff --git a/manager/manager.hpp b/manager/manager.hpp
index 88875d1..2fbc7f2 100644
--- a/manager/manager.hpp
+++ b/manager/manager.hpp
@@ -68,18 +68,15 @@
return left.name == right.name;
}
- using group = std::set<phosphor::led::Layout::LedAction>;
- using LedLayout = std::unordered_map<std::string, group>;
-
/** @brief static global map constructed at compile time */
- const LedLayout& ledMap;
+ const GroupMap& ledMap;
/** @brief Refer the user supplied LED layout and sdbusplus handler
*
* @param [in] bus - sdbusplus handler
- * @param [in] LedLayout - LEDs group layout
+ * @param [in] GroupMap - LEDs group layout
*/
- Manager(sdbusplus::bus::bus& bus, const LedLayout& ledLayout) :
+ Manager(sdbusplus::bus::bus& bus, const GroupMap& ledLayout) :
ledMap(ledLayout), bus(bus)
{
// Nothing here
@@ -95,8 +92,8 @@
*
* @return - Success or exception thrown
*/
- bool setGroupState(const std::string& path, bool assert, group& ledsAssert,
- group& ledsDeAssert);
+ bool setGroupState(const std::string& path, bool assert,
+ ActionSet& ledsAssert, ActionSet& ledsDeAssert);
/** @brief Finds the set of LEDs to operate on and executes action
*
@@ -106,7 +103,7 @@
*
* @return: None
*/
- void driveLEDs(group& ledsAssert, group& ledsDeAssert);
+ void driveLEDs(ActionSet& ledsAssert, ActionSet& ledsDeAssert);
/** @brief Chooses appropriate action to be triggered on physical LED
* and calls into function that applies the actual action.
@@ -124,7 +121,8 @@
* @param[in] callBack - Custom callback when enabled lamp test
*/
void setLampTestCallBack(
- std::function<bool(group& ledsAssert, group& ledsDeAssert)> callBack);
+ std::function<bool(ActionSet& ledsAssert, ActionSet& ledsDeAssert)>
+ callBack);
private:
/** @brief sdbusplus handler */
@@ -137,18 +135,18 @@
DBusHandler dBusHandler;
/** @brief Pointers to groups that are in asserted state */
- std::set<const group*> assertedGroups;
+ std::set<const ActionSet*> assertedGroups;
/** @brief Contains the highest priority actions for all
* asserted LEDs.
*/
- group currentState;
+ ActionSet currentState;
/** @brief Contains the set of all actions for asserted LEDs */
- group combinedState;
+ ActionSet combinedState;
/** @brief Custom callback when enabled lamp test */
- std::function<bool(group& ledsAssert, group& ledsDeAssert)>
+ std::function<bool(ActionSet& ledsAssert, ActionSet& ledsDeAssert)>
lampTestCallBack;
/** @brief Returns action string based on enum