monitor: Move tach sensor template function to header
The `readPropertyFromMessage` template function should be in the tach
sensor header file.
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Change-Id: I931d8f2a4b5eafbd05aeeef6f4127db2cdd6819e
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index ed00a9b..dc02ade 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -176,36 +176,6 @@
}
}
-/**
- * @brief Reads a property from the input message and stores it in value.
- * T is the value type.
- *
- * Note: This can only be called once per message.
- *
- * @param[in] msg - the dbus message that contains the data
- * @param[in] interface - the interface the property is on
- * @param[in] propertName - the name of the property
- * @param[out] value - the value to store the property value in
- */
-template <typename T>
-static void readPropertyFromMessage(sdbusplus::message::message& msg,
- const std::string& interface,
- const std::string& propertyName, T& value)
-{
- std::string sensor;
- std::map<std::string, std::variant<T>> data;
- msg.read(sensor, data);
-
- if (sensor.compare(interface) == 0)
- {
- auto propertyMap = data.find(propertyName);
- if (propertyMap != data.end())
- {
- value = std::get<T>(propertyMap->second);
- }
- }
-}
-
void TachSensor::handleTargetChange(sdbusplus::message::message& msg)
{
readPropertyFromMessage(msg, _interface, FAN_TARGET_PROPERTY, _tachTarget);
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 76a800d..88c8547 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -105,6 +105,37 @@
const sdeventplus::Event& event);
/**
+ * @brief Reads a property from the input message and stores it in value.
+ * T is the value type.
+ *
+ * Note: This can only be called once per message.
+ *
+ * @param[in] msg - the dbus message that contains the data
+ * @param[in] interface - the interface the property is on
+ * @param[in] propertName - the name of the property
+ * @param[out] value - the value to store the property value in
+ */
+ template <typename T>
+ static void readPropertyFromMessage(sdbusplus::message::message& msg,
+ const std::string& interface,
+ const std::string& propertyName,
+ T& value)
+ {
+ std::string sensor;
+ std::map<std::string, std::variant<T>> data;
+ msg.read(sensor, data);
+
+ if (sensor.compare(interface) == 0)
+ {
+ auto propertyMap = data.find(propertyName);
+ if (propertyMap != data.end())
+ {
+ value = std::get<T>(propertyMap->second);
+ }
+ }
+ }
+
+ /**
* @brief Returns the target speed value
*/
uint64_t getTarget() const;