blob: dab8b8ec864f35ffc6baa1e35a9779a23409fb3f [file] [log] [blame]
SunnySrivastava1984c743d822020-04-27 05:49:22 -05001#pragma once
2
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -05003#include "types.hpp"
4
SunnySrivastava1984c743d822020-04-27 05:49:22 -05005namespace openpower
6{
7namespace vpd
8{
9namespace manager
10{
11namespace reader
12{
13
14/** @class ReaderImpl
15 * @brief Implements functionalities related to reading of VPD related data
16 * from the system.
SunnySrivastava1984c743d822020-04-27 05:49:22 -050017 */
18class ReaderImpl
19{
20 public:
21 ReaderImpl() = default;
22 ReaderImpl(const ReaderImpl&) = delete;
23 ReaderImpl& operator=(const ReaderImpl&) = delete;
24 ReaderImpl(ReaderImpl&&) = delete;
25 ReaderImpl& operator=(ReaderImpl&&) = delete;
26 ~ReaderImpl() = default;
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050027
28 /** @brief An API to expand a given unexpanded location code.
29 * @param[in] locationCode - unexpanded location code.
30 * @param[in] nodeNumber - node on which we are looking for location code.
31 * @param[in] frusLocationCode - mapping of inventory path and location
32 * code.
33 * @return Expanded location code.
34 */
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050035 inventory::LocationCode getExpandedLocationCode(
36 const inventory::LocationCode& locationCode,
37 const inventory::NodeNumber& nodeNumber,
SunnySrivastava1984bca5aaa2020-04-21 05:31:04 -050038 const inventory::LocationCodeMap& frusLocationCode) const;
39
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050040 /** @brief An API to get list of all the FRUs at the given location code
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050041 * @param[in] - location code in unexpanded format
42 * @param[in] - node number
43 * @param[in] - mapping of location code and Inventory path
44 * @return list of Inventory paths at the given location
45 */
46 inventory::ListOfPaths getFrusAtLocation(
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050047 const inventory::LocationCode& locationCode,
48 const inventory::NodeNumber& nodeNumber,
49 const inventory::LocationCodeMap& frusLocationCode) const;
50
51 /** @brief An API to get list of all the FRUs at the given location code
52 * @param[in] - location code in unexpanded format
53 * @param[in] - mapping of location code and Inventory path
54 * @return list of Inventory paths at the given location
55 */
56 inventory::ListOfPaths getFRUsByExpandedLocationCode(
57 const inventory::LocationCode& locationCode,
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050058 const inventory::LocationCodeMap& frusLocationCode) const;
59
60 private:
61 /** @brief An api to check validity of location code
62 * @param[in] - location code
63 * @return true/false based on validity check
64 */
SunnySrivastava1984fb5815a2020-04-24 08:03:52 -050065 bool isValidLocationCode(const inventory::LocationCode& locationCode) const;
66
67 /** @brief An API to split expanded location code to its un-expanded
68 * format as represented in VPD JSON and the node number.
69 * @param[in] Location code in expanded format.
70 * @return Location code in un-expanded format and its node number.
71 */
72 std::tuple<inventory::LocationCode, inventory::NodeNumber>
73 getCollapsedLocationCode(
74 const inventory::LocationCode& locationCode) const;
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050075
SunnySrivastava1984c743d822020-04-27 05:49:22 -050076}; // class ReaderImpl
77
78} // namespace reader
79} // namespace manager
80} // namespace vpd
SunnySrivastava19841356d7e2020-04-24 04:29:35 -050081} // namespace openpower