X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_DataModelReader.cpp;h=20e8203508c9ec8f034260b970241df8f9c70dc5;hb=bdbfb368d71ed11cc0391354a7d86c880cd94949;hp=5479a98e16fb9a65cccd39a6b871f51c2b65cc7d;hpb=3e3fc52de000b4d8e51fdcffe7f72f82237833ad;p=modules%2Fshaper.git diff --git a/src/Config/Config_DataModelReader.cpp b/src/Config/Config_DataModelReader.cpp index 5479a98e1..20e820350 100644 --- a/src/Config/Config_DataModelReader.cpp +++ b/src/Config/Config_DataModelReader.cpp @@ -11,11 +11,11 @@ #include #include "Config_Common.h" -#include +#include Config_DataModelReader::Config_DataModelReader() - : Config_XMLReader(DATAMODEL_FILE) + : Config_XMLReader(DATAMODEL_FILE), isRootReading(true), myIsResultLink(false) { } @@ -29,12 +29,96 @@ void Config_DataModelReader::processNode(xmlNodePtr theNode) std::string aName = getProperty(theNode, FOLDER_NAME); std::string aGroupType = getProperty(theNode, GROUP_TYPE); if (aName.empty() || aGroupType.empty()) - Events_Error::send("Reading dataModel.xml: wrong folder definition"); - - myRootFolderNames.push_back(aName); - myRootFolderTypes.push_back(aGroupType); - myRootFolderIcons.push_back(getProperty(theNode, NODE_ICON)); - } else if (isNode(theNode, ROOT_NODE, NULL)) { + Events_InfoMessage("Config_DataModelReader", + "Reading dataModel.xml: wrong folder definition.").send(); + + std::string aIcon = getProperty(theNode, NODE_ICON); + std::string aEmpty = getProperty(theNode, SHOW_EMPTY); + std::string aFeatures = getProperty(theNode, FOLDER_FEATURES); + std::string::iterator aIt; + for (aIt = aEmpty.begin(); aIt != aEmpty.end(); aIt++) { + (*aIt) = toupper(*aIt); + } + bool aIsEmpty = (aEmpty == "FALSE")? false : true; + + if (isRootReading) { + myRootFolderNames.push_back(aName); + myRootFolderTypes.push_back(aGroupType); + myRootFolderIcons.push_back(aIcon); + myRootFolderShowEmpty.push_back(aIsEmpty); + myRootFeaturesList.push_back(aFeatures); + } else { + mySubFolderNames.push_back(aName); + mySubFolderTypes.push_back(aGroupType); + mySubFolderIcons.push_back(aIcon); + mySubFolderShowEmpty.push_back(aIsEmpty); + mySubFeaturesList.push_back(aFeatures); + } + } else if (isNode(theNode, ROOT_DOCUMENT, NULL)) { + isRootReading = true; myRootTypes = getProperty(theNode, GROUP_TYPE); + } else if (isNode(theNode, SUB_DOCUMENT, NULL)) { + isRootReading = false; + mySubTypes = getProperty(theNode, GROUP_TYPE); + std::string isResult = getProperty(theNode, LINK_ITEM); + std::string::iterator aIt; + for (aIt = isResult.begin(); aIt != isResult.end(); aIt++) { + (*aIt) = toupper(*aIt); + } + myIsResultLink = (isResult == "TRUE")? true : false; + } +} + +int Config_DataModelReader::rootFolderId(std::string theType) const +{ + std::vector::const_iterator aIt; + int aId; + for (aIt = myRootFolderTypes.cbegin(), aId = 0; aIt != myRootFolderTypes.cend(); ++aIt, ++aId) { + if ((*aIt) == theType) + return aId; + } + return -1; +} + +int Config_DataModelReader::subFolderId(std::string theType) const +{ + std::vector::const_iterator aIt; + int aId; + for (aIt = mySubFolderTypes.cbegin(), aId = 0; aIt != mySubFolderTypes.cend(); ++aIt, ++aId) { + if ((*aIt) == theType) + return aId; + } + return -1; +} + +std::string getFolderFeatures(const std::string& theFolderName, + const std::vector& theNames, + const std::vector& theFeatures) +{ + int aId; + bool aFound = false; + std::vector::const_iterator aIt; + for(aIt = theNames.cbegin(), aId = 0; aIt != theNames.cend(); ++aIt, ++aId) { + if ((*aIt) == theFolderName) { + aFound = true; + break; + } } + if (aFound) + return theFeatures.at(aId); + return std::string(); +} + +std::string Config_DataModelReader:: + subFolderFeatures(const std::string& theFolderName) const +{ + return getFolderFeatures(theFolderName, mySubFolderNames, mySubFeaturesList); } + + +std::string Config_DataModelReader:: + rootFolderFeatures(const std::string& theFolderName) const +{ + return getFolderFeatures(theFolderName, myRootFolderNames, myRootFeaturesList); +} +