1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * Config_DataModelReader.cpp
6 * Created on: Jul 21, 2015
10 #include "Config_DataModelReader.h"
11 #include <Config_Keywords.h>
12 #include "Config_Common.h"
14 #include <Events_InfoMessage.h>
17 Config_DataModelReader::Config_DataModelReader()
18 : Config_XMLReader(DATAMODEL_FILE), isRootReading(true), myIsResultLink(false)
22 Config_DataModelReader::~Config_DataModelReader()
26 void Config_DataModelReader::processNode(xmlNodePtr theNode)
28 if (isNode(theNode, NODE_FOLDER, NULL)) {
29 std::string aName = getProperty(theNode, FOLDER_NAME);
30 std::string aGroupType = getProperty(theNode, GROUP_TYPE);
31 if (aName.empty() || aGroupType.empty())
32 Events_InfoMessage("Config_DataModelReader",
33 "Reading dataModel.xml: wrong folder definition.").send();
35 std::string aIcon = getProperty(theNode, NODE_ICON);
36 std::string aEmpty = getProperty(theNode, SHOW_EMPTY);
37 std::string aFeatures = getProperty(theNode, FOLDER_FEATURES);
38 std::string::iterator aIt;
39 for (aIt = aEmpty.begin(); aIt != aEmpty.end(); aIt++) {
40 (*aIt) = toupper(*aIt);
42 bool aIsEmpty = (aEmpty == "FALSE")? false : true;
45 myRootFolderNames.push_back(aName);
46 myRootFolderTypes.push_back(aGroupType);
47 myRootFolderIcons.push_back(aIcon);
48 myRootFolderShowEmpty.push_back(aIsEmpty);
49 myRootFeaturesList.push_back(aFeatures);
51 mySubFolderNames.push_back(aName);
52 mySubFolderTypes.push_back(aGroupType);
53 mySubFolderIcons.push_back(aIcon);
54 mySubFolderShowEmpty.push_back(aIsEmpty);
55 mySubFeaturesList.push_back(aFeatures);
57 } else if (isNode(theNode, ROOT_DOCUMENT, NULL)) {
59 myRootTypes = getProperty(theNode, GROUP_TYPE);
60 } else if (isNode(theNode, SUB_DOCUMENT, NULL)) {
61 isRootReading = false;
62 mySubTypes = getProperty(theNode, GROUP_TYPE);
63 std::string isResult = getProperty(theNode, LINK_ITEM);
64 std::string::iterator aIt;
65 for (aIt = isResult.begin(); aIt != isResult.end(); aIt++) {
66 (*aIt) = toupper(*aIt);
68 myIsResultLink = (isResult == "TRUE")? true : false;
72 int Config_DataModelReader::rootFolderId(std::string theType) const
74 std::vector<std::string>::const_iterator aIt;
76 for (aIt = myRootFolderTypes.cbegin(), aId = 0; aIt != myRootFolderTypes.cend(); ++aIt, ++aId) {
77 if ((*aIt) == theType)
83 int Config_DataModelReader::subFolderId(std::string theType) const
85 std::vector<std::string>::const_iterator aIt;
87 for (aIt = mySubFolderTypes.cbegin(), aId = 0; aIt != mySubFolderTypes.cend(); ++aIt, ++aId) {
88 if ((*aIt) == theType)
94 std::string getFolderFeatures(const std::string& theFolderName,
95 const std::vector<std::string>& theNames,
96 const std::vector<std::string>& theFeatures)
100 std::vector<std::string>::const_iterator aIt;
101 for(aIt = theNames.cbegin(), aId = 0; aIt != theNames.cend(); ++aIt, ++aId) {
102 if ((*aIt) == theFolderName) {
108 return theFeatures.at(aId);
109 return std::string();
112 std::string Config_DataModelReader::
113 subFolderFeatures(const std::string& theFolderName) const
115 return getFolderFeatures(theFolderName, mySubFolderNames, mySubFeaturesList);
119 std::string Config_DataModelReader::
120 rootFolderFeatures(const std::string& theFolderName) const
122 return getFolderFeatures(theFolderName, myRootFolderNames, myRootFeaturesList);