μHAL (v2.7.9)
Part of the IPbus software repository
Classes | Public Member Functions | Static Public Member Functions | 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

virtual ~NodeTreeBuilder ()
 Destructor. More...
 
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...
 
Nodebuild (const pugi::xml_node &aNode, const boost::filesystem::path &aAddressFilePath)
 

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...
 
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)
 

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 std::string mIdAttribute = "id"
 
static const std::string mAddressAttribute = "address"
 
static const std::string mParametersAttribute = "parameters"
 
static const std::string mTagsAttribute = "tags"
 
static const std::string mDescriptionAttribute = "description"
 
static const std::string mPermissionsAttribute = "permission"
 
static const std::string mMaskAttribute = "mask"
 
static const std::string mModeAttribute = "mode"
 
static const std::string mSizeAttribute = "size"
 
static const std::string mClassAttribute = "class"
 
static const std::string mModuleAttribute = "module"
 
static const std::string mFirmwareInfo = "fwinfo"
 
static boost::shared_ptr< NodeTreeBuildermInstance
 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 87 of file NodeTreeBuilder.hpp.

Constructor & Destructor Documentation

◆ NodeTreeBuilder()

uhal::NodeTreeBuilder::NodeTreeBuilder ( )
private

◆ ~NodeTreeBuilder()

uhal::NodeTreeBuilder::~NodeTreeBuilder ( )
virtual

Destructor.

Definition at line 138 of file NodeTreeBuilder.cpp.

References clearAddressFileCache().

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

◆ build()

Node * uhal::NodeTreeBuilder::build ( const pugi::xml_node aNode,
const boost::filesystem::path &  aAddressFilePath 
)

◆ 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 564 of file NodeTreeBuilder.cpp.

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

Referenced by build().

◆ 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 204 of file NodeTreeBuilder.cpp.

References build(), pugi::xml_node::child(), uhal::Error, uhal::Info, pugi::xml_document::load_buffer_inplace(), uhal::log(), mNodes, uhal::utilities::PugiXMLParseResultPrettifier(), and uhal::Quote().

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 182 of file NodeTreeBuilder.cpp.

References mNodes.

Referenced by uhal::ConnectionManager::clearAddressFileCache(), and ~NodeTreeBuilder().

◆ 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 144 of file NodeTreeBuilder.cpp.

References mInstance, and NodeTreeBuilder().

Referenced by uhal::tests::BOOST_FIXTURE_TEST_CASE(), 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 155 of file NodeTreeBuilder.cpp.

References CallBack(), uhal::Integer(), uhal::log(), 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

◆ 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 std::string uhal::NodeTreeBuilder::mAddressAttribute = "address"
staticprivate

Definition at line 157 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setAddr().

◆ mClassAttribute

const std::string uhal::NodeTreeBuilder::mClassAttribute = "class"
staticprivate

Definition at line 165 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setClassName().

◆ mDescriptionAttribute

const std::string uhal::NodeTreeBuilder::mDescriptionAttribute = "description"
staticprivate

Definition at line 160 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setDescription().

◆ mFileCallStack

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

Definition at line 172 of file NodeTreeBuilder.hpp.

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

◆ mFirmwareInfo

const std::string uhal::NodeTreeBuilder::mFirmwareInfo = "fwinfo"
staticprivate

Definition at line 167 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setFirmwareInfo().

◆ mIdAttribute

const std::string uhal::NodeTreeBuilder::mIdAttribute = "id"
staticprivate

Definition at line 156 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setUid().

◆ mInstance

boost::shared_ptr< NodeTreeBuilder > uhal::NodeTreeBuilder::mInstance
staticprivate

The single instance of the class.

Definition at line 176 of file NodeTreeBuilder.hpp.

Referenced by getInstance().

◆ mMaskAttribute

const std::string uhal::NodeTreeBuilder::mMaskAttribute = "mask"
staticprivate

Definition at line 162 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setMask().

◆ mModeAttribute

const std::string uhal::NodeTreeBuilder::mModeAttribute = "mode"
staticprivate

Definition at line 163 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setModeAndSize().

◆ 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 729 of file NodeTreeBuilder.cpp.

Referenced by setModeAndSize().

◆ mModuleAttribute

const std::string uhal::NodeTreeBuilder::mModuleAttribute = "module"
staticprivate

Definition at line 166 of file NodeTreeBuilder.hpp.

Referenced by moduleNodeCreator(), and NodeTreeBuilder().

◆ mNodeParser

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

Definition at line 170 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 179 of file NodeTreeBuilder.hpp.

Referenced by CallBack(), and clearAddressFileCache().

◆ mNodeTreeClassAttributeGrammar

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

Definition at line 196 of file NodeTreeBuilder.hpp.

◆ mNodeTreeFirmwareInfoAttributeGrammar

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

Definition at line 198 of file NodeTreeBuilder.hpp.

Referenced by setFirmwareInfo().

◆ mNodeTreeParametersGrammar

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

Definition at line 197 of file NodeTreeBuilder.hpp.

Referenced by setPars().

◆ mParametersAttribute

const std::string uhal::NodeTreeBuilder::mParametersAttribute = "parameters"
staticprivate

Definition at line 158 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setPars().

◆ mPermissionsAttribute

const std::string uhal::NodeTreeBuilder::mPermissionsAttribute = "permission"
staticprivate

Definition at line 161 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setPermissions().

◆ 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 713 of file NodeTreeBuilder.cpp.

Referenced by setPermissions().

◆ mSizeAttribute

const std::string uhal::NodeTreeBuilder::mSizeAttribute = "size"
staticprivate

Definition at line 164 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setModeAndSize().

◆ mTagsAttribute

const std::string uhal::NodeTreeBuilder::mTagsAttribute = "tags"
staticprivate

Definition at line 159 of file NodeTreeBuilder.hpp.

Referenced by NodeTreeBuilder(), and setTags().

◆ mTopLevelNodeParser

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

Definition at line 169 of file NodeTreeBuilder.hpp.

Referenced by build(), and NodeTreeBuilder().


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