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.cpp b/manager/manager.cpp
index 998f22d..12f507a 100644
--- a/manager/manager.cpp
+++ b/manager/manager.cpp
@@ -16,7 +16,7 @@
// Assert -or- De-assert
bool Manager::setGroupState(const std::string& path, bool assert,
- group& ledsAssert, group& ledsDeAssert)
+ ActionSet& ledsAssert, ActionSet& ledsDeAssert)
{
if (assert)
{
@@ -30,8 +30,8 @@
}
}
- // This will contain the union of what's already in the asserted group
- group desiredState{};
+ // This will contain the union of what's already in the asserted ActionSet
+ ActionSet desiredState{};
for (const auto& grp : assertedGroups)
{
desiredState.insert(grp->cbegin(), grp->cend());
@@ -39,7 +39,7 @@
// Find difference between Combined and Desired to identify
// which LEDs are getting altered
- group transient{};
+ ActionSet transient{};
std::set_difference(combinedState.begin(), combinedState.end(),
desiredState.begin(), desiredState.end(),
std::inserter(transient, transient.begin()), ledComp);
@@ -47,7 +47,7 @@
{
// Find common LEDs between transient and Desired to know if some LEDs
// are changing state and not really getting DeAsserted
- group ledsTransient{};
+ ActionSet ledsTransient{};
std::set_intersection(
transient.begin(), transient.end(), desiredState.begin(),
desiredState.end(),
@@ -79,7 +79,7 @@
// Now LEDs that are to be Asserted. These could either be fresh asserts
// -or- change between [On]<-->[Blink]
- group temp{};
+ ActionSet temp{};
std::unique_copy(desiredState.begin(), desiredState.end(),
std::inserter(temp, temp.begin()), ledEqual);
if (temp.size())
@@ -100,13 +100,14 @@
}
void Manager::setLampTestCallBack(
- std::function<bool(group& ledsAssert, group& ledsDeAssert)> callBack)
+ std::function<bool(ActionSet& ledsAssert, ActionSet& ledsDeAssert)>
+ callBack)
{
lampTestCallBack = callBack;
}
/** @brief Run through the map and apply action on the LEDs */
-void Manager::driveLEDs(group& ledsAssert, group& ledsDeAssert)
+void Manager::driveLEDs(ActionSet& ledsAssert, ActionSet& ledsDeAssert)
{
#ifdef USE_LAMP_TEST
// Use the lampTestCallBack method and trigger the callback method in the