diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-05-20 21:42:38 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-06-19 16:26:44 -0400 |
commit | c1283ae8472dbd4e2c3593b76b7600ac72640b80 (patch) | |
tree | 1e45c148d19a59a561df430a1f4ba3728196d910 /src/templates | |
parent | 893b348890781dba2603ead61cf6f724350d0b47 (diff) | |
download | phosphor-dbus-monitor-c1283ae8472dbd4e2c3593b76b7600ac72640b80.tar.gz phosphor-dbus-monitor-c1283ae8472dbd4e2c3593b76b7600ac72640b80.zip |
Add support for callbacks
Callbacks are the response in the PDM 'trigger->response' model.
Add general support for implementing callbacks and implement
a log to systemd journal using that framework.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I8bead5368ee5472a02b47e8bba9e9df3a1f346bc
Diffstat (limited to 'src/templates')
-rw-r--r-- | src/templates/generated.mako.hpp | 29 | ||||
-rw-r--r-- | src/templates/journal.mako.cpp | 3 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp index 0911e3a..61c2b6f 100644 --- a/src/templates/generated.mako.hpp +++ b/src/templates/generated.mako.hpp @@ -5,6 +5,7 @@ #include <array> #include <string> #include "data_types.hpp" +#include "journal.hpp" #include "propertywatchimpl.hpp" #include "sdbusplus.hpp" @@ -107,15 +108,15 @@ struct ConfigPropertyIndicies { PropertyIndex::key_type { - ConfigPaths::get()[${i[0]}], - ConfigInterfaces::get()[${i[2]}], - ConfigProperties::get()[${i[3]}] + std::cref(ConfigPaths::get()[${i[0]}]), + std::cref(ConfigInterfaces::get()[${i[2]}]), + std::cref(ConfigProperties::get()[${i[3]}]) }, PropertyIndex::mapped_type { - ConfigMeta::get()[${i[1]}], - ConfigMeta::get()[${i[4]}], - ConfigPropertyStorage::get()[${i[5]}] + std::cref(ConfigMeta::get()[${i[1]}]), + std::cref(ConfigMeta::get()[${i[4]}]), + std::ref(ConfigPropertyStorage::get()[${i[5]}]) }, }, % endfor @@ -127,6 +128,22 @@ struct ConfigPropertyIndicies } }; +struct ConfigPropertyCallbacks +{ + using Callbacks = std::array<std::unique_ptr<Callback>, ${len(callbacks)}>; + + static auto& get() + { + static const Callbacks propertyCallbacks = + { +% for c in callbacks: + ${c.construct(loader, indent=indent +3)}, +% endfor + }; + return propertyCallbacks; + } +}; + struct ConfigPropertyWatches { using PropertyWatches = std::array<std::unique_ptr<Watch>, ${len(watches)}>; diff --git a/src/templates/journal.mako.cpp b/src/templates/journal.mako.cpp new file mode 100644 index 0000000..787337d --- /dev/null +++ b/src/templates/journal.mako.cpp @@ -0,0 +1,3 @@ +std::make_unique<Journal<${c.datatype}, phosphor::logging::level::${c.severity}>>( +${indent(1)}"${c.message}", +${indent(1)}ConfigPropertyIndicies::get()[${c.instances}])\ |