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 |
| 31 | explicit ReaderImpl(IUtil& obj) : utilObj(obj) |
| 32 | { |
| 33 | } |
| 34 | #endif |
| 35 | |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 36 | /** @brief An API to expand a given unexpanded location code. |
| 37 | * @param[in] locationCode - unexpanded location code. |
| 38 | * @param[in] nodeNumber - node on which we are looking for location code. |
| 39 | * @param[in] frusLocationCode - mapping of inventory path and location |
| 40 | * code. |
| 41 | * @return Expanded location code. |
| 42 | */ |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 43 | inventory::LocationCode getExpandedLocationCode( |
| 44 | const inventory::LocationCode& locationCode, |
| 45 | const inventory::NodeNumber& nodeNumber, |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 46 | const inventory::LocationCodeMap& frusLocationCode) const; |
| 47 | |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 48 | /** @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] | 49 | * @param[in] - location code in unexpanded format |
| 50 | * @param[in] - node number |
| 51 | * @param[in] - mapping of location code and Inventory path |
| 52 | * @return list of Inventory paths at the given location |
| 53 | */ |
| 54 | inventory::ListOfPaths getFrusAtLocation( |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 55 | const inventory::LocationCode& locationCode, |
| 56 | const inventory::NodeNumber& nodeNumber, |
| 57 | const inventory::LocationCodeMap& frusLocationCode) const; |
| 58 | |
| 59 | /** @brief An API to get list of all the FRUs at the given location code |
| 60 | * @param[in] - location code in unexpanded format |
| 61 | * @param[in] - mapping of location code and Inventory path |
| 62 | * @return list of Inventory paths at the given location |
| 63 | */ |
| 64 | inventory::ListOfPaths getFRUsByExpandedLocationCode( |
| 65 | const inventory::LocationCode& locationCode, |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 66 | const inventory::LocationCodeMap& frusLocationCode) const; |
| 67 | |
| 68 | private: |
| 69 | /** @brief An api to check validity of location code |
| 70 | * @param[in] - location code |
| 71 | * @return true/false based on validity check |
| 72 | */ |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 73 | bool isValidLocationCode(const inventory::LocationCode& locationCode) const; |
| 74 | |
| 75 | /** @brief An API to split expanded location code to its un-expanded |
| 76 | * format as represented in VPD JSON and the node number. |
| 77 | * @param[in] Location code in expanded format. |
| 78 | * @return Location code in un-expanded format and its node number. |
| 79 | */ |
| 80 | std::tuple<inventory::LocationCode, inventory::NodeNumber> |
| 81 | getCollapsedLocationCode( |
| 82 | const inventory::LocationCode& locationCode) const; |
SunnySrivastava1984 | 97f8df0 | 2020-05-30 12:05:53 -0500 | [diff] [blame^] | 83 | #ifdef ManagerTest |
| 84 | IUtil& utilObj; |
| 85 | #endif |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 86 | |
SunnySrivastava1984 | c743d82 | 2020-04-27 05:49:22 -0500 | [diff] [blame] | 87 | }; // class ReaderImpl |
| 88 | |
| 89 | } // namespace reader |
| 90 | } // namespace manager |
| 91 | } // namespace vpd |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 92 | } // namespace openpower |