summaryrefslogtreecommitdiffstats
path: root/control
diff options
context:
space:
mode:
Diffstat (limited to 'control')
-rw-r--r--control/functor.hpp69
-rw-r--r--control/handlers.hpp18
2 files changed, 87 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
diff --git a/control/handlers.hpp b/control/handlers.hpp
index 79c299b..3f42d3c 100644
--- a/control/handlers.hpp
+++ b/control/handlers.hpp
@@ -30,6 +30,24 @@ auto setProperty(const char* path, const char* interface, const char* property)
};
}
+/**
+ * @brief A handler function to set/update service name owner state
+ * @details Sets or updates service name owner state used by a group where
+ * a service name without an owner represents the service no longer exists
+ *
+ * @param[in] group - Group associated with a service
+ *
+ * @return Lambda function
+ * A lambda function to set/update the service name owner state
+ */
+auto setService(Group&& group)
+{
+ return [group = std::move(group)](auto& zone, auto& name, bool hasOwner)
+ {
+ // TODO Update service name owner state list of a group
+ };
+}
+
} // namespace handler
} // namespace control
} // namespace fan
OpenPOWER on IntegriCloud