| #pragma once |
| |
| namespace phosphor |
| { |
| namespace fan |
| { |
| namespace control |
| { |
| namespace handler |
| { |
| |
| /** |
| * @brief A handler function to set/update a property on a zone |
| * @details Sets or updates a zone property to the given value using the |
| * provided zone dbus object's set property function |
| * |
| * @param[in] intf - Interface on zone object |
| * @param[in] prop - Property on interface |
| * @param[in] func - Zone set property function pointer |
| * @param[in] value - Value to set property to |
| * @param[in] persist - Persist property value or not |
| * |
| * @return Lambda function |
| * A lambda function to set/update the zone property |
| */ |
| template <typename T> |
| auto setZoneProperty(const char* intf, const char* prop, T (Zone::*func)(T), |
| T&& value, bool persist) |
| { |
| return [=, value = std::forward<T>(value)](auto& zone) { |
| (zone.*func)(value); |
| if (persist) |
| { |
| zone.setPersisted(intf, prop); |
| } |
| }; |
| } |
| |
| /** |
| * @brief A handler function to set/update a property |
| * @details Sets or updates a property's value determined by a combination of |
| * an object's path, interface, and property names |
| * |
| * @param[in] path - Object's path name |
| * @param[in] interface - Object's interface name |
| * @param[in] property - Object's property name |
| * |
| * @return Lambda function |
| * A lambda function to set/update the property value |
| */ |
| template <typename T> |
| auto setProperty() |
| { |
| return [](auto& zone, auto& path, auto& intf, auto& prop, T&& arg) { |
| zone.setPropertyValue(path, intf, prop, std::forward<T>(arg)); |
| }; |
| } |
| |
| /** |
| * @brief A handler function to set/update service name owner state |
| * @details Sets or updates service name owner state used by a group where |
| * a service name without an owner represents the service no longer exists |
| * |
| * @param[in] group - Group associated with a service |
| * |
| * @return Lambda function |
| * A lambda function to set/update the service name owner state |
| */ |
| inline auto setService(Group&& group) |
| { |
| return [group = std::move(group)](auto& zone, auto& name, bool hasOwner) { |
| // Update service name owner state list of a group |
| zone.setServiceOwner(&group, name, hasOwner); |
| }; |
| } |
| |
| /** |
| * @brief A handler function to remove an interface from an object path |
| * @details Removes an interface from an object's path which includes removing |
| * all properties that would be under that interface |
| * |
| * @param[in] path - Object's path name |
| * @param[in] interface - Object's interface name |
| * |
| * @return Lambda function |
| * A lambda function to remove the interface |
| */ |
| inline auto removeInterface(const char* path, const char* interface) |
| { |
| return [=](auto& zone) { zone.removeObjectInterface(path, interface); }; |
| } |
| |
| } // namespace handler |
| } // namespace control |
| } // namespace fan |
| } // namespace phosphor |