Salome HOME
Roll back the modification, not yet approved
[modules/shaper.git] / src / Config / Config_DataModelReader.cpp
index 5479a98e16fb9a65cccd39a6b871f51c2b65cc7d..e9113e85e9bb99c1058a6f122b578814714d8b61 100644 (file)
@@ -15,7 +15,7 @@
 
 
 Config_DataModelReader::Config_DataModelReader()
-    : Config_XMLReader(DATAMODEL_FILE)
+    : Config_XMLReader(DATAMODEL_FILE), isRootReading(true), myIsResultLink(false)
 {
 }
 
@@ -31,10 +31,58 @@ void Config_DataModelReader::processNode(xmlNodePtr theNode)
     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)) {
+    std::string aIcon = getProperty(theNode, NODE_ICON);
+    std::string aEmpty = getProperty(theNode, SHOW_EMPTY);
+    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);
+   } else {
+      mySubFolderNames.push_back(aName);
+      mySubFolderTypes.push_back(aGroupType);
+      mySubFolderIcons.push_back(aIcon);
+      mySubFolderShowEmpty.push_back(aIsEmpty);
+   }
+  } 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<std::string>::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<std::string>::const_iterator aIt;
+  int aId;
+  for (aIt = mySubFolderTypes.cbegin(), aId = 0; aIt != mySubFolderTypes.cend(); ++aIt, ++aId) {
+    if ((*aIt) == theType)
+      return aId;
   }
+  return -1;
 }