blob: 4de3c9b83a7e3ec1ab50a0d8f7a3148db3cc61c8 [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
31 explicit ReaderImpl(IUtil& obj) : utilObj(obj)
32 {
33 }
34#endif
35
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050036 /** @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 */
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050043 inventory::LocationCode getExpandedLocationCode(
44 const inventory::LocationCode& locationCode,
45 const inventory::NodeNumber& nodeNumber,
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050046 const inventory::LocationCodeMap& frusLocationCode) const;
47
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050048 /** @brief An API to get list of all the FRUs at the given location code
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050049 * @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(
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050055 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,
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050066 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 */
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050073 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;
SunnySrivastava198497f8df02020-05-30 12:05:53 -050083#ifdef ManagerTest
84 IUtil& utilObj;
85#endif
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050086
SunnySrivastava1984c743d822020-04-27 05:49:22 -050087}; // class ReaderImpl
88
89} // namespace reader
90} // namespace manager
91} // namespace vpd
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050092} // namespace openpower