Add parsing JSON for State Sensor PDR

According to spec DSP0248_1.2.0: 28.6 and sensor_pdr.json, parse JSON
and generate PDR structure.

Tested with JSON file:
https://gist.github.com/lxwinspur/6a40abea7330c25e4d49826e890c4be9

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I654913b6fa07f34f405f7dd41a5f1ac0ae2706fb
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 3a9266e..61d09ad 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -6,6 +6,7 @@
 #include "pdr.hpp"
 #include "pdr_numeric_effecter.hpp"
 #include "pdr_state_effecter.hpp"
+#include "pdr_state_sensor.hpp"
 #include "platform_numeric_effecter.hpp"
 #include "platform_state_effecter.hpp"
 
@@ -54,16 +55,31 @@
     }};
 
 void Handler::addDbusObjMaps(
-    uint16_t effecterId,
-    std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj)
+    uint16_t id,
+    std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj,
+    TypeId typeId)
 {
-    dbusObjMaps.emplace(effecterId, dbusObj);
+    if (typeId == TypeId::PLDM_SENSOR_ID)
+    {
+        sensorDbusObjMaps.emplace(id, dbusObj);
+    }
+    else
+    {
+        effecterDbusObjMaps.emplace(id, dbusObj);
+    }
 }
 
 const std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>&
-    Handler::getDbusObjMaps(uint16_t effecterId) const
+    Handler::getDbusObjMaps(uint16_t id, TypeId typeId) const
 {
-    return dbusObjMaps.at(effecterId);
+    if (typeId == TypeId::PLDM_SENSOR_ID)
+    {
+        return sensorDbusObjMaps.at(id);
+    }
+    else
+    {
+        return effecterDbusObjMaps.at(id);
+    }
 }
 
 void Handler::generate(const pldm::utils::DBusHandler& dBusIntf,
@@ -93,6 +109,12 @@
              pdr_numeric_effecter::generateNumericEffecterPDR<
                  pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this,
                                                     repo);
+         }},
+        {PLDM_STATE_SENSOR_PDR, [this](const DBusHandler& dBusIntf,
+                                       const auto& json, RepoInterface& repo) {
+             pdr_state_sensor::generateStateSensorPDR<pldm::utils::DBusHandler,
+                                                      Handler>(dBusIntf, json,
+                                                               *this, repo);
          }}};
 
     Type pdrType{};
@@ -109,6 +131,13 @@
                     pdrType = effecter.value("pdrType", 0);
                     generateHandlers.at(pdrType)(dBusIntf, effecter, repo);
                 }
+
+                auto sensorPDRs = json.value("sensorPDRs", empty);
+                for (const auto& sensor : sensorPDRs)
+                {
+                    pdrType = sensor.value("pdrType", 0);
+                    generateHandlers.at(pdrType)(dBusIntf, sensor, repo);
+                }
             }
         }
         catch (const InternalFailure& e)