Salome HOME
PR: merge from branch BR_auto_V310 tag mergefrom_OCC_development_for_3_2_0a2_10mar06
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study.cxx
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/
19 //
20 //  File   : SALOMEDS_Study.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25
26 #include "utilities.h" 
27
28 #include "SALOMEDS_Study.hxx"
29
30 #include "SALOMEDS.hxx"
31 #include "SALOMEDS_SComponent.hxx"
32 #include "SALOMEDS_SObject.hxx"
33 #include "SALOMEDS_StudyBuilder.hxx"
34 #include "SALOMEDS_ChildIterator.hxx"
35 #include "SALOMEDS_SComponentIterator.hxx"
36 #include "SALOMEDS_AttributeStudyProperties.hxx"
37 #include "SALOMEDS_AttributeParameter.hxx"
38 #include "SALOMEDS_UseCaseBuilder.hxx"
39
40 #include "SALOMEDSImpl_SComponent.hxx"
41 #include "SALOMEDSImpl_SObject.hxx"
42 #include "SALOMEDSImpl_StudyBuilder.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_SComponentIterator.hxx"
45 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
46 #include "SALOMEDSImpl_AttributeParameter.hxx"
47 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
48
49 #include "SALOMEDS_Driver_i.hxx"
50 #include "SALOMEDS_Study_i.hxx"
51
52 #include <TCollection_AsciiString.hxx> 
53 #include <TColStd_HSequenceOfAsciiString.hxx>
54 #include <TColStd_HSequenceOfTransient.hxx>
55
56 #include "Utils_ORB_INIT.hxx" 
57 #include "Utils_SINGLETON.hxx" 
58
59 #ifdef WIN32
60 #include <process.h>
61 #else
62 #include <sys/types.h>
63 #include <unistd.h>
64 #endif
65
66 #include "OpUtil.hxx"
67
68 using namespace std; 
69
70 SALOMEDS_Study::SALOMEDS_Study(const Handle(SALOMEDSImpl_Study)& theStudy)
71 {
72   _isLocal = true;
73   _local_impl = theStudy;
74   _corba_impl = SALOMEDS::Study::_nil();
75   init_orb();
76 }
77
78 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
79 {
80 #ifdef WIN32
81   long pid =  (long)_getpid();
82 #else
83   long pid =  (long)getpid();
84 #endif  
85
86   long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
87   if(_isLocal) {
88     _local_impl = ((SALOMEDSImpl_Study*)(addr));
89     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
90   }
91   else {
92     _local_impl = NULL;
93     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
94   }
95
96   init_orb();
97 }
98
99 SALOMEDS_Study::~SALOMEDS_Study()
100 {
101 }
102
103 std::string SALOMEDS_Study::GetPersistentReference()
104 {
105   std::string aRef;
106   if (_isLocal) {
107     SALOMEDS::Locker lock;
108     aRef = _local_impl->GetPersistentReference().ToCString();
109   }
110   else aRef = _corba_impl->GetPersistentReference();
111   return aRef;
112 }
113
114 std::string SALOMEDS_Study::GetTransientReference()
115 {
116   std::string aRef;
117   if (_isLocal) {
118     SALOMEDS::Locker lock;
119     aRef = _local_impl->GetTransientReference().ToCString();
120   }
121   else aRef = _corba_impl->GetTransientReference();
122   return aRef;
123 }
124  
125 bool SALOMEDS_Study::IsEmpty()
126 {
127   bool ret;
128   if (_isLocal) {
129     SALOMEDS::Locker lock;
130     ret = _local_impl->IsEmpty();
131   }
132   else ret = _corba_impl->IsEmpty();
133   return ret;
134 }
135
136 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
137 {
138   SALOMEDSClient_SComponent* aSCO = NULL;
139   if (_isLocal) {
140     SALOMEDS::Locker lock;
141
142     Handle(SALOMEDSImpl_SComponent) aSCO_impl =
143       _local_impl->FindComponent((char*)aComponentName.c_str());
144     if (aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
145     aSCO = new SALOMEDS_SComponent(aSCO_impl);
146   }
147   else {
148     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
149     if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
150     aSCO = new SALOMEDS_SComponent(aSCO_impl);
151   }
152   return _PTR(SComponent)(aSCO);
153 }
154  
155 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
156 {  
157   SALOMEDSClient_SComponent* aSCO = NULL;
158   if (_isLocal) {
159     SALOMEDS::Locker lock;
160
161     Handle(SALOMEDSImpl_SComponent) aSCO_impl =
162       _local_impl->FindComponentID((char*)aComponentID.c_str());
163     if (aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
164     aSCO = new SALOMEDS_SComponent(aSCO_impl);
165   }
166   else {
167     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
168     if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
169     aSCO = new SALOMEDS_SComponent(aSCO_impl);
170   }
171   return _PTR(SComponent)(aSCO);
172 }
173  
174 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
175 {
176   SALOMEDSClient_SObject* aSO = NULL;
177
178   if (_isLocal) {
179     SALOMEDS::Locker lock;
180
181     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject((char*)anObjectName.c_str());
182     if (aSO_impl.IsNull()) return _PTR(SObject)(aSO);
183     Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO_impl);
184     if (!aSCO_impl.IsNull()) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
185     aSO = new SALOMEDS_SObject(aSO_impl);
186   }
187   else { 
188     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
189     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
190     SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
191     if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
192     aSO = new SALOMEDS_SObject(aSO_impl);
193   }
194
195   return _PTR(SObject)(aSO);
196 }
197
198 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName, 
199                                                             const std::string& aComponentName)   
200 {
201   std::vector<_PTR(SObject)> aVector;
202   int i, aLength = 0;
203
204   if (_isLocal) {
205     SALOMEDS::Locker lock;
206
207     Handle(TColStd_HSequenceOfTransient) aSeq =
208       _local_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str());
209     aLength = aSeq->Length();
210     for (i = 1; i<= aLength; i++) 
211       aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject
212                                       (Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
213   }
214   else {
215     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(), 
216                                                                             (char*)aComponentName.c_str());
217     aLength = aSeq->length();
218     for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
219   }
220
221   return aVector;
222 }
223
224 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
225 {
226   SALOMEDSClient_SObject* aSO = NULL;
227   if (_isLocal) {
228     SALOMEDS::Locker lock;
229
230     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID((char*)anObjectID.c_str());
231     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
232     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
233   }
234   else { 
235     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
236     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
237     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
238   }
239   return _PTR(SObject)(aSO);
240 }
241  
242 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
243 {
244   SALOMEDSClient_SObject* aSO = NULL;
245   if (_isLocal) {
246     SALOMEDS::Locker lock;
247     aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str()));
248   }
249   else aSO = new SALOMEDS_SObject(_corba_impl->CreateObjectID((char*)anObjectID.c_str())); 
250   return _PTR(SObject)(aSO);
251 }
252
253 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
254 {
255   SALOMEDSClient_SObject* aSO = NULL;
256   if (_isLocal) {
257     SALOMEDS::Locker lock;
258
259     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectIOR((char*)anObjectIOR.c_str());
260     if (aSO_impl.IsNull()) return _PTR(SObject)(aSO);
261     aSO = new SALOMEDS_SObject(aSO_impl);
262   }
263   else { 
264     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
265     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
266     aSO = new SALOMEDS_SObject(aSO_impl);
267   }
268   return _PTR(SObject)(aSO);
269 }
270
271 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
272 {
273   SALOMEDSClient_SObject* aSO = NULL;
274   if (_isLocal) {
275     SALOMEDS::Locker lock;
276
277     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectByPath((char*)thePath.c_str());
278     if (aSO_impl.IsNull()) return _PTR(SObject)(aSO);
279     aSO = new SALOMEDS_SObject(aSO_impl);
280   }
281   else {
282     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
283     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
284     aSO = new SALOMEDS_SObject(aSO_impl);
285   }
286   return _PTR(SObject)(aSO);
287 }
288
289 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
290 {
291   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
292   std::string aPath;
293   if (_isLocal) {
294     SALOMEDS::Locker lock;
295     aPath = _local_impl->GetObjectPath(aSO->GetLocalImpl()).ToCString();
296   }
297   else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
298   return aPath;
299 }
300
301 void SALOMEDS_Study::SetContext(const std::string& thePath)
302 {
303   if (_isLocal) {
304     SALOMEDS::Locker lock;
305     _local_impl->SetContext((char*)thePath.c_str());
306   }
307   else _corba_impl->SetContext((char*)thePath.c_str());
308 }
309
310 std::string SALOMEDS_Study::GetContext()  
311 {
312   std::string aPath;
313   if (_isLocal) {
314     SALOMEDS::Locker lock;
315     aPath = _local_impl->GetContext().ToCString();
316   }
317   else aPath = _corba_impl->GetContext();
318   return aPath;
319 }
320
321 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
322 {
323   std::vector<std::string> aVector;
324   int aLength, i;
325   if (_isLocal) {
326     SALOMEDS::Locker lock;
327
328     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetObjectNames((char*)theContext.c_str());
329     aLength = aSeq->Length();
330     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
331   }
332   else {
333     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
334     aLength = aSeq->length();
335     for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
336   }
337   return aVector;
338 }
339  
340 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
341 {
342   std::vector<std::string> aVector;
343   int aLength, i;
344   if (_isLocal) {
345     SALOMEDS::Locker lock;
346
347     Handle(TColStd_HSequenceOfAsciiString) aSeq =
348       _local_impl->GetDirectoryNames((char*)theContext.c_str());
349     aLength = aSeq->Length();
350     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
351   }
352   else {
353     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
354     aLength = aSeq->length();
355     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
356   }
357   return aVector;
358 }
359  
360 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
361 {
362   std::vector<std::string> aVector;
363   int aLength, i;
364   if (_isLocal) {
365     SALOMEDS::Locker lock;
366
367     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetFileNames((char*)theContext.c_str());
368     aLength = aSeq->Length();
369     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
370   }
371   else {
372     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
373     aLength = aSeq->length();
374
375     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
376   }
377   return aVector;
378 }
379  
380 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
381 {
382   std::vector<std::string> aVector;
383   int aLength, i;
384   if (_isLocal) {
385     SALOMEDS::Locker lock;
386
387     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetComponentNames((char*)theContext.c_str());
388     aLength = aSeq->Length();
389     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
390   }
391   else {
392     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
393     aLength = aSeq->length();
394     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
395   }
396   return aVector;
397 }
398
399 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
400 {
401   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
402   SALOMEDSClient_ChildIterator* aCI = NULL; 
403   if (_isLocal) {
404     SALOMEDS::Locker lock;
405
406     Handle(SALOMEDSImpl_ChildIterator) aCIimpl = _local_impl->NewChildIterator(aSO->GetLocalImpl());
407     aCI = new SALOMEDS_ChildIterator(aCIimpl);
408   }
409   else {
410     SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
411     aCI = new SALOMEDS_ChildIterator(aCIimpl);
412   }
413
414   return _PTR(ChildIterator)(aCI);
415 }
416
417 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
418 {
419   SALOMEDSClient_SComponentIterator* aCI = NULL; 
420   if (_isLocal) {
421     SALOMEDS::Locker lock;
422
423     SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
424     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
425   }
426   else {
427     SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
428     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
429   }
430
431   return _PTR(SComponentIterator)(aCI);
432 }
433
434 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
435 {
436   SALOMEDSClient_StudyBuilder* aSB = NULL; 
437   if (_isLocal) {
438     SALOMEDS::Locker lock;
439
440     Handle(SALOMEDSImpl_StudyBuilder) aSBimpl = _local_impl->NewBuilder();
441     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
442   }
443   else {
444     SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
445     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
446   }
447
448   return _PTR(StudyBuilder)(aSB);
449 }
450
451 std::string SALOMEDS_Study::Name()
452 {
453   std::string aName;
454   if (_isLocal) {
455     SALOMEDS::Locker lock;
456     aName = _local_impl->Name().ToCString();
457   }
458   else aName = _corba_impl->Name();
459   return aName;
460 }
461
462 void SALOMEDS_Study::Name(const std::string& theName)
463 {
464   if (_isLocal) {
465     SALOMEDS::Locker lock;
466     _local_impl->Name((char*)theName.c_str());
467   }
468   else _corba_impl->Name((char*)theName.c_str());
469 }
470
471 bool SALOMEDS_Study::IsSaved()
472 {
473   bool isSaved;
474   if (_isLocal) {
475     SALOMEDS::Locker lock;
476     isSaved = _local_impl->IsSaved();
477   }
478   else isSaved = _corba_impl->IsSaved();
479   return isSaved;
480 }
481
482 void SALOMEDS_Study::IsSaved(bool save)
483 {
484   if (_isLocal) {
485     SALOMEDS::Locker lock;
486     _local_impl->IsSaved(save);
487   }
488   else _corba_impl->IsSaved(save);
489 }
490
491 bool SALOMEDS_Study::IsModified()
492 {
493   bool isModified;
494   if (_isLocal) {
495     SALOMEDS::Locker lock;
496     isModified = _local_impl->IsModified();
497   }
498   else isModified = _corba_impl->IsModified();
499   return isModified;
500 }
501  
502 std::string SALOMEDS_Study::URL()
503 {
504   std::string aURL;
505   if (_isLocal) {
506     SALOMEDS::Locker lock;
507     aURL = _local_impl->URL().ToCString();
508   }
509   else aURL = _corba_impl->URL();
510   return aURL;
511 }
512
513 void SALOMEDS_Study::URL(const std::string& url)
514 {
515   if (_isLocal) {
516     SALOMEDS::Locker lock;
517     _local_impl->URL((char*)url.c_str());
518   }
519   else _corba_impl->URL((char*)url.c_str());
520 }
521
522 int SALOMEDS_Study::StudyId()
523 {
524   int anID;
525   if (_isLocal) {
526     SALOMEDS::Locker lock;
527     anID = _local_impl->StudyId();
528   }
529   else anID = _corba_impl->StudyId();
530   return anID;
531 }
532  
533 void SALOMEDS_Study::StudyId(int id) 
534 {
535   if (_isLocal) {
536     SALOMEDS::Locker lock;
537     _local_impl->StudyId(id);
538   }
539   else _corba_impl->StudyId(id);  
540 }
541
542 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
543 {
544   std::vector<_PTR(SObject)> aVector;
545   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
546   int aLength, i;
547   if (_isLocal) {
548     SALOMEDS::Locker lock;
549
550     Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindDependances(aSO->GetLocalImpl());
551     if (!aSeq.IsNull()) {
552       aLength = aSeq->Length();
553       for (i = 1; i <= aLength; i++) 
554         aVector.push_back(_PTR(SObject)(
555           new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
556     }
557   }
558   else {
559     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
560     aLength = aSeq->length();
561     for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
562   }
563   return aVector;
564 }
565  
566 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
567 {
568   SALOMEDSClient_AttributeStudyProperties* aProp;
569   if (_isLocal) {
570     SALOMEDS::Locker lock;
571     aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
572   }
573   else aProp = new SALOMEDS_AttributeStudyProperties(_corba_impl->GetProperties());
574   return _PTR(AttributeStudyProperties)(aProp);
575 }
576  
577 std::string SALOMEDS_Study::GetLastModificationDate() 
578 {
579   std::string aDate;
580   if (_isLocal) {
581     SALOMEDS::Locker lock;
582     aDate = _local_impl->GetLastModificationDate().ToCString();
583   }
584   else aDate = _corba_impl->GetLastModificationDate();
585   return aDate;
586 }
587
588 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
589 {
590   std::vector<std::string> aVector;
591   int aLength, i;
592   if (_isLocal) {
593     SALOMEDS::Locker lock;
594
595     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetModificationsDate();
596     aLength = aSeq->Length();
597     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
598   }
599   else {
600     SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
601     aLength = aSeq->length();
602     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
603   }
604   return aVector;
605 }
606
607 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
608 {
609   SALOMEDSClient_UseCaseBuilder* aUB = NULL;
610   if (_isLocal) {
611     SALOMEDS::Locker lock;
612
613     Handle(SALOMEDSImpl_UseCaseBuilder) aUBimpl = _local_impl->GetUseCaseBuilder();
614     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
615   }
616   else {
617     SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
618     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
619   }
620
621   return _PTR(UseCaseBuilder)(aUB);
622 }
623
624 void SALOMEDS_Study::Close()
625 {
626   if (_isLocal) {
627     SALOMEDS::Locker lock;
628     _local_impl->Close();
629   }
630   else _corba_impl->Close();
631 }
632
633 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
634 {
635   if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
636   else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
637 }
638
639 bool SALOMEDS_Study::DumpStudy(const string& thePath, const string& theBaseName, bool isPublished)
640 {
641   //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
642   bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished);
643   return ret;
644 }     
645
646 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) 
647 {
648   return _orb->object_to_string(theObject); 
649 }
650
651 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR) 
652
653   return _orb->string_to_object(theIOR.c_str()); 
654
655
656 void SALOMEDS_Study::init_orb()
657 {
658   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
659   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()); 
660   _orb = init(0 , 0 ) ;     
661 }
662
663 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
664 {
665   if (_isLocal) {
666     SALOMEDS::Locker lock;
667
668     if (!CORBA::is_nil(_corba_impl)) return _corba_impl;
669     std::string anIOR = _local_impl->GetTransientReference().ToCString();
670     SALOMEDS::Study_var aStudy;
671     if (!_local_impl->IsError() && anIOR != "") {
672       aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
673     }
674     else {
675       SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
676       aStudy = aStudy_servant->_this();
677       _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
678     }
679     return aStudy._retn();
680   }
681   else {
682     return _corba_impl;
683   }
684
685   return SALOMEDS::Study::_nil();
686 }
687
688 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint)
689 {
690   SALOMEDSClient_AttributeParameter* AP = NULL;
691   if(theSavePoint >= 0) {
692     if (_isLocal) {
693       SALOMEDS::Locker lock;
694       AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
695     }
696     else {
697       AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
698     }
699   }
700   return _PTR(AttributeParameter)(AP);
701 }
702
703 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const string& theID, 
704                                                              const string& theModuleName, int theSavePoint)
705 {
706   SALOMEDSClient_AttributeParameter* AP = NULL;
707   if(theSavePoint > 0) {
708     if (_isLocal) {
709       SALOMEDS::Locker lock;
710       AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
711     }
712     else {
713       AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
714     }
715   }
716   return _PTR(AttributeParameter)(AP);
717 }