Salome HOME
d17f54eaeef01d6dc12b30890fc57c9af9e38015
[modules/shaper.git] / 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    * \param theXmlFile - full path to the xml file which will be processed by the reader
31    */
32   CONFIG_EXPORT Config_DataModelReader();
33   CONFIG_EXPORT virtual ~Config_DataModelReader();
34
35   // ROOT folders propertiues *****************
36   /// Returns name of type of tree items in root
37   CONFIG_EXPORT std::string rootType() const { return myRootTypes; }
38
39   /// Returns number of folders under root 
40   CONFIG_EXPORT int rootFoldersNumber() const { return myRootFolderNames.size(); }
41
42   /// Returns name of the folder by its Id
43   /// \param theId id of the folder
44   CONFIG_EXPORT std::string rootFolderName(int theId) const { return myRootFolderNames[theId]; }
45
46   /// Returns data type in the folder by its Id
47   /// \param theId id of the folder
48   CONFIG_EXPORT std::string rootFolderType(int theId) const { return myRootFolderTypes[theId]; }
49
50   /// Returns icon of a folder by its Id
51   /// \param theId id of the folder
52   CONFIG_EXPORT std::string rootFolderIcon(int theId) const { return myRootFolderIcons[theId]; }
53
54   /// Returns id of a folder containing the given type
55   /// \param theType type of objects in folder
56   CONFIG_EXPORT int rootFolderId(std::string theType) const;
57
58   /// Returns true if the folder can be shown without items
59   /// \param theId id of the folder
60   CONFIG_EXPORT bool rootShowEmpty(int theId) const { return myRootFolderShowEmpty[theId]; }
61
62
63
64   // SUB folders propertiues ********************
65   /// Returns name of type of tree items in sub document
66   CONFIG_EXPORT std::string subType() const { return mySubTypes; }
67
68   /// Returns number of folders under sub document 
69   CONFIG_EXPORT int subFoldersNumber() const { return mySubFolderNames.size(); }
70
71   /// Returns name of the folder by its Id
72   /// \param theId id of the folder
73   CONFIG_EXPORT std::string subFolderName(int theId) const { return mySubFolderNames[theId]; }
74
75   /// Returns data type in the folder by its Id
76   /// \param theId id of the folder
77   CONFIG_EXPORT std::string subFolderType(int theId) const { return mySubFolderTypes[theId]; }
78
79   /// Returns icon of a folder by its Id
80   /// \param theId id of the folder
81   CONFIG_EXPORT std::string subFolderIcon(int theId) const { return mySubFolderIcons[theId]; }
82
83   /// Returns true if the folder can be shown without items
84   /// \param theId id of the folder
85   CONFIG_EXPORT bool subShowEmpty(int theId) const { return mySubFolderShowEmpty[theId]; }
86
87   /// Returns id of a folder containing the given type
88   /// \param theType type of objects in folder
89   CONFIG_EXPORT int subFolderId(std::string theType) const;
90
91   /// Returns true if the sub-document data tree has to be attached to Part Result node
92   /// Otherwise it has to be connected to Part feature node
93   CONFIG_EXPORT bool isAttachToResult() const { return myIsResultLink; }
94
95 protected:
96   /// Overloaded method. Defines how to process each node
97   virtual void processNode(xmlNodePtr theNode);
98
99 private:
100   bool isRootReading;
101
102   /// Root document data
103   std::vector<std::string> myRootFolderNames;
104   std::vector<std::string> myRootFolderTypes;
105   std::vector<std::string> myRootFolderIcons;
106   std::vector<bool> myRootFolderShowEmpty;
107
108   std::string myRootTypes;
109
110   /// Sub document data
111   std::vector<std::string> mySubFolderNames;
112   std::vector<std::string> mySubFolderTypes;
113   std::vector<std::string> mySubFolderIcons;
114   std::vector<bool> mySubFolderShowEmpty;
115
116   bool myIsResultLink;
117   std::string mySubTypes;
118 };
119
120
121 #endif