μHAL (v2.6.5)
Part of the IPbus software repository
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
uhal::NodeTreeBuilder Class Reference

A class to build a node tree from an Address table file NOTE! This is a factory method and must be Mutex protected if it is used in multithreaded environments! More...

#include <uhal/NodeTreeBuilder.hpp>

Inheritance diagram for uhal::NodeTreeBuilder:
[legend]
Collaboration diagram for uhal::NodeTreeBuilder:
[legend]

Classes

struct  mode_lut
 A look-up table that the boost qi parser uses for associating strings ("single","block","port","incremental","non-incremental","inc","non-inc") with enumerated mode types. More...
 
struct  permissions_lut
 A look-up table that the boost qi parser uses for associating strings ("r","w","rw","wr","read","write","readwrite","writeread") with enumerated permissions types. More...
 

Public Member Functions

NodegetNodeTree (const std::string &aFilenameExpr, const boost::filesystem::path &aPath)
 Construct a node tree from file whose name is specified. More...
 
void clearAddressFileCache ()
 Clears address filename -> Node tree cache. NOT thread safe; for tread-safety, use ConnectionManager method. More...
 

Static Public Member Functions

static NodeTreeBuildergetInstance ()
 Static method to retrieve the single instance of the class. More...
 

Private Member Functions

 NodeTreeBuilder ()
 Default constructor This is private since only a single instance is to be created, using the getInstance method. More...
 
virtual ~NodeTreeBuilder ()
 Destructor. More...
 
void CallBack (const std::string &aProtocol, const boost::filesystem::path &aPath, std::vector< uint8_t > &aFile, std::vector< const Node * > &aAddressTable)
 Method called once the file specified in the call to getNodeTree( aFilenameExpr ) has been opened. More...
 
void calculateHierarchicalAddresses (Node *aNode, const uint32_t &aAddr)
 Propagate the addresses down through the hierarchical structure. More...
 
void checkForAddressCollisions (Node *aNode, const boost::filesystem::path &aPath)
 
NodeplainNodeCreator (const bool &aRequireId, const pugi::xml_node &aXmlNode)
 
NodemoduleNodeCreator (const bool &aRequireId, const pugi::xml_node &aXmlNode)
 
NodebitmaskNodeCreator (const bool &aRequireId, const pugi::xml_node &aXmlNode)
 
void setUid (const bool &aRequireId, const pugi::xml_node &aXmlNode, Node *aNode)
 
