sensor: Pass the dbus property type as a template parameter

readingAssertion and reading type of sensors, take the dbus
property type as template parameters. Instead of generating
code to handle that, the function parameter is updated with
the template parameter.

Resolves openbmc/openbmc#2220

Change-Id: Ib9e15727ba96e3a53c46f17bffc9ef68dbf73194
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index f420490..5cc024e 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -29,64 +29,6 @@
 
 using namespace ipmi::sensor;
 
-%for key in sensorDict.iterkeys():
-<%
-    sensor = sensorDict[key]
-    readingType = sensor["readingType"]
-    interfaces = sensor["interfaces"]
-    for interface, properties in interfaces.items():
-        for property, values in properties.items():
-            for offset, attributes in values.items():
-                type = attributes["type"]
-%>\
-%if "readingAssertion" == readingType:
-namespace sensor_${key}
-{
-
-inline ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData,
-                                   const Info& sensorInfo)
-{
-    return set::readingAssertion<${type}>(cmdData, sensorInfo);
-}
-
-namespace get
-{
-
-inline GetSensorResponse readingAssertion(const Info& sensorInfo)
-{
-    return ipmi::sensor::get::readingAssertion<${type}>(sensorInfo);
-}
-
-} //namespace get
-
-} // namespace sensor_${key}
-
-%elif "readingData" == readingType:
-
-namespace sensor_${key}
-{
-
-inline ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
-                              const Info& sensorInfo)
-{
-    return set::readingData<${type}>(cmdData, sensorInfo);
-}
-
-namespace get
-{
-
-inline GetSensorResponse readingData(const Info& sensorInfo)
-{
-    return ipmi::sensor::get::readingData<${type}>(sensorInfo);
-}
-
-} //namespace get
-
-} // namespace sensor_${key}
-
-%endif
-% endfor
-
 extern const IdInfoMap sensors = {
 % for key in sensorDict.iterkeys():
    % if key:
@@ -106,12 +48,13 @@
        updateFunc += sensor["readingType"]
        getFunc = interfaceDict[serviceInterface]["getFunc"]
        getFunc += sensor["readingType"]
-       if "readingAssertion" == valueReadingType:
-           updateFunc = "sensor_" + str(key) + "::" + valueReadingType
-           getFunc = "sensor_" + str(key) + "::get::" + valueReadingType
-       elif "readingData" == valueReadingType:
-           updateFunc = "sensor_" + str(key) + "::" + valueReadingType
-           getFunc = "sensor_" + str(key) + "::get::" + valueReadingType
+       if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
+           for interface,properties in interfaces.items():
+               for dbus_property,property_value in properties.items():
+                   for offset,values in property_value.items():
+                       valueType = values["type"]
+           updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
+           getFunc = "get::" + valueReadingType + "<" + valueType + ">"
        sensorInterface = serviceInterface
        if serviceInterface == "org.freedesktop.DBus.Properties":
            sensorInterface = next(iter(interfaces))