platform-mc: Enlist common types for Terminus

platform_mc::Terminus class is using its own defined types for generic
types of PDR fields that are already defined in common/types.hpp.
This commit removes those redundantly defined types and enlists common
types.

This commit also moves all the newly defined types in terminus.hpp to
common/types.hpp for wider uses.

Change-Id: I2f3fb4adc99235aa530eb338787f66eee4bc3aa2
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
diff --git a/common/types.hpp b/common/types.hpp
index 7bbe22f..2c1b319 100644
--- a/common/types.hpp
+++ b/common/types.hpp
@@ -192,6 +192,36 @@
 using EventState = uint8_t;
 using TerminusValidity = uint8_t;
 using EffecterID = uint16_t;
+using EntityName = std::string;
+using SensorCount = uint8_t;
+using NameLanguageTag = std::string;
+using SensorName = std::string;
+using SensorAuxiliaryNames = std::tuple<
+    SensorID, SensorCount,
+    std::vector<std::vector<std::pair<NameLanguageTag, SensorName>>>>;
+using AuxiliaryNames = std::vector<std::pair<NameLanguageTag, std::string>>;
+
+/** @struct EntityKey
+ *
+ *  EntityKey uniquely identifies the PLDM entity and a combination of Entity
+ *  Type, Entity Instance Number, Entity Container ID
+ *
+ */
+struct EntityKey
+{
+    EntityType type;            //!< Entity type
+    EntityInstance instanceIdx; //!< Entity instance number
+    ContainerID containerId;    //!< Entity container ID
+
+    bool operator==(const EntityKey& e) const
+    {
+        return ((type == e.type) && (instanceIdx == e.instanceIdx) &&
+                (containerId == e.containerId));
+    }
+};
+
+using EntityKey = struct EntityKey;
+using EntityAuxiliaryNames = std::tuple<EntityKey, AuxiliaryNames>;
 
 //!< Subset of the State Set that is supported by a effecter/sensor
 using PossibleStates = std::set<uint8_t>;
diff --git a/platform-mc/terminus.cpp b/platform-mc/terminus.cpp
index fdaacf4..eb87d3b 100644
--- a/platform-mc/terminus.cpp
+++ b/platform-mc/terminus.cpp
@@ -269,7 +269,7 @@
 }
 
 std::shared_ptr<SensorAuxiliaryNames> Terminus::getSensorAuxiliaryNames(
-    SensorId id)
+    SensorID id)
 {
     auto it = std::find_if(
         sensorAuxiliaryNamesTbl.begin(), sensorAuxiliaryNamesTbl.end(),
@@ -570,7 +570,7 @@
     addNextSensorFromPDRs();
 }
 
-std::shared_ptr<NumericSensor> Terminus::getSensorObject(SensorId id)
+std::shared_ptr<NumericSensor> Terminus::getSensorObject(SensorID id)
 {
     if (terminusName.empty())
     {
@@ -730,7 +730,7 @@
     }
 }
 
-std::vector<std::string> Terminus::getSensorNames(const SensorId& sensorId)
+std::vector<std::string> Terminus::getSensorNames(const SensorID& sensorId)
 {
     std::vector<std::string> sensorNames;
     std::string defaultName =
diff --git a/platform-mc/terminus.hpp b/platform-mc/terminus.hpp
index fd878b5..147e6e7 100644
--- a/platform-mc/terminus.hpp
+++ b/platform-mc/terminus.hpp
@@ -24,40 +24,7 @@
 namespace platform_mc
 {
 
-using ContainerID = uint16_t;
-using EntityInstanceNumber = uint16_t;
-using EntityName = std::string;
-using EntityType = uint16_t;
-using SensorId = uint16_t;
-using SensorCnt = uint8_t;
-using NameLanguageTag = std::string;
-using SensorName = std::string;
-using SensorAuxiliaryNames = std::tuple<
-    SensorId, SensorCnt,
-    std::vector<std::vector<std::pair<NameLanguageTag, SensorName>>>>;
-
-/** @struct EntityKey
- *
- *  EntityKey uniquely identifies the PLDM entity and a combination of Entity
- *  Type, Entity Instance Number, Entity Container ID
- *
- */
-struct EntityKey
-{
-    EntityType type;                  //!< Entity type
-    EntityInstanceNumber instanceIdx; //!< Entity instance number
-    ContainerID containerId;          //!< Entity container ID
-
-    bool operator==(const EntityKey& e) const
-    {
-        return ((type == e.type) && (instanceIdx == e.instanceIdx) &&
-                (containerId == e.containerId));
-    }
-};
-
-using AuxiliaryNames = std::vector<std::pair<NameLanguageTag, std::string>>;
-using EntityKey = struct EntityKey;
-using EntityAuxiliaryNames = std::tuple<EntityKey, AuxiliaryNames>;
+using namespace pldm::pdr;
 
 /**
  * @brief Terminus
@@ -199,7 +166,7 @@
      *  @param[in] id - sensor ID
      *  @return sensor auxiliary names
      */
-    std::shared_ptr<SensorAuxiliaryNames> getSensorAuxiliaryNames(SensorId id);
+    std::shared_ptr<SensorAuxiliaryNames> getSensorAuxiliaryNames(SensorID id);
 
     /** @brief Get Numeric Sensor Object by sensorID
      *
@@ -207,7 +174,7 @@
      *
      *  @return sensor object
      */
-    std::shared_ptr<NumericSensor> getSensorObject(SensorId id);
+    std::shared_ptr<NumericSensor> getSensorObject(SensorID id);
 
   private:
     /** @brief Find the Terminus Name from the Entity Auxiliary name list
@@ -289,7 +256,7 @@
      *  @return vector of sensor name strings
      *
      */
-    std::vector<std::string> getSensorNames(const SensorId& sensorId);
+    std::vector<std::string> getSensorNames(const SensorID& sensorId);
 
     /** @brief Add the next sensor PDR to this terminus, iterated by
      *         sensorPdrIt.
@@ -349,7 +316,7 @@
         compactNumericSensorPdrs{};
 
     /** @brief Iteration to loop through sensor PDRs when adding sensors */
-    SensorId sensorPdrIt = 0;
+    SensorID sensorPdrIt = 0;
 };
 } // namespace platform_mc
 } // namespace pldm