void setClassName (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setPars (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setAddr (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setTags (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setDescription (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setModule (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setPermissions (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setMask (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setModeAndSize (const pugi::xml_node &aXmlNode, Node *aNode)
 
void setFirmwareInfo (const pugi::xml_node &aXmlNode, Node *aNode)
 
void addChildren (const pugi::xml_node &aXmlNode, Node *aNode)
 

Static Private Member Functions

static bool NodePtrCompare (Node *aNodeL, Node *aNodeR)
 

Private Attributes

Parser< Node *> mTopLevelNodeParser
 
Parser< Node *> mNodeParser
 
std::deque< boost::filesystem::path > mFileCallStack
 
boost::unordered_map< std::string, const Node *> mNodes
 Hash map associating a Node tree with a file name so that we do not need to repeatedly parse the xml documents if someone asks for a second copy of a particular node tree. More...
 
grammars::NodeTreeClassAttributeGrammar mNodeTreeClassAttributeGrammar
 
grammars::NodeTreeParametersGrammar mNodeTreeParametersGrammar
 
grammars::NodeTreeFirmwareinfoAttributeGrammar mNodeTreeFirmwareInfoAttributeGrammar
 

Static Private Attributes

static const char * mIdAttribute = "id"
 
static const char * mAddressAttribute = "address"
 
static const char * mParametersAttribute = "parameters"
 
static const char * mTagsAttribute = "tags"
 
static const char * mDescriptionAttribute = "description"
 
static const char * mPermissionsAttribute = "permission"
 
static const char * mMaskAttribute = "mask"
 
static const char * mModeAttribute = "mode"
 
static const char * mSizeAttribute = "size"
 
static const char * mClassAttribute = "class"
 
static const char * mModuleAttribute = "module"
 
static const char * mFirmwareInfo = "fwinfo"
 
static NodeTreeBuildermInstance = NULL
 The single instance of the class. More...
 
uhal::NodeTreeBuilder::permissions_lut mPermissionsLut
 An instance of a look-up table that the boost qi parser uses for associating strings with enumerated permissions types. More...
 
uhal::NodeTreeBuilder::mode_lut mModeLut
 An instance of a look-up table that the boost qi parser uses for associating strings with enumerated permissions types. More...
 

Detailed Description

A class to build a node tree from an Address table file NOTE! This is a factory method and must be Mutex protected if it is used in multithreaded environments!

Definition at line 102 of file NodeTreeBuilder.hpp.

Constructor & Destructor Documentation

◆ NodeTreeBuilder()

uhal::NodeTreeBuilder::NodeTreeBuilder ( )
private

Default constructor This is private since only a single instance is to be created, using the getInstance method.

Definition at line 79 of file NodeTreeBuilder.cpp.

References bitmaskNodeCreator(), mNodeParser, moduleNodeCreator(), mTopLevelNodeParser, uhal::Rule< R >::optional(), plainNodeCreator(), and uhal::Rule< R >::require().

Referenced by getInstance().

◆ ~NodeTreeBuilder()

uhal::NodeTreeBuilder::~NodeTreeBuilder ( )
privatevirtual

Destructor.

Definition at line 136 of file NodeTreeBuilder.cpp.

Member Function Documentation

◆ addChildren()

void uhal::NodeTreeBuilder::addChildren ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ bitmaskNodeCreator()

Node * uhal::NodeTreeBuilder::bitmaskNodeCreator ( const bool &  aRequireId,
const pugi::xml_node &  aXmlNode 
)
private

◆ calculateHierarchicalAddresses()

void uhal::NodeTreeBuilder::calculateHierarchicalAddresses ( Node aNode,
const uint32_t &  aAddr 
)
private

Propagate the addresses down through the hierarchical structure.

Parameters
aNodethe node whose address we are calculating
aAddrthe parent address which will be applied to the children

Definition at line 554 of file NodeTreeBuilder.cpp.

References uhal::defs::HIERARCHICAL, uhal::defs::INCREMENTAL, uhal::Integer(), uhal::Node::mAddr, uhal::Node::mChildren, uhal::Node::mMode, uhal::Node::mPartialAddr, uhal::Node::mSize, NodePtrCompare(), uhal::defs::NOMASK, and uhal::defs::SINGLE.

Referenced by CallBack().

◆ CallBack()

void uhal::NodeTreeBuilder::CallBack ( const std::string &  aProtocol,
const boost::filesystem::path &  aPath,
std::vector< uint8_t > &  aFile,
std::vector< const Node * > &  aAddressTable 
)
private

Method called once the file specified in the call to getNodeTree( aFilenameExpr ) has been opened.

Parameters
aProtocolThe protocol by which the file was loaded
aPathThe fully qualified path to the file which has been opened
aFileA byte vector containing the content of the opened file. Done like this since the routine handles local and http files identically
aAddressTableThe address table constructed from the file

Definition at line 189 of file NodeTreeBuilder.cpp.

References calculateHierarchicalAddresses(), checkForAddressCollisions(), uhal::Error, uhal::Info, mFileCallStack, mNodes, mTopLevelNodeParser, uhal::utilities::PugiXMLParseResultPrettifier(), uhal::Quote(), and ThisLocation.

Referenced by getNodeTree().

◆ checkForAddressCollisions()

void uhal::NodeTreeBuilder::checkForAddressCollisions ( Node aNode,
const boost::filesystem::path &  aPath 
)
private

◆ clearAddressFileCache()

void uhal::NodeTreeBuilder::clearAddressFileCache ( )

Clears address filename -> Node tree cache. NOT thread safe; for tread-safety, use ConnectionManager method.

Definition at line 179 of file NodeTreeBuilder.cpp.

References mNodes.

Referenced by uhal::ConnectionManager::clearAddressFileCache().

◆ getInstance()

NodeTreeBuilder & uhal::NodeTreeBuilder::getInstance ( )
static

Static method to retrieve the single instance of the class.

Returns
the single instance of the class

Definition at line 142 of file NodeTreeBuilder.cpp.

References mInstance, and NodeTreeBuilder().

Referenced by uhal::ConnectionManager::clearAddressFileCache(), and uhal::ConnectionManager::getDevice().

◆ getNodeTree()

Node * uhal::NodeTreeBuilder::getNodeTree ( const std::string &  aFilenameExpr,
const boost::filesystem::path &  aPath 
)

Construct a node tree from file whose name is specified.

NOT thread safe; for thread-safety, use ConnectionManager getDevice/getDevices methods

Parameters
aFilenameExpra Filename Expression
aPatha path that will be prepended to relative filenames for local files. Ignored for http files.
Returns
a freshly cloned node tree

Definition at line 152 of file NodeTreeBuilder.cpp.

References CallBack(), uhal::Integer(), uhal::utilities::OpenFile(), uhal::utilities::ParseSemicolonDelimitedUriList(), and uhal::Quote().

Referenced by moduleNodeCreator().

◆ moduleNodeCreator()

Node * uhal::NodeTreeBuilder::moduleNodeCreator ( const bool &  aRequireId,
const pugi::xml_node &  aXmlNode 
)
private

◆ NodePtrCompare()

bool uhal::NodeTreeBuilder::NodePtrCompare ( Node aNodeL,
Node aNodeR 
)
staticprivate

Definition at line 516 of file NodeTreeBuilder.cpp.

References uhal::Node::mAddr.

Referenced by calculateHierarchicalAddresses().

◆ plainNodeCreator()

Node * uhal::NodeTreeBuilder::plainNodeCreator ( const bool &  aRequireId,
const pugi::xml_node &  aXmlNode 
)
private

◆ setAddr()

void uhal::NodeTreeBuilder::setAddr ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setClassName()

void uhal::NodeTreeBuilder::setClassName ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setDescription()

void uhal::NodeTreeBuilder::setDescription ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setFirmwareInfo()

void uhal::NodeTreeBuilder::setFirmwareInfo ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setMask()

void uhal::NodeTreeBuilder::setMask ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setModeAndSize()

void uhal::NodeTreeBuilder::setModeAndSize ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setModule()

void uhal::NodeTreeBuilder::setModule ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setPars()

void uhal::NodeTreeBuilder::setPars ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setPermissions()

void uhal::NodeTreeBuilder::setPermissions ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setTags()

void uhal::NodeTreeBuilder::setTags ( const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

◆ setUid()

void uhal::NodeTreeBuilder::setUid ( const bool &  aRequireId,
const pugi::xml_node &  aXmlNode,
Node aNode 
)
private

Member Data Documentation

◆ mAddressAttribute

const char * uhal::NodeTreeBuilder::mAddressAttribute = "address"
staticprivate

Definition at line 181 of file NodeTreeBuilder.hpp.

Referenced by setAddr().

◆ mClassAttribute

const char * uhal::NodeTreeBuilder::mClassAttribute = "class"
staticprivate

Definition at line 189 of file NodeTreeBuilder.hpp.

Referenced by setClassName().

◆ mDescriptionAttribute

const char * uhal::NodeTreeBuilder::mDescriptionAttribute = "description"
staticprivate

Definition at line 184 of file NodeTreeBuilder.hpp.

Referenced by setDescription().

◆ mFileCallStack

std::deque< boost::filesystem::path > uhal::NodeTreeBuilder::mFileCallStack
private

Definition at line 196 of file NodeTreeBuilder.hpp.

Referenced by CallBack(), moduleNodeCreator(), and setModule().

◆ mFirmwareInfo

const char * uhal::NodeTreeBuilder::mFirmwareInfo = "fwinfo"
staticprivate

Definition at line 191 of file NodeTreeBuilder.hpp.

Referenced by setFirmwareInfo().

◆ mIdAttribute

const char * uhal::NodeTreeBuilder::mIdAttribute = "id"
staticprivate

Definition at line 180 of file NodeTreeBuilder.hpp.

Referenced by setUid().

◆ mInstance

NodeTreeBuilder * uhal::NodeTreeBuilder::mInstance = NULL
staticprivate

The single instance of the class.

Definition at line 200 of file NodeTreeBuilder.hpp.

Referenced by getInstance().

◆ mMaskAttribute

const char * uhal::NodeTreeBuilder::mMaskAttribute = "mask"
staticprivate

Definition at line 186 of file NodeTreeBuilder.hpp.

Referenced by setMask().

◆ mModeAttribute

const char * uhal::NodeTreeBuilder::mModeAttribute = "mode"
staticprivate

Definition at line 187 of file NodeTreeBuilder.hpp.

◆ mModeLut

const NodeTreeBuilder::mode_lut uhal::NodeTreeBuilder::mModeLut
staticprivate

An instance of a look-up table that the boost qi parser uses for associating strings with enumerated permissions types.

Definition at line 863 of file NodeTreeBuilder.cpp.

Referenced by setModeAndSize().

◆ mModuleAttribute

const char * uhal::NodeTreeBuilder::mModuleAttribute = "module"
staticprivate

Definition at line 190 of file NodeTreeBuilder.hpp.

Referenced by moduleNodeCreator().

◆ mNodeParser

Parser< Node* > uhal::NodeTreeBuilder::mNodeParser
private

Definition at line 194 of file NodeTreeBuilder.hpp.

Referenced by addChildren(), and NodeTreeBuilder().

◆ mNodes

boost::unordered_map< std::string , const Node* > uhal::NodeTreeBuilder::mNodes
private

Hash map associating a Node tree with a file name so that we do not need to repeatedly parse the xml documents if someone asks for a second copy of a particular node tree.

Definition at line 203 of file NodeTreeBuilder.hpp.

Referenced by CallBack(), and clearAddressFileCache().

◆ mNodeTreeClassAttributeGrammar

grammars::NodeTreeClassAttributeGrammar uhal::NodeTreeBuilder::mNodeTreeClassAttributeGrammar
private

Definition at line 221 of file NodeTreeBuilder.hpp.

◆ mNodeTreeFirmwareInfoAttributeGrammar

grammars::NodeTreeFirmwareinfoAttributeGrammar uhal::NodeTreeBuilder::mNodeTreeFirmwareInfoAttributeGrammar
private

Definition at line 223 of file NodeTreeBuilder.hpp.

Referenced by setFirmwareInfo().

◆ mNodeTreeParametersGrammar

grammars::NodeTreeParametersGrammar uhal::NodeTreeBuilder::mNodeTreeParametersGrammar
private

Definition at line 222 of file NodeTreeBuilder.hpp.

Referenced by setPars().

◆ mParametersAttribute

const char * uhal::NodeTreeBuilder::mParametersAttribute = "parameters"
staticprivate

Definition at line 182 of file NodeTreeBuilder.hpp.

Referenced by setPars().

◆ mPermissionsAttribute

const char * uhal::NodeTreeBuilder::mPermissionsAttribute = "permission"
staticprivate

Definition at line 185 of file NodeTreeBuilder.hpp.

◆ mPermissionsLut

const NodeTreeBuilder::permissions_lut uhal::NodeTreeBuilder::mPermissionsLut
staticprivate

An instance of a look-up table that the boost qi parser uses for associating strings with enumerated permissions types.

Definition at line 847 of file NodeTreeBuilder.cpp.

Referenced by setPermissions().

◆ mSizeAttribute

const char * uhal::NodeTreeBuilder::mSizeAttribute = "size"
staticprivate

Definition at line 188 of file NodeTreeBuilder.hpp.

◆ mTagsAttribute

const char * uhal::NodeTreeBuilder::mTagsAttribute = "tags"
staticprivate

Definition at line 183 of file NodeTreeBuilder.hpp.

Referenced by setTags().

◆ mTopLevelNodeParser

Parser< Node* > uhal::NodeTreeBuilder::mTopLevelNodeParser
private

Definition at line 193 of file NodeTreeBuilder.hpp.

Referenced by CallBack(), and NodeTreeBuilder().


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