SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 3 | #include "types.hpp" |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 4 | #include "utilInterface.hpp" |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 5 | |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 6 | namespace openpower |
| 7 | { |
| 8 | namespace vpd |
| 9 | { |
| 10 | namespace manager |
| 11 | { |
| 12 | namespace reader |
| 13 | { |
| 14 | |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 15 | using IUtil = openpower::vpd::utils::interface::UtilityInterface; |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 16 | /** @class ReaderImpl |
| 17 | * @brief Implements functionalities related to reading of VPD related data |
| 18 | * from the system. |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 19 | */ |
| 20 | class ReaderImpl |
| 21 | { |
| 22 | public: |
| 23 | ReaderImpl() = default; |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 24 | ReaderImpl(const ReaderImpl&) = default; |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 25 | ReaderImpl& operator=(const ReaderImpl&) = delete; |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 26 | ReaderImpl(ReaderImpl&&) = default; |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 27 | ReaderImpl& operator=(ReaderImpl&&) = delete; |
| 28 | ~ReaderImpl() = default; |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 29 | |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 30 | #ifdef ManagerTest |
Patrick Williams | c78d887 | 2023-05-10 07:50:56 -0500 | [diff] [blame] | 31 | explicit ReaderImpl(IUtil& obj) : utilObj(obj) {} |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 32 | #endif |
| 33 | |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 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 | */ |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 41 | inventory::LocationCode getExpandedLocationCode( |
| 42 | const inventory::LocationCode& locationCode, |
| 43 | const inventory::NodeNumber& nodeNumber, |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 44 | const inventory::LocationCodeMap& frusLocationCode) const; |
| 45 | |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 46 | /** @brief An API to get list of all the FRUs at the given location code |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 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( |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 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, |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 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 | */ |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 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; |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame] | 81 | #ifdef ManagerTest |
| 82 | IUtil& utilObj; |
| 83 | #endif |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 84 | |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 85 | }; // class ReaderImpl |
| 86 | |
| 87 | } // namespace reader |
| 88 | } // namespace manager |
| 89 | } // namespace vpd |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 90 | } // namespace openpower |