blob: ef5d5d8fa4567881f875df571057bd7443d42dc7 [file] [log] [blame]
Matthew Barth38a93a82017-05-11 14:12:27 -05001#pragma once
2
3namespace phosphor
4{
5namespace fan
6{
7namespace control
8{
9namespace handler
10{
11
12/**
13 * @brief A handler function to set/update a property
14 * @details Sets or updates a property's value determined by a combination of
15 * an object's path and property names
16 *
17 * @param[in] path - Object's path name
Matthew Barthcec5ab72017-06-02 15:20:56 -050018 * @param[in] interface - Object's interface name
Matthew Barth38a93a82017-05-11 14:12:27 -050019 * @param[in] property - Object's property name
20 *
21 * @return Lambda function
22 * A lambda function to set/update the property value
23 */
24template <typename T>
Matthew Barthcec5ab72017-06-02 15:20:56 -050025auto setProperty(const char* path, const char* interface, const char* property)
Matthew Barth38a93a82017-05-11 14:12:27 -050026{
27 return [=](auto& zone, T&& arg)
28 {
Matthew Barthcec5ab72017-06-02 15:20:56 -050029 zone.setPropertyValue(path, interface, property, std::forward<T>(arg));
Matthew Barth38a93a82017-05-11 14:12:27 -050030 };
31}
32
Matthew Barth8fa02da2017-09-28 12:18:20 -050033/**
34 * @brief A handler function to set/update service name owner state
35 * @details Sets or updates service name owner state used by a group where
36 * a service name without an owner represents the service no longer exists
37 *
38 * @param[in] group - Group associated with a service
39 *
40 * @return Lambda function
41 * A lambda function to set/update the service name owner state
42 */
43auto setService(Group&& group)
44{
45 return [group = std::move(group)](auto& zone, auto& name, bool hasOwner)
46 {
Matthew Barth5a302572017-10-03 11:27:06 -050047 // Update service name owner state list of a group
48 zone.setServiceOwner(&group, name, hasOwner);
Matthew Barth8fa02da2017-09-28 12:18:20 -050049 };
50}
51
Matthew Barth1499a5c2018-03-20 15:52:33 -050052/**
53 * @brief A handler function to remove an interface from an object path
54 * @details Removes an interface from an object's path which includes removing
55 * all properties that would be under that interface
56 *
57 * @param[in] path - Object's path name
58 * @param[in] interface - Object's interface name
59 *
60 * @return Lambda function
61 * A lambda function to remove the interface
62 */
63auto removeInterface(const char* path, const char* interface)
64{
65 return[=](auto& zone)
66 {
67 zone.removeObjIntf(path, interface);
68 };
69}
70
Matthew Barth38a93a82017-05-11 14:12:27 -050071} // namespace handler
72} // namespace control
73} // namespace fan
74} // namespace phosphor