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