irioCoreCpp Library Module  2.1.0
irio::ParserManager Class Reference

Responsible for managing the parsing of resources for a bitfile. More...

#include <parserManager.h>

Public Member Functions

 ParserManager (const bfp::BFP &bfp)
 Constructs a ParserManager object with the given BFP object. More...
 
bool findRegister (const std::string &resourceName, const GroupResource &group, bfp::Register *reg, const bool optional=false)
 Finds a register with the given resource name. More...
 
bool findDMA (const std::string &resourceName, const GroupResource &group, bfp::DMA *dma, const bool optional=false)
 Finds a DMA with the given resource name. More...
 
bool findRegisterAddress (const std::string &resourceName, const GroupResource &group, std::uint32_t *address, const bool optional=false)
 Finds the address of a register with the given resource name. More...
 
bool findDMANum (const std::string &resourceName, const GroupResource &group, std::uint32_t *address, const bool optional=false)
 Finds the DMA number of a resource with the given name. More...
 
bool findRegisterEnumAddress (const std::string &resourceName, std::uint32_t nResource, const GroupResource &group, std::unordered_map< std::uint32_t, const std::uint32_t > *mapInsert, const bool optional=false)
 Finds the address of a register with the given resource name. More...
 
bool findDMAEnumNum (const std::string &resourceName, std::uint32_t nResource, const GroupResource &group, std::unordered_map< std::uint32_t, const std::uint32_t > *mapInsert, const bool optional=false)
 Finds the DMA number of a DMA with the given name, The resource follows an enumeration naming convention. More...
 
void compareResourcesMap (const std::unordered_map< std::uint32_t, const std::uint32_t > &mapA, const std::string &nameTermA, const std::unordered_map< std::uint32_t, const std::uint32_t > &mapB, const std::string &nameTermB, const GroupResource &group)
 Compares two resource maps and logs any differences. More...
 
void logResourceError (const std::string &resourceName, const std::string &errMsg, const GroupResource &group)
 Logs an error related to a resource. More...
 
bool hasErrorOccurred () const
 Checks if an error has occurred during parsing. More...
 
void printInfo (std::ostream &os=std::cout, const bool onlyErrors=false) const
 Prints resources found, not found and incompatibilities. More...
 
void printInfoError (std::ostream &os=std::cerr) const
 Prints resources not found and incompatibilities. More...
 
void printInfoXML (const std::string &filename) const
 Prints resources found, not found and incompatibilities in XML format. More...
 
void logResourceFound (const std::string &resourceName, const GroupResource &group)
 Logs that a resource has been found. More...
 
void logResourceNotFound (const std::string &resourceName, const GroupResource &group)
 Logs that a resource has not been found. More...
 

Private Attributes

bfp::BFP m_bfp
 The BFP object used by the parser manager.
 
std::unordered_map< GroupResource, GroupInfom_groupInfo
 Map to divide information of found resources per group.
 
bool m_error = false
 True if some resource was not found.
 

Detailed Description

Responsible for managing the parsing of resources for a bitfile.

The ParserManager class provides methods for finding registers, DMAs, register addresses and DMA numbers. It also logs which resources have been found or not. It provides methods for logging resource incompatibilities and printing the problems found.

Definition at line 76 of file parserManager.h.

Constructor & Destructor Documentation

◆ ParserManager()

irio::ParserManager::ParserManager ( const bfp::BFP bfp)
explicit

Constructs a ParserManager object with the given BFP object.

Parameters
bfpThe BFP object to be used for parsing.

Member Function Documentation

◆ compareResourcesMap()

void irio::ParserManager::compareResourcesMap ( const std::unordered_map< std::uint32_t, const std::uint32_t > &  mapA,
const std::string &  nameTermA,
const std::unordered_map< std::uint32_t, const std::uint32_t > &  mapB,
const std::string &  nameTermB,
const GroupResource &  group 
)

Compares two resource maps and logs any differences.

Parameters
mapAThe first resource map.
nameTermAThe name of the first resource map.
mapBThe second resource map.
nameTermBThe name of the second resource map.
groupThe group of the resources.

◆ findDMA()

bool irio::ParserManager::findDMA ( const std::string &  resourceName,
const GroupResource &  group,
bfp::DMA dma,
const bool  optional = false 
)

Finds a DMA with the given resource name.

Parameters
resourceNameThe name of the resource.
groupThe group of the resource. Used for logging.
dmaPointer to store the found DMA.
optionalFlag indicating if the DMA is optional. If true and the resource is not found, it will not be logged.
Returns
True if the DMA is found, false otherwise.

