1 #pragma once 2 3 #include "types.hpp" 4 #include "utilInterface.hpp" 5 6 namespace openpower 7 { 8 namespace vpd 9 { 10 namespace manager 11 { 12 namespace reader 13 { 14 15 using IUtil = openpower::vpd::utils::interface::UtilityInterface; 16 /** @class ReaderImpl 17 * @brief Implements functionalities related to reading of VPD related data 18 * from the system. 19 */ 20 class ReaderImpl 21 { 22 public: 23 ReaderImpl() = default; 24 ReaderImpl(const ReaderImpl&) = default; 25 ReaderImpl& operator=(const ReaderImpl&) = delete; 26 ReaderImpl(ReaderImpl&&) = default; 27 ReaderImpl& operator=(ReaderImpl&&) = delete; 28 ~ReaderImpl() = default; 29 30 #ifdef ManagerTest ReaderImpl(IUtil & obj)31 explicit ReaderImpl(IUtil& obj) : utilObj(obj) {} 32 #endif 33 34 /** @brief An API to expand a given unexpanded location code. 35 * @param[in] locationCode - unexpanded location code. 36 * @param[in] nodeNumber - node on which we are looking for location code. 37 * @param[in] frusLocationCode - mapping of inventory path and location 38 * code. 39 * @return Expanded location code. 40 */ 41 inventory::LocationCode getExpandedLocationCode( 42 const inventory::LocationCode& locationCode, 43 const inventory::NodeNumber& nodeNumber, 44 const inventory::LocationCodeMap& frusLocationCode) const; 45 46 /** @brief An API to get list of all the FRUs at the given location code 47 * @param[in] - location code in unexpanded format 48 * @param[in] - node number 49 * @param[in] - mapping of location code and Inventory path 50 * @return list of Inventory paths at the given location 51 */ 52 inventory::ListOfPaths getFrusAtLocation( 53 const inventory::LocationCode& locationCode, 54 const inventory::NodeNumber& nodeNumber, 55 const inventory::LocationCodeMap& frusLocationCode) const; 56 57 /** @brief An API to get list of all the FRUs at the given location code 58 * @param[in] - location code in unexpanded format 59 * @param[in] - mapping of location code and Inventory path 60 * @return list of Inventory paths at the given location 61 */ 62 inventory::ListOfPaths getFRUsByExpandedLocationCode( 63 const inventory::LocationCode& locationCode, 64 const inventory::LocationCodeMap& frusLocationCode) const; 65 66 private: 67 /** @brief An api to check validity of location code 68 * @param[in] - location code 69 * @return true/false based on validity check 70 */ 71 bool isValidLocationCode(const inventory::LocationCode& locationCode) const; 72 73 /** @brief An API to split expanded location code to its un-expanded 74 * format as represented in VPD JSON and the node number. 75 * @param[in] Location code in expanded format. 76 * @return Location code in un-expanded format and its node number. 77 */ 78 std::tuple<inventory::LocationCode, inventory::NodeNumber> 79 getCollapsedLocationCode( 80 const inventory::LocationCode& locationCode) const; 81 #ifdef ManagerTest 82 IUtil& utilObj; 83 #endif 84 85 }; // class ReaderImpl 86 87 } // namespace reader 88 } // namespace manager 89 } // namespace vpd 90 } // namespace openpower 91