Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / Config / Config_DataModelReader.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef CONFIG_DATAMODELREADER_H_
22 #define CONFIG_DATAMODELREADER_H_
23
24 #include <Config_def.h>
25 #include <Config_XMLReader.h>
26
27 #include <vector>
28 #include <string>
29
30 /*!
31  * \class Config_DataModelReader
32  * \ingroup Config
33  * \brief Class that reads data model definition XML for
34  * further processing in the XGUI_DataModel
35  */
36 class Config_DataModelReader : public Config_XMLReader
37 {
38  public:
39   /*!
40    * Constructor
41    */
42   CONFIG_EXPORT Config_DataModelReader();
43   CONFIG_EXPORT virtual ~Config_DataModelReader();
44
45   // ROOT folders propertiues *****************
46   /// Returns name of type of tree items in root
47   CONFIG_EXPORT std::string rootType() const { return myRootTypes; }
48
49   /// Returns number of folders under root
50   CONFIG_EXPORT size_t rootFoldersNumber() const { return myRootFolderNames.size(); }
51
52   /// Returns name of the folder by its Id
53   /// \param theId id of the folder
54   CONFIG_EXPORT std::string rootFolderName(int theId) const { return myRootFolderNames[theId]; }
55
56   /// Returns data type in the folder by its Id
57   /// \param theId id of the folder
58   CONFIG_EXPORT std::string rootFolderType(int theId) const { return myRootFolderTypes[theId]; }
59
60   /// Returns icon of a folder by its Id
61   /// \param theId id of the folder
62   CONFIG_EXPORT std::string rootFolderIcon(int theId) const { return myRootFolderIcons[theId]; }
63
64   /// Returns id of a folder containing the given type
65   /// \param theType type of objects in folder
66   CONFIG_EXPORT int rootFolderId(std::string theType) const;
67
68   /// Returns true if the folder can be shown without items
69   /// \param theId id of the folder
70   CONFIG_EXPORT bool rootShowEmpty(int theId) const { return myRootFolderShowEmpty[theId]; }
71
72   /// Returns list of features attached to folder with name theFolderName in sub-document
73   /// \param theFolderName a name of the folder
74   CONFIG_EXPORT std::string rootFolderFeatures(const std::string& theFolderName) const;
75
76
77   // SUB folders propertiues ********************
78   /// Returns name of type of tree items in sub document
79   CONFIG_EXPORT std::string subType() const { return mySubTypes; }
80
81   /// Returns number of folders under sub document
82   CONFIG_EXPORT size_t subFoldersNumber() const { return mySubFolderNames.size(); }
83
84   /// Returns name of the folder by its Id
85   /// \param theId id of the folder
86   CONFIG_EXPORT std::string subFolderName(int theId) const { return mySubFolderNames[theId]; }
87
88   /// Returns data type in the folder by its Id
89   /// \param theId id of the folder
90   CONFIG_EXPORT std::string subFolderType(int theId) const { return mySubFolderTypes[theId]; }
91
92   /// Returns icon of a folder by its Id
93   /// \param theId id of the folder
94   CONFIG_EXPORT std::string subFolderIcon(int theId) const { return mySubFolderIcons[theId]; }
95
96   /// Returns true if the folder can be shown without items
97   /// \param theId id of the folder
98   CONFIG_EXPORT bool subShowEmpty(int theId) const { return mySubFolderShowEmpty[theId]; }
99
100   /// Returns id of a folder containing the given type
101   /// \param theType type of objects in folder
102   CONFIG_EXPORT int subFolderId(std::string theType) const;
103
104   /// Returns list of features attached to folder with name theFolderName in sub-document
105   /// \param theFolderName a name of the folder
106   CONFIG_EXPORT std::string subFolderFeatures(const std::string& theFolderName) const;
107
108
109   /// Returns true if the sub-document data tree has to be attached to Part Result node
110   /// Otherwise it has to be connected to Part feature node
111   CONFIG_EXPORT bool isAttachToResult() const { return myIsResultLink; }
112
113 protected:
114   /// Overloaded method. Defines how to process each node
115   virtual void processNode(xmlNodePtr theNode);
116
117 private:
118   bool isRootReading;
119
120   /// Root document data
121   std::vector<std::string> myRootFolderNames;
122   std::vector<std::string> myRootFolderTypes;
123   std::vector<std::string> myRootFolderIcons;
124   std::vector<std::string> myRootFeaturesList;
125   std::vector<bool> myRootFolderShowEmpty;
126
127   std::string myRootTypes;
128
129   /// Sub document data
130   std::vector<std::string> mySubFolderNames;
131   std::vector<std::string> mySubFolderTypes;
132   std::vector<std::string> mySubFolderIcons;
133   std::vector<std::string> mySubFeaturesList;
134   std::vector<bool> mySubFolderShowEmpty;
135
136   bool myIsResultLink;
137   std::string mySubTypes;
138 };
139
140
141 #endif