◆ findDMAEnumNum()

bool irio::ParserManager::findDMAEnumNum ( const std::string &  resourceName,
std::uint32_t  nResource,
const GroupResource &  group,
std::unordered_map< std::uint32_t, const std::uint32_t > *  mapInsert,
const bool  optional = false 
)

Finds the DMA number of a DMA with the given name, The resource follows an enumeration naming convention.

Enumeration convention: resourceName<n> where n is a number

Parameters
resourceNameThe name of the resource.
nResourceThe number of the resource.
groupThe group of the resource.
mapInsertPointer to the enumeration map.
optionalFlag indicating if the DMA number is optional.
Returns
True if the DMA number is found, false otherwise.

◆ findDMANum()

bool irio::ParserManager::findDMANum ( const std::string &  resourceName,
const GroupResource &  group,
std::uint32_t *  address,
const bool  optional = false 
)

Finds the DMA number of a resource with the given name.

Parameters
resourceNameThe name of the resource.
groupThe group of the resource. Used for logging.
addressPointer to store the found DMA number.
optionalFlag indicating if the resource is optional. If true and the resource is not found, it will not be logged.
Returns
True if the DMA number is found, false otherwise.

◆ findRegister()

bool irio::ParserManager::findRegister ( const std::string &  resourceName,
const GroupResource &  group,
bfp::Register reg,
const bool  optional = false 
)

Finds a register with the given resource name.

Parameters
resourceNameThe name of the resource.
groupThe group of the resource. Used for logging.
regPointer to store the found register.
optionalFlag indicating if the register is optional. If true and the resource is not found, it will not be logged.
Returns
True if the register is found, false otherwise.

◆ findRegisterAddress()

bool irio::ParserManager::findRegisterAddress ( const std::string &  resourceName,
const GroupResource &  group,
std::uint32_t *  address,
const bool  optional = false 
)

Finds the address of a register with the given resource name.

Parameters
resourceNameThe name of the resource.
groupThe group of the resource. Used for logging.
addressPointer to store the found address.
optionalFlag indicating if the resource is optional. If true and the resource is not found, it will not be logged.
Returns
True if the address is found, false otherwise.

◆ findRegisterEnumAddress()

bool irio::ParserManager::findRegisterEnumAddress ( const std::string &  resourceName,
std::uint32_t  nResource,
const GroupResource &  group,
std::unordered_map< std::uint32_t, const std::uint32_t > *  mapInsert,
const bool  optional = false 
)

Finds the address of a register with the given resource name.

The register follows an enumeration naming convention.

Enumeration convention: resourceName<n> where n is a number

Parameters
resourceNameThe name of the resource.
nResourceThe number of the resource.
groupThe group of the resource.
mapInsertPointer to the enumeration map.
optionalFlag indicating if the address is optional.
Returns
True if the address is found, false otherwise.

◆ hasErrorOccurred()

bool irio::ParserManager::hasErrorOccurred ( ) const

Checks if an error has occurred during parsing.

Returns
True if an error has occurred, false otherwise.

◆ logResourceError()

void irio::ParserManager::logResourceError ( const std::string &  resourceName,
const std::string &  errMsg,
const GroupResource &  group 
)

Logs an error related to a resource.

Parameters
resourceNameThe name of the resource.
errMsgThe error message.
groupThe group of the resource.

◆ logResourceFound()

void irio::ParserManager::logResourceFound ( const std::string &  resourceName,
const GroupResource &  group 
)

Logs that a resource has been found.

Parameters
resourceNameThe name of the resource.
groupThe group of the resource.

◆ logResourceNotFound()

void irio::ParserManager::logResourceNotFound ( const std::string &  resourceName,
const GroupResource &  group 
)

Logs that a resource has not been found.

Parameters
resourceNameThe name of the resource.
groupThe group of the resource.

◆ printInfo()

void irio::ParserManager::printInfo ( std::ostream &  os = std::cout,
const bool  onlyErrors = false 
) const

Prints resources found, not found and incompatibilities.

Parameters
osThe output stream to print the information to.
onlyErrorsOnly output not found or error. Default: print everything

◆ printInfoError()

void irio::ParserManager::printInfoError ( std::ostream &  os = std::cerr) const

Prints resources not found and incompatibilities.

Parameters
osThe output stream to print the error information to.

◆ printInfoXML()

void irio::ParserManager::printInfoXML ( const std::string &  filename) const

Prints resources found, not found and incompatibilities in XML format.

Parameters
filenameThe name of the XML file to write the information to.

The documentation for this class was generated from the following file: