Back to index

salome-kernel  6.5.0
SALOMEDS_StudyBuilder.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDS_StudyBuilder.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "utilities.h"
00028 
00029 #include "SALOMEDS_StudyBuilder.hxx"
00030 
00031 #include "SALOMEDS.hxx"
00032 #include "SALOMEDS_SObject.hxx"
00033 #include "SALOMEDS_SComponent.hxx"
00034 #include "SALOMEDS_GenericAttribute.hxx"
00035 #include "SALOMEDS_StudyManager.hxx"
00036 #include "SALOMEDS_StudyBuilder_i.hxx"
00037 
00038 #include "SALOMEDS_Driver_i.hxx"
00039 
00040 #include "SALOMEDSImpl_SObject.hxx"
00041 #include "SALOMEDSImpl_SComponent.hxx"
00042 #include "SALOMEDSImpl_GenericAttribute.hxx"
00043 
00044 #include <string>
00045 #include <stdexcept>
00046 
00047 #include "DF_Attribute.hxx"
00048 
00049 #include "Utils_CorbaException.hxx"
00050 #include "Utils_ORB_INIT.hxx" 
00051 #include "Utils_SINGLETON.hxx" 
00052 
00053 SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuilder)
00054 {
00055   _isLocal = true;
00056   _local_impl = theBuilder;
00057   _corba_impl = SALOMEDS::StudyBuilder::_nil();
00058 
00059   init_orb();
00060 }
00061 
00062 SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder)
00063 {
00064   _isLocal = false;
00065   _local_impl = NULL;
00066   _corba_impl = SALOMEDS::StudyBuilder::_duplicate(theBuilder);
00067 
00068   init_orb();
00069 }
00070 
00071 SALOMEDS_StudyBuilder::~SALOMEDS_StudyBuilder() 
00072 {
00073 }
00074 
00075 _PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& ComponentDataType)
00076 {
00077   SALOMEDSClient_SComponent* aSCO = NULL;
00078 
00079   if (_isLocal) {
00080     CheckLocked();
00081     SALOMEDS::Locker lock;
00082 
00083     SALOMEDSImpl_SComponent aSCO_impl =_local_impl->NewComponent(ComponentDataType);
00084     if(!aSCO_impl) return _PTR(SComponent)(aSCO);
00085     aSCO = new SALOMEDS_SComponent(aSCO_impl);
00086   }
00087   else {
00088     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->NewComponent((char*)ComponentDataType.c_str());
00089     if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
00090     aSCO = new SALOMEDS_SComponent(aSCO_impl);
00091   }
00092 
00093   return _PTR(SComponent)(aSCO);
00094 }
00095 
00096 void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& theSCO, 
00097                                                      const std::string& ComponentIOR)
00098 {
00099   if(!theSCO) return;
00100 
00101   SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
00102   if (_isLocal) {
00103     CheckLocked();
00104     SALOMEDS::Locker lock;
00105 
00106     _local_impl->DefineComponentInstance(*(dynamic_cast<SALOMEDSImpl_SComponent*>(aSCO->GetLocalImpl())),
00107                                          ComponentIOR);
00108   }
00109   else {
00110     CORBA::Object_var obj = _orb->string_to_object(ComponentIOR.c_str());
00111     _corba_impl->DefineComponentInstance(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()), obj);
00112   }
00113 }
00114 
00115 void SALOMEDS_StudyBuilder::RemoveComponent(const _PTR(SComponent)& theSCO)
00116 {
00117   if(!theSCO) return;
00118   SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
00119   if (_isLocal) {
00120     CheckLocked();
00121     SALOMEDS::Locker lock;
00122 
00123     _local_impl->RemoveComponent(*(dynamic_cast<SALOMEDSImpl_SComponent*>(aSCO->GetLocalImpl())));
00124   }
00125   else _corba_impl->RemoveComponent(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()));
00126 }
00127 
00128 _PTR(SObject) SALOMEDS_StudyBuilder::NewObject(const _PTR(SObject)& theFatherObject)
00129 {
00130   CheckLocked();
00131 
00132   SALOMEDSClient_SObject* aSO = NULL;
00133   SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject.get());
00134   if (father == NULL) return _PTR(SObject)(aSO);
00135   if (_isLocal) {
00136     SALOMEDS::Locker lock;
00137 
00138     SALOMEDSImpl_SObject aSO_impl = _local_impl->NewObject(*(father->GetLocalImpl()));
00139     if(!aSO_impl) return _PTR(SObject)(aSO);
00140     aSO = new SALOMEDS_SObject(aSO_impl);
00141   }
00142   else {
00143     SALOMEDS::SObject_var aSO_impl = _corba_impl->NewObject(father->GetCORBAImpl());
00144     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00145     aSO = new SALOMEDS_SObject(aSO_impl);
00146   }
00147 
00148   return _PTR(SObject)(aSO);
00149 }
00150 
00151 _PTR(SObject) SALOMEDS_StudyBuilder::NewObjectToTag(const _PTR(SObject)& theFatherObject, int theTag)
00152 {  
00153   CheckLocked();
00154 
00155   SALOMEDSClient_SObject* aSO = NULL;
00156   SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject.get());
00157   if (father == NULL) return _PTR(SObject)(aSO);
00158   if (_isLocal) {
00159     SALOMEDS::Locker lock;
00160 
00161     SALOMEDSImpl_SObject aSO_impl = _local_impl->NewObjectToTag(*(father->GetLocalImpl()), theTag);
00162     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
00163     aSO = new SALOMEDS_SObject(aSO_impl);
00164   }
00165   else {
00166     SALOMEDS::SObject_var aSO_impl = _corba_impl->NewObjectToTag(father->GetCORBAImpl(), theTag);
00167     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00168     aSO = new SALOMEDS_SObject(aSO_impl);
00169   }
00170 
00171   return _PTR(SObject)(aSO);
00172 }
00173 
00174 void SALOMEDS_StudyBuilder::AddDirectory(const std::string& thePath)
00175 {
00176   if (_isLocal) {
00177     CheckLocked();
00178     SALOMEDS::Locker lock;
00179 
00180     _local_impl->AddDirectory((char*)thePath.c_str());
00181     if (_local_impl->IsError()) {
00182       std::string anErrorCode = _local_impl->GetErrorCode();
00183       if (anErrorCode == "StudyNameAlreadyUsed")  throw SALOMEDS::Study::StudyNameAlreadyUsed(); 
00184       if (anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory(); 
00185       if (anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent();  
00186     }
00187   }
00188   else _corba_impl->AddDirectory((char*)thePath.c_str());
00189 }
00190 
00191 void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR)
00192 {
00193   if(!theSCO) return;
00194 
00195   SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
00196   CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
00197   SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
00198   
00199   if (_isLocal) {
00200     SALOMEDS::Locker lock;
00201 
00202     SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(aDriver, _orb);    
00203     SALOMEDSImpl_SComponent aSCO_impl = *(dynamic_cast<SALOMEDSImpl_SComponent*>(aSCO->GetLocalImpl()));
00204     bool isDone = _local_impl->LoadWith(aSCO_impl, drv);
00205     delete drv;
00206     if(!isDone && _local_impl->IsError()) 
00207       THROW_SALOME_CORBA_EXCEPTION(_local_impl->GetErrorCode().c_str(),SALOME::BAD_PARAM);
00208   }
00209   else {
00210     _corba_impl->LoadWith(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()), aDriver);
00211   }
00212 }
00213 
00214 void SALOMEDS_StudyBuilder::Load(const _PTR(SObject)& theSCO)
00215 {
00216   SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
00217   if (_isLocal) _local_impl->Load(*(dynamic_cast<SALOMEDSImpl_SComponent*>(aSCO->GetLocalImpl())));
00218   else _corba_impl->Load(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()));
00219 }
00220 
00221 void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO)
00222 {
00223   if(!theSO) return;
00224 
00225   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00226   if (_isLocal) {
00227     CheckLocked();
00228     SALOMEDS::Locker lock;
00229 
00230     _local_impl->RemoveObject(*(aSO->GetLocalImpl()));
00231   }
00232   else _corba_impl->RemoveObject(aSO->GetCORBAImpl());
00233 }
00234 
00235 void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO)
00236 {
00237   if(!theSO) return;
00238 
00239   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00240   if (_isLocal) {
00241     CheckLocked();
00242     SALOMEDS::Locker lock;
00243 
00244     _local_impl->RemoveObjectWithChildren(*(aSO->GetLocalImpl()));
00245   }
00246   else _corba_impl->RemoveObjectWithChildren(aSO->GetCORBAImpl());
00247 }
00248 
00249 _PTR(GenericAttribute) SALOMEDS_StudyBuilder::FindOrCreateAttribute(const _PTR(SObject)& theSO, 
00250                                                                     const std::string& aTypeOfAttribute)
00251 {  
00252   SALOMEDSClient_GenericAttribute* anAttr = NULL;
00253   if(!theSO) return _PTR(GenericAttribute)(anAttr);
00254   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00255   if (_isLocal) {
00256     SALOMEDS::Locker lock;
00257 
00258     SALOMEDSImpl_GenericAttribute* aGA;
00259     try {
00260       aGA = dynamic_cast<SALOMEDSImpl_GenericAttribute*>
00261         (_local_impl->FindOrCreateAttribute(*(aSO->GetLocalImpl()), aTypeOfAttribute));
00262     }
00263     catch (...) {
00264       throw SALOMEDS::StudyBuilder::LockProtection();
00265     }
00266     anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aGA);
00267   }
00268   else {
00269     SALOMEDS::GenericAttribute_var aGA =
00270       _corba_impl->FindOrCreateAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str());
00271     anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aGA);
00272   }
00273 
00274   return _PTR(GenericAttribute)(anAttr);
00275 }
00276 
00277 bool SALOMEDS_StudyBuilder::FindAttribute(const _PTR(SObject)& theSO, 
00278                                           _PTR(GenericAttribute)& anAttribute, 
00279                                           const std::string& aTypeOfAttribute)
00280 {
00281   bool ret;
00282 
00283   if(!theSO) return false;
00284 
00285   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00286   if (_isLocal) {
00287     SALOMEDS::Locker lock;
00288 
00289     DF_Attribute* anAttr = NULL;
00290     ret = _local_impl->FindAttribute(*(aSO->GetLocalImpl()), anAttr, aTypeOfAttribute);
00291     if(ret) {
00292       SALOMEDSImpl_GenericAttribute* aGA = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(anAttr);
00293       anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(aGA));
00294     }
00295   }
00296   else {
00297     SALOMEDS::GenericAttribute_var aGA;
00298     ret = _corba_impl->FindAttribute(aSO->GetCORBAImpl(), aGA.out(), (char*)aTypeOfAttribute.c_str()); 
00299     if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(aGA));
00300   }
00301 
00302   return ret;
00303 }
00304 
00305 void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute)
00306 {
00307   if(!theSO) return;
00308 
00309   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00310   if (_isLocal) {
00311     CheckLocked();
00312     SALOMEDS::Locker lock;
00313 
00314     _local_impl->RemoveAttribute(*(aSO->GetLocalImpl()), (char*)aTypeOfAttribute.c_str());
00315   }
00316   else _corba_impl->RemoveAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str());
00317 }
00318 
00319 void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject)
00320 {
00321   if(!me || !thereferencedObject) {
00322     throw DFexception("Invalid arguments");
00323   }
00324 
00325   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
00326   SALOMEDS_SObject* aRefSO = dynamic_cast<SALOMEDS_SObject*>(thereferencedObject.get());
00327   if (_isLocal) {
00328     CheckLocked();
00329     SALOMEDS::Locker lock;
00330 
00331     _local_impl->Addreference(*(aSO->GetLocalImpl()), *(aRefSO->GetLocalImpl()));
00332   }
00333   else _corba_impl->Addreference(aSO->GetCORBAImpl(), aRefSO->GetCORBAImpl());
00334 }
00335 
00336 void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me)
00337 {
00338   if(!me) return;
00339   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
00340   if (_isLocal) {
00341     CheckLocked();
00342     SALOMEDS::Locker lock;
00343 
00344     _local_impl->RemoveReference(*(aSO->GetLocalImpl()));
00345   }
00346   else _corba_impl->RemoveReference(aSO->GetCORBAImpl());
00347 }
00348 
00349 void SALOMEDS_StudyBuilder::SetGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
00350 {
00351   if(!theSO) return;
00352 
00353   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00354   if (_isLocal) {
00355     CheckLocked();
00356     SALOMEDS::Locker lock;
00357 
00358     _local_impl->SetGUID(*(aSO->GetLocalImpl()), theGUID);
00359   }
00360   else _corba_impl->SetGUID(aSO->GetCORBAImpl(), (char*)theGUID.c_str());
00361 }
00362  
00363 bool SALOMEDS_StudyBuilder::IsGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
00364 {
00365   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00366   bool ret;
00367   if (_isLocal) {
00368     SALOMEDS::Locker lock;
00369 
00370     ret = _local_impl->IsGUID(*(aSO->GetLocalImpl()), (char*)theGUID.c_str());
00371   }
00372   else ret = _corba_impl->IsGUID(aSO->GetCORBAImpl(), (char*)theGUID.c_str());
00373 
00374   return ret;
00375 }
00376 
00377 void SALOMEDS_StudyBuilder::NewCommand()
00378 {
00379   if (_isLocal) {
00380     SALOMEDS::Locker lock;
00381     _local_impl->NewCommand();
00382   }
00383   else _corba_impl->NewCommand();
00384 }
00385  
00386 void SALOMEDS_StudyBuilder::CommitCommand()
00387 {
00388   if (_isLocal) {
00389     SALOMEDS::Locker lock;
00390     try {
00391       _local_impl->CommitCommand();
00392     }
00393     catch(...) {
00394       throw SALOMEDS::StudyBuilder::LockProtection();
00395     }
00396   }
00397   else _corba_impl->CommitCommand();
00398 }
00399 
00400 bool SALOMEDS_StudyBuilder::HasOpenCommand()
00401 {
00402   bool ret;
00403   if (_isLocal) {
00404     SALOMEDS::Locker lock;
00405     ret = _local_impl->HasOpenCommand();
00406   }
00407   else ret = _corba_impl->HasOpenCommand();
00408   return ret;
00409 }
00410 
00411 void SALOMEDS_StudyBuilder::AbortCommand()
00412 {
00413   if (_isLocal) {
00414     SALOMEDS::Locker lock;
00415     _local_impl->AbortCommand();
00416   }
00417   else _corba_impl->AbortCommand();
00418 }
00419 
00420 void SALOMEDS_StudyBuilder::Undo()
00421 {
00422   if (_isLocal) {
00423     SALOMEDS::Locker lock;
00424     try {
00425       _local_impl->Undo();
00426     }
00427     catch(...) {
00428       throw SALOMEDS::StudyBuilder::LockProtection();
00429     }
00430   }
00431   else _corba_impl->Undo();
00432 }
00433 
00434 void SALOMEDS_StudyBuilder::Redo()
00435 {
00436   if (_isLocal) {
00437     SALOMEDS::Locker lock;
00438     try {
00439       _local_impl->Redo();
00440     }
00441     catch(...) {
00442       throw SALOMEDS::StudyBuilder::LockProtection();
00443     }
00444   }
00445   else _corba_impl->Redo(); 
00446 }
00447 
00448 bool SALOMEDS_StudyBuilder::GetAvailableUndos()
00449 {
00450   bool ret;
00451   if (_isLocal) {
00452     SALOMEDS::Locker lock;
00453     ret = _local_impl->GetAvailableUndos();
00454   }
00455   else ret = _corba_impl->GetAvailableUndos();
00456   return ret;
00457 }
00458 
00459 bool SALOMEDS_StudyBuilder::GetAvailableRedos()
00460 {
00461   bool ret;
00462   if (_isLocal) {
00463     SALOMEDS::Locker lock;
00464     ret = _local_impl->GetAvailableRedos();
00465   }
00466   else ret = _corba_impl->GetAvailableRedos();
00467   return ret; 
00468 }
00469 
00470 int SALOMEDS_StudyBuilder::UndoLimit()
00471 {
00472   int aLimit;
00473   if (_isLocal) {
00474     SALOMEDS::Locker lock;
00475     aLimit = _local_impl->UndoLimit();
00476   }
00477   else aLimit = _corba_impl->UndoLimit();
00478   return aLimit;
00479 }
00480  
00481 void SALOMEDS_StudyBuilder::UndoLimit(int theLimit)
00482 {
00483   if (_isLocal) {
00484     CheckLocked();
00485     SALOMEDS::Locker lock;
00486 
00487     _local_impl->UndoLimit(theLimit);
00488   }
00489   else _corba_impl->UndoLimit(theLimit);
00490 }
00491  
00492 void SALOMEDS_StudyBuilder::CheckLocked()
00493 {
00494   //There is only local part as CORBA part throws the correct exeception
00495   if (_isLocal) {
00496     SALOMEDS::Locker lock;
00497     try {
00498       _local_impl->CheckLocked();
00499     }
00500     catch(...) {
00501       throw SALOMEDS::StudyBuilder::LockProtection();
00502     }
00503   }
00504 }
00505 
00506 void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::string& theValue)
00507 {
00508   if(!theSO) return;
00509 
00510   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00511   if (_isLocal) {
00512     CheckLocked();
00513     SALOMEDS::Locker lock;
00514 
00515     _local_impl->SetName(*(aSO->GetLocalImpl()), theValue);
00516   }
00517   else _corba_impl->SetName(aSO->GetCORBAImpl(), (char*)theValue.c_str());
00518 }
00519 
00520 void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::string& theValue)
00521 {
00522   if(!theSO) return;
00523 
00524   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00525   if (_isLocal) {
00526     CheckLocked();
00527     SALOMEDS::Locker lock;
00528 
00529     _local_impl->SetComment(*(aSO->GetLocalImpl()), theValue);
00530   }
00531   else _corba_impl->SetComment(aSO->GetCORBAImpl(), (char*)theValue.c_str());
00532 }
00533 
00534 void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string& theValue)
00535 {
00536   if(!theSO) return;
00537 
00538   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00539   if (_isLocal) {
00540     CheckLocked();
00541     SALOMEDS::Locker lock;
00542 
00543     _local_impl->SetIOR(*(aSO->GetLocalImpl()), theValue);
00544   }
00545   else _corba_impl->SetIOR(aSO->GetCORBAImpl(), (char*)theValue.c_str());
00546 }
00547 
00548 SALOMEDS::StudyBuilder_ptr SALOMEDS_StudyBuilder::GetBuilder()
00549 {
00550   if(_isLocal) {
00551     if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::StudyBuilder::_duplicate(_corba_impl);
00552     SALOMEDS_StudyBuilder_i* servant = new SALOMEDS_StudyBuilder_i(_local_impl, _orb);
00553     SALOMEDS::StudyBuilder_var aBuilder = servant->StudyBuilder::_this();
00554     _corba_impl = SALOMEDS::StudyBuilder::_duplicate(aBuilder);
00555     return aBuilder._retn();
00556   }
00557   else {
00558     return SALOMEDS::StudyBuilder::_duplicate(_corba_impl);
00559   }
00560   return SALOMEDS::StudyBuilder::_nil();
00561 }
00562 
00563 void SALOMEDS_StudyBuilder::init_orb()
00564 {
00565   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
00566   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()); 
00567   _orb = init(0 , 0 );     
00568 }