40 #ifndef _uhal_NodeTreeBuilder_hpp_ 41 #define _uhal_NodeTreeBuilder_hpp_ 47 #include <boost/filesystem/path.hpp> 48 #include <boost/spirit/include/qi.hpp> 54 #include "pugixml.hpp" 64 UHAL_DEFINE_EXCEPTION_CLASS ( NodeMustHaveUID ,
"Exception class to handle the case where creation of a node was attempted without it having a UID." )
66 UHAL_DEFINE_EXCEPTION_CLASS ( IncorrectAddressTableFileCount , "Exception class to handle the case where too many or two few address files are specified." )
68 UHAL_DEFINE_EXCEPTION_CLASS ( FailedToOpenAddressTableFile , "Exception class to handle the case where the address file failed to open." )
70 UHAL_DEFINE_EXCEPTION_CLASS ( IncrementalNodeRequiresSizeAttribute , "Exception class to handle the case where an incremental node is specified without a size attribute." )
72 UHAL_DEFINE_EXCEPTION_CLASS ( ArraySizeExceedsRegisterBound , "Exception class to handle the case where a memory block has a size which would exceed the available register space." )
74 #ifdef THROW_ON_ADDRESS_SPACE_OVERLAP 80 UHAL_DEFINE_EXCEPTION_CLASS ( BlockAccessNodeCannotHaveChild ,
"Exception class to handle the case when someone tries to give a block access node a child." )
83 UHAL_DEFINE_EXCEPTION_CLASS ( MaskedNodeCannotHaveChild , "Exception class to handle the case when someone tries to give a bit-masked node a child." )
131 Node* getNodeTree (
const std::string& aFilenameExpr ,
const boost::filesystem::path& aPath );
134 void clearAddressFileCache();
145 void CallBack (
const std::string& aProtocol ,
const boost::filesystem::path& aPath , std::vector<uint8_t>& aFile , std::vector< const Node* >& aAddressTable );
153 void calculateHierarchicalAddresses (
Node* aNode ,
const uint32_t& aAddr );
156 void checkForAddressCollisions (
Node* aNode ,
const boost::filesystem::path& aPath );
159 static bool NodePtrCompare (
Node* aNodeL,
Node* aNodeR );
162 Node* plainNodeCreator (
const bool& aRequireId ,
const pugi::xml_node& aXmlNode );
164 Node* moduleNodeCreator (
const bool& aRequireId ,
const pugi::xml_node& aXmlNode );
165 Node* bitmaskNodeCreator (
const bool& aRequireId ,
const pugi::xml_node& aXmlNode );
167 void setUid (
const bool& aRequireId ,
const pugi::xml_node& aXmlNode ,
Node* aNode );
168 void setClassName (
const pugi::xml_node& aXmlNode ,
Node* aNode );
169 void setPars (
const pugi::xml_node& aXmlNode ,
Node* aNode );
170 void setAddr (
const pugi::xml_node& aXmlNode ,
Node* aNode );
171 void setTags (
const pugi::xml_node& aXmlNode ,
Node* aNode );
172 void setDescription (
const pugi::xml_node& aXmlNode ,
Node* aNode );
173 void setModule (
const pugi::xml_node& aXmlNode ,
Node* aNode );
174 void setPermissions (
const pugi::xml_node& aXmlNode ,
Node* aNode );
175 void setMask (
const pugi::xml_node& aXmlNode ,
Node* aNode );
176 void setModeAndSize (
const pugi::xml_node& aXmlNode ,
Node* aNode );
177 void setFirmwareInfo (
const pugi::xml_node& aXmlNode ,
Node* aNode );
178 void addChildren (
const pugi::xml_node& aXmlNode ,
Node* aNode );
203 boost::unordered_map< std::string , const Node* >
mNodes;
206 static const struct permissions_lut : boost::spirit::qi::symbols<char, defs::NodePermission>
214 static const struct mode_lut : boost::spirit::qi::symbols<char, defs::BlockReadWriteMode>
A class to build a node tree from an Address table file NOTE! This is a factory method and must be Mu...
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.
grammars::NodeTreeFirmwareinfoAttributeGrammar mNodeTreeFirmwareInfoAttributeGrammar
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 ...
A struct wrapping a set of rules as a grammar that can parse a NodeTreeParametersGrammar of the form ...
static const char * mParametersAttribute
static NodeTreeBuilder * mInstance
The single instance of the class.
static const char * mModeAttribute
static const char * mAddressAttribute
#define UHAL_DEFINE_EXCEPTION_CLASS(ClassName, ClassDescription)
Parser< Node *> mNodeParser
static const char * mModuleAttribute
static const char * mMaskAttribute
std::deque< boost::filesystem::path > mFileCallStack
static const char * mSizeAttribute
static const char * mPermissionsAttribute
A heirarchical node for navigating heirarchical firmwares.
static const char * mFirmwareInfo
static const char * mTagsAttribute
static const char * mDescriptionAttribute
static const char * mIdAttribute
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.
Parser< Node *> mTopLevelNodeParser
grammars::NodeTreeParametersGrammar mNodeTreeParametersGrammar
static const char * mClassAttribute
grammars::NodeTreeClassAttributeGrammar mNodeTreeClassAttributeGrammar
Forward declaration of the Parser so we can declare it friend.