blob: 7525a4f99e2a152249e30193ba2e29fd0203fd85 [file] [log] [blame]
SunnySrivastava1984c743d822020-04-27 05:49:22 -05001#pragma once
2
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -05003#include "types.hpp"
SunnySrivastava198497f8df02020-05-30 12:05:53 -05004#include "utilInterface.hpp"
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -05005
SunnySrivastava1984c743d822020-04-27 05:49:22 -05006namespace openpower
7{
8namespace vpd
9{
10namespace manager
11{
12namespace reader
13{
14
SunnySrivastava198497f8df02020-05-30 12:05:53 -050015using IUtil = openpower::vpd::utils::interface::UtilityInterface;
SunnySrivastava1984c743d822020-04-27 05:49:22 -050016/** @class ReaderImpl
17 * @brief Implements functionalities related to reading of VPD related data
18 * from the system.
SunnySrivastava1984c743d822020-04-27 05:49:22 -050019 */
20class ReaderImpl
21{
22 public:
23 ReaderImpl() = default;
SunnySrivastava198497f8df02020-05-30 12:05:53 -050024 ReaderImpl(const ReaderImpl&) = default;
SunnySrivastava1984c743d822020-04-27 05:49:22 -050025 ReaderImpl& operator=(const ReaderImpl&) = delete;
SunnySrivastava198497f8df02020-05-30 12:05:53 -050026 ReaderImpl(ReaderImpl&&) = default;
SunnySrivastava1984c743d822020-04-27 05:49:22 -050027 ReaderImpl& operator=(ReaderImpl&&) = delete;
28 ~ReaderImpl() = default;
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050029
SunnySrivastava198497f8df02020-05-30 12:05:53 -050030#ifdef ManagerTest
Patrick Williamsc78d8872023-05-10 07:50:56 -050031 explicit ReaderImpl(IUtil& obj) : utilObj(obj) {}
SunnySrivastava198497f8df02020-05-30 12:05:53 -050032#endif
33
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050034 /** @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 */
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050041 inventory::LocationCode getExpandedLocationCode(
42 const inventory::LocationCode& locationCode,
43 const inventory::NodeNumber& nodeNumber,
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050044 const inventory::LocationCodeMap& frusLocationCode) const;
45
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050046 /** @brief An API to get list of all the FRUs at the given location code
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050047 * @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(
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050053 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,
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050064 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 */
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050071 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;
SunnySrivastava198497f8df02020-05-30 12:05:53 -050081#ifdef ManagerTest
82 IUtil& utilObj;
83#endif
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050084
SunnySrivastava1984c743d822020-04-27 05:49:22 -050085}; // class ReaderImpl
86
87} // namespace reader
88} // namespace manager
89} // namespace vpd
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050090} // namespace openpower