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