Salome HOME
ENV: Windows porting.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study.cxx
1 //  File   : SALOMEDS_Study.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5
6
7 #include "utilities.h" 
8
9 #include "SALOMEDS_Study.hxx"
10 #include "SALOMEDS_SComponent.hxx"
11 #include "SALOMEDSImpl_SComponent.hxx"
12 #include "SALOMEDS_SObject.hxx"
13 #include "SALOMEDSImpl_SObject.hxx"
14 #include "SALOMEDS_StudyBuilder.hxx"
15 #include "SALOMEDSImpl_StudyBuilder.hxx"
16 #include "SALOMEDS_ChildIterator.hxx"
17 #include "SALOMEDSImpl_ChildIterator.hxx"
18 #include "SALOMEDS_SComponentIterator.hxx"
19 #include "SALOMEDSImpl_SComponentIterator.hxx"
20 #include "SALOMEDS_AttributeStudyProperties.hxx"
21 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
22 #include "SALOMEDS_UseCaseBuilder.hxx"
23 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
24
25 #include "SALOMEDS_Driver_i.hxx"
26 #include "SALOMEDS_Study_i.hxx"
27
28 #include <TCollection_AsciiString.hxx> 
29 #include <TColStd_HSequenceOfAsciiString.hxx>
30 #include <TColStd_HSequenceOfTransient.hxx>
31
32 #include "Utils_ORB_INIT.hxx" 
33 #include "Utils_SINGLETON.hxx" 
34
35 #ifdef WIN32
36 #include <process.h>
37 #else
38 #include <sys/types.h>
39 #include <unistd.h>
40 #endif
41
42 #include "OpUtil.hxx"
43
44 using namespace std; 
45
46 SALOMEDS_Study::SALOMEDS_Study(const Handle(SALOMEDSImpl_Study)& theStudy)
47 {
48   _isLocal = true;
49   _local_impl = theStudy;
50   _corba_impl = SALOMEDS::Study::_nil();
51   init_orb();
52 }
53
54 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
55 {
56 #ifdef WIN32
57   long pid =  (long)_getpid();
58 #else
59   long pid =  (long)getpid();
60 #endif  
61
62   long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
63   if(_isLocal) {
64     _local_impl = ((SALOMEDSImpl_Study*)(addr));
65     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
66   }
67   else {
68     _local_impl = NULL;
69     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
70   }
71
72   init_orb();
73 }
74
75 SALOMEDS_Study::~SALOMEDS_Study()
76 {
77 }
78
79 std::string SALOMEDS_Study::GetPersistentReference()
80 {
81   std::string aRef;
82   if(_isLocal) aRef = _local_impl->GetPersistentReference().ToCString();
83   else aRef = _corba_impl->GetPersistentReference();
84   return aRef;
85 }
86
87 std::string SALOMEDS_Study::GetTransientReference()
88 {
89   std::string aRef;
90   if(_isLocal) aRef = _local_impl->GetTransientReference().ToCString();
91   else aRef = _corba_impl->GetTransientReference();
92   return aRef;
93 }
94  
95 bool SALOMEDS_Study::IsEmpty()
96 {
97   bool ret;
98   if(_isLocal) ret = _local_impl->IsEmpty();
99   else ret = _corba_impl->IsEmpty();
100   return ret;
101 }
102
103 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
104 {
105   SALOMEDSClient_SComponent* aSCO = NULL;
106   if(_isLocal) {
107     Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponent((char*)aComponentName.c_str());
108     if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
109     aSCO = new SALOMEDS_SComponent(aSCO_impl);
110   }
111   else {
112     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
113     if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
114     aSCO = new SALOMEDS_SComponent(aSCO_impl);
115   }
116   return _PTR(SComponent)(aSCO);
117 }
118  
119 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
120 {  
121   SALOMEDSClient_SComponent* aSCO = NULL;
122   if(_isLocal) {
123     Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponentID((char*)aComponentID.c_str());
124     if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
125     aSCO = new SALOMEDS_SComponent(aSCO_impl);
126   }
127   else {
128     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
129     if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
130     aSCO = new SALOMEDS_SComponent(aSCO_impl);
131   }
132   return _PTR(SComponent)(aSCO);
133   
134 }
135  
136 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
137 {
138   SALOMEDSClient_SObject* aSO = NULL;
139
140   if(_isLocal) {
141     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject((char*)anObjectName.c_str());
142     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
143     Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO_impl);
144     if(!aSCO_impl.IsNull()) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
145     aSO = new SALOMEDS_SObject(aSO_impl);
146   }
147   else { 
148     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
149     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
150     SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
151     if(!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
152     aSO = new SALOMEDS_SObject(aSO_impl);
153   }
154
155   return _PTR(SObject)(aSO);
156 }
157  
158 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName, 
159                                                                       const std::string& aComponentName)   
160 {
161   std::vector<_PTR(SObject)> aVector;
162   int i, aLength = 0;
163   
164   if(_isLocal) {
165     Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str());
166     aLength = aSeq->Length();
167     for(i = 1; i<= aLength; i++) 
168       aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
169   }
170   else {
171     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(), 
172                                                                             (char*)aComponentName.c_str());
173     aLength = aSeq->length();
174     for(i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
175   }
176
177   return aVector;
178 }
179  
180 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
181 {
182   SALOMEDSClient_SObject* aSO = NULL;
183   if(_isLocal) {
184     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID((char*)anObjectID.c_str());
185     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
186     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
187   }
188   else { 
189     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
190     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
191     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
192   }
193   return _PTR(SObject)(aSO);
194 }
195  
196 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
197 {
198   SALOMEDSClient_SObject* aSO = NULL;
199   if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str()));
200   else aSO = new SALOMEDS_SObject(_corba_impl->CreateObjectID((char*)anObjectID.c_str())); 
201   return _PTR(SObject)(aSO);
202 }
203  
204 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
205 {
206   SALOMEDSClient_SObject* aSO = NULL;
207   if(_isLocal) {
208     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectIOR((char*)anObjectIOR.c_str());
209     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
210     aSO = new SALOMEDS_SObject(aSO_impl);
211   }
212   else { 
213     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
214     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
215     aSO = new SALOMEDS_SObject(aSO_impl);
216   }
217   return _PTR(SObject)(aSO);
218 }
219
220 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
221 {
222   SALOMEDSClient_SObject* aSO = NULL;
223   if(_isLocal) {
224     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectByPath((char*)thePath.c_str());
225     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
226     aSO = new SALOMEDS_SObject(aSO_impl);
227   }
228   else {
229     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
230     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
231     aSO = new SALOMEDS_SObject(aSO_impl);
232   }
233   return _PTR(SObject)(aSO);
234 }
235
236 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
237 {
238   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
239   std::string aPath;
240   if(_isLocal) aPath = _local_impl->GetObjectPath(aSO->GetLocalImpl()).ToCString();
241   else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
242   return aPath;
243 }
244
245 void SALOMEDS_Study::SetContext(const std::string& thePath)
246 {
247   if(_isLocal) _local_impl->SetContext((char*)thePath.c_str());
248   else _corba_impl->SetContext((char*)thePath.c_str());
249 }
250
251 std::string SALOMEDS_Study::GetContext()  
252 {
253   std::string aPath;
254   if(_isLocal) aPath = _local_impl->GetContext().ToCString();
255   else aPath = _corba_impl->GetContext();
256   return aPath;
257 }
258
259 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
260 {
261   std::vector<std::string> aVector;
262   int aLength, i;
263   if(_isLocal) {
264     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetObjectNames((char*)theContext.c_str());
265     aLength = aSeq->Length();
266     for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
267   }
268   else {
269     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
270     aLength = aSeq->length();
271     for(i = 0; i<aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
272   }
273   return aVector;
274 }
275  
276 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
277 {
278   std::vector<std::string> aVector;
279   int aLength, i;
280   if(_isLocal) {
281     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetDirectoryNames((char*)theContext.c_str());
282     aLength = aSeq->Length();
283     for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
284   }
285   else {
286     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
287     aLength = aSeq->length();
288     for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
289   }
290   return aVector;
291 }
292  
293 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
294 {
295   std::vector<std::string> aVector;
296   int aLength, i;
297   if(_isLocal) {
298     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetFileNames((char*)theContext.c_str());
299     aLength = aSeq->Length();
300     for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
301   }
302   else {
303     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
304     aLength = aSeq->length();
305
306     for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
307   }
308   return aVector;
309 }
310  
311 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
312 {
313   std::vector<std::string> aVector;
314   int aLength, i;
315   if(_isLocal) {
316     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetComponentNames((char*)theContext.c_str());
317     aLength = aSeq->Length();
318     for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
319   }
320   else {
321     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
322     aLength = aSeq->length();
323     for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
324   }
325   return aVector;
326 }
327
328 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
329 {
330   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
331   SALOMEDSClient_ChildIterator* aCI = NULL; 
332   if(_isLocal) {
333     Handle(SALOMEDSImpl_ChildIterator) aCIimpl = _local_impl->NewChildIterator(aSO->GetLocalImpl());
334     aCI = new SALOMEDS_ChildIterator(aCIimpl);
335   }
336   else {
337     SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
338     aCI = new SALOMEDS_ChildIterator(aCIimpl);
339   }
340
341   return _PTR(ChildIterator)(aCI);
342 }
343
344 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
345 {
346   SALOMEDSClient_SComponentIterator* aCI = NULL; 
347   if(_isLocal) {
348     SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
349     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
350   }
351   else {
352     SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
353     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
354   }
355
356   return _PTR(SComponentIterator)(aCI);
357 }
358  
359 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
360 {
361   SALOMEDSClient_StudyBuilder* aSB = NULL; 
362   if(_isLocal) {
363     Handle(SALOMEDSImpl_StudyBuilder) aSBimpl = _local_impl->NewBuilder();
364     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
365   }
366   else {
367     SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
368     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
369   }
370
371   return _PTR(StudyBuilder)(aSB);
372 }
373
374 std::string SALOMEDS_Study::Name()
375 {
376   std::string aName;
377   if(_isLocal) aName = _local_impl->Name().ToCString();
378   else aName = _corba_impl->Name();
379   return aName;
380 }
381  
382 void SALOMEDS_Study::Name(const std::string& theName)
383 {
384   if(_isLocal) _local_impl->Name((char*)theName.c_str());
385   else _corba_impl->Name((char*)theName.c_str());
386 }
387
388 bool SALOMEDS_Study::IsSaved()
389 {
390   bool isSaved;
391   if(_isLocal) isSaved = _local_impl->IsSaved();
392   else isSaved = _corba_impl->IsSaved();
393   return isSaved;
394 }
395
396 void SALOMEDS_Study::IsSaved(bool save)
397 {
398   if(_isLocal) _local_impl->IsSaved(save);
399   else _corba_impl->IsSaved(save);
400 }
401
402 bool SALOMEDS_Study::IsModified()
403 {
404   bool isModified;
405   if(_isLocal) isModified = _local_impl->IsModified();
406   else isModified = _corba_impl->IsModified();
407   return isModified;
408 }
409  
410 std::string SALOMEDS_Study::URL()
411 {
412   std::string aURL;
413   if(_isLocal) aURL = _local_impl->URL().ToCString();
414   else aURL = _corba_impl->URL();
415   return aURL;
416 }
417
418 void SALOMEDS_Study::URL(const std::string& url)
419 {
420   if(_isLocal) _local_impl->URL((char*)url.c_str());
421   else _corba_impl->URL((char*)url.c_str());
422 }
423
424 int SALOMEDS_Study::StudyId()
425 {
426   int anID;
427   if(_isLocal) anID = _local_impl->StudyId();
428   else anID = _corba_impl->StudyId();
429   return anID;
430 }
431  
432 void SALOMEDS_Study::StudyId(int id) 
433 {
434   if(_isLocal) _local_impl->StudyId(id);
435   else _corba_impl->StudyId(id);  
436 }
437
438 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
439 {
440   std::vector<_PTR(SObject)> aVector;
441   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
442   int aLength, i;
443   if(_isLocal) {
444     Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindDependances(aSO->GetLocalImpl());
445     aLength = aSeq->Length();
446     for(i=1; i<=aLength; i++) 
447       aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
448   }
449   else {
450     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
451     aLength = aSeq->length();
452     for(i=0; i<aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
453   }
454   return aVector;
455 }
456  
457 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
458 {
459   SALOMEDSClient_AttributeStudyProperties* aProp;
460   if(_isLocal) aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
461   else aProp = new SALOMEDS_AttributeStudyProperties(_corba_impl->GetProperties());
462   return _PTR(AttributeStudyProperties)(aProp);
463 }
464  
465 std::string SALOMEDS_Study::GetLastModificationDate() 
466 {
467   std::string aDate;
468   if(_isLocal) aDate = _local_impl->GetLastModificationDate().ToCString();
469   else aDate = _corba_impl->GetLastModificationDate();
470   return aDate;
471 }
472
473 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
474 {
475   std::vector<std::string> aVector;
476   int aLength, i;
477   if(_isLocal) {
478     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetModificationsDate();
479     aLength = aSeq->Length();
480     for(i=1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
481   }
482   else {
483     SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
484     aLength = aSeq->length();
485     for(i=0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
486   }
487   return aVector;
488 }
489
490 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
491 {
492   SALOMEDSClient_UseCaseBuilder* aUB = NULL;
493   if(_isLocal) {
494     Handle(SALOMEDSImpl_UseCaseBuilder) aUBimpl = _local_impl->GetUseCaseBuilder();
495     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
496   }
497   else {
498     SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
499     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
500   }
501
502   return _PTR(UseCaseBuilder)(aUB);
503 }
504
505 void SALOMEDS_Study::Close()
506 {
507   if(_isLocal) _local_impl->Close();
508   else _corba_impl->Close();
509 }
510
511 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
512 {
513   if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
514   else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
515 }
516
517 bool SALOMEDS_Study::DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished)
518 {
519   bool ret;
520   if(_isLocal) {
521     SALOMEDS_DriverFactory_i* aFactory = new SALOMEDS_DriverFactory_i(_orb);
522     ret = _local_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished, aFactory);
523     delete aFactory;
524   }
525   else ret = _corba_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished);
526   return ret;
527 }     
528
529 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) 
530 {
531   return _orb->object_to_string(theObject); 
532 }
533
534 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR) 
535
536   return _orb->string_to_object(theIOR.c_str()); 
537
538
539 void SALOMEDS_Study::init_orb()
540 {
541   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
542   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()); 
543   _orb = init(0 , 0 ) ;     
544 }
545
546 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
547 {
548   if(_isLocal) {
549     if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
550     std::string anIOR = _local_impl->GetTransientReference().ToCString();
551     SALOMEDS::Study_var aStudy;
552     if(!_local_impl->IsError() && anIOR != "") {
553       aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
554     }
555     else {
556       SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
557       aStudy = aStudy_servant->_this();
558       _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
559     }
560     return aStudy._retn();
561   }
562   else {
563     return _corba_impl;
564   }
565    
566   return SALOMEDS::Study::_nil();
567 }