Convert event group to a vector of tuples
In preparation for storing each event group member's property state used
within the event's actions, the group type should be converted to a
vector of tuples. This vector will allow, if user defines, easier use of
different interfaces and properties on the same path to be used within
the same event group.
Tested:
Generated code for groups reflects vector instead of map
Actions against groups remain unchanged
Change-Id: I9f4bb609de424d9004d43524fd04737a50fb2c6f
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/actions.cpp b/control/actions.cpp
index 25b6a09..3c3b194 100644
--- a/control/actions.cpp
+++ b/control/actions.cpp
@@ -107,9 +107,9 @@
try
{
auto value = zone.template getPropertyValue<int64_t>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second));
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
base = std::max(base, value);
}
catch (const std::out_of_range& oore)
@@ -141,9 +141,9 @@
{
return sum +
zone.template getPropertyValue<int64_t>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second));
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
}
catch (const std::out_of_range& oore)
{
@@ -193,9 +193,9 @@
{
return sum +
zone.template getPropertyValue<int64_t>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second));
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
}
catch (const std::out_of_range& oore)
{
diff --git a/control/actions.hpp b/control/actions.hpp
index bb98b7c..9b9bbed 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -94,9 +94,9 @@
try
{
if (zone.template getPropertyValue<T>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second)) == state)
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry)) == state)
{
numAtState++;
}
@@ -179,9 +179,9 @@
try
{
T value = zone.template getPropertyValue<T>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second));
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
// TODO openbmc/phosphor-fan-presence#7 - Support possible
// state types for comparison
if (value >= state)
@@ -236,9 +236,9 @@
try
{
T value = zone.template getPropertyValue<T>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second));
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
// TODO openbmc/phosphor-fan-presence#7 - Support possible
// state types for comparison
if (value < state)
@@ -308,9 +308,9 @@
try
{
return zone.template getPropertyValue<T>(
- entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second)) == state;
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry)) == state;
}
catch (const std::out_of_range& oore)
{
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py
index b3d9baf..1ccc420 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -143,9 +143,9 @@
for member in group['members']:
e += "{\n"
e += "\"" + member['object'] + "\",\n"
- e += "{\"" + member['interface'] + "\",\n"
- e += " \"" + member['property'] + "\"}\n"
- e += "},\n"
+ e += "\"" + member['interface'] + "\",\n"
+ e += "\"" + member['property'] + "\"\n"
+ e += "},\n"
e += "},\n"
e += "std::vector<Action>{\n"
diff --git a/control/templates/defs.mako b/control/templates/defs.mako
index 6308774..d574c57 100644
--- a/control/templates/defs.mako
+++ b/control/templates/defs.mako
@@ -35,8 +35,8 @@
%for member in group['members']:
{
"${member['object']}",
- {"${member['interface']}",
- "${member['property']}"}
+ "${member['interface']}",
+ "${member['property']}"
},
%endfor
%endfor
diff --git a/control/templates/fan_zone_defs.mako.cpp b/control/templates/fan_zone_defs.mako.cpp
index eb30762..5eadc6d 100644
--- a/control/templates/fan_zone_defs.mako.cpp
+++ b/control/templates/fan_zone_defs.mako.cpp
@@ -104,8 +104,8 @@
%for member in group['members']:
{
"${member['object']}",
- {"${member['interface']}",
- "${member['property']}"}
+ "${member['interface']}",
+ "${member['property']}"
},
%endfor
%endfor
diff --git a/control/triggers.cpp b/control/triggers.cpp
index 2307730..376ac9b 100644
--- a/control/triggers.cpp
+++ b/control/triggers.cpp
@@ -57,17 +57,17 @@
// Set event data for each host group member
for (auto& entry : group)
{
- if (entry.first == zone.getPath())
+ if (std::get<pathPos>(entry) == zone.getPath())
{
auto ifaces = zone.getIfaces();
// Group member interface in list owned by zone
if (std::find(ifaces.begin(), ifaces.end(),
- std::get<intfPos>(entry.second)) != ifaces.end())
+ std::get<intfPos>(entry)) != ifaces.end())
{
// Store path,interface,property as a managed object
- zone.setObjectData(entry.first,
- std::get<intfPos>(entry.second),
- std::get<propPos>(entry.second),
+ zone.setObjectData(std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry),
eventData.get());
}
}
diff --git a/control/types.hpp b/control/types.hpp
index e53c60e..4bead3a 100644
--- a/control/types.hpp
+++ b/control/types.hpp
@@ -42,9 +42,12 @@
std::vector<std::string>,
std::string>;
-constexpr auto intfPos = 0;
-constexpr auto propPos = 1;
-using Group = std::map<std::string, std::tuple<std::string, std::string>>;
+constexpr auto pathPos = 0;
+constexpr auto intfPos = 1;
+constexpr auto propPos = 2;
+using Group = std::vector<std::tuple<std::string,
+ std::string,
+ std::string>>;
using ZoneHandler = std::function<void(Zone&)>;
using Handler = std::function<void(sdbusplus::bus::bus&,
sdbusplus::message::message&,
diff --git a/control/zone.cpp b/control/zone.cpp
index 3e06fd0..944da09 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -206,8 +206,8 @@
bool hasOwner = false;
try
{
- name = getService(it->first,
- std::get<intfPos>(it->second));
+ name = getService(std::get<pathPos>(*it),
+ std::get<intfPos>(*it));
hasOwner = util::SDBusPlus::callMethodAndRead<bool>(
_bus,
"org.freedesktop.DBus",