Salome HOME
Copyright update 2022
[modules/shaper.git] / src / Config / Config_DataModelReader.h
1 // Copyright (C) 2014-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef CONFIG_DATAMODELREADER_H_
21 #define CONFIG_DATAMODELREADER_H_
22
23 #include <Config_def.h>
24 #include <Config_XMLReader.h>
25
26 #include <vector>
27 #include <string>
28
29 /*!
30  * \class Config_DataModelReader
31  * \ingroup Config
32  * \brief Class that reads data model definition XML for
33  * further processing in the XGUI_DataModel
34  */
35 class Config_DataModelReader : public Config_XMLReader
36 {
37  public:
38   /*!
39    * Constructor
40    */
41   CONFIG_EXPORT Config_DataModelReader();
42   CONFIG_EXPORT virtual ~Config_DataModelReader();
43
44   // ROOT folders propertiues *****************
45   /// Returns name of type of tree items in root
46   CONFIG_EXPORT std::string rootType() const { return myRootTypes; }
47
48   /// Returns number of folders under root
49   CONFIG_EXPORT size_t rootFoldersNumber() const { return myRootFolderNames.size(); }
50
51   /// Returns name of the folder by its Id
52   /// \param theId id of the folder
53   CONFIG_EXPORT std::string rootFolderName(int theId) const { return myRootFolderNames[theId]; }
54
55   /// Returns data type in the folder by its Id
56   /// \param theId id of the folder
57   CONFIG_EXPORT std::string rootFolderType(int theId) const { return myRootFolderTypes[theId]; }
58
59   /// Returns icon of a folder by its Id
60   /// \param theId id of the folder
61   CONFIG_EXPORT std::string rootFolderIcon(int theId) const { return myRootFolderIcons[theId]; }
62
63   /// Returns id of a folder containing the given type
64   /// \param theType type of objects in folder
65   CONFIG_EXPORT int rootFolderId(std::string theType) const;
66
67   /// Returns true if the folder can be shown without items
68   /// \param theId id of the folder
69   CONFIG_EXPORT bool rootShowEmpty(int theId) const { return myRootFolderShowEmpty[theId]; }
70
71   /// Returns list of features attached to folder with name theFolderName in sub-document
72   /// \param theFolderName a name of the folder
73   CONFIG_EXPORT std::string rootFolderFeatures(const std::string& theFolderName) const;
74
75
76   // SUB folders propertiues ********************
77   /// Returns name of type of tree items in sub document
78   CONFIG_EXPORT std::string subType() const { return mySubTypes; }
79
80   /// Returns number of folders under sub document
81   CONFIG_EXPORT size_t subFoldersNumber() const { return mySubFolderNames.size(); }
82
83   /// Returns name of the folder by its Id
84   /// \param theId id of the folder
85   CONFIG_EXPORT std::string subFolderName(int theId) const { return mySubFolderNames[theId]; }
86
87   /// Returns data type in the folder by its Id
88   /// \param theId id of the folder
89   CONFIG_EXPORT std::string subFolderType(int theId) const { return mySubFolderTypes[theId]; }
90
91   /// Returns icon of a folder by its Id
92   /// \param theId id of the folder
93   CONFIG_EXPORT std::string subFolderIcon(int theId) const { return mySubFolderIcons[theId]; }
94
95   /// Returns true if the folder can be shown without items
96   /// \param theId id of the folder
97   CONFIG_EXPORT bool subShowEmpty(int theId) const { return mySubFolderShowEmpty[theId]; }
98
99   /// Returns id of a folder containing the given type
100   /// \param theType type of objects in folder
101   CONFIG_EXPORT int subFolderId(std::string theType) const;
102
103   /// Returns list of features attached to folder with name theFolderName in sub-document
104   /// \param theFolderName a name of the folder
105   CONFIG_EXPORT std::string subFolderFeatures(const std::string& theFolderName) const;
106
107
108   /// Returns true if the sub-document data tree has to be attached to Part Result node
109   /// Otherwise it has to be connected to Part feature node
110   CONFIG_EXPORT bool isAttachToResult() const { return myIsResultLink; }
111
112 protected:
113   /// Overloaded method. Defines how to process each node
114   virtual void processNode(xmlNodePtr theNode);
115
116 private:
117   bool isRootReading;
118
119   /// Root document data
120   std::vector<std::string> myRootFolderNames;
121   std::vector<std::string> myRootFolderTypes;
122   std::vector<std::string> myRootFolderIcons;
123   std::vector<std::string> myRootFeaturesList;
124   std::vector<bool> myRootFolderShowEmpty;
125
126   std::string myRootTypes;
127
128   /// Sub document data
129   std::vector<std::string> mySubFolderNames;
130   std::vector<std::string> mySubFolderTypes;
131   std::vector<std::string> mySubFolderIcons;
132   std::vector<std::string> mySubFeaturesList;
133   std::vector<bool> mySubFolderShowEmpty;
134
135   bool myIsResultLink;
136   std::string mySubTypes;
137 };
138
139
140 #endif