#pragma once #include #include "fan_speed.hpp" /** @class Targets * @brief Target type traits. * * @tparam T - The target type. */ template struct Targets { static void fail() { static_assert(sizeof(Targets) == -1, "Unsupported Target type"); } }; /**@brief Targets specialization for fan speed. */ template <> struct Targets { static constexpr InterfaceType type = InterfaceType::FAN_SPEED; }; /** @brief addTarget * * Creates the target type interface * * @tparam T - The target type * * @param[in] sensor - A sensor type and name * @param[in] instance - The target instance path * @param[in] info - The sdbusplus server connection and interfaces * * @return A shared pointer to the target interface object * Will be empty if no interface was created */ template std::shared_ptr addTarget(const SensorSet::key_type& sensor, const std::string& instancePath, const std::string& devPath, ObjectInfo& info) { std::shared_ptr target; namespace fs = std::experimental::filesystem; static constexpr bool deferSignals = true; auto& bus = *std::get(info); auto& obj = std::get(info); auto& objPath = std::get(info); // Check if target sysfs file exists auto sysfsFullPath = sysfs::make_sysfs_path(instancePath, sensor.first, sensor.second, hwmon::entry::target); if (fs::exists(sysfsFullPath)) { target = std::make_shared(instancePath, devPath, sensor.second, bus, objPath.c_str(), deferSignals); auto type = Targets::type; obj[type] = target; } return target; }