Salome HOME
Removed includes and libraries of OCC
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_Study.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_Study.hxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #ifndef __SALOMEDSIMPL_STUDY_I_H__
25 #define __SALOMEDSIMPL_STUDY_I_H__
26
27 // std C++ headers
28 #include <iostream>
29 #include <string>
30 #include <vector>
31 #include <map>
32
33 // Cascade headers
34 #include "DF_Document.hxx"
35 #include "DF_Label.hxx"
36 #include <stdio.h>
37
38 //SALOMEDSImpl headers
39 #include "SALOMEDSImpl_SComponentIterator.hxx"
40 #include "SALOMEDSImpl_SObject.hxx"
41 #include "SALOMEDSImpl_StudyBuilder.hxx"
42 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
43 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
44 #include "SALOMEDSImpl_AttributeIOR.hxx"
45 #include "SALOMEDSImpl_AttributeParameter.hxx"
46 #include "SALOMEDSImpl_Callback.hxx"
47 #include "SALOMEDSImpl_Driver.hxx" 
48 #include "SALOMEDSImpl_ChildIterator.hxx" 
49
50 class SALOMEDSImpl_StudyManager;
51 class SALOMEDSImpl_GenericAttribute;
52
53
54 class SALOMEDSImpl_Study
55 {
56 private:
57   std::string              _name;  
58   DF_Document*             _doc;  // Document
59   bool                     _Saved; // True if the Study is saved
60   std::string              _URL; //URL of the persistent reference of the study
61   int                      _StudyId; 
62   DF_Label                 _current;
63   bool                     _autoFill; 
64   std::string              _errorCode;
65   std::vector<std::string> _lockers;
66   SALOMEDSImpl_Callback*   _cb;
67   SALOMEDSImpl_StudyBuilder*   _builder;
68   SALOMEDSImpl_UseCaseBuilder* _useCaseBuilder;
69
70   std::map<std::string, SALOMEDSImpl_SObject> _mapOfSO;
71   std::map<std::string, SALOMEDSImpl_SComponent> _mapOfSCO;
72   std::map<std::string, DF_Label> myIORLabels;
73  
74
75   SALOMEDSImpl_SObject   _FindObject(const SALOMEDSImpl_SObject& SO,
76                               const std::string& anObjectName,
77                               bool& _find);
78                                        
79   SALOMEDSImpl_SObject   _FindObjectIOR(const SALOMEDSImpl_SObject& SO,
80                                  const std::string& anObjectIOR,
81                                  bool& _find);
82
83 public:
84
85   Standard_EXPORT static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel);
86   Standard_EXPORT static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel);
87   Standard_EXPORT static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel);
88   Standard_EXPORT static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute);
89
90   //! standard constructor
91   Standard_EXPORT SALOMEDSImpl_Study(const DF_Document*, const std::string& study_name);
92   
93   //! standard destructor
94   Standard_EXPORT virtual ~SALOMEDSImpl_Study(); 
95   
96   //! method to Get persistent reference of study (idem URL())
97   Standard_EXPORT virtual std::string GetPersistentReference();
98
99   //! method to Get transient reference of study
100   Standard_EXPORT virtual std::string GetTransientReference();
101
102   Standard_EXPORT virtual void SetTransientReference(const std::string& theIOR);
103
104   //! method to detect if a study is empty
105   Standard_EXPORT virtual bool IsEmpty();
106
107   //! method to Find a Component with ComponentDataType = aComponentName
108   Standard_EXPORT virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName);
109
110   //! method to Find a Component Find a Component from it's ID
111   Standard_EXPORT virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID);
112
113   //! method to  Find an Object with SALOMEDSImpl::Name = anObjectName 
114   Standard_EXPORT virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName);
115
116
117   //! method to Find Object(s) with SALOMEDSImpl::Name=anObjectName in a component with ComponentDataType = aComponentName
118   Standard_EXPORT virtual std::vector<SALOMEDSImpl_SObject> FindObjectByName( const std::string& anObjectName, 
119                                                                        const std::string& aComponentName ) ;
120   
121   //! method to Find an Object with ID = anObjectID 
122   Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID);
123
124   //! method to Create an Object with ID = anObjectID 
125   Standard_EXPORT virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID);
126
127   //! method to Find an Object with ID = anObjectIOR 
128   Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR);
129
130   //! method to Find an Object by its path
131   Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath);
132
133   //! method to get a path of SObject
134   Standard_EXPORT virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject);
135
136   Standard_EXPORT std::string GetObjectPathByIOR(const std::string& theIOR);
137
138   //! method to set a context: root ('/') is UserData component
139   Standard_EXPORT virtual bool SetContext(const std::string& thePath);
140
141   //! method to get a context
142   Standard_EXPORT virtual std::string GetContext();  
143
144   //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
145   Standard_EXPORT virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
146
147   //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
148   Standard_EXPORT virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
149
150   //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
151   Standard_EXPORT virtual std::vector<std::string> GetFileNames(const std::string& theContext);
152
153   //! method to get all components names
154   Standard_EXPORT virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
155
156   //! method to Create a ChildIterator from an SObject 
157   Standard_EXPORT virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO);
158
159   //! method to Create a SComponentIterator 
160   Standard_EXPORT virtual SALOMEDSImpl_SComponentIterator NewComponentIterator();
161
162   //! method to Create a StudyBuilder
163   Standard_EXPORT virtual SALOMEDSImpl_StudyBuilder* NewBuilder();
164  
165   //! method to get study name
166   Standard_EXPORT virtual std::string Name();
167
168   //! method to set study name
169   Standard_EXPORT virtual void  Name(const std::string& name);
170
171   //! method to get if study has been saved
172   Standard_EXPORT virtual bool IsSaved();
173
174   //! method to set if study has been saved
175   Standard_EXPORT virtual void  IsSaved(bool save);
176
177   //! method to Detect if a Study has been modified since it has been saved
178   Standard_EXPORT virtual bool IsModified();
179
180   //! method to get URL of the study (idem GetPersistentReference) 
181   Standard_EXPORT virtual std::string URL();
182
183   //! method to set URL of the study
184   Standard_EXPORT virtual void  URL(const std::string& url);
185
186   Standard_EXPORT virtual bool IsLocked();
187
188   Standard_EXPORT virtual int StudyId();
189
190   Standard_EXPORT virtual void  StudyId(int id);
191
192   Standard_EXPORT virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel);
193   
194   Standard_EXPORT virtual std::vector<SALOMEDSImpl_SObject> FindDependances(const SALOMEDSImpl_SObject& anObject);
195
196   Standard_EXPORT virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties();
197
198   Standard_EXPORT virtual std::string GetLastModificationDate();
199
200   Standard_EXPORT virtual std::vector<std::string> GetModificationsDate();
201
202   Standard_EXPORT virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder();
203
204   Standard_EXPORT virtual void Close();
205
206   Standard_EXPORT void EnableUseCaseAutoFilling(bool isEnabled);
207
208   Standard_EXPORT virtual std::string GetErrorCode() { return _errorCode; }
209   Standard_EXPORT virtual bool IsError() { return _errorCode != ""; }
210
211   Standard_EXPORT virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry);
212   Standard_EXPORT virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel);
213   Standard_EXPORT virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry);
214   Standard_EXPORT virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel);
215   Standard_EXPORT virtual DF_Attribute* GetAttribute(const std::string& theEntry, 
216                                                      const std::string& theType);
217
218   Standard_EXPORT virtual bool HasCurrentContext() { return !_current.IsNull(); }
219
220   Standard_EXPORT virtual bool DumpStudy(const std::string& thePath, 
221                                          const std::string& theBaseName, 
222                                          bool isPublished,
223                                          SALOMEDSImpl_DriverFactory* theFactory);
224
225   Standard_EXPORT static std::string GetDumpStudyComment(const char* theComponentName = 0);
226
227   Standard_EXPORT virtual DF_Document* GetDocument() { return _doc; } 
228
229   //The method dump creates a txt file that contain a dump of the study, for debug use
230   Standard_EXPORT void dump(const std::string& theFileName);
231
232   //This method marks the study as being modified
233   Standard_EXPORT void Modify();
234
235   Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint);
236
237   Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID, 
238                                                                               const char* theModuleName,
239                                                                               int theSavePoint);
240
241   //Locks the study, theLockerID is identificator of the of the one who locked the study for ex. IOR
242   Standard_EXPORT void SetStudyLock(const char* theLockerID);
243
244   //Returns True if the study is locked
245   Standard_EXPORT bool IsStudyLocked();
246
247   //Unlocks the study
248   Standard_EXPORT void UnLockStudy(const char* theLockerID);
249   
250   //Returns an ID of the study locker
251   Standard_EXPORT std::vector<std::string> GetLockerID();
252
253   //Returns a callback 
254   Standard_EXPORT SALOMEDSImpl_Callback* GetCallback() { return _cb; }
255
256   //Returns a list of IOR's stored in the study
257   Standard_EXPORT std::vector<std::string> GetIORs();
258
259
260 friend class SALOMEDSImpl_StudyManager;    
261 friend class SALOMEDSImpl_GenericAttribute;
262 };
263 #endif