blob: 4de3c9b83a7e3ec1ab50a0d8f7a3148db3cc61c8 [file] [log] [blame]
#pragma once
#include "types.hpp"
#include "utilInterface.hpp"
namespace openpower
{
namespace vpd
{
namespace manager
{
namespace reader
{
using IUtil = openpower::vpd::utils::interface::UtilityInterface;
/** @class ReaderImpl
* @brief Implements functionalities related to reading of VPD related data
* from the system.
*/
class ReaderImpl
{
public:
ReaderImpl() = default;
ReaderImpl(const ReaderImpl&) = default;
ReaderImpl& operator=(const ReaderImpl&) = delete;
ReaderImpl(ReaderImpl&&) = default;
ReaderImpl& operator=(ReaderImpl&&) = delete;
~ReaderImpl() = default;
#ifdef ManagerTest
explicit ReaderImpl(IUtil& obj) : utilObj(obj)
{
}
#endif
/** @brief An API to expand a given unexpanded location code.
* @param[in] locationCode - unexpanded location code.
* @param[in] nodeNumber - node on which we are looking for location code.
* @param[in] frusLocationCode - mapping of inventory path and location
* code.
* @return Expanded location code.
*/
inventory::LocationCode getExpandedLocationCode(
const inventory::LocationCode& locationCode,
const inventory::NodeNumber& nodeNumber,
const inventory::LocationCodeMap& frusLocationCode) const;
/** @brief An API to get list of all the FRUs at the given location code
* @param[in] - location code in unexpanded format
* @param[in] - node number
* @param[in] - mapping of location code and Inventory path
* @return list of Inventory paths at the given location
*/
inventory::ListOfPaths getFrusAtLocation(
const inventory::LocationCode& locationCode,
const inventory::NodeNumber& nodeNumber,
const inventory::LocationCodeMap& frusLocationCode) const;
/** @brief An API to get list of all the FRUs at the given location code
* @param[in] - location code in unexpanded format
* @param[in] - mapping of location code and Inventory path
* @return list of Inventory paths at the given location
*/
inventory::ListOfPaths getFRUsByExpandedLocationCode(
const inventory::LocationCode& locationCode,
const inventory::LocationCodeMap& frusLocationCode) const;
private:
/** @brief An api to check validity of location code
* @param[in] - location code
* @return true/false based on validity check
*/
bool isValidLocationCode(const inventory::LocationCode& locationCode) const;
/** @brief An API to split expanded location code to its un-expanded
* format as represented in VPD JSON and the node number.
* @param[in] Location code in expanded format.
* @return Location code in un-expanded format and its node number.
*/
std::tuple<inventory::LocationCode, inventory::NodeNumber>
getCollapsedLocationCode(
const inventory::LocationCode& locationCode) const;
#ifdef ManagerTest
IUtil& utilObj;
#endif
}; // class ReaderImpl
} // namespace reader
} // namespace manager
} // namespace vpd
} // namespace openpower