pldm: Rearranging datatype declaration
This commit adds support to eliminating duplication of datatypes which
enhancing clarity and manageability throughout the pldm repository.
This is rearrangement of declaration of data types so it can be used
host-bmc and oem layer both the places.
Change-Id: Ieb1232884b8e2128e8bf97dafd01e4ad5524ede0
Signed-off-by: Kamalkumar Patel <kamalkumar.patel@ibm.com>
diff --git a/common/utils.hpp b/common/utils.hpp
index 0c5c506..ef7b085 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -157,7 +157,14 @@
std::pair<pldm::dbus::Interface,
std::vector<std::pair<pldm::dbus::Property,
std::variant<pldm::dbus::Property>>>>>;
+
using ObjectPath = std::string;
+using EntityName = std::string;
+using Entities = std::vector<pldm_entity_node*>;
+using EntityAssociations = std::vector<Entities>;
+using ObjectPathMaps = std::map<fs::path, pldm_entity_node*>;
+using EntityMaps = std::map<pldm::pdr::EntityType, EntityName>;
+
using ServiceName = std::string;
using Interfaces = std::vector<std::string>;
using MapperServiceMap = std::vector<std::pair<ServiceName, Interfaces>>;
diff --git a/host-bmc/host_pdr_handler.hpp b/host-bmc/host_pdr_handler.hpp
index 0af0f63..4fafe8d 100644
--- a/host-bmc/host_pdr_handler.hpp
+++ b/host-bmc/host_pdr_handler.hpp
@@ -23,7 +23,6 @@
namespace pldm
{
-using EntityType = uint16_t;
// vector which would hold the PDR record handle data returned by
// pldmPDRRepositoryChgEvent event data
using ChangeEntry = uint32_t;
@@ -324,11 +323,11 @@
/** @brief maps an object path to pldm_entity from the BMC's entity
* association tree
*/
- ObjectPathMaps objPathMap;
+ pldm::utils::ObjectPathMaps objPathMap;
/** @brief maps an entity name to map, maps to entity name to pldm_entity
*/
- EntityAssociations entityAssociations;
+ pldm::utils::EntityAssociations entityAssociations;
/** @brief the vector of FRU Record Data Format
*/
@@ -339,7 +338,7 @@
/** @brief entityID and entity name is only loaded once
*/
- EntityMaps entityMaps;
+ pldm::utils::EntityMaps entityMaps;
};
} // namespace pldm
diff --git a/host-bmc/test/meson.build b/host-bmc/test/meson.build
index fd3e8c9..9b7cbba 100644
--- a/host-bmc/test/meson.build
+++ b/host-bmc/test/meson.build
@@ -6,7 +6,6 @@
'../../common/utils.cpp',
'../utils.cpp',
'../custom_dbus.cpp',
- '../utils.cpp'
]
tests = [
diff --git a/host-bmc/utils.cpp b/host-bmc/utils.cpp
index 784401c..196e2f5 100644
--- a/host-bmc/utils.cpp
+++ b/host-bmc/utils.cpp
@@ -1,12 +1,12 @@
-#include "common/utils.hpp"
+#include "utils.hpp"
#include "libpldm/entity.h"
-#include "utils.hpp"
-
#include <cstdlib>
#include <iostream>
+using namespace pldm::utils;
+
namespace pldm
{
namespace hostbmc
diff --git a/host-bmc/utils.hpp b/host-bmc/utils.hpp
index 6a3629e..d576fd4 100644
--- a/host-bmc/utils.hpp
+++ b/host-bmc/utils.hpp
@@ -1,5 +1,6 @@
#include "libpldm/pdr.h"
+#include "common/utils.hpp"
#include "libpldmresponder/oem_handler.hpp"
#include <nlohmann/json.hpp>
@@ -12,17 +13,9 @@
#include <vector>
PHOSPHOR_LOG2_USING;
+
namespace pldm
{
-using Json = nlohmann::json;
-namespace fs = std::filesystem;
-using ObjectPath = fs::path;
-using EntityName = std::string;
-using EntityType = uint16_t;
-using Entities = std::vector<pldm_entity_node*>;
-using EntityAssociations = std::vector<Entities>;
-using ObjectPathMaps = std::map<ObjectPath, pldm_entity_node*>;
-using EntityMaps = std::map<EntityType, EntityName>;
namespace hostbmc
{
namespace utils
@@ -36,9 +29,9 @@
* @return
*/
void updateEntityAssociation(
- const EntityAssociations& entityAssoc,
- pldm_entity_association_tree* entityTree, ObjectPathMaps& objPathMap,
- EntityMaps entityMaps,
+ const pldm::utils::EntityAssociations& entityAssoc,
+ pldm_entity_association_tree* entityTree,
+ pldm::utils::ObjectPathMaps& objPathMap, pldm::utils::EntityMaps entityMaps,
pldm::responder::oem_platform::Handler* oemPlatformHandler);
/** @brief Parsing entity to DBus string mapping from json file
@@ -47,7 +40,7 @@
*
* @return returns the entity to DBus string mapping object
*/
-EntityMaps parseEntityMap(const fs::path& filePath);
+pldm::utils::EntityMaps parseEntityMap(const fs::path& filePath);
} // namespace utils
} // namespace hostbmc
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index 263a201..b7c437a 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -23,7 +23,7 @@
{
int pldm::responder::oem_ibm_platform::Handler::
getOemStateSensorReadingsHandler(
- EntityType entityType, EntityInstance entityInstance,
+ pldm::pdr::EntityType entityType, EntityInstance entityInstance,
StateSetId stateSetId, CompositeCount compSensorCnt,
std::vector<get_sensor_state_field>& stateField)
{
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
index 7b73242..9fe1894 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
@@ -144,7 +144,8 @@
}
int getOemStateSensorReadingsHandler(
- EntityType entityType, pldm::pdr::EntityInstance entityInstance,
+ pldm::pdr::EntityType entityType,
+ pldm::pdr::EntityInstance entityInstance,
pldm::pdr::StateSetId stateSetId,
pldm::pdr::CompositeCount compSensorCnt,
std::vector<get_sensor_state_field>& stateField);
diff --git a/oem/ibm/libpldmresponder/utils.cpp b/oem/ibm/libpldmresponder/utils.cpp
index a29a0d4..88fe1b9 100644
--- a/oem/ibm/libpldmresponder/utils.cpp
+++ b/oem/ibm/libpldmresponder/utils.cpp
@@ -15,6 +15,8 @@
PHOSPHOR_LOG2_USING;
+using namespace pldm::utils;
+
namespace pldm
{
namespace responder