summaryrefslogtreecommitdiffstats
path: root/src/templates
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-05-21 10:06:07 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-19 16:26:47 -0400
commit4041d720cf6387aa198c620cc9c6eaa86ac18cba (patch)
treeda24ecea922de6ea3cd83276ded0c148cbeddeba /src/templates
parent731171a12c6d52ead2d93303867b6d731d4d6728 (diff)
downloadphosphor-dbus-monitor-4041d720cf6387aa198c620cc9c6eaa86ac18cba.tar.gz
phosphor-dbus-monitor-4041d720cf6387aa198c620cc9c6eaa86ac18cba.zip
Add conditional callbacks
Enable conditional application of callbacks. Change-Id: I9d765e5f585aac40994b65da3b51ea891beae9bf Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'src/templates')
-rw-r--r--src/templates/conditional.mako.cpp3
-rw-r--r--src/templates/count.mako.cpp4
-rw-r--r--src/templates/generated.mako.hpp17
3 files changed, 24 insertions, 0 deletions
diff --git a/src/templates/conditional.mako.cpp b/src/templates/conditional.mako.cpp
new file mode 100644
index 0000000..3cc9564
--- /dev/null
+++ b/src/templates/conditional.mako.cpp
@@ -0,0 +1,3 @@
+std::make_unique<ConditionalCallback<ConfigPropertyCallbacks>>(
+${indent(1)}ConfigPropertyCallbackGroups::get()[${c.graph}],
+${indent(1)}*ConfigConditions::get()[${c.condition}])\
diff --git a/src/templates/count.mako.cpp b/src/templates/count.mako.cpp
new file mode 100644
index 0000000..d348518
--- /dev/null
+++ b/src/templates/count.mako.cpp
@@ -0,0 +1,4 @@
+std::make_unique<CountCondition<${c.datatype}>>(
+${indent(1)}ConfigPropertyIndicies::get()[${c.instances}],
+${indent(1)}[](const auto& item){return item ${c.countop} ${c.countbound};},
+${indent(1)}[](const auto& item){return item ${c.op} ${c.bound};})\
diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp
index 67b9149..a4819e2 100644
--- a/src/templates/generated.mako.hpp
+++ b/src/templates/generated.mako.hpp
@@ -4,6 +4,7 @@
#include <array>
#include <string>
+#include "count.hpp"
#include "data_types.hpp"
#include "journal.hpp"
#include "propertywatchimpl.hpp"
@@ -145,6 +146,22 @@ struct ConfigPropertyCallbackGroups
}
};
+struct ConfigConditions
+{
+ using Conditions = std::array<std::unique_ptr<Conditional>, ${len(conditions)}>;
+
+ static auto& get()
+ {
+ static const Conditions propertyConditions =
+ {
+% for c in conditions:
+ ${c.construct(loader, indent=indent +3)},
+% endfor
+ };
+ return propertyConditions;
+ }
+};
+
struct ConfigPropertyCallbacks
{
using Callbacks = std::array<std::unique_ptr<Callback>, ${len(callbacks)}>;
OpenPOWER on IntegriCloud