A class to build a node tree from an address table file. More...
#include <uhal/NodeTreeBuilder.hpp>
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 | |
NodeTreeBuilder (const NodeTreeBuilder &)=delete | |
NodeTreeBuilder & | operator= (const NodeTreeBuilder &)=delete |
virtual | ~NodeTreeBuilder () |
Destructor. More... | |
Node * | getNodeTree (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... | |
Node * | build (const pugi::xml_node &aNode, const boost::filesystem::path &aAddressFilePath) |
Static Public Member Functions | |
static NodeTreeBuilder & | getInstance () |
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) |
Node * | plainNodeCreator (const bool &aRequireId, const pugi::xml_node &aXmlNode) |
Node * | moduleNodeCreator (const bool &aRequireId, const pugi::xml_node &aXmlNode) |
Node * | bitmaskNodeCreator (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 |
std::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 std::shared_ptr< NodeTreeBuilder > | mInstance |
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... | |
A class to build a node tree from an address table file.
Definition at line 84 of file NodeTreeBuilder.hpp.
|
private |
Default constructor This is private since only a single instance is to be created, using the getInstance method.
Definition at line 75 of file NodeTreeBuilder.cpp.
References bitmaskNodeCreator(), mAddressAttribute, mClassAttribute, mDescriptionAttribute, mFirmwareInfo, mIdAttribute, mMaskAttribute, mModeAttribute, mModuleAttribute, mNodeParser, moduleNodeCreator(), mParametersAttribute, mPermissionsAttribute, mSizeAttribute, mTagsAttribute, mTopLevelNodeParser, uhal::Rule< R >::optional(), plainNodeCreator(), and uhal::Rule< R >::require().
Referenced by getInstance().
|
delete |
|
virtual |
|
private |
Definition at line 531 of file NodeTreeBuilder.cpp.
References pugi::xml_node::child(), uhal::log(), uhal::Node::mChildren, uhal::Node::mChildrenMap, uhal::Node::mMode, mNodeParser, uhal::Node::mUid, pugi::xml_node::next_sibling(), uhal::defs::NON_INCREMENTAL, and uhal::Quote().
Referenced by plainNodeCreator().
|
private |
Definition at line 308 of file NodeTreeBuilder.cpp.
References pugi::xml_node::child(), uhal::Debug, uhal::log(), uhal::Node::mUid, setAddr(), setClassName(), setDescription(), setFirmwareInfo(), setMask(), setModule(), setPars(), setPermissions(), setTags(), and setUid().
Referenced by NodeTreeBuilder().
Node * uhal::NodeTreeBuilder::build | ( | const pugi::xml_node & | aNode, |
const boost::filesystem::path & | aAddressFilePath | ||
) |
Definition at line 186 of file NodeTreeBuilder.cpp.
References calculateHierarchicalAddresses(), checkForAddressCollisions(), mFileCallStack, and mTopLevelNodeParser.
Referenced by CallBack().
|
private |
Propagate the addresses down through the hierarchical structure.
aNode | the node whose address we are calculating |
aAddr | the parent address which will be applied to the children |
Definition at line 556 of file NodeTreeBuilder.cpp.
References calculateHierarchicalAddresses(), uhal::detail::compareNodeAddr(), uhal::defs::HIERARCHICAL, uhal::defs::INCREMENTAL, uhal::Integer(), uhal::log(), uhal::Node::mAddr, uhal::Node::mChildren, uhal::Node::mMask, uhal::Node::mMode, uhal::Node::mParent, uhal::Node::mPartialAddr, uhal::Node::mSize, uhal::defs::NOMASK, and uhal::defs::SINGLE.
Referenced by build(), and calculateHierarchicalAddresses().
|
private |
Method called once the file specified in the call to getNodeTree( aFilenameExpr ) has been opened.
aProtocol | The protocol by which the file was loaded |
aPath | The fully qualified path to the file which has been opened |
aFile | A byte vector containing the content of the opened file. Done like this since the routine handles local and http files identically |
aAddressTable | The address table constructed from the file |
Definition at line 198 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().
|
private |
Definition at line 635 of file NodeTreeBuilder.cpp.
References uhal::Error, uhal::detail::getAddressOverlaps(), uhal::log(), uhal::Quote(), uhal::Warning, and uhal::detail::writeNodeOverlapReport().
Referenced by build().
void uhal::NodeTreeBuilder::clearAddressFileCache | ( | ) |
Clears address filename -> Node tree cache. NOT thread safe; for tread-safety, use ConnectionManager method.
Definition at line 178 of file NodeTreeBuilder.cpp.
References mNodes.
Referenced by uhal::ConnectionManager::clearAddressFileCache(), and ~NodeTreeBuilder().
|
static |
Static method to retrieve the single instance of the class.
Definition at line 140 of file NodeTreeBuilder.cpp.
References mInstance, and NodeTreeBuilder().
Referenced by uhal::tests::BOOST_FIXTURE_TEST_CASE(), uhal::ConnectionManager::clearAddressFileCache(), and uhal::ConnectionManager::getDevice().
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
aFilenameExpr | a Filename Expression |
aPath | a path that will be prepended to relative filenames for local files. Ignored for http files. |
Definition at line 151 of file NodeTreeBuilder.cpp.
References CallBack(), first(), uhal::Integer(), uhal::log(), uhal::utilities::OpenFile(), uhal::utilities::ParseSemicolonDelimitedUriList(), and uhal::Quote().
Referenced by moduleNodeCreator().
|
private |
Definition at line 278 of file NodeTreeBuilder.cpp.
References uhal::DerivedNodeFactory::convertToClassType(), uhal::Debug, uhal::DerivedNodeFactory::getInstance(), getNodeTree(), uhal::utilities::GetXMLattribute< false >(), uhal::log(), uhal::Node::mClassName, mFileCallStack, mModuleAttribute, uhal::Node::mUid, setAddr(), setClassName(), setDescription(), setFirmwareInfo(), setModule(), setPars(), setTags(), and setUid().
Referenced by NodeTreeBuilder().
|
delete |
|
private |
Definition at line 251 of file NodeTreeBuilder.cpp.
References addChildren(), uhal::DerivedNodeFactory::convertToClassType(), uhal::Debug, uhal::DerivedNodeFactory::getInstance(), uhal::log(), uhal::Node::mClassName, uhal::Node::mUid, setAddr(), setClassName(), setDescription(), setFirmwareInfo(), setModeAndSize(), setModule(), setPars(), setPermissions(), setTags(), and setUid().
Referenced by NodeTreeBuilder().
|
private |
Definition at line 358 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), mAddressAttribute, and uhal::Node::mPartialAddr.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 367 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), mClassAttribute, and uhal::Node::mClassName.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 416 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), uhal::Node::mDescription, and mDescriptionAttribute.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 508 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), uhal::NodeTreeFirmwareInfoAttribute::mArguments, uhal::Node::mFirmwareInfo, mFirmwareInfo, mNodeTreeFirmwareInfoAttributeGrammar, and uhal::NodeTreeFirmwareInfoAttribute::mType.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 460 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), uhal::Node::mMask, and mMaskAttribute.
Referenced by bitmaskNodeCreator().
|
private |
Definition at line 467 of file NodeTreeBuilder.cpp.
References pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::utilities::GetXMLattribute< false >(), uhal::defs::INCREMENTAL, uhal::log(), uhal::Node::mMode, mModeAttribute, mModeLut, uhal::Node::mSize, mSizeAttribute, uhal::Node::mUid, uhal::defs::NON_INCREMENTAL, uhal::Notice, uhal::Quote(), and uhal::Warning.
Referenced by plainNodeCreator().
|
private |
Definition at line 434 of file NodeTreeBuilder.cpp.
References mFileCallStack, and uhal::Node::mModule.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 376 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), mNodeTreeParametersGrammar, uhal::Node::mParameters, and mParametersAttribute.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 442 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), uhal::Node::mPermission, mPermissionsAttribute, mPermissionsLut, and uhal::Node::mUid.
Referenced by bitmaskNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 397 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), uhal::Node::mTags, and mTagsAttribute.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
private |
Definition at line 337 of file NodeTreeBuilder.cpp.
References uhal::utilities::GetXMLattribute< false >(), mIdAttribute, and uhal::Node::mUid.
Referenced by bitmaskNodeCreator(), moduleNodeCreator(), and plainNodeCreator().
|
staticprivate |
Definition at line 158 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setAddr().
|
staticprivate |
Definition at line 166 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setClassName().
|
staticprivate |
Definition at line 161 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setDescription().
|
private |
Definition at line 173 of file NodeTreeBuilder.hpp.
Referenced by build(), moduleNodeCreator(), and setModule().
|
staticprivate |
Definition at line 168 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setFirmwareInfo().
|
staticprivate |
Definition at line 157 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setUid().
|
staticprivate |
The single instance of the class.
Definition at line 177 of file NodeTreeBuilder.hpp.
Referenced by getInstance().
|
staticprivate |
Definition at line 163 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setMask().
|
staticprivate |
Definition at line 164 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setModeAndSize().
|
staticprivate |
An instance of a look-up table that the boost qi parser uses for associating strings with enumerated permissions types.
Definition at line 719 of file NodeTreeBuilder.cpp.
Referenced by setModeAndSize().
|
staticprivate |
Definition at line 167 of file NodeTreeBuilder.hpp.
Referenced by moduleNodeCreator(), and NodeTreeBuilder().
Definition at line 171 of file NodeTreeBuilder.hpp.
Referenced by addChildren(), and NodeTreeBuilder().
|
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 180 of file NodeTreeBuilder.hpp.
Referenced by CallBack(), and clearAddressFileCache().
|
private |
Definition at line 197 of file NodeTreeBuilder.hpp.
|
private |
Definition at line 199 of file NodeTreeBuilder.hpp.
Referenced by setFirmwareInfo().
|
private |
Definition at line 198 of file NodeTreeBuilder.hpp.
Referenced by setPars().
|
staticprivate |
Definition at line 159 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setPars().
|
staticprivate |
Definition at line 162 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setPermissions().
|
staticprivate |
An instance of a look-up table that the boost qi parser uses for associating strings with enumerated permissions types.
Definition at line 703 of file NodeTreeBuilder.cpp.
Referenced by setPermissions().
|
staticprivate |
Definition at line 165 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setModeAndSize().
|
staticprivate |
Definition at line 160 of file NodeTreeBuilder.hpp.
Referenced by NodeTreeBuilder(), and setTags().
Definition at line 170 of file NodeTreeBuilder.hpp.
Referenced by build(), and NodeTreeBuilder().