blob: fd6fe6abc546c70b156ce87ea3d679306240a943 [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"
Matthew Barth3b3efc52021-01-15 16:24:42 -06005#include "zone.hpp"
Matthew Barth3e1bb272020-05-26 11:09:21 -05006
Matthew Barth38a93a82017-05-11 14:12:27 -05007#include <phosphor-logging/log.hpp>
8
9namespace phosphor
10{
11namespace fan
12{
13namespace control
14{
15class Zone;
16
Matthew Barth336f18a2017-09-26 09:15:56 -050017using namespace phosphor::fan;
Matthew Barth5a302572017-10-03 11:27:06 -050018using namespace sdbusplus::bus::match;
Matthew Barth38a93a82017-05-11 14:12:27 -050019using namespace phosphor::logging;
20
21/**
Matthew Barth1b3e9602019-02-13 11:37:03 -060022 * @brief Create a zone handler function object
23 *
24 * @param[in] handler - The handler being created
25 *
26 * @return - The created zone handler function object
27 */
28template <typename T>
29auto make_zoneHandler(T&& handler)
30{
31 return ZoneHandler(std::forward<T>(handler));
32}
33
34/**
Matthew Barth1b4de262018-03-06 13:03:16 -060035 * @brief Create a trigger function object
36 *
37 * @param[in] trigger - The trigger being created
38 *
39 * @return - The created trigger function object
40 */
41template <typename T>
42auto make_trigger(T&& trigger)
43{
Matthew Barth3e1bb272020-05-26 11:09:21 -050044 return Trigger(std::forward<T>(trigger));
Matthew Barth1b4de262018-03-06 13:03:16 -060045}
46
47/**
Matthew Barth38a93a82017-05-11 14:12:27 -050048 * @brief Create a handler function object
49 *
50 * @param[in] handler - The handler being created
51 *
52 * @return - The created handler function object
53 */
Matthew Barth926df662018-10-09 09:51:12 -050054template <typename T, typename U>
55auto make_handler(U&& handler)
Matthew Barth38a93a82017-05-11 14:12:27 -050056{
Matthew Barth926df662018-10-09 09:51:12 -050057 return T(std::forward<U>(handler));
Matthew Barth38a93a82017-05-11 14:12:27 -050058}
59
60/**
Matthew Barth17d1fe22017-05-11 15:00:36 -050061 * @brief Create an action function object
62 *
63 * @param[in] action - The action being created
64 *
65 * @return - The created action function object
66 */
67template <typename T>
68auto make_action(T&& action)
69{
70 return Action(std::forward<T>(action));
71}
72
73/**
Matthew Barth926df662018-10-09 09:51:12 -050074 * @struct Properties
75 * @brief A set of match filter functors for Dbus property values. Each
76 * functor provides an associated process for retrieving the value
77 * for a given property and providing it to the given handler function.
Matthew Barth38a93a82017-05-11 14:12:27 -050078 *
79 * @tparam T - The type of the property value
80 * @tparam U - The type of the handler
81 */
82template <typename T, typename U>
Matthew Barth926df662018-10-09 09:51:12 -050083struct Properties
Matthew Barth38a93a82017-05-11 14:12:27 -050084{
Matthew Barth926df662018-10-09 09:51:12 -050085 Properties() = delete;
86 ~Properties() = default;
87 Properties(const Properties&) = default;
88 Properties& operator=(const Properties&) = default;
89 Properties(Properties&&) = default;
90 Properties& operator=(Properties&&) = default;
Matthew Barth9f93bd32020-05-28 16:57:14 -050091 explicit Properties(U&& handler) :
92 _path(""), _intf(""), _prop(""), _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -050093 {}
94 Properties(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -050095 U&& handler) :
Patrick Williamsdfddd642024-08-16 15:21:51 -040096 _path(path), _intf(intf), _prop(prop),
97 _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -050098 {}
Matthew Barth38a93a82017-05-11 14:12:27 -050099
100 /** @brief Run signal handler function
101 *
102 * Extract the property from the PropertiesChanged
Matthew Barth926df662018-10-09 09:51:12 -0500103 * message and run the handler function.
Matthew Barth38a93a82017-05-11 14:12:27 -0500104 */
Mike Cappsa0819562022-06-13 10:17:10 -0400105 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Barth38a93a82017-05-11 14:12:27 -0500106 Zone& zone) const
107 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500108 if (msg)
Matthew Barth38a93a82017-05-11 14:12:27 -0500109 {
Matthew Barth469d1362018-10-11 14:10:47 -0500110 std::string intf;
Matthew Barth469d1362018-10-11 14:10:47 -0500111 msg.read(intf);
112 if (intf != _intf)
Matthew Barth336f18a2017-09-26 09:15:56 -0500113 {
Matthew Barth469d1362018-10-11 14:10:47 -0500114 // Interface name does not match on object
Matthew Barth336f18a2017-09-26 09:15:56 -0500115 return;
116 }
117
Matthew Barth7f4c5482020-02-07 16:14:46 -0600118 std::map<std::string, PropertyVariantType> props;
Matthew Barth469d1362018-10-11 14:10:47 -0500119 msg.read(props);
120 auto it = props.find(_prop);
121 if (it == props.cend())
Matthew Barth336f18a2017-09-26 09:15:56 -0500122 {
Matthew Barth469d1362018-10-11 14:10:47 -0500123 // Property not included in dictionary of properties changed
Matthew Barth336f18a2017-09-26 09:15:56 -0500124 return;
125 }
126
Matthew Barth7f4c5482020-02-07 16:14:46 -0600127 // Retrieve the property's value applying any visitors necessary
Patrick Williamsdfddd642024-08-16 15:21:51 -0400128 auto value =
129 zone.getPropertyValueVisitor<T>(_intf, _prop, it->second);
Matthew Barth7f4c5482020-02-07 16:14:46 -0600130
131 _handler(zone, _path, _intf, _prop, std::forward<T>(value));
Matthew Barth336f18a2017-09-26 09:15:56 -0500132 }
133 else
Matthew Barth38a93a82017-05-11 14:12:27 -0500134 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500135 try
136 {
Matthew Barth469d1362018-10-11 14:10:47 -0500137 auto val = zone.getPropertyByName<T>(_path, _intf, _prop);
138 _handler(zone, _path, _intf, _prop, std::forward<T>(val));
Matthew Barth336f18a2017-09-26 09:15:56 -0500139 }
Patrick Williamscb356d42022-07-22 19:26:53 -0500140 catch (const sdbusplus::exception_t&)
Matthew Barth86be4762018-07-17 10:51:36 -0500141 {
142 // Property will not be used unless a property changed
143 // signal message is received for this property.
144 }
145 catch (const util::DBusError&)
Matthew Barth336f18a2017-09-26 09:15:56 -0500146 {
147 // Property will not be used unless a property changed
148 // signal message is received for this property.
Matthew Barth336f18a2017-09-26 09:15:56 -0500149 }
Matthew Barth38a93a82017-05-11 14:12:27 -0500150 }
Matthew Barth38a93a82017-05-11 14:12:27 -0500151 }
152
Matthew Barth926df662018-10-09 09:51:12 -0500153 /** @brief Run init handler function
154 *
155 * Get the property from each member object of the group
156 * and run the handler function.
157 */
158 void operator()(Zone& zone, const Group& group) const
159 {
160 std::for_each(
Matthew Barth3e1bb272020-05-26 11:09:21 -0500161 group.begin(), group.end(),
Patrick Williams61b73292023-05-10 07:50:12 -0500162 [&zone, handler = std::move(_handler)](const auto& member) {
Patrick Williamsdfddd642024-08-16 15:21:51 -0400163 auto path = std::get<pathPos>(member);
164 auto intf = std::get<intfPos>(member);
165 auto prop = std::get<propPos>(member);
166 try
167 {
168 auto val = zone.getPropertyByName<T>(path, intf, prop);
169 handler(zone, path, intf, prop, std::forward<T>(val));
170 }
171 catch (const sdbusplus::exception_t&)
172 {
173 // Property value not sent to handler
174 }
175 catch (const util::DBusError&)
176 {
177 // Property value not sent to handler
178 }
179 });
Matthew Barth926df662018-10-09 09:51:12 -0500180 }
181
Matthew Barth3e1bb272020-05-26 11:09:21 -0500182 private:
Matthew Barth336f18a2017-09-26 09:15:56 -0500183 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500184 const char* _intf;
185 const char* _prop;
Matthew Barth38a93a82017-05-11 14:12:27 -0500186 U _handler;
187};
188
189/**
Matthew Barth469d1362018-10-11 14:10:47 -0500190 * @brief Used to process a Dbus properties changed signal event
Matthew Barth38a93a82017-05-11 14:12:27 -0500191 *
Matthew Barth336f18a2017-09-26 09:15:56 -0500192 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500193 * @param[in] intf - Object interface
194 * @param[in] prop - Object property
Matthew Barth38a93a82017-05-11 14:12:27 -0500195 * @param[in] handler - Handler function to perform
196 *
197 * @tparam T - The type of the property
198 * @tparam U - The type of the handler
199 */
200template <typename T, typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500201auto propertiesChanged(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -0500202 U&& handler)
Matthew Barth38a93a82017-05-11 14:12:27 -0500203{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500204 return Properties<T, U>(path, intf, prop, std::forward<U>(handler));
Matthew Barth926df662018-10-09 09:51:12 -0500205}
206
207/**
Matthew Barth469d1362018-10-11 14:10:47 -0500208 * @brief Used to get the properties of an event's group
Matthew Barth926df662018-10-09 09:51:12 -0500209 *
210 * @param[in] handler - Handler function to perform
211 *
Matthew Barth469d1362018-10-11 14:10:47 -0500212 * @tparam T - The type of all the properties
Matthew Barth926df662018-10-09 09:51:12 -0500213 * @tparam U - The type of the handler
214 */
215template <typename T, typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500216auto getProperties(U&& handler)
Matthew Barth926df662018-10-09 09:51:12 -0500217{
218 return Properties<T, U>(std::forward<U>(handler));
Matthew Barth38a93a82017-05-11 14:12:27 -0500219}
220
Matthew Bartheb639c52017-08-04 09:43:11 -0500221/**
Matthew Barth469d1362018-10-11 14:10:47 -0500222 * @struct Interfaces Added
223 * @brief A match filter functor for Dbus interfaces added signals
Matthew Bartheb639c52017-08-04 09:43:11 -0500224 *
225 * @tparam T - The type of the property value
226 * @tparam U - The type of the handler
227 */
228template <typename T, typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500229struct InterfacesAdded
Matthew Bartheb639c52017-08-04 09:43:11 -0500230{
Matthew Barth469d1362018-10-11 14:10:47 -0500231 InterfacesAdded() = delete;
232 ~InterfacesAdded() = default;
233 InterfacesAdded(const InterfacesAdded&) = default;
234 InterfacesAdded& operator=(const InterfacesAdded&) = default;
235 InterfacesAdded(InterfacesAdded&&) = default;
236 InterfacesAdded& operator=(InterfacesAdded&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500237 InterfacesAdded(const char* path, const char* intf, const char* prop,
Matthew Barth469d1362018-10-11 14:10:47 -0500238 U&& handler) :
Patrick Williamsdfddd642024-08-16 15:21:51 -0400239 _path(path), _intf(intf), _prop(prop),
240 _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -0500241 {}
Matthew Bartheb639c52017-08-04 09:43:11 -0500242
243 /** @brief Run signal handler function
244 *
245 * Extract the property from the InterfacesAdded
246 * message and run the handler function.
247 */
Patrick Williamscb356d42022-07-22 19:26:53 -0500248 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Bartheb639c52017-08-04 09:43:11 -0500249 Zone& zone) const
250 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500251 if (msg)
Matthew Bartheb639c52017-08-04 09:43:11 -0500252 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500253 sdbusplus::message::object_path op;
Matthew Bartheb639c52017-08-04 09:43:11 -0500254
Matthew Barth336f18a2017-09-26 09:15:56 -0500255 msg.read(op);
Matthew Barthd5cfdbe2017-11-14 15:29:50 -0600256 if (static_cast<const std::string&>(op) != _path)
Matthew Barth336f18a2017-09-26 09:15:56 -0500257 {
258 // Object path does not match this handler's path
259 return;
260 }
Matthew Bartheb639c52017-08-04 09:43:11 -0500261
Matthew Barth3e1bb272020-05-26 11:09:21 -0500262 std::map<std::string, std::map<std::string, PropertyVariantType>>
263 intfProp;
Matthew Barth336f18a2017-09-26 09:15:56 -0500264 msg.read(intfProp);
Matthew Barth469d1362018-10-11 14:10:47 -0500265 auto itIntf = intfProp.find(_intf);
Matthew Barth336f18a2017-09-26 09:15:56 -0500266 if (itIntf == intfProp.cend())
267 {
268 // Interface not found on this handler's path
269 return;
270 }
Matthew Barth469d1362018-10-11 14:10:47 -0500271 auto itProp = itIntf->second.find(_prop);
Matthew Barth336f18a2017-09-26 09:15:56 -0500272 if (itProp == itIntf->second.cend())
273 {
274 // Property not found on this handler's path
275 return;
276 }
277
Matthew Barth7f4c5482020-02-07 16:14:46 -0600278 // Retrieve the property's value applying any visitors necessary
Patrick Williamsdfddd642024-08-16 15:21:51 -0400279 auto value =
280 zone.getPropertyValueVisitor<T>(_intf, _prop, itProp->second);
Matthew Barth7f4c5482020-02-07 16:14:46 -0600281
282 _handler(zone, _path, _intf, _prop, std::forward<T>(value));
Matthew Barth336f18a2017-09-26 09:15:56 -0500283 }
Matthew Bartheb639c52017-08-04 09:43:11 -0500284 }
285
Matthew Barth3e1bb272020-05-26 11:09:21 -0500286 private:
Matthew Bartheb639c52017-08-04 09:43:11 -0500287 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500288 const char* _intf;
289 const char* _prop;
Matthew Bartheb639c52017-08-04 09:43:11 -0500290 U _handler;
291};
292
293/**
Matthew Barth926df662018-10-09 09:51:12 -0500294 * @brief Used to process a Dbus interfaces added signal event
Matthew Bartheb639c52017-08-04 09:43:11 -0500295 *
296 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500297 * @param[in] intf - Object interface
298 * @param[in] prop - Object property
Matthew Bartheb639c52017-08-04 09:43:11 -0500299 * @param[in] handler - Handler function to perform
300 *
301 * @tparam T - The type of the property
302 * @tparam U - The type of the handler
303 */
304template <typename T, typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500305auto interfacesAdded(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -0500306 U&& handler)
Matthew Bartheb639c52017-08-04 09:43:11 -0500307{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500308 return InterfacesAdded<T, U>(path, intf, prop, std::forward<U>(handler));
Matthew Bartheb639c52017-08-04 09:43:11 -0500309}
310
Matthew Barth8fa02da2017-09-28 12:18:20 -0500311/**
Matthew Barth469d1362018-10-11 14:10:47 -0500312 * @struct Interfaces Removed
313 * @brief A match filter functor for Dbus interfaces removed signals
Matthew Barth1499a5c2018-03-20 15:52:33 -0500314 *
315 * @tparam U - The type of the handler
316 */
317template <typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500318struct InterfacesRemoved
Matthew Barth1499a5c2018-03-20 15:52:33 -0500319{
Matthew Barth469d1362018-10-11 14:10:47 -0500320 InterfacesRemoved() = delete;
321 ~InterfacesRemoved() = default;
322 InterfacesRemoved(const InterfacesRemoved&) = default;
323 InterfacesRemoved& operator=(const InterfacesRemoved&) = default;
324 InterfacesRemoved(InterfacesRemoved&&) = default;
325 InterfacesRemoved& operator=(InterfacesRemoved&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500326 InterfacesRemoved(const char* path, const char* intf, U&& handler) :
327 _path(path), _intf(intf), _handler(std::forward<U>(handler))
328 {}
Matthew Barth1499a5c2018-03-20 15:52:33 -0500329
330 /** @brief Run signal handler function
331 *
Matthew Barth469d1362018-10-11 14:10:47 -0500332 * Extract the interfaces from the InterfacesRemoved
Matthew Barth1499a5c2018-03-20 15:52:33 -0500333 * message and run the handler function.
334 */
Patrick Williamscb356d42022-07-22 19:26:53 -0500335 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Barth1499a5c2018-03-20 15:52:33 -0500336 Zone& zone) const
337 {
338 if (msg)
339 {
340 std::vector<std::string> intfs;
341 sdbusplus::message::object_path op;
342
343 msg.read(op);
344 if (static_cast<const std::string&>(op) != _path)
345 {
346 // Object path does not match this handler's path
347 return;
348 }
349
350 msg.read(intfs);
Matthew Barth469d1362018-10-11 14:10:47 -0500351 auto itIntf = std::find(intfs.begin(), intfs.end(), _intf);
Matthew Barth1499a5c2018-03-20 15:52:33 -0500352 if (itIntf == intfs.cend())
353 {
354 // Interface not found on this handler's path
355 return;
356 }
357
358 _handler(zone);
359 }
360 }
361
Matthew Barth3e1bb272020-05-26 11:09:21 -0500362 private:
Matthew Barth1499a5c2018-03-20 15:52:33 -0500363 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500364 const char* _intf;
Matthew Barth1499a5c2018-03-20 15:52:33 -0500365 U _handler;
366};
367
368/**
Matthew Barth926df662018-10-09 09:51:12 -0500369 * @brief Used to process a Dbus interfaces removed signal event
Matthew Barth1499a5c2018-03-20 15:52:33 -0500370 *
371 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500372 * @param[in] intf - Object interface
Matthew Barth1499a5c2018-03-20 15:52:33 -0500373 * @param[in] handler - Handler function to perform
374 *
375 * @tparam U - The type of the handler
376 */
377template <typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500378auto interfacesRemoved(const char* path, const char* intf, U&& handler)
Matthew Barth1499a5c2018-03-20 15:52:33 -0500379{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500380 return InterfacesRemoved<U>(path, intf, std::forward<U>(handler));
Matthew Barth1499a5c2018-03-20 15:52:33 -0500381}
382
383/**
Matthew Barth926df662018-10-09 09:51:12 -0500384 * @struct Name Owner
385 * @brief A functor for Dbus name owner signals and methods
Matthew Barth8fa02da2017-09-28 12:18:20 -0500386 *
387 * @tparam U - The type of the handler
388 */
389template <typename U>
Matthew Barth926df662018-10-09 09:51:12 -0500390struct NameOwner
Matthew Barth8fa02da2017-09-28 12:18:20 -0500391{
Matthew Barth926df662018-10-09 09:51:12 -0500392 NameOwner() = delete;
393 ~NameOwner() = default;
394 NameOwner(const NameOwner&) = default;
395 NameOwner& operator=(const NameOwner&) = default;
396 NameOwner(NameOwner&&) = default;
397 NameOwner& operator=(NameOwner&&) = default;
Patrick Williams61b73292023-05-10 07:50:12 -0500398 explicit NameOwner(U&& handler) : _handler(std::forward<U>(handler)) {}
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 */
Mike Cappsa0819562022-06-13 10:17:10 -0400405 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& 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;
Patrick Williamsdfddd642024-08-16 15:21:51 -0400433 std::for_each(
434 group.begin(), group.end(),
435 [&zone, &group, &name, &hasOwner,
436 handler = std::move(_handler)](const auto& member) {
437 auto path = std::get<pathPos>(member);
438 auto intf = std::get<intfPos>(member);
439 try
Matthew Barth926df662018-10-09 09:51:12 -0500440 {
Patrick Williamsdfddd642024-08-16 15:21:51 -0400441 auto servName = zone.getService(path, intf);
442 if (name != servName)
443 {
444 name = servName;
445 hasOwner = util::SDBusPlus::callMethodAndRead<bool>(
446 zone.getBus(), "org.freedesktop.DBus",
447 "/org/freedesktop/DBus", "org.freedesktop.DBus",
448 "NameHasOwner", name);
449 // Update service name owner state list of a group
450 handler(zone, name, hasOwner);
451 }
Matthew Barth926df662018-10-09 09:51:12 -0500452 }
Patrick Williamsdfddd642024-08-16 15:21:51 -0400453 catch (const util::DBusMethodError& e)
454 {
455 // Failed to get service name owner state
456 name = "";
457 hasOwner = false;
458 }
459 });
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