X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FConfig%2FConfig_XMLReader.cpp;h=3b206f3ce7a5717fa0a27b3d2613d30f0ecd7b10;hb=53df1b33d7d3787a433f8e4f3936eed28850c48b;hp=002c9df493ab611ef9d22774d6147ce70e2800e3;hpb=4d6a5c7e00c6d8e68c01ce5947432d9cdfbcb7a5;p=modules%2Fshaper.git diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index 002c9df49..3b206f3ce 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -6,17 +6,17 @@ */ #include +#include +#include +#include -#include +#include #include #include -/* #ifdef WIN32 -//For GetModuleFileNameW -#include +#pragma warning(disable : 4996) // for getenv #endif -*/ #ifdef _DEBUG #include @@ -58,21 +58,26 @@ void Config_XMLReader::readAll() /* * Allows to customize reader's behavior for a node. Virtual. - * The default implementation does nothing. (In debug mode prints + * The default impl does nothing. (In debug mode prints * some info) */ -void Config_XMLReader::processNode(xmlNodePtr aNode) +void Config_XMLReader::processNode(xmlNodePtr theNode) { + if (isNode(theNode, NODE_SOURCE, NULL)) { + std::string aSourceFile = getProperty(theNode, SOURCE_FILE); + Config_XMLReader aSourceReader = Config_XMLReader(aSourceFile); + readRecursively(aSourceReader.findRoot()); #ifdef _DEBUG - std::cout << "Config_XMLReader::processNode: " - << aNode->name << " content: " - << aNode->content << std::endl; + std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl; #endif + } else if (isNode(theNode, NODE_VALIDATOR, NULL)) { + processValidator(theNode); + } } /* * Defines which nodes should be processed recursively. Virtual. - * The default implementation is to read all nodes. + * The default impl is to read all nodes. */ bool Config_XMLReader::processChildren(xmlNodePtr aNode) { @@ -84,7 +89,9 @@ bool Config_XMLReader::processChildren(xmlNodePtr aNode) */ xmlNodePtr Config_XMLReader::findRoot() { - myXmlDoc = xmlParseFile(myDocumentPath.c_str()); + if (myXmlDoc == NULL) { + myXmlDoc = xmlParseFile(myDocumentPath.c_str()); + } if (myXmlDoc == NULL) { #ifdef _DEBUG std::cout << "Config_XMLReader::import: " << "Document " << myDocumentPath @@ -92,7 +99,6 @@ xmlNodePtr Config_XMLReader::findRoot() #endif return NULL; } - xmlNodePtr aRoot = xmlDocGetRootElement(myXmlDoc); #ifdef _DEBUG if(aRoot == NULL) { @@ -112,7 +118,11 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent) if (!theParent) return; xmlNodePtr aNode = theParent->xmlChildrenNode; - for(; aNode; aNode = aNode->next) { + for (; aNode; aNode = aNode->next) { + //Still no text processing in features... + if (!isElementNode(aNode)) { + continue; + } processNode(aNode); if (processChildren(aNode)) { readRecursively(aNode); @@ -131,13 +141,33 @@ xmlNodePtr Config_XMLReader::node(void* theNode) /* * Returns named property for a given node as std::string. */ -std::string Config_XMLReader::getProperty(xmlNodePtr theNode, const char* name) +std::string Config_XMLReader::getProperty(xmlNodePtr theNode, const char* theName) { std::string result = ""; - char* aPropChars = (char*) xmlGetProp(theNode, BAD_CAST name); + char* aPropChars = (char*) xmlGetProp(theNode, BAD_CAST theName); if (!aPropChars || aPropChars[0] == 0) return result; result = std::string(aPropChars); return result; } +void Config_XMLReader::processValidator(xmlNodePtr theNode) +{ + Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED); + Events_Loop* aEvLoop = Events_Loop::loop(); + boost::shared_ptr + aMessage(new Config_ValidatorMessage(aValidatoEvent, this)); + std::string aValidatorId; + std::list aValidatorParameters; + getValidatorInfo(theNode, aValidatorId, aValidatorParameters); + aMessage->setValidatorId(aValidatorId); + aMessage->setValidatorParameters(aValidatorParameters); + xmlNodePtr aFeatureOrWdgNode = theNode->parent; + if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) { + aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID)); + } else { + aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID)); + aMessage->setFeatureId(myCurrentFeature); + } + aEvLoop->send(aMessage); +}