blob: 658c76a15a5cdeb2bd14c31f04900ae193b157cc [file] [log] [blame]
Matthew Barth38a93a82017-05-11 14:12:27 -05001#pragma once
2
Matthew Barth336f18a2017-09-26 09:15:56 -05003#include "sdbusplus.hpp"
Matthew Barth3e1bb272020-05-26 11:09:21 -05004#include "types.hpp"
5
Matthew Barth38a93a82017-05-11 14:12:27 -05006#include <phosphor-logging/log.hpp>
7
8namespace phosphor
9{
10namespace fan
11{
12namespace control
13{
14class Zone;
15
Matthew Barth336f18a2017-09-26 09:15:56 -050016using namespace phosphor::fan;
Matthew Barth5a302572017-10-03 11:27:06 -050017using namespace sdbusplus::bus::match;
Matthew Barth38a93a82017-05-11 14:12:27 -050018using namespace phosphor::logging;
19
20/**
Matthew Barth1b3e9602019-02-13 11:37:03 -060021 * @brief Create a zone handler function object
22 *
23 * @param[in] handler - The handler being created
24 *
25 * @return - The created zone handler function object
26 */
27template <typename T>
28auto make_zoneHandler(T&& handler)
29{
30 return ZoneHandler(std::forward<T>(handler));
31}
32
33/**
Matthew Barth1b4de262018-03-06 13:03:16 -060034 * @brief Create a trigger function object
35 *
36 * @param[in] trigger - The trigger being created
37 *
38 * @return - The created trigger function object
39 */
40template <typename T>
41auto make_trigger(T&& trigger)
42{
Matthew Barth3e1bb272020-05-26 11:09:21 -050043 return Trigger(std::forward<T>(trigger));
Matthew Barth1b4de262018-03-06 13:03:16 -060044}
45
46/**
Matthew Barth38a93a82017-05-11 14:12:27 -050047 * @brief Create a handler function object
48 *
49 * @param[in] handler - The handler being created
50 *
51 * @return - The created handler function object
52 */
Matthew Barth926df662018-10-09 09:51:12 -050053template <typename T, typename U>
54auto make_handler(U&& handler)
Matthew Barth38a93a82017-05-11 14:12:27 -050055{
Matthew Barth926df662018-10-09 09:51:12 -050056 return T(std::forward<U>(handler));
Matthew Barth38a93a82017-05-11 14:12:27 -050057}
58
59/**
Matthew Barth17d1fe22017-05-11 15:00:36 -050060 * @brief Create an action function object
61 *
62 * @param[in] action - The action being created
63 *
64 * @return - The created action function object
65 */
66template <typename T>
67auto make_action(T&& action)
68{
69 return Action(std::forward<T>(action));
70}
71
72/**
Matthew Barth926df662018-10-09 09:51:12 -050073 * @struct Properties
74 * @brief A set of match filter functors for Dbus property values. Each
75 * functor provides an associated process for retrieving the value
76 * for a given property and providing it to the given handler function.
Matthew Barth38a93a82017-05-11 14:12:27 -050077 *
78 * @tparam T - The type of the property value
79 * @tparam U - The type of the handler
80 */
81template <typename T, typename U>
Matthew Barth926df662018-10-09 09:51:12 -050082struct Properties
Matthew Barth38a93a82017-05-11 14:12:27 -050083{
Matthew Barth926df662018-10-09 09:51:12 -050084 Properties() = delete;
85 ~Properties() = default;
86 Properties(const Properties&) = default;
87 Properties& operator=(const Properties&) = default;
88 Properties(Properties&&) = default;
89 Properties& operator=(Properties&&) = default;
Matthew Barth9f93bd32020-05-28 16:57:14 -050090 explicit Properties(U&& handler) :
91 _path(""), _intf(""), _prop(""), _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -050092 {}
93 Properties(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -050094 U&& handler) :
Matthew Barth336f18a2017-09-26 09:15:56 -050095 _path(path),
Matthew Barth3e1bb272020-05-26 11:09:21 -050096 _intf(intf), _prop(prop), _handler(std::forward<U>(handler))
97 {}
Matthew Barth38a93a82017-05-11 14:12:27 -050098
99 /** @brief Run signal handler function
100 *
101 * Extract the property from the PropertiesChanged
Matthew Barth926df662018-10-09 09:51:12 -0500102 * message and run the handler function.
Matthew Barth38a93a82017-05-11 14:12:27 -0500103 */
Matthew Barth3e1bb272020-05-26 11:09:21 -0500104 void operator()(sdbusplus::bus::bus& bus, sdbusplus::message::message& msg,
Matthew Barth38a93a82017-05-11 14:12:27 -0500105 Zone& zone) const
106 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500107 if (msg)
Matthew Barth38a93a82017-05-11 14:12:27 -0500108 {
Matthew Barth469d1362018-10-11 14:10:47 -0500109 std::string intf;
Matthew Barth469d1362018-10-11 14:10:47 -0500110 msg.read(intf);
111 if (intf != _intf)
Matthew Barth336f18a2017-09-26 09:15:56 -0500112 {
Matthew Barth469d1362018-10-11 14:10:47 -0500113 // Interface name does not match on object
Matthew Barth336f18a2017-09-26 09:15:56 -0500114 return;
115 }
116
Matthew Barth7f4c5482020-02-07 16:14:46 -0600117 std::map<std::string, PropertyVariantType> props;
Matthew Barth469d1362018-10-11 14:10:47 -0500118 msg.read(props);
119 auto it = props.find(_prop);
120 if (it == props.cend())
Matthew Barth336f18a2017-09-26 09:15:56 -0500121 {
Matthew Barth469d1362018-10-11 14:10:47 -0500122 // Property not included in dictionary of properties changed
Matthew Barth336f18a2017-09-26 09:15:56 -0500123 return;
124 }
125
Matthew Barth7f4c5482020-02-07 16:14:46 -0600126 // Retrieve the property's value applying any visitors necessary
127 auto value =
128 zone.getPropertyValueVisitor<T>(_intf, _prop, it->second);
129
130 _handler(zone, _path, _intf, _prop, std::forward<T>(value));
Matthew Barth336f18a2017-09-26 09:15:56 -0500131 }
132 else
Matthew Barth38a93a82017-05-11 14:12:27 -0500133 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500134 try
135 {
Matthew Barth469d1362018-10-11 14:10:47 -0500136 auto val = zone.getPropertyByName<T>(_path, _intf, _prop);
137 _handler(zone, _path, _intf, _prop, std::forward<T>(val));
Matthew Barth336f18a2017-09-26 09:15:56 -0500138 }
Matthew Barth86be4762018-07-17 10:51:36 -0500139 catch (const sdbusplus::exception::SdBusError&)
140 {
141 // Property will not be used unless a property changed
142 // signal message is received for this property.
143 }
144 catch (const util::DBusError&)
Matthew Barth336f18a2017-09-26 09:15:56 -0500145 {
146 // Property will not be used unless a property changed
147 // signal message is received for this property.
Matthew Barth336f18a2017-09-26 09:15:56 -0500148 }
Matthew Barth38a93a82017-05-11 14:12:27 -0500149 }
Matthew Barth38a93a82017-05-11 14:12:27 -0500150 }
151
Matthew Barth926df662018-10-09 09:51:12 -0500152 /** @brief Run init handler function
153 *
154 * Get the property from each member object of the group
155 * and run the handler function.
156 */
157 void operator()(Zone& zone, const Group& group) const
158 {
159 std::for_each(
Matthew Barth3e1bb272020-05-26 11:09:21 -0500160 group.begin(), group.end(),
161 [&zone, handler = std::move(_handler)](auto const& member) {
Matthew Barth926df662018-10-09 09:51:12 -0500162 auto path = std::get<pathPos>(member);
163 auto intf = std::get<intfPos>(member);
164 auto prop = std::get<propPos>(member);
165 try
166 {
167 auto val = zone.getPropertyByName<T>(path, intf, prop);
Matthew Barth469d1362018-10-11 14:10:47 -0500168 handler(zone, path, intf, prop, std::forward<T>(val));
Matthew Barth926df662018-10-09 09:51:12 -0500169 }
170 catch (const sdbusplus::exception::SdBusError&)
171 {
172 // Property value not sent to handler
173 }
174 catch (const util::DBusError&)
175 {
176 // Property value not sent to handler
177 }
Matthew Barth3e1bb272020-05-26 11:09:21 -0500178 });
Matthew Barth926df662018-10-09 09:51:12 -0500179 }
180
Matthew Barth3e1bb272020-05-26 11:09:21 -0500181 private:
Matthew Barth336f18a2017-09-26 09:15:56 -0500182 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500183 const char* _intf;
184 const char* _prop;
Matthew Barth38a93a82017-05-11 14:12:27 -0500185 U _handler;
186};
187
188/**
Matthew Barth469d1362018-10-11 14:10:47 -0500189 * @brief Used to process a Dbus properties changed signal event
Matthew Barth38a93a82017-05-11 14:12:27 -0500190 *
Matthew Barth336f18a2017-09-26 09:15:56 -0500191 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500192 * @param[in] intf - Object interface
193 * @param[in] prop - Object property
Matthew Barth38a93a82017-05-11 14:12:27 -0500194 * @param[in] handler - Handler function to perform
195 *
196 * @tparam T - The type of the property
197 * @tparam U - The type of the handler
198 */
199template <typename T, typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500200auto propertiesChanged(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -0500201 U&& handler)
Matthew Barth38a93a82017-05-11 14:12:27 -0500202{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500203 return Properties<T, U>(path, intf, prop, std::forward<U>(handler));
Matthew Barth926df662018-10-09 09:51:12 -0500204}
205
206/**
Matthew Barth469d1362018-10-11 14:10:47 -0500207 * @brief Used to get the properties of an event's group
Matthew Barth926df662018-10-09 09:51:12 -0500208 *
209 * @param[in] handler - Handler function to perform
210 *
Matthew Barth469d1362018-10-11 14:10:47 -0500211 * @tparam T - The type of all the properties
Matthew Barth926df662018-10-09 09:51:12 -0500212 * @tparam U - The type of the handler
213 */
214template <typename T, typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500215auto getProperties(U&& handler)
Matthew Barth926df662018-10-09 09:51:12 -0500216{
217 return Properties<T, U>(std::forward<U>(handler));
Matthew Barth38a93a82017-05-11 14:12:27 -0500218}
219
Matthew Bartheb639c52017-08-04 09:43:11 -0500220/**
Matthew Barth469d1362018-10-11 14:10:47 -0500221 * @struct Interfaces Added
222 * @brief A match filter functor for Dbus interfaces added signals
Matthew Bartheb639c52017-08-04 09:43:11 -0500223 *
224 * @tparam T - The type of the property value
225 * @tparam U - The type of the handler
226 */
227template <typename T, typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500228struct InterfacesAdded
Matthew Bartheb639c52017-08-04 09:43:11 -0500229{
Matthew Barth469d1362018-10-11 14:10:47 -0500230 InterfacesAdded() = delete;
231 ~InterfacesAdded() = default;
232 InterfacesAdded(const InterfacesAdded&) = default;
233 InterfacesAdded& operator=(const InterfacesAdded&) = default;
234 InterfacesAdded(InterfacesAdded&&) = default;
235 InterfacesAdded& operator=(InterfacesAdded&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500236 InterfacesAdded(const char* path, const char* intf, const char* prop,
Matthew Barth469d1362018-10-11 14:10:47 -0500237 U&& handler) :
Matthew Bartheb639c52017-08-04 09:43:11 -0500238 _path(path),
Matthew Barth3e1bb272020-05-26 11:09:21 -0500239 _intf(intf), _prop(prop), _handler(std::forward<U>(handler))
240 {}
Matthew Bartheb639c52017-08-04 09:43:11 -0500241
242 /** @brief Run signal handler function
243 *
244 * Extract the property from the InterfacesAdded
245 * message and run the handler function.
246 */
Matthew Barth3e1bb272020-05-26 11:09:21 -0500247 void operator()(sdbusplus::bus::bus&, sdbusplus::message::message& msg,
Matthew Bartheb639c52017-08-04 09:43:11 -0500248 Zone& zone) const
249 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500250 if (msg)
Matthew Bartheb639c52017-08-04 09:43:11 -0500251 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500252 sdbusplus::message::object_path op;
Matthew Bartheb639c52017-08-04 09:43:11 -0500253
Matthew Barth336f18a2017-09-26 09:15:56 -0500254 msg.read(op);
Matthew Barthd5cfdbe2017-11-14 15:29:50 -0600255 if (static_cast<const std::string&>(op) != _path)
Matthew Barth336f18a2017-09-26 09:15:56 -0500256 {
257 // Object path does not match this handler's path
258 return;
259 }
Matthew Bartheb639c52017-08-04 09:43:11 -0500260
Matthew Barth3e1bb272020-05-26 11:09:21 -0500261 std::map<std::string, std::map<std::string, PropertyVariantType>>
262 intfProp;
Matthew Barth336f18a2017-09-26 09:15:56 -0500263 msg.read(intfProp);
Matthew Barth469d1362018-10-11 14:10:47 -0500264 auto itIntf = intfProp.find(_intf);
Matthew Barth336f18a2017-09-26 09:15:56 -0500265 if (itIntf == intfProp.cend())
266 {
267 // Interface not found on this handler's path
268 return;
269 }
Matthew Barth469d1362018-10-11 14:10:47 -0500270 auto itProp = itIntf->second.find(_prop);
Matthew Barth336f18a2017-09-26 09:15:56 -0500271 if (itProp == itIntf->second.cend())
272 {
273 // Property not found on this handler's path
274 return;
275 }
276
Matthew Barth7f4c5482020-02-07 16:14:46 -0600277 // Retrieve the property's value applying any visitors necessary
278 auto value =
279 zone.getPropertyValueVisitor<T>(_intf, _prop, itProp->second);
280
281 _handler(zone, _path, _intf, _prop, std::forward<T>(value));
Matthew Barth336f18a2017-09-26 09:15:56 -0500282 }
Matthew Bartheb639c52017-08-04 09:43:11 -0500283 }
284
Matthew Barth3e1bb272020-05-26 11:09:21 -0500285 private:
Matthew Bartheb639c52017-08-04 09:43:11 -0500286 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500287 const char* _intf;
288 const char* _prop;
Matthew Bartheb639c52017-08-04 09:43:11 -0500289 U _handler;
290};
291
292/**
Matthew Barth926df662018-10-09 09:51:12 -0500293 * @brief Used to process a Dbus interfaces added signal event
Matthew Bartheb639c52017-08-04 09:43:11 -0500294 *
295 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500296 * @param[in] intf - Object interface
297 * @param[in] prop - Object property
Matthew Bartheb639c52017-08-04 09:43:11 -0500298 * @param[in] handler - Handler function to perform
299 *
300 * @tparam T - The type of the property
301 * @tparam U - The type of the handler
302 */
303template <typename T, typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500304auto interfacesAdded(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -0500305 U&& handler)
Matthew Bartheb639c52017-08-04 09:43:11 -0500306{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500307 return InterfacesAdded<T, U>(path, intf, prop, std::forward<U>(handler));
Matthew Bartheb639c52017-08-04 09:43:11 -0500308}
309
Matthew Barth8fa02da2017-09-28 12:18:20 -0500310/**
Matthew Barth469d1362018-10-11 14:10:47 -0500311 * @struct Interfaces Removed
312 * @brief A match filter functor for Dbus interfaces removed signals
Matthew Barth1499a5c2018-03-20 15:52:33 -0500313 *
314 * @tparam U - The type of the handler
315 */
316template <typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500317struct InterfacesRemoved
Matthew Barth1499a5c2018-03-20 15:52:33 -0500318{
Matthew Barth469d1362018-10-11 14:10:47 -0500319 InterfacesRemoved() = delete;
320 ~InterfacesRemoved() = default;
321 InterfacesRemoved(const InterfacesRemoved&) = default;
322 InterfacesRemoved& operator=(const InterfacesRemoved&) = default;
323 InterfacesRemoved(InterfacesRemoved&&) = default;
324 InterfacesRemoved& operator=(InterfacesRemoved&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500325 InterfacesRemoved(const char* path, const char* intf, U&& handler) :
326 _path(path), _intf(intf), _handler(std::forward<U>(handler))
327 {}
Matthew Barth1499a5c2018-03-20 15:52:33 -0500328
329 /** @brief Run signal handler function
330 *
Matthew Barth469d1362018-10-11 14:10:47 -0500331 * Extract the interfaces from the InterfacesRemoved
Matthew Barth1499a5c2018-03-20 15:52:33 -0500332 * message and run the handler function.
333 */
Matthew Barth3e1bb272020-05-26 11:09:21 -0500334 void operator()(sdbusplus::bus::bus&, sdbusplus::message::message& msg,
Matthew Barth1499a5c2018-03-20 15:52:33 -0500335 Zone& zone) const
336 {
337 if (msg)
338 {
339 std::vector<std::string> intfs;
340 sdbusplus::message::object_path op;
341
342 msg.read(op);
343 if (static_cast<const std::string&>(op) != _path)
344 {
345 // Object path does not match this handler's path
346 return;
347 }
348
349 msg.read(intfs);
Matthew Barth469d1362018-10-11 14:10:47 -0500350 auto itIntf = std::find(intfs.begin(), intfs.end(), _intf);
Matthew Barth1499a5c2018-03-20 15:52:33 -0500351 if (itIntf == intfs.cend())
352 {
353 // Interface not found on this handler's path
354 return;
355 }
356
357 _handler(zone);
358 }
359 }
360
Matthew Barth3e1bb272020-05-26 11:09:21 -0500361 private:
Matthew Barth1499a5c2018-03-20 15:52:33 -0500362 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500363 const char* _intf;
Matthew Barth1499a5c2018-03-20 15:52:33 -0500364 U _handler;
365};
366
367/**
Matthew Barth926df662018-10-09 09:51:12 -0500368 * @brief Used to process a Dbus interfaces removed signal event
Matthew Barth1499a5c2018-03-20 15:52:33 -0500369 *
370 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500371 * @param[in] intf - Object interface
Matthew Barth1499a5c2018-03-20 15:52:33 -0500372 * @param[in] handler - Handler function to perform
373 *
374 * @tparam U - The type of the handler
375 */
376template <typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500377auto interfacesRemoved(const char* path, const char* intf, U&& handler)
Matthew Barth1499a5c2018-03-20 15:52:33 -0500378{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500379 return InterfacesRemoved<U>(path, intf, std::forward<U>(handler));
Matthew Barth1499a5c2018-03-20 15:52:33 -0500380}
381
382/**
Matthew Barth926df662018-10-09 09:51:12 -0500383 * @struct Name Owner
384 * @brief A functor for Dbus name owner signals and methods
Matthew Barth8fa02da2017-09-28 12:18:20 -0500385 *
386 * @tparam U - The type of the handler
387 */
388template <typename U>
Matthew Barth926df662018-10-09 09:51:12 -0500389struct NameOwner
Matthew Barth8fa02da2017-09-28 12:18:20 -0500390{
Matthew Barth926df662018-10-09 09:51:12 -0500391 NameOwner() = delete;
392 ~NameOwner() = default;
393 NameOwner(const NameOwner&) = default;
394 NameOwner& operator=(const NameOwner&) = default;
395 NameOwner(NameOwner&&) = default;
396 NameOwner& operator=(NameOwner&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500397 explicit NameOwner(U&& handler) : _handler(std::forward<U>(handler))
398 {}
Matthew Barth8fa02da2017-09-28 12:18:20 -0500399
400 /** @brief Run signal handler function
401 *
402 * Extract the name owner from the NameOwnerChanged
Matthew Barth926df662018-10-09 09:51:12 -0500403 * message and run the handler function.
Matthew Barth8fa02da2017-09-28 12:18:20 -0500404 */
Matthew Barth3e1bb272020-05-26 11:09:21 -0500405 void operator()(sdbusplus::bus::bus& bus, sdbusplus::message::message& msg,
Matthew Barth8fa02da2017-09-28 12:18:20 -0500406 Zone& zone) const
407 {
408 if (msg)
409 {
Matthew Barth9f93bd32020-05-28 16:57:14 -0500410 std::string name;
411 bool hasOwner = false;
412
Matthew Barth5a302572017-10-03 11:27:06 -0500413 // Handle NameOwnerChanged signals
414 msg.read(name);
415
416 std::string oldOwn;
417 msg.read(oldOwn);
418
419 std::string newOwn;
420 msg.read(newOwn);
421 if (!newOwn.empty())
422 {
423 hasOwner = true;
424 }
Matthew Barth926df662018-10-09 09:51:12 -0500425 _handler(zone, name, hasOwner);
Matthew Barth8fa02da2017-09-28 12:18:20 -0500426 }
Matthew Barth926df662018-10-09 09:51:12 -0500427 }
Matthew Barth5a302572017-10-03 11:27:06 -0500428
Matthew Barth3e1bb272020-05-26 11:09:21 -0500429 void operator()(Zone& zone, const Group& group) const
Matthew Barth926df662018-10-09 09:51:12 -0500430 {
431 std::string name = "";
432 bool hasOwner = false;
433 std::for_each(
Matthew Barth3e1bb272020-05-26 11:09:21 -0500434 group.begin(), group.end(),
435 [&zone, &group, &name, &hasOwner,
436 handler = std::move(_handler)](auto const& member) {
Matthew Barth926df662018-10-09 09:51:12 -0500437 auto path = std::get<pathPos>(member);
438 auto intf = std::get<intfPos>(member);
439 try
440 {
441 auto servName = zone.getService(path, intf);
442 if (name != servName)
443 {
444 name = servName;
445 hasOwner = util::SDBusPlus::callMethodAndRead<bool>(
Matthew Barth3e1bb272020-05-26 11:09:21 -0500446 zone.getBus(), "org.freedesktop.DBus",
447 "/org/freedesktop/DBus", "org.freedesktop.DBus",
448 "NameHasOwner", name);
Matthew Barth926df662018-10-09 09:51:12 -0500449 // Update service name owner state list of a group
450 handler(zone, name, hasOwner);
451 }
452 }
453 catch (const util::DBusMethodError& e)
454 {
455 // Failed to get service name owner state
456 name = "";
457 hasOwner = false;
458 }
Matthew Barth3e1bb272020-05-26 11:09:21 -0500459 });
Matthew Barth8fa02da2017-09-28 12:18:20 -0500460 }
461
Matthew Barth3e1bb272020-05-26 11:09:21 -0500462 private:
Matthew Barth8fa02da2017-09-28 12:18:20 -0500463 U _handler;
464};
465
466/**
467 * @brief Used to process a Dbus name owner changed signal event
468 *
Matthew Barth8fa02da2017-09-28 12:18:20 -0500469 * @param[in] handler - Handler function to perform
470 *
471 * @tparam U - The type of the handler
472 *
473 * @return - The NameOwnerChanged signal struct
474 */
475template <typename U>
Matthew Barth926df662018-10-09 09:51:12 -0500476auto nameOwnerChanged(U&& handler)
Matthew Barth8fa02da2017-09-28 12:18:20 -0500477{
Matthew Barth926df662018-10-09 09:51:12 -0500478 return NameOwner<U>(std::forward<U>(handler));
479}
480
481/**
482 * @brief Used to process the init of a name owner event
483 *
484 * @param[in] handler - Handler function to perform
485 *
486 * @tparam U - The type of the handler
487 *
488 * @return - The NameOwnerChanged signal struct
489 */
490template <typename U>
491auto nameHasOwner(U&& handler)
492{
493 return NameOwner<U>(std::forward<U>(handler));
Matthew Barth8fa02da2017-09-28 12:18:20 -0500494}
495
Matthew Barth38a93a82017-05-11 14:12:27 -0500496} // namespace control
497} // namespace fan
498} // namespace phosphor