sensor-cache: Use new get function

The get function for sensor-cache will use the sdbusplus message to get
the sensor data instead of making DBus calls, where the sdbusplus
message could be a signal callback, or the getAllProperty's reply message.

So the get function's prototype is changed.

Tested: Verify the build is OK when enable or disable the sensor-cache
        option.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Ife2f55d87ce2b0941a4efdb599e46d80d827c2ff
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 4ab0e87..91654af 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -140,6 +140,7 @@
                                      const InstancePath& path,
                                      const DbusInterface& interface);
 
+#ifndef FEATURE_SENSORS_CACHE
 /**
  *  @brief Map the Dbus info to sensor's assertion status in the Get sensor
  *         reading command response.
@@ -331,6 +332,77 @@
     return response;
 }
 
+#else
+
+using SensorCacheMap =
+    std::map<uint8_t, std::optional<ipmi::sensor::GetSensorResponse>>;
+extern SensorCacheMap sensorCacheMap;
+
+/**
+ *  @brief Map the Dbus info to sensor's assertion status in the Get sensor
+ *         reading command response.
+ *
+ *  @param[in] id - The sensor id
+ *  @param[in] sensorInfo - Dbus info related to sensor.
+ *  @param[in] msg - Dbus message from match callback.
+ *
+ *  @return Response for get sensor reading command.
+ */
+std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo,
+                                           sdbusplus::message::message& msg);
+
+/**
+ *  @brief Maps the Dbus info to the reading field in the Get sensor reading
+ *         command response.
+ *
+ *  @param[in] id - The sensor id
+ *  @param[in] sensorInfo - Dbus info related to sensor.
+ *  @param[in] msg - Dbus message from match callback.
+ *
+ *  @return Response for get sensor reading command.
+ */
+std::optional<GetSensorResponse> eventdata2(uint8_t id, const Info& sensorInfo,
+                                            sdbusplus::message::message& msg);
+
+/**
+ *  @brief readingAssertion is a case where the entire assertion state field
+ *         serves as the sensor value.
+ *
+ *  @tparam T - type of the dbus property related to sensor.
+ *  @param[in] id - The sensor id
+ *  @param[in] sensorInfo - Dbus info related to sensor.
+ *  @param[in] msg - Dbus message from match callback.
+ *
+ *  @return Response for get sensor reading command.
+ */
+template <typename T>
+std::optional<GetSensorResponse>
+    readingAssertion(uint8_t id, const Info& sensorInfo,
+                     sdbusplus::message::message& msg)
+{
+    // TODO
+    return {};
+}
+
+/** @brief Get sensor reading from the dbus message from match
+ *
+ *  @tparam T - type of the dbus property related to sensor.
+ *  @param[in] id - The sensor id
+ *  @param[in] sensorInfo - Dbus info related to sensor.
+ *  @param[in] msg - Dbus message from match callback.
+ *
+ *  @return Response for get sensor reading command.
+ */
+template <typename T>
+std::optional<GetSensorResponse> readingData(uint8_t id, const Info& sensorInfo,
+                                             sdbusplus::message::message& msg)
+{
+    // TODO
+    return {};
+}
+
+#endif // FEATURE_SENSORS_CACHE
+
 } // namespace get
 
 namespace set