summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-02-19 13:34:43 -0600
committerMatt Spinler <spinler@us.ibm.com>2018-02-23 13:51:48 -0600
commitabe43ab439bba463f4727a98ed0cc0c6a5e8251f (patch)
tree84416bf5d4d38ce4d7ced993596e5b661e3e38da
parentc458deea83b4356f07194691e301037d8e831d46 (diff)
downloadphosphor-dbus-monitor-abe43ab439bba463f4727a98ed0cc0c6a5e8251f.zip
phosphor-dbus-monitor-abe43ab439bba463f4727a98ed0cc0c6a5e8251f.tar.gz
Extend storage array to contain additional data
This array was originally just an array of objects of type 'any'. This commit changes it to be an array of tuples of type <any, any> to add an extra field for use by anything that needs it. For example, the storage is currently used to store property values, and a future change to the CountCondition class will now also store the result of the comparisons done between the property values and another value specified in the rule YAML. Then, a callback will be able to see the result of whether each property passed the check. Tested: Build and run unit tests Change-Id: I58f32c9f4068b15a02b1ff7f28871161cafebddb Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--src/count.hpp4
-rw-r--r--src/data_types.hpp5
-rw-r--r--src/event.hpp7
-rw-r--r--src/journal.cpp5
-rw-r--r--src/propertywatchimpl.hpp3
-rw-r--r--src/templates/generated.mako.hpp2
-rw-r--r--src/test/propertywatchtest.cpp4
7 files changed, 17 insertions, 13 deletions
diff --git a/src/count.hpp b/src/count.hpp
index 51a76eb..0ac6420 100644
--- a/src/count.hpp
+++ b/src/count.hpp
@@ -64,12 +64,12 @@ class CountCondition : public IndexedConditional
const auto& storage = std::get<2>(
item.second);
// Don't count properties that don't exist.
- if (storage.get().empty())
+ if (std::get<0>(storage.get()).empty())
{
return false;
}
const auto& value = any_ns::any_cast<T>(
- storage);
+ std::get<0>(storage.get()));
return propertyOp(value);
});
// *INDENT-ON*
diff --git a/src/data_types.hpp b/src/data_types.hpp
index 12d1d6d..f1512db 100644
--- a/src/data_types.hpp
+++ b/src/data_types.hpp
@@ -18,7 +18,8 @@ constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
constexpr auto pathIndex = 0;
constexpr auto propertyIndex = 2;
-constexpr auto valueIndex = 2;
+constexpr auto storageIndex = 2;
+constexpr auto valueIndex = 0;
constexpr auto metaIndex = 1;
enum class Context
@@ -70,7 +71,7 @@ using PropertyIndex = TupleRefMap <
TupleOfRefs<
const std::string,
const std::string,
- any_ns::any>,
+ std::tuple<any_ns::any, any_ns::any>>,
const std::string,
const std::string,
const std::string >;
diff --git a/src/event.hpp b/src/event.hpp
index ad02986..b5f1e90 100644
--- a/src/event.hpp
+++ b/src/event.hpp
@@ -46,10 +46,11 @@ class EventBase : public IndexedCallback
for (const auto& n : index)
{
const auto& path = std::get<pathIndex>(n.first);
- const auto& propertyMeta = std::get<propertyIndex>(n.first);
- const auto& value = std::get<valueIndex>(n.second);
+ const auto& propertyMeta = std::get<metaIndex>(n.first);
+ const auto& storage = std::get<storageIndex>(n.second);
+ const auto& value = std::get<valueIndex>(storage.get());
- if (!value.get().empty())
+ if (!value.empty())
{
createEvent(
path,
diff --git a/src/journal.cpp b/src/journal.cpp
index c348cfb..7069c74 100644
--- a/src/journal.cpp
+++ b/src/journal.cpp
@@ -29,9 +29,10 @@ void JournalBase::operator()(Context ctx)
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& value = std::get<2>(n.second);
+ const auto& storage = std::get<2>(n.second);
+ const auto& value = std::get<0>(storage.get());
- if (!value.get().empty())
+ if (!value.empty())
{
log(message,
pathMeta,
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 43875b9..9fe57d5 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -146,7 +146,8 @@ void PropertyWatchOfType<T, DBusInterfaceType>::propertiesChanged(
continue;
}
- std::get<2>(item->second).get() = p.second.template get<T>();
+ std::get<0>(std::get<2>(item->second).get()) =
+ p.second.template get<T>();
// Invoke callback if present.
this->callback(Context::SIGNAL);
diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp
index 4a5b87c..1b73198 100644
--- a/src/templates/generated.mako.hpp
+++ b/src/templates/generated.mako.hpp
@@ -93,7 +93,7 @@ struct ConfigProperties
struct ConfigPropertyStorage
{
- using Storage = std::array<any_ns::any, ${len(instances)}>;
+ using Storage = std::array<std::tuple<any_ns::any, any_ns::any>, ${len(instances)}>;
static auto& get()
{
diff --git a/src/test/propertywatchtest.cpp b/src/test/propertywatchtest.cpp
index b92dbec..c97e8d3 100644
--- a/src/test/propertywatchtest.cpp
+++ b/src/test/propertywatchtest.cpp
@@ -27,7 +27,7 @@ const std::array<std::string, 2> properties =
const std::string meta;
-std::array<any_ns::any, 8> storage = { };
+std::array<std::tuple<any_ns::any, any_ns::any>, 8> storage = { };
const PropertyIndex watchIndex =
{
@@ -204,7 +204,7 @@ void testStart()
ndx = 0;
for (auto s : storage)
{
- ASSERT_EQ(s.empty(), false);
+ ASSERT_EQ(std::get<0>(s).empty(), false);
ASSERT_EQ(any_ns::any_cast<T>(s), ExpectedValues<T>::get(ndx));
++ndx;
}
OpenPOWER on IntegriCloud