Salome HOME
bfa702ddd73f1d4bb47c7bff64e986d3db394780
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study_i.hxx
1 // Copyright (C) 2007-2016  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 #include "SALOMEDS_Driver_i.hxx"
46
47 #include "SALOMEDSImpl_Study.hxx"
48 #include "SALOMEDSImpl_AttributeIOR.hxx"
49
50 class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study
51 {
52 private:
53   CORBA::ORB_var                 _orb;
54   SALOMEDSImpl_Study*            _impl;  
55   SALOMEDS_StudyBuilder_i*       _builder;    
56   SALOMEDSImpl_AbstractCallback* _notifier;
57   SALOMEDS_DriverFactory_i*      _factory;
58   bool                           _closed;
59
60 public:
61
62   //! standard constructor
63   SALOMEDS_Study_i(CORBA::ORB_ptr);
64   
65   //! standard destructor
66   virtual ~SALOMEDS_Study_i();
67   
68   virtual void Init();
69   virtual void Clear();
70
71   //! method to Open a Study
72   /*!
73     \param char* arguments, the study URL
74     \return Study_ptr arguments
75   */
76   virtual bool Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception);
77
78   //! method to save a Study
79   virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile);
80   virtual CORBA::Boolean SaveASCII(CORBA::Boolean theMultiFile);
81
82   //! method to save a Study to the persistent reference aUrl
83   /*!
84     \param char* arguments, the new URL of the study
85   */
86   virtual CORBA::Boolean SaveAs(const char* aUrl, CORBA::Boolean theMultiFile);
87   virtual CORBA::Boolean SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile);
88
89   //! method to copy the object
90   /*!
91     \param theObject object to copy
92   */
93   virtual CORBA::Boolean Copy(SALOMEDS::SObject_ptr theObject);
94   virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
95   //! method to paste the object in study
96   /*!
97     \param theObject object to paste
98   */
99   virtual SALOMEDS::SObject_ptr Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection);
100   virtual CORBA::Boolean CanPaste(SALOMEDS::SObject_ptr theObject);
101
102   //! method to Get persistent reference of study (idem URL())
103   /*!
104     \sa URL()
105     \return char* arguments, the persistent reference of the study
106   */  
107   virtual char* GetPersistentReference();
108
109
110   //! method to Get transient reference of study
111   /*!
112     \return char* arguments, the transient reference of the study
113   */  
114   virtual char* GetTransientReference();
115
116   //! method to detect if a study is empty
117   /*!
118     \return bool arguments, true if study is empty
119   */  
120   virtual CORBA::Boolean IsEmpty();
121
122   //! method to Find a Component with ComponentDataType = aComponentName
123   /*!
124     \param aComponentName char* arguments
125     \return SComponent_ptr arguments, the component found
126   */  
127   virtual SALOMEDS::SComponent_ptr FindComponent (const char* aComponentName);
128
129   //! method to Find a Component Find a Component from it's ID
130   /*!
131     \param aComponentID char* arguments
132     \return SComponent_ptr arguments, the component found
133   */  
134   virtual SALOMEDS::SComponent_ptr FindComponentID(const char* aComponentID);
135
136   //! method to  Find an Object with SALOMEDS::Name = anObjectName 
137   /*!
138     \param anObjectName char* arguments
139     \return SObject_ptr arguments, the object found
140   */  
141   virtual SALOMEDS::SObject_ptr FindObject(const char* anObjectName);
142
143
144   //! method to Find Object(s) with SALOMEDS::Name = anObjectName in a component with ComponentDataType = aComponentName
145   /*!
146     \param anObjectName char* arguments
147     \param aComponentName char* arguments
148     \return ListOfSObject_ptr arguments, a list of objects found
149   */  
150   
151   virtual SALOMEDS::Study::ListOfSObject* FindObjectByName( const char* anObjectName, const char* aComponentName ) ;
152   
153   //! method to Find an Object with ID = anObjectID 
154   /*!
155     \param anObjectID char* arguments
156     \return SObject_ptr arguments, the object found
157   */  
158   virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID);
159
160   //! method to Create an Object with ID = anObjectID 
161   /*!
162     \param anObjectID char* arguments
163     \return SObject_ptr arguments, the object found
164   */  
165   virtual SALOMEDS::SObject_ptr CreateObjectID(const char* anObjectID);
166
167   //! method to Find an Object with ID = anObjectIOR 
168   /*!
169     \param anObjectIOR char* arguments
170     \return SObject_ptr arguments, the object found
171   */  
172   virtual SALOMEDS::SObject_ptr FindObjectIOR(const char* anObjectIOR);
173
174   //! method to Find an Object by its path
175   /*!
176     \param thePath char* arguments
177     \return SObject_ptr arguments, the object found
178   */
179   virtual SALOMEDS::SObject_ptr FindObjectByPath(const char* thePath);
180
181   //! method to get a path of SObject
182   /*!
183     \param aSO  SObject_ptr arguments
184     \return char* arguments, the path of the SObject
185   */
186   virtual char* GetObjectPath(CORBA::Object_ptr theObject);
187
188   //! method to set a context: root ('/') is UserData component
189   /*!
190   */
191   virtual void SetContext(const char* thePath);
192
193   //! method to get a context
194   /*!
195   */
196   virtual char* GetContext();  
197
198   //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
199   /*!
200   */
201   virtual SALOMEDS::ListOfStrings* GetObjectNames(const char* theContext);
202
203   //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
204   /*!
205   */
206   virtual SALOMEDS::ListOfStrings* GetDirectoryNames(const char* theContext);
207
208   //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
209   /*!
210   */
211   virtual SALOMEDS::ListOfStrings* GetFileNames(const char* theContext);
212
213   //! method to get all components names
214   /*!
215   */
216   virtual SALOMEDS::ListOfStrings* GetComponentNames(const char* theContext);
217
218   //! method to Create a ChildIterator from an SObject 
219   /*!
220     \param aSO  SObject_ptr arguments
221     \return ChildIterator_ptr arguments, the created ChildIterator
222   */  
223   virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO);
224
225   //! method to Create a SComponentIterator 
226   /*!
227     \return SComponentIterator_ptr arguments, the created SComponentIterator
228   */  
229   virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator();
230
231   //! method to Create a StudyBuilder
232   /*!
233     \return StudyBuilder_ptr arguments, the created StudyBuilder
234   */  
235   virtual SALOMEDS::StudyBuilder_ptr NewBuilder();
236  
237   //! method to get study name
238   /*!
239     \return char* arguments, the study name
240   */
241   virtual char* Name();
242
243   //! method to get if study has been saved
244   /*!
245     \return bool arguments
246   */
247   virtual CORBA::Boolean IsSaved();
248
249  //! method to set if study has been saved
250   /*!
251     \param save bool arguments
252   */
253   virtual void  IsSaved(CORBA::Boolean save);
254
255  //! method to Detect if a Study has been modified since it has been saved
256   /*!
257     \return bool arguments
258   */
259   virtual CORBA::Boolean IsModified();
260
261  //! method to set Modified flag of a Study to True
262   virtual void Modified();
263
264   //! method to get URL of the study (idem GetPersistentReference) 
265   /*!
266     \return char* arguments, the study URL 
267   */
268   virtual char* URL();
269
270  //! method to set URL of the study
271   /*!
272     \param url char* arguments, the study URL
273   */
274   virtual void  URL(const char* url);
275
276   static SALOMEDS::Study_ptr GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb);
277
278   static void IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute);
279
280   virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel);
281   
282   virtual SALOMEDS::Study::ListOfSObject* FindDependances(SALOMEDS::SObject_ptr anObject);
283
284   virtual SALOMEDS::AttributeStudyProperties_ptr GetProperties();
285
286   virtual char* GetLastModificationDate();
287
288   virtual SALOMEDS::ListOfDates* GetModificationsDate();
289
290   virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject) {return _orb->object_to_string(theObject); }
291   virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); };
292
293   virtual SALOMEDS::UseCaseBuilder_ptr GetUseCaseBuilder();
294
295   void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled); 
296
297   // postponed destroying of CORBA object functionality
298   virtual void AddPostponed(const char* theIOR);
299
300   virtual void AddCreatedPostponed(const char* theIOR);
301
302   virtual void RemovePostponed(CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
303                                                         // if theUndoLimit==0, removes all
304   virtual void UndoPostponed(CORBA::Long theWay); // theWay = 1: resurrect objects,
305                                                 // theWay = -1: get back to the list of postponed
306
307   virtual SALOMEDS::AttributeParameter_ptr GetCommonParameters(const char* theID, CORBA::Long theSavePoint);
308   virtual SALOMEDS::AttributeParameter_ptr GetModuleParameters(const char* theID, 
309                                                                const char* theModuleName, 
310                                                                CORBA::Long theSavePoint);
311
312   virtual void SetStudyLock(const char* theLockerID);
313
314   virtual bool IsStudyLocked();
315
316   virtual void UnLockStudy(const char* theLockerID);
317
318   virtual SALOMEDS::ListOfStrings* GetLockerID();
319
320   virtual void SetReal(const char* theVarName, CORBA::Double theValue);
321   
322   virtual void SetInteger(const char* theVarName, CORBA::Long theValue);
323
324   virtual void SetBoolean(const char* theVarName, CORBA::Boolean theValue);
325
326   virtual void SetString(const char* theVarName, const char* theValue);
327
328   virtual void SetStringAsDouble(const char* theVarName, CORBA::Double theValue);
329
330   virtual CORBA::Double GetReal(const char* theVarName);
331   
332   virtual CORBA::Long GetInteger(const char* theVarName);
333
334   virtual CORBA::Boolean GetBoolean(const char* theVarName);
335
336   virtual char* GetString(const char* theVarName);
337
338   virtual CORBA::Boolean IsReal(const char* theVarName);
339   
340   virtual CORBA::Boolean IsInteger(const char* theVarName);
341
342   virtual CORBA::Boolean IsBoolean(const char* theVarName);
343
344   virtual CORBA::Boolean IsString(const char* theVarName);
345
346   virtual CORBA::Boolean IsVariable(const char* theVarName);
347
348   virtual SALOMEDS::ListOfStrings* GetVariableNames();
349
350   virtual CORBA::Boolean RemoveVariable(const char* theVarName);
351
352   virtual CORBA::Boolean RenameVariable(const char* theVarName, const char* theNewVarName);
353
354   virtual CORBA::Boolean IsVariableUsed(const char* theVarName);
355   
356   virtual SALOMEDS::ListOfListOfStrings* ParseVariables(const char* theVars);
357
358   virtual char* GetDefaultScript(const char* theModuleName, const char* theShift);
359
360   virtual CORBA::Boolean DumpStudy(const char* thePath,
361                                    const char* theBaseName,
362                                    CORBA::Boolean isPublished,
363                                    CORBA::Boolean isMultiFile);
364
365   virtual SALOMEDSImpl_Study* GetImpl() { return _impl; }
366
367   virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
368
369   void ping(){};
370   CORBA::Long getPID();
371   void ShutdownWithExit();
372
373   void Shutdown();
374
375   virtual void attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify);
376   virtual void detach(SALOMEDS::Observer_ptr theObs);
377 };
378 #endif