blob: d7997c8ba436b37e6f2e949e8441502e4b17957a [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 -05007namespace phosphor
8{
9namespace fan
10{
11namespace control
12{
13class Zone;
14
Matthew Barth336f18a2017-09-26 09:15:56 -050015using namespace phosphor::fan;
Matthew Barth5a302572017-10-03 11:27:06 -050016using namespace sdbusplus::bus::match;
Matthew Barth38a93a82017-05-11 14:12:27 -050017
18/**
Matthew Barth1b3e9602019-02-13 11:37:03 -060019 * @brief Create a zone handler function object
20 *
21 * @param[in] handler - The handler being created
22 *
23 * @return - The created zone handler function object
24 */
25template <typename T>
26auto make_zoneHandler(T&& handler)
27{
28 return ZoneHandler(std::forward<T>(handler));
29}
30
31/**
Matthew Barth1b4de262018-03-06 13:03:16 -060032 * @brief Create a trigger function object
33 *
34 * @param[in] trigger - The trigger being created
35 *
36 * @return - The created trigger function object
37 */
38template <typename T>
39auto make_trigger(T&& trigger)
40{
Matthew Barth3e1bb272020-05-26 11:09:21 -050041 return Trigger(std::forward<T>(trigger));
Matthew Barth1b4de262018-03-06 13:03:16 -060042}
43
44/**
Matthew Barth38a93a82017-05-11 14:12:27 -050045 * @brief Create a handler function object
46 *
47 * @param[in] handler - The handler being created
48 *
49 * @return - The created handler function object
50 */
Matthew Barth926df662018-10-09 09:51:12 -050051template <typename T, typename U>
52auto make_handler(U&& handler)
Matthew Barth38a93a82017-05-11 14:12:27 -050053{
Matthew Barth926df662018-10-09 09:51:12 -050054 return T(std::forward<U>(handler));
Matthew Barth38a93a82017-05-11 14:12:27 -050055}
56
57/**
Matthew Barth17d1fe22017-05-11 15:00:36 -050058 * @brief Create an action function object
59 *
60 * @param[in] action - The action being created
61 *
62 * @return - The created action function object
63 */
64template <typename T>
65auto make_action(T&& action)
66{
67 return Action(std::forward<T>(action));
68}
69
70/**
Matthew Barth926df662018-10-09 09:51:12 -050071 * @struct Properties
72 * @brief A set of match filter functors for Dbus property values. Each
73 * functor provides an associated process for retrieving the value
74 * for a given property and providing it to the given handler function.
Matthew Barth38a93a82017-05-11 14:12:27 -050075 *
76 * @tparam T - The type of the property value
77 * @tparam U - The type of the handler
78 */
79template <typename T, typename U>
Matthew Barth926df662018-10-09 09:51:12 -050080struct Properties
Matthew Barth38a93a82017-05-11 14:12:27 -050081{
Matthew Barth926df662018-10-09 09:51:12 -050082 Properties() = delete;
83 ~Properties() = default;
84 Properties(const Properties&) = default;
85 Properties& operator=(const Properties&) = default;
86 Properties(Properties&&) = default;
87 Properties& operator=(Properties&&) = default;
Matthew Barth9f93bd32020-05-28 16:57:14 -050088 explicit Properties(U&& handler) :
89 _path(""), _intf(""), _prop(""), _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -050090 {}
91 Properties(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -050092 U&& handler) :
Patrick Williamsdfddd642024-08-16 15:21:51 -040093 _path(path), _intf(intf), _prop(prop),
94 _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -050095 {}
Matthew Barth38a93a82017-05-11 14:12:27 -050096
97 /** @brief Run signal handler function
98 *
99 * Extract the property from the PropertiesChanged
Matthew Barth926df662018-10-09 09:51:12 -0500100 * message and run the handler function.
Matthew Barth38a93a82017-05-11 14:12:27 -0500101 */
Mike Cappsa0819562022-06-13 10:17:10 -0400102 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Barth38a93a82017-05-11 14:12:27 -0500103 Zone& zone) const
104 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500105 if (msg)
Matthew Barth38a93a82017-05-11 14:12:27 -0500106 {
Matthew Barth469d1362018-10-11 14:10:47 -0500107 std::string intf;
Matthew Barth469d1362018-10-11 14:10:47 -0500108 msg.read(intf);
109 if (intf != _intf)
Matthew Barth336f18a2017-09-26 09:15:56 -0500110 {
Matthew Barth469d1362018-10-11 14:10:47 -0500111 // Interface name does not match on object
Matthew Barth336f18a2017-09-26 09:15:56 -0500112 return;
113 }
114
Matthew Barth7f4c5482020-02-07 16:14:46 -0600115 std::map<std::string, PropertyVariantType> props;
Matthew Barth469d1362018-10-11 14:10:47 -0500116 msg.read(props);
117 auto it = props.find(_prop);
118 if (it == props.cend())
Matthew Barth336f18a2017-09-26 09:15:56 -0500119 {
Matthew Barth469d1362018-10-11 14:10:47 -0500120 // Property not included in dictionary of properties changed
Matthew Barth336f18a2017-09-26 09:15:56 -0500121 return;
122 }
123
Matthew Barth7f4c5482020-02-07 16:14:46 -0600124 // Retrieve the property's value applying any visitors necessary
Patrick Williamsdfddd642024-08-16 15:21:51 -0400125 auto value =
126 zone.getPropertyValueVisitor<T>(_intf, _prop, it->second);
Matthew Barth7f4c5482020-02-07 16:14:46 -0600127
128 _handler(zone, _path, _intf, _prop, std::forward<T>(value));
Matthew Barth336f18a2017-09-26 09:15:56 -0500129 }
130 else
Matthew Barth38a93a82017-05-11 14:12:27 -0500131 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500132 try
133 {
Matthew Barth469d1362018-10-11 14:10:47 -0500134 auto val = zone.getPropertyByName<T>(_path, _intf, _prop);
135 _handler(zone, _path, _intf, _prop, std::forward<T>(val));
Matthew Barth336f18a2017-09-26 09:15:56 -0500136 }
Patrick Williamscb356d42022-07-22 19:26:53 -0500137 catch (const sdbusplus::exception_t&)
Matthew Barth86be4762018-07-17 10:51:36 -0500138 {
139 // Property will not be used unless a property changed
140 // signal message is received for this property.
141 }
142 catch (const util::DBusError&)
Matthew Barth336f18a2017-09-26 09:15:56 -0500143 {
144 // Property will not be used unless a property changed
145 // signal message is received for this property.
Matthew Barth336f18a2017-09-26 09:15:56 -0500146 }
Matthew Barth38a93a82017-05-11 14:12:27 -0500147 }
Matthew Barth38a93a82017-05-11 14:12:27 -0500148 }
149
Matthew Barth926df662018-10-09 09:51:12 -0500150 /** @brief Run init handler function
151 *
152 * Get the property from each member object of the group
153 * and run the handler function.
154 */
155 void operator()(Zone& zone, const Group& group) const
156 {
157 std::for_each(
Matthew Barth3e1bb272020-05-26 11:09:21 -0500158 group.begin(), group.end(),
Patrick Williams61b73292023-05-10 07:50:12 -0500159 [&zone, handler = std::move(_handler)](const auto& member) {
Patrick Williamsdfddd642024-08-16 15:21:51 -0400160 auto path = std::get<pathPos>(member);
161 auto intf = std::get<intfPos>(member);
162 auto prop = std::get<propPos>(member);
163 try
164 {
165 auto val = zone.getPropertyByName<T>(path, intf, prop);
166 handler(zone, path, intf, prop, std::forward<T>(val));
167 }
168 catch (const sdbusplus::exception_t&)
169 {
170 // Property value not sent to handler
171 }
172 catch (const util::DBusError&)
173 {
174 // Property value not sent to handler
175 }
176 });
Matthew Barth926df662018-10-09 09:51:12 -0500177 }
178
Matthew Barth3e1bb272020-05-26 11:09:21 -0500179 private:
Matthew Barth336f18a2017-09-26 09:15:56 -0500180 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500181 const char* _intf;
182 const char* _prop;
Matthew Barth38a93a82017-05-11 14:12:27 -0500183 U _handler;
184};
185
186/**
Matthew Barth469d1362018-10-11 14:10:47 -0500187 * @brief Used to process a Dbus properties changed signal event
Matthew Barth38a93a82017-05-11 14:12:27 -0500188 *
Matthew Barth336f18a2017-09-26 09:15:56 -0500189 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500190 * @param[in] intf - Object interface
191 * @param[in] prop - Object property
Matthew Barth38a93a82017-05-11 14:12:27 -0500192 * @param[in] handler - Handler function to perform
193 *
194 * @tparam T - The type of the property
195 * @tparam U - The type of the handler
196 */
197template <typename T, typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500198auto propertiesChanged(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -0500199 U&& handler)
Matthew Barth38a93a82017-05-11 14:12:27 -0500200{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500201 return Properties<T, U>(path, intf, prop, std::forward<U>(handler));
Matthew Barth926df662018-10-09 09:51:12 -0500202}
203
204/**
Matthew Barth469d1362018-10-11 14:10:47 -0500205 * @brief Used to get the properties of an event's group
Matthew Barth926df662018-10-09 09:51:12 -0500206 *
207 * @param[in] handler - Handler function to perform
208 *
Matthew Barth469d1362018-10-11 14:10:47 -0500209 * @tparam T - The type of all the properties
Matthew Barth926df662018-10-09 09:51:12 -0500210 * @tparam U - The type of the handler
211 */
212template <typename T, typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500213auto getProperties(U&& handler)
Matthew Barth926df662018-10-09 09:51:12 -0500214{
215 return Properties<T, U>(std::forward<U>(handler));
Matthew Barth38a93a82017-05-11 14:12:27 -0500216}
217
Matthew Bartheb639c52017-08-04 09:43:11 -0500218/**
Matthew Barth469d1362018-10-11 14:10:47 -0500219 * @struct Interfaces Added
220 * @brief A match filter functor for Dbus interfaces added signals
Matthew Bartheb639c52017-08-04 09:43:11 -0500221 *
222 * @tparam T - The type of the property value
223 * @tparam U - The type of the handler
224 */
225template <typename T, typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500226struct InterfacesAdded
Matthew Bartheb639c52017-08-04 09:43:11 -0500227{
Matthew Barth469d1362018-10-11 14:10:47 -0500228 InterfacesAdded() = delete;
229 ~InterfacesAdded() = default;
230 InterfacesAdded(const InterfacesAdded&) = default;
231 InterfacesAdded& operator=(const InterfacesAdded&) = default;
232 InterfacesAdded(InterfacesAdded&&) = default;
233 InterfacesAdded& operator=(InterfacesAdded&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500234 InterfacesAdded(const char* path, const char* intf, const char* prop,
Matthew Barth469d1362018-10-11 14:10:47 -0500235 U&& handler) :
Patrick Williamsdfddd642024-08-16 15:21:51 -0400236 _path(path), _intf(intf), _prop(prop),
237 _handler(std::forward<U>(handler))
Matthew Barth3e1bb272020-05-26 11:09:21 -0500238 {}
Matthew Bartheb639c52017-08-04 09:43:11 -0500239
240 /** @brief Run signal handler function
241 *
242 * Extract the property from the InterfacesAdded
243 * message and run the handler function.
244 */
Patrick Williamscb356d42022-07-22 19:26:53 -0500245 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Bartheb639c52017-08-04 09:43:11 -0500246 Zone& zone) const
247 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500248 if (msg)
Matthew Bartheb639c52017-08-04 09:43:11 -0500249 {
Matthew Barth336f18a2017-09-26 09:15:56 -0500250 sdbusplus::message::object_path op;
Matthew Bartheb639c52017-08-04 09:43:11 -0500251
Matthew Barth336f18a2017-09-26 09:15:56 -0500252 msg.read(op);
Matthew Barthd5cfdbe2017-11-14 15:29:50 -0600253 if (static_cast<const std::string&>(op) != _path)
Matthew Barth336f18a2017-09-26 09:15:56 -0500254 {
255 // Object path does not match this handler's path
256 return;
257 }
Matthew Bartheb639c52017-08-04 09:43:11 -0500258
Matthew Barth3e1bb272020-05-26 11:09:21 -0500259 std::map<std::string, std::map<std::string, PropertyVariantType>>
260 intfProp;
Matthew Barth336f18a2017-09-26 09:15:56 -0500261 msg.read(intfProp);
Matthew Barth469d1362018-10-11 14:10:47 -0500262 auto itIntf = intfProp.find(_intf);
Matthew Barth336f18a2017-09-26 09:15:56 -0500263 if (itIntf == intfProp.cend())
264 {
265 // Interface not found on this handler's path
266 return;
267 }
Matthew Barth469d1362018-10-11 14:10:47 -0500268 auto itProp = itIntf->second.find(_prop);
Matthew Barth336f18a2017-09-26 09:15:56 -0500269 if (itProp == itIntf->second.cend())
270 {
271 // Property not found on this handler's path
272 return;
273 }
274
Matthew Barth7f4c5482020-02-07 16:14:46 -0600275 // Retrieve the property's value applying any visitors necessary
Patrick Williamsdfddd642024-08-16 15:21:51 -0400276 auto value =
277 zone.getPropertyValueVisitor<T>(_intf, _prop, itProp->second);
Matthew Barth7f4c5482020-02-07 16:14:46 -0600278
279 _handler(zone, _path, _intf, _prop, std::forward<T>(value));
Matthew Barth336f18a2017-09-26 09:15:56 -0500280 }
Matthew Bartheb639c52017-08-04 09:43:11 -0500281 }
282
Matthew Barth3e1bb272020-05-26 11:09:21 -0500283 private:
Matthew Bartheb639c52017-08-04 09:43:11 -0500284 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500285 const char* _intf;
286 const char* _prop;
Matthew Bartheb639c52017-08-04 09:43:11 -0500287 U _handler;
288};
289
290/**
Matthew Barth926df662018-10-09 09:51:12 -0500291 * @brief Used to process a Dbus interfaces added signal event
Matthew Bartheb639c52017-08-04 09:43:11 -0500292 *
293 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500294 * @param[in] intf - Object interface
295 * @param[in] prop - Object property
Matthew Bartheb639c52017-08-04 09:43:11 -0500296 * @param[in] handler - Handler function to perform
297 *
298 * @tparam T - The type of the property
299 * @tparam U - The type of the handler
300 */
301template <typename T, typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500302auto interfacesAdded(const char* path, const char* intf, const char* prop,
Matthew Barth926df662018-10-09 09:51:12 -0500303 U&& handler)
Matthew Bartheb639c52017-08-04 09:43:11 -0500304{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500305 return InterfacesAdded<T, U>(path, intf, prop, std::forward<U>(handler));
Matthew Bartheb639c52017-08-04 09:43:11 -0500306}
307
Matthew Barth8fa02da2017-09-28 12:18:20 -0500308/**
Matthew Barth469d1362018-10-11 14:10:47 -0500309 * @struct Interfaces Removed
310 * @brief A match filter functor for Dbus interfaces removed signals
Matthew Barth1499a5c2018-03-20 15:52:33 -0500311 *
312 * @tparam U - The type of the handler
313 */
314template <typename U>
Matthew Barth469d1362018-10-11 14:10:47 -0500315struct InterfacesRemoved
Matthew Barth1499a5c2018-03-20 15:52:33 -0500316{
Matthew Barth469d1362018-10-11 14:10:47 -0500317 InterfacesRemoved() = delete;
318 ~InterfacesRemoved() = default;
319 InterfacesRemoved(const InterfacesRemoved&) = default;
320 InterfacesRemoved& operator=(const InterfacesRemoved&) = default;
321 InterfacesRemoved(InterfacesRemoved&&) = default;
322 InterfacesRemoved& operator=(InterfacesRemoved&&) = default;
Matthew Barth3e1bb272020-05-26 11:09:21 -0500323 InterfacesRemoved(const char* path, const char* intf, U&& handler) :
324 _path(path), _intf(intf), _handler(std::forward<U>(handler))
325 {}
Matthew Barth1499a5c2018-03-20 15:52:33 -0500326
327 /** @brief Run signal handler function
328 *
Matthew Barth469d1362018-10-11 14:10:47 -0500329 * Extract the interfaces from the InterfacesRemoved
Matthew Barth1499a5c2018-03-20 15:52:33 -0500330 * message and run the handler function.
331 */
Patrick Williamscb356d42022-07-22 19:26:53 -0500332 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Barth1499a5c2018-03-20 15:52:33 -0500333 Zone& zone) const
334 {
335 if (msg)
336 {
337 std::vector<std::string> intfs;
338 sdbusplus::message::object_path op;
339
340 msg.read(op);
341 if (static_cast<const std::string&>(op) != _path)
342 {
343 // Object path does not match this handler's path
344 return;
345 }
346
347 msg.read(intfs);
Matthew Barth469d1362018-10-11 14:10:47 -0500348 auto itIntf = std::find(intfs.begin(), intfs.end(), _intf);
Matthew Barth1499a5c2018-03-20 15:52:33 -0500349 if (itIntf == intfs.cend())
350 {
351 // Interface not found on this handler's path
352 return;
353 }
354
355 _handler(zone);
356 }
357 }
358
Matthew Barth3e1bb272020-05-26 11:09:21 -0500359 private:
Matthew Barth1499a5c2018-03-20 15:52:33 -0500360 const char* _path;
Matthew Barth469d1362018-10-11 14:10:47 -0500361 const char* _intf;
Matthew Barth1499a5c2018-03-20 15:52:33 -0500362 U _handler;
363};
364
365/**
Matthew Barth926df662018-10-09 09:51:12 -0500366 * @brief Used to process a Dbus interfaces removed signal event
Matthew Barth1499a5c2018-03-20 15:52:33 -0500367 *
368 * @param[in] path - Object path
Matthew Barth469d1362018-10-11 14:10:47 -0500369 * @param[in] intf - Object interface
Matthew Barth1499a5c2018-03-20 15:52:33 -0500370 * @param[in] handler - Handler function to perform
371 *
372 * @tparam U - The type of the handler
373 */
374template <typename U>
Matthew Barth3e1bb272020-05-26 11:09:21 -0500375auto interfacesRemoved(const char* path, const char* intf, U&& handler)
Matthew Barth1499a5c2018-03-20 15:52:33 -0500376{
Matthew Barth3e1bb272020-05-26 11:09:21 -0500377 return InterfacesRemoved<U>(path, intf, std::forward<U>(handler));
Matthew Barth1499a5c2018-03-20 15:52:33 -0500378}
379
380/**
Matthew Barth926df662018-10-09 09:51:12 -0500381 * @struct Name Owner
382 * @brief A functor for Dbus name owner signals and methods
Matthew Barth8fa02da2017-09-28 12:18:20 -0500383 *
384 * @tparam U - The type of the handler
385 */
386template <typename U>
Matthew Barth926df662018-10-09 09:51:12 -0500387struct NameOwner
Matthew Barth8fa02da2017-09-28 12:18:20 -0500388{
Matthew Barth926df662018-10-09 09:51:12 -0500389 NameOwner() = delete;
390 ~NameOwner() = default;
391 NameOwner(const NameOwner&) = default;
392 NameOwner& operator=(const NameOwner&) = default;
393 NameOwner(NameOwner&&) = default;
394 NameOwner& operator=(NameOwner&&) = default;
Patrick Williams61b73292023-05-10 07:50:12 -0500395 explicit NameOwner(U&& handler) : _handler(std::forward<U>(handler)) {}
Matthew Barth8fa02da2017-09-28 12:18:20 -0500396
397 /** @brief Run signal handler function
398 *
399 * Extract the name owner from the NameOwnerChanged
Matthew Barth926df662018-10-09 09:51:12 -0500400 * message and run the handler function.
Matthew Barth8fa02da2017-09-28 12:18:20 -0500401 */
Mike Cappsa0819562022-06-13 10:17:10 -0400402 void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Matthew Barth8fa02da2017-09-28 12:18:20 -0500403 Zone& zone) const
404 {
405 if (msg)
406 {
Matthew Barth9f93bd32020-05-28 16:57:14 -0500407 std::string name;
408 bool hasOwner = false;
409
Matthew Barth5a302572017-10-03 11:27:06 -0500410 // Handle NameOwnerChanged signals
411 msg.read(name);
412
413 std::string oldOwn;
414 msg.read(oldOwn);
415
416 std::string newOwn;
417 msg.read(newOwn);
418 if (!newOwn.empty())
419 {
420 hasOwner = true;
421 }
Matthew Barth926df662018-10-09 09:51:12 -0500422 _handler(zone, name, hasOwner);
Matthew Barth8fa02da2017-09-28 12:18:20 -0500423 }
Matthew Barth926df662018-10-09 09:51:12 -0500424 }
Matthew Barth5a302572017-10-03 11:27:06 -0500425
Matthew Barth3e1bb272020-05-26 11:09:21 -0500426 void operator()(Zone& zone, const Group& group) const
Matthew Barth926df662018-10-09 09:51:12 -0500427 {
428 std::string name = "";
429 bool hasOwner = false;
Patrick Williamsdfddd642024-08-16 15:21:51 -0400430 std::for_each(
431 group.begin(), group.end(),
432 [&zone, &group, &name, &hasOwner,
433 handler = std::move(_handler)](const auto& member) {
434 auto path = std::get<pathPos>(member);
435 auto intf = std::get<intfPos>(member);
436 try
Matthew Barth926df662018-10-09 09:51:12 -0500437 {
Patrick Williamsdfddd642024-08-16 15:21:51 -0400438 auto servName = zone.getService(path, intf);
439 if (name != servName)
440 {
441 name = servName;
442 hasOwner = util::SDBusPlus::callMethodAndRead<bool>(
443 zone.getBus(), "org.freedesktop.DBus",
444 "/org/freedesktop/DBus", "org.freedesktop.DBus",
445 "NameHasOwner", name);
446 // Update service name owner state list of a group
447 handler(zone, name, hasOwner);
448 }
Matthew Barth926df662018-10-09 09:51:12 -0500449 }
Patrick Williamsdfddd642024-08-16 15:21:51 -0400450 catch (const util::DBusMethodError& e)
451 {
452 // Failed to get service name owner state
453 name = "";
454 hasOwner = false;
455 }
456 });
Matthew Barth8fa02da2017-09-28 12:18:20 -0500457 }
458
Matthew Barth3e1bb272020-05-26 11:09:21 -0500459 private:
Matthew Barth8fa02da2017-09-28 12:18:20 -0500460 U _handler;
461};
462
463/**
464 * @brief Used to process a Dbus name owner changed signal event
465 *
Matthew Barth8fa02da2017-09-28 12:18:20 -0500466 * @param[in] handler - Handler function to perform
467 *
468 * @tparam U - The type of the handler
469 *
470 * @return - The NameOwnerChanged signal struct
471 */
472template <typename U>
Matthew Barth926df662018-10-09 09:51:12 -0500473auto nameOwnerChanged(U&& handler)
Matthew Barth8fa02da2017-09-28 12:18:20 -0500474{
Matthew Barth926df662018-10-09 09:51:12 -0500475 return NameOwner<U>(std::forward<U>(handler));
476}
477
478/**
479 * @brief Used to process the init of a name owner event
480 *
481 * @param[in] handler - Handler function to perform
482 *
483 * @tparam U - The type of the handler
484 *
485 * @return - The NameOwnerChanged signal struct
486 */
487template <typename U>
488auto nameHasOwner(U&& handler)
489{
490 return NameOwner<U>(std::forward<U>(handler));
Matthew Barth8fa02da2017-09-28 12:18:20 -0500491}
492
Matthew Barth38a93a82017-05-11 14:12:27 -0500493} // namespace control
494} // namespace fan
495} // namespace phosphor