summaryrefslogtreecommitdiffstats
path: root/control/functor.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-09-28 12:18:20 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-11-17 15:43:52 +0000
commit8fa02dabe17db9761086d77c390ceb281e2936c9 (patch)
treee43360e58eec4f9947475ad680213c6128b6fb36 /control/functor.hpp
parent336f18a541e93e2cc1719180df73ef8b357c962f (diff)
downloadphosphor-fan-presence-8fa02dabe17db9761086d77c390ceb281e2936c9.tar.gz
phosphor-fan-presence-8fa02dabe17db9761086d77c390ceb281e2936c9.zip
Stub NameOwnerChanged signal support
NameOwnerChanged signals will be used within fan control to configure set speed events for when services providing parameters to the fan control application have unexpectedly terminated. Change-Id: I04f3c7ca2842732e33dc94b0280ad4483f7f1286 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control/functor.hpp')
-rw-r--r--control/functor.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/control/functor.hpp b/control/functor.hpp
index daaa1b7..1f3e4d8 100644
--- a/control/functor.hpp
+++ b/control/functor.hpp
@@ -251,6 +251,75 @@ auto objectSignal(const char* path,
std::forward<U>(handler));
}
+/**
+ * @struct Name Owner Changed
+ * @brief A match filter functor for Dbus name owner changed signals
+ *
+ * @tparam U - The type of the handler
+ */
+template <typename U>
+struct NameOwnerChanged
+{
+ NameOwnerChanged() = delete;
+ ~NameOwnerChanged() = default;
+ NameOwnerChanged(const NameOwnerChanged&) = default;
+ NameOwnerChanged& operator=(const NameOwnerChanged&) = default;
+ NameOwnerChanged(NameOwnerChanged&&) = default;
+ NameOwnerChanged& operator=(NameOwnerChanged&&) = default;
+ NameOwnerChanged(const char* path,
+ const char* iface,
+ U&& handler) :
+ _path(path),
+ _iface(iface),
+ _handler(std::forward<U>(handler)) { }
+
+ /** @brief Run signal handler function
+ *
+ * Extract the name owner from the NameOwnerChanged
+ * message (or read the name owner when the message is null)
+ * and run the handler function.
+ */
+ void operator()(sdbusplus::bus::bus& bus,
+ sdbusplus::message::message& msg,
+ Zone& zone) const
+ {
+ if (msg)
+ {
+ // TODO Handle NameOwnerChanged signals
+ }
+ else
+ {
+ // TODO Initialize NameOwnerChanged data store with service names
+ }
+ }
+
+private:
+ const char* _path;
+ const char* _iface;
+ U _handler;
+};
+
+/**
+ * @brief Used to process a Dbus name owner changed signal event
+ *
+ * @param[in] path - Object path
+ * @param[in] iface - Object interface
+ * @param[in] handler - Handler function to perform
+ *
+ * @tparam U - The type of the handler
+ *
+ * @return - The NameOwnerChanged signal struct
+ */
+template <typename U>
+auto ownerSignal(const char* path,
+ const char* iface,
+ U&& handler)
+{
+ return NameOwnerChanged<U>(path,
+ iface,
+ std::forward<U>(handler));
+}
+
} // namespace control
} // namespace fan
} // namespace phosphor
OpenPOWER on IntegriCloud