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/callback.hpp | |
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/callback.hpp')
-rw-r--r-- | src/callback.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/callback.hpp b/src/callback.hpp new file mode 100644 index 0000000..d7a678c --- /dev/null +++ b/src/callback.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "data_types.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +/** @class Callback + * @brief Callback interface. + * + * Callbacks of any type can be run. + */ +class Callback +{ + public: + Callback() = default; + Callback(const Callback&) = delete; + Callback(Callback&&) = default; + Callback& operator=(const Callback&) = delete; + Callback& operator=(Callback&&) = default; + virtual ~Callback() = default; + + /** @brief Run the callback. */ + virtual void operator()() = 0; +}; + +/** @class IndexedCallback + * @brief Callback with an index. + */ +class IndexedCallback : public Callback +{ + public: + IndexedCallback() = delete; + IndexedCallback(const IndexedCallback&) = delete; + IndexedCallback(IndexedCallback&&) = default; + IndexedCallback& operator=(const IndexedCallback&) = delete; + IndexedCallback& operator=(IndexedCallback&&) = default; + virtual ~IndexedCallback() = default; + explicit IndexedCallback(const PropertyIndex& callbackIndex) + : Callback(), index(callbackIndex) {} + + /** @brief Run the callback. */ + virtual void operator()() override = 0; + + protected: + + /** @brief Property names and their associated storage. */ + const PropertyIndex& index; +}; + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor |