Salome HOME
[EDF29093] : Quick fix resorbed
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study.cxx
index 86629e27142cfb4d9cb0a410b318bbf2327ff5ff..8f438d9f4ea55151182b1b355dce427dcfeb514a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -53,8 +53,7 @@
 #include "SALOMEDS_Driver_i.hxx"
 #include "SALOMEDS_Study_i.hxx"
 
-#include "Utils_ORB_INIT.hxx" 
-#include "Utils_SINGLETON.hxx" 
+#include "OpUtil.hxx"
 
 #include "Basics_Utils.hxx"
 
@@ -70,6 +69,9 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
   _isLocal = true;
   _local_impl = theStudy;
   _corba_impl = SALOMEDS::Study::_nil();
+
+  pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
+
   InitORB();
 }
 
@@ -81,7 +83,9 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
   long pid =  (long)getpid();
 #endif  
 
-  long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
+  pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
+
+  CORBA::LongLong addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
   if(_isLocal) {
     _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
@@ -100,9 +104,7 @@ SALOMEDS_Study::~SALOMEDS_Study()
 
 void SALOMEDS_Study::InitORB()
 {
-  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  _orb = init(0 , 0 ) ;
+  _orb = KERNEL::GetRefToORB();
 }
 
 void SALOMEDS_Study::Init()
@@ -125,12 +127,18 @@ bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
 {
   if(CORBA::is_nil(_corba_impl))
     return false;
-  std::wstring wtheStudyUrl = std::wstring(theStudyUrl.begin(), theStudyUrl.end());
+  std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
   
-  if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) )
-    return false;
+  return _corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() );
+}
 
-  return true;
+bool SALOMEDS_Study::CanOpen(const std::string& theStudyUrl)
+{
+  if(CORBA::is_nil(_corba_impl))
+    return false;
+  std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
+  
+  return _corba_impl->CanOpen( (wchar_t*)wtheStudyUrl.c_str() );
 }
 
 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
@@ -342,7 +350,7 @@ std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& a
     SALOMEDS::Locker lock;
 
     std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
-    aLength = aSeq.size();
+    aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
     for (i = 0; i< aLength; i++) 
       aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
   }
@@ -583,7 +591,7 @@ std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)&
 
     std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
     if (aSeq.size()) {
-      aLength = aSeq.size();
+      aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
       for (i = 0; i < aLength; i++) 
         aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
     }