sensor: Modify mako template to generate sensor getter func

Change-Id: If198d9a9fb1145bbaeda528e3f80356527b80059
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 5b1ffd7..b2da7ca 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -10,14 +10,17 @@
     serviceInterface = sensor["serviceInterface"]
     if serviceInterface == "org.freedesktop.DBus.Properties":
         updateFunc = "set::"
+        getFunc = "get::"
     elif serviceInterface == "xyz.openbmc_project.Inventory.Manager":
         updateFunc = "notify::"
+        getFunc = "inventory::get::"
     else:
         assert "Un-supported interface: " + serviceInterface
     endif
     if serviceInterface not in interfaceDict:
         interfaceDict[serviceInterface] = {}
         interfaceDict[serviceInterface]["updateFunc"] = updateFunc
+        interfaceDict[serviceInterface]["getFunc"] = getFunc
 %>\
 % endfor
 
@@ -46,6 +49,16 @@
     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:
@@ -59,6 +72,16 @@
     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
@@ -81,17 +104,21 @@
        valueReadingType = sensor["readingType"]
        updateFunc = interfaceDict[serviceInterface]["updateFunc"]
        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
        sensorInterface = serviceInterface
        if serviceInterface == "org.freedesktop.DBus.Properties":
            sensorInterface = next(iter(interfaces))
        mutability = sensor.get("mutability", "Mutability::Read")
 %>
         ${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
-        ${offset},${exp},${offset * pow(10,exp)},${updateFunc},Mutability(${mutability}),{
+        ${offset},${exp},${offset * pow(10,exp)},${updateFunc},${getFunc},Mutability(${mutability}),{
     % for interface,properties in interfaces.items():
             {"${interface}",{
             % for dbus_property,property_value in properties.items():