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_Error.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_Error::send("Reading dataModel.xml: wrong folder definition");
34 std::string aIcon = getProperty(theNode, NODE_ICON);
35 std::string aEmpty = getProperty(theNode, SHOW_EMPTY);
36 std::string aFeatures = getProperty(theNode, FOLDER_FEATURES);
37 std::string::iterator aIt;
38 for (aIt = aEmpty.begin(); aIt != aEmpty.end(); aIt++) {
39 (*aIt) = toupper(*aIt);
41 bool aIsEmpty = (aEmpty == "FALSE")? false : true;
44 myRootFolderNames.push_back(aName);
45 myRootFolderTypes.push_back(aGroupType);
46 myRootFolderIcons.push_back(aIcon);
47 myRootFolderShowEmpty.push_back(aIsEmpty);
48 myRootFeaturesList.push_back(aFeatures);
50 mySubFolderNames.push_back(aName);
51 mySubFolderTypes.push_back(aGroupType);
52 mySubFolderIcons.push_back(aIcon);
53 mySubFolderShowEmpty.push_back(aIsEmpty);
54 mySubFeaturesList.push_back(aFeatures);
56 } else if (isNode(theNode, ROOT_DOCUMENT, NULL)) {
58 myRootTypes = getProperty(theNode, GROUP_TYPE);
59 } else if (isNode(theNode, SUB_DOCUMENT, NULL)) {
60 isRootReading = false;
61 mySubTypes = getProperty(theNode, GROUP_TYPE);
62 std::string isResult = getProperty(theNode, LINK_ITEM);
63 std::string::iterator aIt;
64 for (aIt = isResult.begin(); aIt != isResult.end(); aIt++) {
65 (*aIt) = toupper(*aIt);
67 myIsResultLink = (isResult == "TRUE")? true : false;
71 int Config_DataModelReader::rootFolderId(std::string theType) const
73 std::vector<std::string>::const_iterator aIt;
75 for (aIt = myRootFolderTypes.cbegin(), aId = 0; aIt != myRootFolderTypes.cend(); ++aIt, ++aId) {
76 if ((*aIt) == theType)
82 int Config_DataModelReader::subFolderId(std::string theType) const
84 std::vector<std::string>::const_iterator aIt;
86 for (aIt = mySubFolderTypes.cbegin(), aId = 0; aIt != mySubFolderTypes.cend(); ++aIt, ++aId) {
87 if ((*aIt) == theType)
93 std::string getFolderFeatures(const std::string& theFolderName,
94 const std::vector<std::string>& theNames,
95 const std::vector<std::string>& theFeatures)
99 std::vector<std::string>::const_iterator aIt;
100 for(aIt = theNames.cbegin(), aId = 0; aIt != theNames.cend(); ++aIt, ++aId) {
101 if ((*aIt) == theFolderName) {
107 return theFeatures.at(aId);
108 return std::string();
111 std::string Config_DataModelReader::
112 subFolderFeatures(const std::string& theFolderName) const
114 return getFolderFeatures(theFolderName, mySubFolderNames, mySubFeaturesList);
118 std::string Config_DataModelReader::
119 rootFolderFeatures(const std::string& theFolderName) const
121 return getFolderFeatures(theFolderName, myRootFolderNames, myRootFeaturesList);