1 #pragma once 2 3 namespace phosphor 4 { 5 namespace fan 6 { 7 namespace control 8 { 9 namespace handler 10 { 11 12 /** 13 * @brief A handler function to set/update a property on a zone 14 * @details Sets or updates a zone property to the given value using the 15 * provided zone dbus object's set property function 16 * 17 * @param[in] value - Value to set property to 18 * @param[in] func - Zone set property function pointer 19 * 20 * @return Lambda function 21 * A lambda function to set/update the zone property 22 */ 23 template <typename T> 24 auto setZoneProperty(T (Zone::*func)(T), T&& value) 25 { 26 return [func, value = std::forward<T>(value)](auto& zone) 27 { 28 (zone.*func)(value); 29 }; 30 } 31 32 /** 33 * @brief A handler function to set/update a property 34 * @details Sets or updates a property's value determined by a combination of 35 * an object's path and property names 36 * 37 * @param[in] path - Object's path name 38 * @param[in] interface - Object's interface name 39 * @param[in] property - Object's property name 40 * 41 * @return Lambda function 42 * A lambda function to set/update the property value 43 */ 44 template <typename T> 45 auto setProperty(const char* path, const char* interface, const char* property) 46 { 47 return [=](auto& zone, T&& arg) 48 { 49 zone.setPropertyValue(path, interface, property, std::forward<T>(arg)); 50 }; 51 } 52 53 /** 54 * @brief A handler function to set/update service name owner state 55 * @details Sets or updates service name owner state used by a group where 56 * a service name without an owner represents the service no longer exists 57 * 58 * @param[in] group - Group associated with a service 59 * 60 * @return Lambda function 61 * A lambda function to set/update the service name owner state 62 */ 63 auto setService(Group&& group) 64 { 65 return [group = std::move(group)](auto& zone, auto& name, bool hasOwner) 66 { 67 // Update service name owner state list of a group 68 zone.setServiceOwner(&group, name, hasOwner); 69 }; 70 } 71 72 /** 73 * @brief A handler function to remove an interface from an object path 74 * @details Removes an interface from an object's path which includes removing 75 * all properties that would be under that interface 76 * 77 * @param[in] path - Object's path name 78 * @param[in] interface - Object's interface name 79 * 80 * @return Lambda function 81 * A lambda function to remove the interface 82 */ 83 auto removeInterface(const char* path, const char* interface) 84 { 85 return[=](auto& zone) 86 { 87 zone.removeObjectInterface(path, interface); 88 }; 89 } 90 91 } // namespace handler 92 } // namespace control 93 } // namespace fan 94 } // namespace phosphor 95