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