Salome HOME
d988daa48980d470f9422a733010db99cb807ab7
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study_i.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOMEDS_Study_i.hxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #ifndef __SALOMEDS_STUDY_I_H__
28 #define __SALOMEDS_STUDY_I_H__
29
30 // std C++ headers
31 #include <iostream>
32
33 // IDL headers
34 #include <SALOMEconfig.h>
35 #include CORBA_SERVER_HEADER(SALOME_GenericObj)
36 #include CORBA_SERVER_HEADER(SALOMEDS)
37
38 #include <stdio.h>
39
40 //SALOMEDS headers
41 #include "SALOMEDS_SComponentIterator_i.hxx"
42 #include "SALOMEDS_StudyBuilder_i.hxx"
43 #include "SALOMEDS_SObject_i.hxx"
44 #include "SALOMEDS_UseCaseBuilder_i.hxx"
45
46 #include "SALOMEDSImpl_Study.hxx"
47 #include "SALOMEDSImpl_AttributeIOR.hxx"
48
49 class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study
50 {
51 private:
52   CORBA::ORB_var                 _orb;
53   SALOMEDSImpl_Study*            _impl;  
54   SALOMEDS_StudyBuilder_i*       _builder;    
55   static std::map<SALOMEDSImpl_Study*, SALOMEDS_Study_i*> _mapOfStudies;
56   SALOMEDSImpl_AbstractCallback* _notifier;
57   SALOMEDSImpl_AbstractCallback* _genObjRegister;
58
59 public:
60
61   //! standard constructor
62   SALOMEDS_Study_i(SALOMEDSImpl_Study*, CORBA::ORB_ptr);
63   
64   //! standard destructor
65   virtual ~SALOMEDS_Study_i(); 
66   
67   //! method to Get persistent reference of study (idem URL())
68   /*!
69     \sa URL()
70     \return char* arguments, the persistent reference of the study
71   */  
72   virtual char* GetPersistentReference();
73
74
75   //! method to Get transient reference of study
76   /*!
77     \return char* arguments, the transient reference of the study
78   */  
79   virtual char* GetTransientReference();
80
81   //! method to detect if a study is empty
82   /*!
83     \return bool arguments, true if study is empty
84   */  
85   virtual CORBA::Boolean IsEmpty();
86
87   //! method to Find a Component with ComponentDataType = aComponentName
88   /*!
89     \param aComponentName char* arguments
90     \return SComponent_ptr arguments, the component found
91   */  
92   virtual SALOMEDS::SComponent_ptr FindComponent (const char* aComponentName);
93
94   //! method to Find a Component Find a Component from it's ID
95   /*!
96     \param aComponentID char* arguments
97     \return SComponent_ptr arguments, the component found
98   */  
99   virtual SALOMEDS::SComponent_ptr FindComponentID(const char* aComponentID);
100
101   //! method to  Find an Object with SALOMEDS::Name = anObjectName 
102   /*!
103     \param anObjectName char* arguments
104     \return SObject_ptr arguments, the object found
105   */  
106   virtual SALOMEDS::SObject_ptr FindObject(const char* anObjectName);
107
108
109   //! method to Find Object(s) with SALOMEDS::Name = anObjectName in a component with ComponentDataType = aComponentName
110   /*!
111     \param anObjectName char* arguments
112     \param aComponentName char* arguments
113     \return ListOfSObject_ptr arguments, a list of objects found
114   */  
115   
116   virtual SALOMEDS::Study::ListOfSObject* FindObjectByName( const char* anObjectName, const char* aComponentName ) ;
117   
118   //! method to Find an Object with ID = anObjectID 
119   /*!
120     \param anObjectID char* arguments
121     \return SObject_ptr arguments, the object found
122   */  
123   virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID);
124
125   //! method to Create an Object with ID = anObjectID 
126   /*!
127     \param anObjectID char* arguments
128     \return SObject_ptr arguments, the object found
129   */  
130   virtual SALOMEDS::SObject_ptr CreateObjectID(const char* anObjectID);
131
132   //! method to Find an Object with ID = anObjectIOR 
133   /*!
134     \param anObjectIOR char* arguments
135     \return SObject_ptr arguments, the object found
136   */  
137   virtual SALOMEDS::SObject_ptr FindObjectIOR(const char* anObjectIOR);
138
139   //! method to Find an Object by its path
140   /*!
141     \param thePath char* arguments
142     \return SObject_ptr arguments, the object found
143   */
144   virtual SALOMEDS::SObject_ptr FindObjectByPath(const char* thePath);
145
146   //! method to get a path of SObject
147   /*!
148     \param aSO  SObject_ptr arguments
149     \return char* arguments, the path of the SObject
150   */
151   virtual char* GetObjectPath(CORBA::Object_ptr theObject);
152
153   //! method to set a context: root ('/') is UserData component
154   /*!
155   */
156   virtual void SetContext(const char* thePath);
157
158   //! method to get a context
159   /*!
160   */
161   virtual char* GetContext();  
162
163   //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
164   /*!
165   */
166   virtual SALOMEDS::ListOfStrings* GetObjectNames(const char* theContext);
167
168   //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
169   /*!
170   */
171   virtual SALOMEDS::ListOfStrings* GetDirectoryNames(const char* theContext);
172
173   //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
174   /*!
175   */
176   virtual SALOMEDS::ListOfStrings* GetFileNames(const char* theContext);
177
178   //! method to get all components names
179   /*!
180   */
181   virtual SALOMEDS::ListOfStrings* GetComponentNames(const char* theContext);
182
183   //! method to Create a ChildIterator from an SObject 
184   /*!
185     \param aSO  SObject_ptr arguments
186     \return ChildIterator_ptr arguments, the created ChildIterator
187   */  
188   virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO);
189
190   //! method to Create a SComponentIterator 
191   /*!
192     \return SComponentIterator_ptr arguments, the created SComponentIterator
193   */  
194   virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator();
195
196   //! method to Create a StudyBuilder
197   /*!
198     \return StudyBuilder_ptr arguments, the created StudyBuilder
199   */  
200   virtual SALOMEDS::StudyBuilder_ptr NewBuilder();
201  
202   //! method to get study name
203   /*!
204     \return char* arguments, the study name
205   */
206   virtual char* Name();
207
208   //! method to set study name
209   /*!
210     \param name char* arguments, the study name
211   */
212   virtual void  Name(const char* name);
213
214   //! method to get if study has been saved
215   /*!
216     \return bool arguments
217   */
218   virtual CORBA::Boolean IsSaved();
219
220  //! method to set if study has been saved
221   /*!
222     \param save bool arguments
223   */
224   virtual void  IsSaved(CORBA::Boolean save);
225
226  //! method to Detect if a Study has been modified since it has been saved
227   /*!
228     \return bool arguments
229   */
230   virtual CORBA::Boolean IsModified();
231
232  //! method to set Modified flag of a Study to True
233   virtual void Modified();
234
235   //! method to get URL of the study (idem GetPersistentReference) 
236   /*!
237     \return char* arguments, the study URL 
238   */
239   virtual char* URL();
240
241  //! method to set URL of the study
242   /*!
243     \param url char* arguments, the study URL
244   */
245   virtual void  URL(const char* url);
246
247   virtual CORBA::Short StudyId();
248   virtual void  StudyId(CORBA::Short id);
249
250   static SALOMEDS::Study_ptr GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb);
251   static SALOMEDS_Study_i* GetStudyServant(SALOMEDSImpl_Study*, CORBA::ORB_ptr orb);
252
253   static void IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute);
254
255   virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel);
256   
257   virtual SALOMEDS::Study::ListOfSObject* FindDependances(SALOMEDS::SObject_ptr anObject);
258
259   virtual SALOMEDS::AttributeStudyProperties_ptr GetProperties();
260
261   virtual char* GetLastModificationDate();
262
263   virtual SALOMEDS::ListOfDates* GetModificationsDate();
264
265   virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject) {return _orb->object_to_string(theObject); }
266   virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); };
267
268   virtual SALOMEDS::UseCaseBuilder_ptr GetUseCaseBuilder();
269
270   virtual void Close();
271
272   void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled); 
273
274   // postponed destroying of CORBA object functionality
275   virtual void AddPostponed(const char* theIOR);
276
277   virtual void AddCreatedPostponed(const char* theIOR);
278
279 #ifndef WIN32
280   virtual void RemovePostponed(const CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
281                                                         // if theUndoLimit==0, removes all
282   virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects,
283                                                 // theWay = -1: get back to the list of postponed
284 #else
285   virtual void RemovePostponed(CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
286                                                         // if theUndoLimit==0, removes all
287   virtual void UndoPostponed(CORBA::Long theWay); // theWay = 1: resurrect objects,
288                                                 // theWay = -1: get back to the list of postponed
289 #endif
290
291   virtual SALOMEDS::AttributeParameter_ptr GetCommonParameters(const char* theID, CORBA::Long theSavePoint);
292   virtual SALOMEDS::AttributeParameter_ptr GetModuleParameters(const char* theID, 
293                                                                const char* theModuleName, 
294                                                                CORBA::Long theSavePoint);
295
296   virtual void SetStudyLock(const char* theLockerID);
297
298   virtual bool IsStudyLocked();
299
300   virtual void UnLockStudy(const char* theLockerID);
301
302   virtual SALOMEDS::ListOfStrings* GetLockerID();
303
304   virtual void SetReal(const char* theVarName, CORBA::Double theValue);
305   
306   virtual void SetInteger(const char* theVarName, CORBA::Long theValue);
307
308   virtual void SetBoolean(const char* theVarName, CORBA::Boolean theValue);
309
310   virtual void SetString(const char* theVarName, const char* theValue);
311
312   virtual void SetStringAsDouble(const char* theVarName, CORBA::Double theValue);
313
314   virtual CORBA::Double GetReal(const char* theVarName);
315   
316   virtual CORBA::Long GetInteger(const char* theVarName);
317
318   virtual CORBA::Boolean GetBoolean(const char* theVarName);
319
320   virtual char* GetString(const char* theVarName);
321
322   virtual CORBA::Boolean IsReal(const char* theVarName);
323   
324   virtual CORBA::Boolean IsInteger(const char* theVarName);
325
326   virtual CORBA::Boolean IsBoolean(const char* theVarName);
327
328   virtual CORBA::Boolean IsString(const char* theVarName);
329
330   virtual CORBA::Boolean IsVariable(const char* theVarName);
331
332   virtual SALOMEDS::ListOfStrings* GetVariableNames();
333
334   virtual CORBA::Boolean RemoveVariable(const char* theVarName);
335
336   virtual CORBA::Boolean RenameVariable(const char* theVarName, const char* theNewVarName);
337
338   virtual CORBA::Boolean IsVariableUsed(const char* theVarName);
339   
340   virtual SALOMEDS::ListOfListOfStrings* ParseVariables(const char* theVars);
341
342   virtual char* GetDefaultScript(const char* theModuleName, const char* theShift);
343
344   virtual CORBA::Boolean DumpStudy(const char* thePath,
345                                    const char* theBaseName,
346                                    CORBA::Boolean isPublished,
347                                    CORBA::Boolean isMultiFile);
348
349   virtual SALOMEDSImpl_Study* GetImpl() { return _impl; }
350
351   virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
352
353   virtual void attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify);
354   virtual void detach(SALOMEDS::Observer_ptr theObs);
355 };
356 #endif