Back to index

salome-kernel  6.5.0
SALOMEDS_Study.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_Study.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "utilities.h" 
00028 
00029 #include "SALOMEDS_Study.hxx"
00030 
00031 #include "SALOMEDS.hxx"
00032 #include "SALOMEDS_SComponent.hxx"
00033 #include "SALOMEDS_SObject.hxx"
00034 #include "SALOMEDS_StudyBuilder.hxx"
00035 #include "SALOMEDS_ChildIterator.hxx"
00036 #include "SALOMEDS_SComponentIterator.hxx"
00037 #include "SALOMEDS_AttributeStudyProperties.hxx"
00038 #include "SALOMEDS_AttributeParameter.hxx"
00039 #include "SALOMEDS_UseCaseBuilder.hxx"
00040 
00041 #include "SALOMEDSImpl_SComponent.hxx"
00042 #include "SALOMEDSImpl_SObject.hxx"
00043 #include "SALOMEDSImpl_StudyBuilder.hxx"
00044 #include "SALOMEDSImpl_ChildIterator.hxx"
00045 #include "SALOMEDSImpl_SComponentIterator.hxx"
00046 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
00047 #include "SALOMEDSImpl_AttributeParameter.hxx"
00048 #include "SALOMEDSImpl_GenericVariable.hxx"
00049 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
00050 
00051 #include "SALOMEDS_Driver_i.hxx"
00052 #include "SALOMEDS_Study_i.hxx"
00053 
00054 #include "Utils_ORB_INIT.hxx" 
00055 #include "Utils_SINGLETON.hxx" 
00056 
00057 #include "Basics_Utils.hxx"
00058 
00059 #ifdef WIN32
00060 #include <process.h>
00061 #else
00062 #include <sys/types.h>
00063 #include <unistd.h>
00064 #endif
00065 
00066 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
00067 {
00068   _isLocal = true;
00069   _local_impl = theStudy;
00070   _corba_impl = SALOMEDS::Study::_nil();
00071   init_orb();
00072 }
00073 
00074 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
00075 {
00076 #ifdef WIN32
00077   long pid =  (long)_getpid();
00078 #else
00079   long pid =  (long)getpid();
00080 #endif  
00081 
00082   long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
00083   if(_isLocal) {
00084     _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
00085     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
00086   }
00087   else {
00088     _local_impl = NULL;
00089     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
00090   }
00091 
00092   init_orb();
00093 }
00094 
00095 SALOMEDS_Study::~SALOMEDS_Study()
00096 {
00097 }
00098 
00099 std::string SALOMEDS_Study::GetPersistentReference()
00100 {
00101   std::string aRef;
00102   if (_isLocal) {
00103     SALOMEDS::Locker lock;
00104     aRef = _local_impl->GetPersistentReference();
00105   }
00106   else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
00107   return aRef;
00108 }
00109 
00110 std::string SALOMEDS_Study::GetTransientReference()
00111 {
00112   std::string aRef;
00113   if (_isLocal) {
00114     SALOMEDS::Locker lock;
00115     aRef = _local_impl->GetTransientReference();
00116   }
00117   else aRef = _corba_impl->GetTransientReference();
00118   return aRef;
00119 }
00120  
00121 bool SALOMEDS_Study::IsEmpty()
00122 {
00123   bool ret;
00124   if (_isLocal) {
00125     SALOMEDS::Locker lock;
00126     ret = _local_impl->IsEmpty();
00127   }
00128   else ret = _corba_impl->IsEmpty();
00129   return ret;
00130 }
00131 
00132 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
00133 {
00134   SALOMEDSClient_SComponent* aSCO = NULL;
00135   if (_isLocal) {
00136     SALOMEDS::Locker lock;
00137 
00138     SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
00139     if (!aSCO_impl) return _PTR(SComponent)(aSCO);
00140     aSCO = new SALOMEDS_SComponent(aSCO_impl);
00141   }
00142   else {
00143     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
00144     if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
00145     aSCO = new SALOMEDS_SComponent(aSCO_impl);
00146   }
00147   return _PTR(SComponent)(aSCO);
00148 }
00149  
00150 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
00151 {  
00152   SALOMEDSClient_SComponent* aSCO = NULL;
00153   if (_isLocal) {
00154     SALOMEDS::Locker lock;
00155 
00156     SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
00157     if (!aSCO_impl) return _PTR(SComponent)(aSCO);
00158     aSCO = new SALOMEDS_SComponent(aSCO_impl);
00159   }
00160   else {
00161     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
00162     if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
00163     aSCO = new SALOMEDS_SComponent(aSCO_impl);
00164   }
00165   return _PTR(SComponent)(aSCO);
00166 }
00167  
00168 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
00169 {
00170   SALOMEDSClient_SObject* aSO = NULL;
00171 
00172   if (_isLocal) {
00173     SALOMEDS::Locker lock;
00174 
00175     SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
00176     if (!aSO_impl) return _PTR(SObject)(aSO);
00177     if(aSO_impl.IsComponent()) {
00178         SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
00179         return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
00180     }   
00181     aSO = new SALOMEDS_SObject(aSO_impl);
00182   }
00183   else { 
00184     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
00185     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00186     SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
00187     if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
00188     aSO = new SALOMEDS_SObject(aSO_impl);
00189   }
00190 
00191   return _PTR(SObject)(aSO);
00192 }
00193 
00194 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName, 
00195                                                             const std::string& aComponentName)   
00196 {
00197   std::vector<_PTR(SObject)> aVector;
00198   int i, aLength = 0;
00199 
00200   if (_isLocal) {
00201     SALOMEDS::Locker lock;
00202 
00203     std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
00204     aLength = aSeq.size();
00205     for (i = 0; i< aLength; i++) 
00206       aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
00207   }
00208   else {
00209     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(), 
00210                                                                             (char*)aComponentName.c_str());
00211     aLength = aSeq->length();
00212     for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
00213   }
00214 
00215   return aVector;
00216 }
00217 
00218 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
00219 {
00220   SALOMEDSClient_SObject* aSO = NULL;
00221   if (_isLocal) {
00222     SALOMEDS::Locker lock;
00223 
00224     SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
00225     if(!aSO_impl) return _PTR(SObject)(aSO);
00226     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
00227   }
00228   else { 
00229     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
00230     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00231     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
00232   }
00233   return _PTR(SObject)(aSO);
00234 }
00235  
00236 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
00237 {
00238   SALOMEDSClient_SObject* aSO = NULL;
00239   if (_isLocal) {
00240     SALOMEDS::Locker lock;
00241     SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
00242     if(!aSO_impl) return _PTR(SObject)(aSO);
00243     aSO = new SALOMEDS_SObject(aSO_impl);
00244   }
00245   else { 
00246     SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
00247     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00248     aSO = new SALOMEDS_SObject(aSO_impl);
00249   }
00250   return _PTR(SObject)(aSO);
00251 }
00252 
00253 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
00254 {
00255   SALOMEDSClient_SObject* aSO = NULL;
00256   if (_isLocal) {
00257     SALOMEDS::Locker lock;
00258 
00259     SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
00260     if (!aSO_impl) return _PTR(SObject)(aSO);
00261     aSO = new SALOMEDS_SObject(aSO_impl);
00262   }
00263   else { 
00264     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
00265     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00266     aSO = new SALOMEDS_SObject(aSO_impl);
00267   }
00268   return _PTR(SObject)(aSO);
00269 }
00270 
00271 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
00272 {
00273   SALOMEDSClient_SObject* aSO = NULL;
00274   if (_isLocal) {
00275     SALOMEDS::Locker lock;
00276 
00277     SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
00278     if (!aSO_impl) return _PTR(SObject)(aSO);
00279     aSO = new SALOMEDS_SObject(aSO_impl);
00280   }
00281   else {
00282     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
00283     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
00284     aSO = new SALOMEDS_SObject(aSO_impl);
00285   }
00286   return _PTR(SObject)(aSO);
00287 }
00288 
00289 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
00290 {
00291   if(!theSO) return "";
00292   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00293   std::string aPath;
00294   if (_isLocal) {
00295     SALOMEDS::Locker lock;
00296     aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
00297   }
00298   else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
00299   return aPath;
00300 }
00301 
00302 void SALOMEDS_Study::SetContext(const std::string& thePath)
00303 {
00304   if (_isLocal) {
00305     SALOMEDS::Locker lock;
00306     _local_impl->SetContext(thePath);
00307   }
00308   else _corba_impl->SetContext((char*)thePath.c_str());
00309 }
00310 
00311 std::string SALOMEDS_Study::GetContext()  
00312 {
00313   std::string aPath;
00314   if (_isLocal) {
00315     SALOMEDS::Locker lock;
00316     aPath = _local_impl->GetContext();
00317   }
00318   else aPath = _corba_impl->GetContext();
00319   return aPath;
00320 }
00321 
00322 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
00323 {
00324   std::vector<std::string> aVector;
00325   int aLength, i;
00326   if (_isLocal) {
00327     SALOMEDS::Locker lock;
00328     aVector = _local_impl->GetObjectNames(theContext);
00329   }
00330   else {
00331     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
00332     aLength = aSeq->length();
00333     for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
00334   }
00335   return aVector;
00336 }
00337  
00338 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
00339 {
00340   std::vector<std::string> aVector;
00341   int aLength, i;
00342   if (_isLocal) {
00343     SALOMEDS::Locker lock;
00344     aVector = _local_impl->GetDirectoryNames(theContext);
00345   }
00346   else {
00347     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
00348     aLength = aSeq->length();
00349     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
00350   }
00351   return aVector;
00352 }
00353  
00354 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
00355 {
00356   std::vector<std::string> aVector;
00357   int aLength, i;
00358   if (_isLocal) {
00359     SALOMEDS::Locker lock;
00360     aVector = _local_impl->GetFileNames(theContext);
00361   }
00362   else {
00363     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
00364     aLength = aSeq->length();
00365 
00366     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
00367   }
00368   return aVector;
00369 }
00370  
00371 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
00372 {
00373   std::vector<std::string> aVector;
00374   int aLength, i;
00375   if (_isLocal) {
00376     SALOMEDS::Locker lock;
00377     aVector = _local_impl->GetComponentNames(theContext);
00378   }
00379   else {
00380     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
00381     aLength = aSeq->length();
00382     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
00383   }
00384   return aVector;
00385 }
00386 
00387 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
00388 {
00389   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00390   SALOMEDSClient_ChildIterator* aCI = NULL; 
00391   if (_isLocal) {
00392     SALOMEDS::Locker lock;
00393     SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
00394     aCI = new SALOMEDS_ChildIterator(aCIimpl);
00395   }
00396   else {
00397     SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
00398     aCI = new SALOMEDS_ChildIterator(aCIimpl);
00399   }
00400 
00401   return _PTR(ChildIterator)(aCI);
00402 }
00403 
00404 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
00405 {
00406   SALOMEDSClient_SComponentIterator* aCI = NULL; 
00407   if (_isLocal) {
00408     SALOMEDS::Locker lock;
00409 
00410     SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
00411     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
00412   }
00413   else {
00414     SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
00415     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
00416   }
00417 
00418   return _PTR(SComponentIterator)(aCI);
00419 }
00420 
00421 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
00422 {
00423   SALOMEDSClient_StudyBuilder* aSB = NULL; 
00424   if (_isLocal) {
00425     SALOMEDS::Locker lock;
00426 
00427     SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
00428     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
00429   }
00430   else {
00431     SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
00432     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
00433   }
00434 
00435   return _PTR(StudyBuilder)(aSB);
00436 }
00437 
00438 std::string SALOMEDS_Study::Name()
00439 {
00440   std::string aName;
00441   if (_isLocal) {
00442     SALOMEDS::Locker lock;
00443     aName = _local_impl->Name();
00444   }
00445   else aName = _corba_impl->Name();
00446   return aName;
00447 }
00448 
00449 void SALOMEDS_Study::Name(const std::string& theName)
00450 {
00451   if (_isLocal) {
00452     SALOMEDS::Locker lock;
00453     _local_impl->Name(theName);
00454   }
00455   else _corba_impl->Name((char*)theName.c_str());
00456 }
00457 
00458 bool SALOMEDS_Study::IsSaved()
00459 {
00460   bool isSaved;
00461   if (_isLocal) {
00462     SALOMEDS::Locker lock;
00463     isSaved = _local_impl->IsSaved();
00464   }
00465   else isSaved = _corba_impl->IsSaved();
00466   return isSaved;
00467 }
00468 
00469 void SALOMEDS_Study::IsSaved(bool save)
00470 {
00471   if (_isLocal) {
00472     SALOMEDS::Locker lock;
00473     _local_impl->IsSaved(save);
00474   }
00475   else _corba_impl->IsSaved(save);
00476 }
00477 
00478 bool SALOMEDS_Study::IsModified()
00479 {
00480   bool isModified;
00481   if (_isLocal) {
00482     SALOMEDS::Locker lock;
00483     isModified = _local_impl->IsModified();
00484   }
00485   else isModified = _corba_impl->IsModified();
00486   return isModified;
00487 }
00488 
00489 void SALOMEDS_Study::Modified()
00490 {
00491   if (_isLocal) {
00492     SALOMEDS::Locker lock;
00493     _local_impl->Modify();
00494   }
00495   else _corba_impl->Modified();
00496 }
00497 
00498  
00499 std::string SALOMEDS_Study::URL()
00500 {
00501   std::string aURL;
00502   if (_isLocal) {
00503     SALOMEDS::Locker lock;
00504     aURL = _local_impl->URL();
00505   }
00506   else aURL = _corba_impl->URL();
00507   return aURL;
00508 }
00509 
00510 void SALOMEDS_Study::URL(const std::string& url)
00511 {
00512   if (_isLocal) {
00513     SALOMEDS::Locker lock;
00514     _local_impl->URL(url);
00515   }
00516   else _corba_impl->URL((char*)url.c_str());
00517 }
00518 
00519 int SALOMEDS_Study::StudyId()
00520 {
00521   int anID;
00522   if (_isLocal) {
00523     SALOMEDS::Locker lock;
00524     anID = _local_impl->StudyId();
00525   }
00526   else anID = _corba_impl->StudyId();
00527   return anID;
00528 }
00529  
00530 void SALOMEDS_Study::StudyId(int id) 
00531 {
00532   if (_isLocal) {
00533     SALOMEDS::Locker lock;
00534     _local_impl->StudyId(id);
00535   }
00536   else _corba_impl->StudyId(id);  
00537 }
00538 
00539 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
00540 {
00541   std::vector<_PTR(SObject)> aVector;
00542   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
00543   int aLength, i;
00544   if (_isLocal) {
00545     SALOMEDS::Locker lock;
00546 
00547     std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
00548     if (aSeq.size()) {
00549       aLength = aSeq.size();
00550       for (i = 0; i < aLength; i++) 
00551         aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
00552     }
00553   }
00554   else {
00555     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
00556     aLength = aSeq->length();
00557     for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
00558   }
00559   return aVector;
00560 }
00561  
00562 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
00563 {
00564   SALOMEDSClient_AttributeStudyProperties* aProp;
00565   if (_isLocal) {
00566     SALOMEDS::Locker lock;
00567     aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
00568   }
00569   else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
00570   return _PTR(AttributeStudyProperties)(aProp);
00571 }
00572  
00573 std::string SALOMEDS_Study::GetLastModificationDate() 
00574 {
00575   std::string aDate;
00576   if (_isLocal) {
00577     SALOMEDS::Locker lock;
00578     aDate = _local_impl->GetLastModificationDate();
00579   }
00580   else aDate = _corba_impl->GetLastModificationDate();
00581   return aDate;
00582 }
00583 
00584 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
00585 {
00586   std::vector<std::string> aVector;
00587   int aLength, i;
00588   if (_isLocal) {
00589     SALOMEDS::Locker lock;
00590     aVector = _local_impl->GetModificationsDate();
00591   }
00592   else {
00593     SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
00594     aLength = aSeq->length();
00595     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
00596   }
00597   return aVector;
00598 }
00599 
00600 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
00601 {
00602   SALOMEDSClient_UseCaseBuilder* aUB = NULL;
00603   if (_isLocal) {
00604     SALOMEDS::Locker lock;
00605 
00606     SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
00607     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
00608   }
00609   else {
00610     SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
00611     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
00612   }
00613 
00614   return _PTR(UseCaseBuilder)(aUB);
00615 }
00616 
00617 void SALOMEDS_Study::Close()
00618 {
00619   if (_isLocal) {
00620     SALOMEDS::Locker lock;
00621     _local_impl->Close();
00622   }
00623   else _corba_impl->Close();
00624 }
00625 
00626 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
00627 {
00628   if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
00629   else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
00630 }
00631 
00632 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
00633                                const std::string& theBaseName,
00634                                bool isPublished,
00635                                bool isMultiFile)
00636 {
00637   //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
00638   if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
00639   bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
00640   return ret;
00641 }     
00642 
00643 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
00644 {
00645   if (_isLocal) {
00646     SALOMEDS::Locker lock;
00647     _local_impl->SetStudyLock(theLockerID.c_str());
00648   }
00649   else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
00650 }
00651  
00652 bool SALOMEDS_Study::IsStudyLocked()
00653 {
00654   bool isLocked;
00655   if (_isLocal) {
00656     SALOMEDS::Locker lock;
00657     isLocked = _local_impl->IsStudyLocked();
00658   }
00659   else isLocked = _corba_impl->IsStudyLocked();
00660   return isLocked;
00661 }
00662  
00663 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
00664 {
00665   if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
00666   else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
00667 }
00668 
00669 std::vector<std::string> SALOMEDS_Study::GetLockerID()
00670 {
00671   std::vector<std::string> aVector;
00672   int aLength, i;
00673   if (_isLocal) {
00674     SALOMEDS::Locker lock;
00675     aVector = _local_impl->GetLockerID();
00676   }
00677   else {
00678     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
00679     aLength = aSeq->length();
00680     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
00681   }
00682   return aVector;
00683 }
00684 
00685 
00686 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
00687 {
00688   if (_isLocal) {
00689     SALOMEDS::Locker lock;
00690     _local_impl->SetVariable(theVarName,
00691                              theValue,
00692                              SALOMEDSImpl_GenericVariable::REAL_VAR);
00693   }
00694   else 
00695     _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
00696 }
00697 
00698 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
00699 {
00700   if (_isLocal) {
00701     SALOMEDS::Locker lock;
00702     _local_impl->SetVariable(theVarName,
00703                              theValue,
00704                              SALOMEDSImpl_GenericVariable::INTEGER_VAR);
00705   }
00706   else 
00707     _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
00708 }
00709 
00710 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
00711 {
00712   if (_isLocal) {
00713     SALOMEDS::Locker lock;
00714     _local_impl->SetVariable(theVarName,
00715                              theValue,
00716                              SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
00717   }
00718   else 
00719     _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
00720 }
00721 
00722 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
00723 {
00724   if (_isLocal) {
00725     SALOMEDS::Locker lock;
00726     _local_impl->SetStringVariable(theVarName,
00727                                    theValue,
00728                                    SALOMEDSImpl_GenericVariable::STRING_VAR);
00729   }
00730   else 
00731     _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
00732 }
00733 
00734 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
00735 {
00736   if (_isLocal) {
00737     SALOMEDS::Locker lock;
00738     _local_impl->SetStringVariableAsDouble(theVarName,
00739                                            theValue,
00740                                            SALOMEDSImpl_GenericVariable::STRING_VAR);
00741   }
00742   else 
00743     _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
00744 }
00745 
00746 double SALOMEDS_Study::GetReal(const std::string& theVarName)
00747 {
00748   double aResult;
00749   if (_isLocal) {
00750     SALOMEDS::Locker lock;
00751     aResult = _local_impl->GetVariableValue(theVarName);
00752   }
00753   else 
00754     aResult = _corba_impl->GetReal((char*)theVarName.c_str());
00755   return aResult;
00756 }
00757 
00758 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
00759 {
00760   int aResult;  
00761   if (_isLocal) {
00762     SALOMEDS::Locker lock;
00763     aResult = (int) _local_impl->GetVariableValue(theVarName);
00764   }
00765   else 
00766     aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
00767   return aResult;
00768 }
00769 
00770 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
00771 {
00772   bool aResult;
00773   if (_isLocal) {
00774     SALOMEDS::Locker lock;
00775     aResult = (bool) _local_impl->GetVariableValue(theVarName);
00776   }
00777   else 
00778     aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
00779   return aResult;
00780 }
00781 
00782 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
00783 {
00784   std::string aResult;
00785   if (_isLocal) {
00786     SALOMEDS::Locker lock;
00787     aResult = _local_impl->GetStringVariableValue(theVarName);
00788   }
00789   else 
00790     aResult = _corba_impl->GetString((char*)theVarName.c_str());
00791   return aResult;
00792 }
00793 
00794 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
00795 {
00796   bool aResult;
00797   if (_isLocal) {
00798     SALOMEDS::Locker lock;
00799     aResult = _local_impl->IsTypeOf(theVarName, 
00800                                    SALOMEDSImpl_GenericVariable::REAL_VAR);
00801   }
00802   else
00803     aResult = _corba_impl->IsReal((char*)theVarName.c_str());
00804   return aResult;
00805 }
00806 
00807 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
00808 {
00809   bool aResult;
00810   if (_isLocal) {
00811     SALOMEDS::Locker lock;
00812     aResult = _local_impl->IsTypeOf(theVarName, 
00813                                    SALOMEDSImpl_GenericVariable::INTEGER_VAR);
00814   }
00815   else
00816     aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
00817   return aResult;
00818 }
00819 
00820 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
00821 {
00822   bool aResult;
00823   if (_isLocal) {
00824     SALOMEDS::Locker lock;
00825     aResult = _local_impl->IsTypeOf(theVarName, 
00826                                    SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
00827   }
00828   else
00829     aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
00830   return aResult;
00831 }
00832 
00833 bool SALOMEDS_Study::IsString(const std::string& theVarName)
00834 {
00835   bool aResult;
00836   if (_isLocal) {
00837     SALOMEDS::Locker lock;
00838     aResult = _local_impl->IsTypeOf(theVarName, 
00839                                     SALOMEDSImpl_GenericVariable::STRING_VAR);
00840   }
00841   else
00842     aResult = _corba_impl->IsString((char*)theVarName.c_str());
00843   return aResult;
00844 }
00845 
00846 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
00847 {
00848   bool aResult;
00849   if (_isLocal) {
00850     SALOMEDS::Locker lock;
00851     aResult = _local_impl->IsVariable(theVarName);
00852   }
00853   else
00854     aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
00855   return aResult;
00856 }
00857 
00858 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
00859 {
00860   std::vector<std::string> aVector;
00861   if (_isLocal) {
00862     SALOMEDS::Locker lock;
00863     aVector = _local_impl->GetVariableNames();
00864   }
00865   else {
00866     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
00867     int aLength = aSeq->length();
00868     for (int i = 0; i < aLength; i++) 
00869       aVector.push_back( std::string(aSeq[i].in()) );
00870   }
00871   return aVector;
00872 }
00873 
00874 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
00875 {
00876   bool aResult;
00877   if (_isLocal) {
00878     SALOMEDS::Locker lock;
00879     aResult = _local_impl->RemoveVariable(theVarName);
00880   }
00881   else
00882     aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
00883   return aResult;
00884 }
00885 
00886 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
00887 {
00888   bool aResult;
00889   if (_isLocal) {
00890     SALOMEDS::Locker lock;
00891     aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
00892   }
00893   else
00894     aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
00895   return aResult;
00896 }
00897 
00898 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
00899 {
00900   bool aResult;
00901   if (_isLocal) {
00902     SALOMEDS::Locker lock;
00903     aResult = _local_impl->IsVariableUsed(theVarName);
00904   }
00905   else
00906     aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
00907   return aResult;
00908 }
00909 
00910 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
00911 {
00912   std::vector< std::vector<std::string> > aResult;
00913   if (_isLocal) {
00914     SALOMEDS::Locker lock;
00915     aResult = _local_impl->ParseVariables(theVars);
00916   }
00917   else {
00918     SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
00919     for (int i = 0, n = aSeq->length(); i < n; i++) {
00920       std::vector<std::string> aVector;
00921       SALOMEDS::ListOfStrings aSection = aSeq[i];
00922       for (int j = 0, m = aSection.length(); j < m; j++) {
00923         aVector.push_back( std::string(aSection[j].in()) );
00924       }
00925       aResult.push_back( aVector );
00926     }
00927   }
00928   return aResult;
00929 }
00930 
00931 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) 
00932 {
00933   return _orb->object_to_string(theObject); 
00934 }
00935 
00936 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR) 
00937 { 
00938   return _orb->string_to_object(theIOR.c_str()); 
00939 } 
00940 
00941 void SALOMEDS_Study::init_orb()
00942 {
00943   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
00944   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()); 
00945   _orb = init(0 , 0 ) ;     
00946 }
00947 
00948 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
00949 {
00950   if (_isLocal) {
00951     SALOMEDS::Locker lock;
00952 
00953     if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
00954     std::string anIOR = _local_impl->GetTransientReference();
00955     SALOMEDS::Study_var aStudy;
00956     if (!_local_impl->IsError() && anIOR != "") {
00957       aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
00958     }
00959     else {
00960       SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
00961       aStudy = aStudy_servant->_this();
00962       _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
00963     }
00964     _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
00965     return aStudy._retn();
00966   }
00967   else {
00968     return SALOMEDS::Study::_duplicate(_corba_impl);
00969   }
00970 
00971   return SALOMEDS::Study::_nil();
00972 }
00973 
00974 
00975 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
00976 {
00977   SALOMEDSClient_AttributeParameter* AP = NULL;
00978   if(theSavePoint >= 0) {
00979     if (_isLocal) {
00980       SALOMEDS::Locker lock;
00981       AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
00982     }
00983     else {
00984       AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
00985     }
00986   }
00987   return _PTR(AttributeParameter)(AP);
00988 }
00989 
00990 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID, 
00991                                                              const std::string& theModuleName, int theSavePoint)
00992 {
00993   SALOMEDSClient_AttributeParameter* AP = NULL;
00994   if(theSavePoint > 0) {
00995     if (_isLocal) {
00996       SALOMEDS::Locker lock;
00997       AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
00998     }
00999     else {
01000       AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
01001     }
01002   }
01003   return _PTR(AttributeParameter)(AP);
01004 }
01005 
01006 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
01007 {
01008   if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
01009   _corba_impl->attach(theObserver,modify);
01010 }