Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame] | 1 | #include "libpldm/pdr.h" |
| 2 | |
| 3 | #include "libpldmresponder/oem_handler.hpp" |
| 4 | |
| 5 | #include <nlohmann/json.hpp> |
| 6 | #include <phosphor-logging/lg2.hpp> |
| 7 | |
| 8 | #include <filesystem> |
| 9 | #include <fstream> |
| 10 | #include <map> |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | |
| 14 | PHOSPHOR_LOG2_USING; |
| 15 | namespace pldm |
| 16 | { |
Kamalkumar Patel | 516122e | 2024-05-07 04:39:32 -0500 | [diff] [blame] | 17 | using Json = nlohmann::json; |
| 18 | namespace fs = std::filesystem; |
| 19 | using ObjectPath = fs::path; |
Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame] | 20 | using EntityName = std::string; |
| 21 | using EntityType = uint16_t; |
Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame] | 22 | using Entities = std::vector<pldm_entity_node*>; |
| 23 | using EntityAssociations = std::vector<Entities>; |
Kamalkumar Patel | 516122e | 2024-05-07 04:39:32 -0500 | [diff] [blame] | 24 | using ObjectPathMaps = std::map<ObjectPath, pldm_entity_node*>; |
| 25 | using EntityMaps = std::map<EntityType, EntityName>; |
Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame] | 26 | namespace hostbmc |
| 27 | { |
| 28 | namespace utils |
| 29 | { |
| 30 | |
Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame] | 31 | /** @brief Vector a entity name to pldm_entity from entity association tree |
| 32 | * @param[in] entityAssoc - Vector of associated pldm entities |
| 33 | * @param[in] entityTree - entity association tree |
| 34 | * @param[out] objPathMap - maps an object path to pldm_entity from the |
| 35 | * BMC's entity association tree |
| 36 | * @return |
| 37 | */ |
Kamalkumar Patel | 15ce5a1 | 2024-05-07 11:45:11 -0500 | [diff] [blame] | 38 | void updateEntityAssociation( |
| 39 | const EntityAssociations& entityAssoc, |
| 40 | pldm_entity_association_tree* entityTree, ObjectPathMaps& objPathMap, |
| 41 | EntityMaps entityMaps, |
| 42 | pldm::responder::oem_platform::Handler* oemPlatformHandler); |
Kamalkumar Patel | 516122e | 2024-05-07 04:39:32 -0500 | [diff] [blame] | 43 | |
| 44 | /** @brief Parsing entity to DBus string mapping from json file |
| 45 | * |
| 46 | * @param[in] filePath - JSON file path for parsing |
| 47 | * |
| 48 | * @return returns the entity to DBus string mapping object |
| 49 | */ |
| 50 | EntityMaps parseEntityMap(const fs::path& filePath); |
Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame] | 51 | |
| 52 | } // namespace utils |
| 53 | } // namespace hostbmc |
| 54 | } // namespace pldm |