Add constants for tuple fields
Add constants for use with std::get.
Tested: Run unit tests
Change-Id: Ic09c13feeda69d61c98f63d227cae8f08d1bf50e
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/src/count.hpp b/src/count.hpp
index 0da0324..9f0ce3e 100644
--- a/src/count.hpp
+++ b/src/count.hpp
@@ -64,18 +64,19 @@
{
//Get the property value from storage[0],
//and save the op result in storage[1].
- const auto& storage = std::get<2>(
+ const auto& storage = std::get<storageIndex>(
item.second);
// Don't count properties that don't exist.
- if (std::get<0>(storage.get()).empty())
+ if (std::get<valueIndex>(
+ storage.get()).empty())
{
return false;
}
const auto& value = any_ns::any_cast<T>(
- std::get<0>(storage.get()));
+ std::get<valueIndex>(storage.get()));
auto r = propertyOp(value);
- std::get<1>(storage.get()) = r;
+ std::get<resultIndex>(storage.get()) = r;
return r;
});
diff --git a/src/data_types.hpp b/src/data_types.hpp
index f1512db..607289a 100644
--- a/src/data_types.hpp
+++ b/src/data_types.hpp
@@ -16,11 +16,20 @@
constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
+
+//PropertyIndex::key_type fields
constexpr auto pathIndex = 0;
+constexpr auto interfaceIndex = 1;
constexpr auto propertyIndex = 2;
+
+//PropertyIndex::mapped_type fields
+constexpr auto pathMetaIndex = 0;
+constexpr auto propertyMetaIndex = 1;
constexpr auto storageIndex = 2;
+
+//ConfigPropertyStorage fields
constexpr auto valueIndex = 0;
-constexpr auto metaIndex = 1;
+constexpr auto resultIndex = 1;
enum class Context
{
diff --git a/src/elog.hpp b/src/elog.hpp
index 3f8ae3b..234ef6f 100644
--- a/src/elog.hpp
+++ b/src/elog.hpp
@@ -171,7 +171,7 @@
* @brief Builds a metadata string with property information
*
* Finds all of the properties in the index that have
- * their condition pass/fail fields (get<1>(storage))
+ * their condition pass/fail fields (get<resultIndex>(storage))
* set to true, and then packs those paths, names, and values
* into a metadata string that looks like:
*
@@ -185,16 +185,17 @@
for (const auto& n : index)
{
- const auto& storage = std::get<2>(n.second).get();
- const auto& result = std::get<1>(storage);
+ const auto& storage = std::get<storageIndex>(n.second).get();
+ const auto& result = std::get<resultIndex>(storage);
if (!result.empty() && any_ns::any_cast<bool>(result))
{
- const auto& path = std::get<0>(n.first).get();
- const auto& propertyName = std::get<2>(n.first).get();
+ const auto& path = std::get<pathIndex>(n.first).get();
+ const auto& propertyName = std::get<propertyIndex>(
+ n.first).get();
auto value = ToString<propertyType>::op(
any_ns::any_cast<propertyType>(
- std::get<0>(storage)));
+ std::get<valueIndex>(storage)));
metadata += path + ":" + propertyName +
'=' + value + '|';
diff --git a/src/event.hpp b/src/event.hpp
index b5f1e90..b9f5167 100644
--- a/src/event.hpp
+++ b/src/event.hpp
@@ -46,7 +46,7 @@
for (const auto& n : index)
{
const auto& path = std::get<pathIndex>(n.first);
- const auto& propertyMeta = std::get<metaIndex>(n.first);
+ const auto& propertyMeta = std::get<propertyIndex>(n.first);
const auto& storage = std::get<storageIndex>(n.second);
const auto& value = std::get<valueIndex>(storage.get());
diff --git a/src/journal.cpp b/src/journal.cpp
index 7069c74..f54c5b3 100644
--- a/src/journal.cpp
+++ b/src/journal.cpp
@@ -26,11 +26,11 @@
{
for (const auto& n : index)
{
- const auto& path = std::get<0>(n.first);
- const auto& pathMeta = std::get<0>(n.second);
- const auto& propertyMeta = std::get<1>(n.second);
- const auto& storage = std::get<2>(n.second);
- const auto& value = std::get<0>(storage.get());
+ const auto& path = std::get<pathIndex>(n.first);
+ const auto& pathMeta = std::get<pathMetaIndex>(n.second);
+ const auto& propertyMeta = std::get<propertyMetaIndex>(n.second);
+ const auto& storage = std::get<storageIndex>(n.second);
+ const auto& value = std::get<valueIndex>(storage.get());
if (!value.empty())
{
diff --git a/src/propertywatch.cpp b/src/propertywatch.cpp
index defde78..63a2c31 100644
--- a/src/propertywatch.cpp
+++ b/src/propertywatch.cpp
@@ -36,9 +36,9 @@
for (const auto& i : index)
{
- const auto& path = std::get<0>(i.first);
- const auto& interface = std::get<1>(i.first);
- const auto& property = std::get<2>(i.first);
+ const auto& path = std::get<pathIndex>(i.first);
+ const auto& interface = std::get<interfaceIndex>(i.first);
+ const auto& property = std::get<propertyIndex>(i.first);
m[path][interface].push_back(property);
}
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 9fe57d5..1f0e4d1 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -146,7 +146,7 @@
continue;
}
- std::get<0>(std::get<2>(item->second).get()) =
+ std::get<valueIndex>(std::get<storageIndex>(item->second).get()) =
p.second.template get<T>();
// Invoke callback if present.