X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDS%2FSALOMEDS_Study.cxx;h=2a14971d7f632ed0283c3130f02e220456d8bd80;hb=495acf55df01f2587dec216530056731338a38f3;hp=e97694d1beb658dc67c90a1a082d706a648f1547;hpb=7d2fe213bdf5bf962ce11e253020c9d3e0bc1cce;p=modules%2Fkernel.git diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index e97694d1b..2a14971d7 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : SALOMEDS_Study.cxx // Author : Sergey RUIN // Module : SALOME @@ -47,6 +48,8 @@ #include "SALOMEDSImpl_GenericVariable.hxx" #include "SALOMEDSImpl_UseCaseBuilder.hxx" +#include + #include "SALOMEDS_Driver_i.hxx" #include "SALOMEDS_Study_i.hxx" @@ -62,14 +65,15 @@ #include #endif -using namespace std; - SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy) { _isLocal = true; _local_impl = theStudy; _corba_impl = SALOMEDS::Study::_nil(); - init_orb(); + + pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 ); + + InitORB(); } SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) @@ -80,7 +84,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(addr); _corba_impl = SALOMEDS::Study::_duplicate(theStudy); @@ -90,32 +96,171 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) _corba_impl = SALOMEDS::Study::_duplicate(theStudy); } - init_orb(); + InitORB(); } SALOMEDS_Study::~SALOMEDS_Study() { } -std::string SALOMEDS_Study::GetPersistentReference() +void SALOMEDS_Study::InitORB() { - std::string aRef; + ORB_INIT &init = *SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init(0 , 0 ) ; +} + +void SALOMEDS_Study::Init() +{ + if(CORBA::is_nil(_corba_impl)) + return; + + _corba_impl->Init(); +} + +void SALOMEDS_Study::Clear() +{ + if(CORBA::is_nil(_corba_impl)) + return; + + _corba_impl->Clear(); +} + +bool SALOMEDS_Study::Open(const std::string& theStudyUrl) +{ + if(CORBA::is_nil(_corba_impl)) + return false; + std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl ); + + if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) ) + return false; + + return true; +} + +bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII) +{ + if(CORBA::is_nil(_corba_impl)) + return false; + + return _corba_impl->Save(theMultiFile, theASCII); +} + +bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII) +{ + if(CORBA::is_nil(_corba_impl)) + return false; + + return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), theMultiFile, theASCII); +} + +SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb) +{ + SALOMEDS_Driver_i* driver = NULL; + + SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent(); + if(!aSCO.IsNull()) { + std::string IOREngine = aSCO.GetIOR(); + if(!IOREngine.empty()) { + CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str()); + Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ; + driver = new SALOMEDS_Driver_i(Engine, orb); + } + } + + return driver; +} + +bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO) +{ + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); + bool ret; + if (_isLocal) { SALOMEDS::Locker lock; - aRef = _local_impl->GetPersistentReference(); + + SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl()); + SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); + ret = _local_impl->CanCopy(aSO_impl, aDriver); + delete aDriver; } - else aRef = _corba_impl->GetPersistentReference(); - return aRef; + else { + ret = _corba_impl->CanCopy(aSO->GetCORBAImpl()); + } + + return ret; } -std::string SALOMEDS_Study::GetTransientReference() +bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO) +{ + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); + bool ret; + if (_isLocal) { + SALOMEDS::Locker lock; + + SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl()); + SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); + ret = _local_impl->Copy(aSO_impl, aDriver); + delete aDriver; + } + else { + ret = _corba_impl->Copy(aSO->GetCORBAImpl()); + } + return ret; +} + +bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO) +{ + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); + bool ret; + + if (_isLocal) { + SALOMEDS::Locker lock; + + SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl()); + SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); + ret = _local_impl->CanPaste(aSO_impl, aDriver); + delete aDriver; + } + else { + ret = _corba_impl->CanPaste(aSO->GetCORBAImpl()); + } + + return ret; +} + +_PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO) +{ + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); + SALOMEDSClient_SObject* aResult = NULL; + + if (_isLocal) { + SALOMEDS::Locker lock; + + SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl()); + SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); + SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver); + delete aDriver; + if(aNewSO.IsNull()) return _PTR(SObject)(aResult); + aResult = new SALOMEDS_SObject(aNewSO); + } + else { + SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl()); + if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult); + aResult = new SALOMEDS_SObject(aNewSO); + } + + return _PTR(SObject)(aResult); +} + +std::string SALOMEDS_Study::GetPersistentReference() { std::string aRef; if (_isLocal) { SALOMEDS::Locker lock; - aRef = _local_impl->GetTransientReference(); + aRef = _local_impl->GetPersistentReference(); } - else aRef = _corba_impl->GetTransientReference(); + else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference(); return aRef; } @@ -176,9 +321,9 @@ _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName) SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName); if (!aSO_impl) return _PTR(SObject)(aSO); if(aSO_impl.IsComponent()) { - SALOMEDSImpl_SComponent aSCO_impl = aSO_impl; + SALOMEDSImpl_SComponent aSCO_impl = aSO_impl; return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl)); - } + } aSO = new SALOMEDS_SObject(aSO_impl); } else { @@ -201,14 +346,14 @@ std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& a if (_isLocal) { SALOMEDS::Locker lock; - vector aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName); + std::vector aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName); aLength = aSeq.size(); for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i]))); } else { SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(), - (char*)aComponentName.c_str()); + (char*)aComponentName.c_str()); aLength = aSeq->length(); for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i]))); } @@ -300,91 +445,6 @@ std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO) return aPath; } -void SALOMEDS_Study::SetContext(const std::string& thePath) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->SetContext(thePath); - } - else _corba_impl->SetContext((char*)thePath.c_str()); -} - -std::string SALOMEDS_Study::GetContext() -{ - std::string aPath; - if (_isLocal) { - SALOMEDS::Locker lock; - aPath = _local_impl->GetContext(); - } - else aPath = _corba_impl->GetContext(); - return aPath; -} - -std::vector SALOMEDS_Study::GetObjectNames(const std::string& theContext) -{ - std::vector aVector; - int aLength, i; - if (_isLocal) { - SALOMEDS::Locker lock; - aVector = _local_impl->GetObjectNames(theContext); - } - else { - SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str()); - aLength = aSeq->length(); - for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in())); - } - return aVector; -} - -std::vector SALOMEDS_Study::GetDirectoryNames(const std::string& theContext) -{ - std::vector aVector; - int aLength, i; - if (_isLocal) { - SALOMEDS::Locker lock; - aVector = _local_impl->GetDirectoryNames(theContext); - } - else { - SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str()); - aLength = aSeq->length(); - for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in()); - } - return aVector; -} - -std::vector SALOMEDS_Study::GetFileNames(const std::string& theContext) -{ - std::vector aVector; - int aLength, i; - if (_isLocal) { - SALOMEDS::Locker lock; - aVector = _local_impl->GetFileNames(theContext); - } - else { - SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str()); - aLength = aSeq->length(); - - for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in()); - } - return aVector; -} - -std::vector SALOMEDS_Study::GetComponentNames(const std::string& theContext) -{ - std::vector aVector; - int aLength, i; - if (_isLocal) { - SALOMEDS::Locker lock; - aVector = _local_impl->GetComponentNames(theContext); - } - else { - SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str()); - aLength = aSeq->length(); - for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in()); - } - return aVector; -} - _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); @@ -443,7 +503,7 @@ std::string SALOMEDS_Study::Name() SALOMEDS::Locker lock; aName = _local_impl->Name(); } - else aName = _corba_impl->Name(); + else aName = Kernel_Utils::encode_s(_corba_impl->Name()); return aName; } @@ -453,7 +513,7 @@ void SALOMEDS_Study::Name(const std::string& theName) SALOMEDS::Locker lock; _local_impl->Name(theName); } - else _corba_impl->Name((char*)theName.c_str()); + else _corba_impl->Name(Kernel_Utils::decode_s(theName)); } bool SALOMEDS_Study::IsSaved() @@ -504,7 +564,8 @@ std::string SALOMEDS_Study::URL() SALOMEDS::Locker lock; aURL = _local_impl->URL(); } - else aURL = _corba_impl->URL(); + else + aURL = Kernel_Utils::encode_s(_corba_impl->URL()); return aURL; } @@ -514,27 +575,7 @@ void SALOMEDS_Study::URL(const std::string& url) SALOMEDS::Locker lock; _local_impl->URL(url); } - else _corba_impl->URL((char*)url.c_str()); -} - -int SALOMEDS_Study::StudyId() -{ - int anID; - if (_isLocal) { - SALOMEDS::Locker lock; - anID = _local_impl->StudyId(); - } - else anID = _corba_impl->StudyId(); - return anID; -} - -void SALOMEDS_Study::StudyId(int id) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->StudyId(id); - } - else _corba_impl->StudyId(id); + else _corba_impl->URL(Kernel_Utils::decode_s(url)); } std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO) @@ -545,7 +586,7 @@ std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& if (_isLocal) { SALOMEDS::Locker lock; - vector aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl())); + std::vector aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl())); if (aSeq.size()) { aLength = aSeq.size(); for (i = 0; i < aLength; i++) @@ -567,7 +608,7 @@ _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties() SALOMEDS::Locker lock; aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties()); } - else aProp = new SALOMEDS_AttributeStudyProperties(_corba_impl->GetProperties()); + else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties()); return _PTR(AttributeStudyProperties)(aProp); } @@ -615,30 +656,24 @@ _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder() return _PTR(UseCaseBuilder)(aUB); } -void SALOMEDS_Study::Close() -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->Close(); - } - else _corba_impl->Close(); -} - void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled) { if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled); else _corba_impl->EnableUseCaseAutoFilling(isEnabled); } -bool SALOMEDS_Study::DumpStudy(const string& thePath, const string& theBaseName, bool isPublished) +bool SALOMEDS_Study::DumpStudy(const std::string& thePath, + const std::string& theBaseName, + bool isPublished, + bool isMultiFile) { - //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one - if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it - bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished); - return ret; + if(CORBA::is_nil(_corba_impl)) + return false; + + return _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile); } -void SALOMEDS_Study::SetStudyLock(const string& theLockerID) +void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID) { if (_isLocal) { SALOMEDS::Locker lock; @@ -658,13 +693,13 @@ bool SALOMEDS_Study::IsStudyLocked() return isLocked; } -void SALOMEDS_Study::UnLockStudy(const string& theLockerID) +void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID) { if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str()); else _corba_impl->UnLockStudy((char*)theLockerID.c_str()); } -vector SALOMEDS_Study::GetLockerID() +std::vector SALOMEDS_Study::GetLockerID() { std::vector aVector; int aLength, i; @@ -681,7 +716,7 @@ vector SALOMEDS_Study::GetLockerID() } -void SALOMEDS_Study::SetReal(const string& theVarName, const double theValue) +void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue) { if (_isLocal) { SALOMEDS::Locker lock; @@ -693,7 +728,7 @@ void SALOMEDS_Study::SetReal(const string& theVarName, const double theValue) _corba_impl->SetReal((char*)theVarName.c_str(),theValue); } -void SALOMEDS_Study::SetInteger(const string& theVarName, const int theValue) +void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue) { if (_isLocal) { SALOMEDS::Locker lock; @@ -705,7 +740,7 @@ void SALOMEDS_Study::SetInteger(const string& theVarName, const int theValue) _corba_impl->SetInteger((char*)theVarName.c_str(),theValue); } -void SALOMEDS_Study::SetBoolean(const string& theVarName, const bool theValue) +void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue) { if (_isLocal) { SALOMEDS::Locker lock; @@ -717,7 +752,31 @@ void SALOMEDS_Study::SetBoolean(const string& theVarName, const bool theValue) _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue); } -double SALOMEDS_Study::GetReal(const string& theVarName) +void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue) +{ + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->SetStringVariable(theVarName, + theValue, + SALOMEDSImpl_GenericVariable::STRING_VAR); + } + else + _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str()); +} + +void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue) +{ + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->SetStringVariableAsDouble(theVarName, + theValue, + SALOMEDSImpl_GenericVariable::STRING_VAR); + } + else + _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue); +} + +double SALOMEDS_Study::GetReal(const std::string& theVarName) { double aResult; if (_isLocal) { @@ -729,7 +788,7 @@ double SALOMEDS_Study::GetReal(const string& theVarName) return aResult; } -int SALOMEDS_Study::GetInteger(const string& theVarName) +int SALOMEDS_Study::GetInteger(const std::string& theVarName) { int aResult; if (_isLocal) { @@ -741,7 +800,7 @@ int SALOMEDS_Study::GetInteger(const string& theVarName) return aResult; } -bool SALOMEDS_Study::GetBoolean(const string& theVarName) +bool SALOMEDS_Study::GetBoolean(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -753,7 +812,19 @@ bool SALOMEDS_Study::GetBoolean(const string& theVarName) return aResult; } -bool SALOMEDS_Study::IsReal(const string& theVarName) +std::string SALOMEDS_Study::GetString(const std::string& theVarName) +{ + std::string aResult; + if (_isLocal) { + SALOMEDS::Locker lock; + aResult = _local_impl->GetStringVariableValue(theVarName); + } + else + aResult = _corba_impl->GetString((char*)theVarName.c_str()); + return aResult; +} + +bool SALOMEDS_Study::IsReal(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -766,7 +837,7 @@ bool SALOMEDS_Study::IsReal(const string& theVarName) return aResult; } -bool SALOMEDS_Study::IsInteger(const string& theVarName) +bool SALOMEDS_Study::IsInteger(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -779,7 +850,7 @@ bool SALOMEDS_Study::IsInteger(const string& theVarName) return aResult; } -bool SALOMEDS_Study::IsBoolean(const string& theVarName) +bool SALOMEDS_Study::IsBoolean(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -792,7 +863,20 @@ bool SALOMEDS_Study::IsBoolean(const string& theVarName) return aResult; } -bool SALOMEDS_Study::IsVariable(const string& theVarName) +bool SALOMEDS_Study::IsString(const std::string& theVarName) +{ + bool aResult; + if (_isLocal) { + SALOMEDS::Locker lock; + aResult = _local_impl->IsTypeOf(theVarName, + SALOMEDSImpl_GenericVariable::STRING_VAR); + } + else + aResult = _corba_impl->IsString((char*)theVarName.c_str()); + return aResult; +} + +bool SALOMEDS_Study::IsVariable(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -804,9 +888,9 @@ bool SALOMEDS_Study::IsVariable(const string& theVarName) return aResult; } -vector SALOMEDS_Study::GetVariableNames() +std::vector SALOMEDS_Study::GetVariableNames() { - vector aVector; + std::vector aVector; if (_isLocal) { SALOMEDS::Locker lock; aVector = _local_impl->GetVariableNames(); @@ -815,12 +899,12 @@ vector SALOMEDS_Study::GetVariableNames() SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames(); int aLength = aSeq->length(); for (int i = 0; i < aLength; i++) - aVector.push_back( string(aSeq[i].in()) ); + aVector.push_back( std::string(aSeq[i].in()) ); } return aVector; } -bool SALOMEDS_Study::RemoveVariable(const string& theVarName) +bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -832,7 +916,7 @@ bool SALOMEDS_Study::RemoveVariable(const string& theVarName) return aResult; } -bool SALOMEDS_Study::RenameVariable(const string& theVarName, const string& theNewVarName) +bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName) { bool aResult; if (_isLocal) { @@ -844,7 +928,7 @@ bool SALOMEDS_Study::RenameVariable(const string& theVarName, const string& theN return aResult; } -bool SALOMEDS_Study::IsVariableUsed(const string& theVarName) +bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName) { bool aResult; if (_isLocal) { @@ -856,9 +940,9 @@ bool SALOMEDS_Study::IsVariableUsed(const string& theVarName) return aResult; } -vector< vector > SALOMEDS_Study::ParseVariables(const string& theVars) +std::vector< std::vector > SALOMEDS_Study::ParseVariables(const std::string& theVars) { - vector< vector > aResult; + std::vector< std::vector > aResult; if (_isLocal) { SALOMEDS::Locker lock; aResult = _local_impl->ParseVariables(theVars); @@ -866,10 +950,10 @@ vector< vector > SALOMEDS_Study::ParseVariables(const string& theVars) else { SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str()); for (int i = 0, n = aSeq->length(); i < n; i++) { - vector aVector; + std::vector aVector; SALOMEDS::ListOfStrings aSection = aSeq[i]; for (int j = 0, m = aSection.length(); j < m; j++) { - aVector.push_back( string(aSection[j].in()) ); + aVector.push_back( std::string(aSection[j].in()) ); } aResult.push_back( aVector ); } @@ -887,41 +971,7 @@ CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR) return _orb->string_to_object(theIOR.c_str()); } -void SALOMEDS_Study::init_orb() -{ - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(0 , 0 ) ; -} - -SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy() -{ - if (_isLocal) { - SALOMEDS::Locker lock; - - if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl); - std::string anIOR = _local_impl->GetTransientReference(); - SALOMEDS::Study_var aStudy; - if (!_local_impl->IsError() && anIOR != "") { - aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str())); - } - else { - SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb); - aStudy = aStudy_servant->_this(); - _local_impl->SetTransientReference(_orb->object_to_string(aStudy)); - } - _corba_impl = SALOMEDS::Study::_duplicate(aStudy); - return aStudy._retn(); - } - else { - return SALOMEDS::Study::_duplicate(_corba_impl); - } - - return SALOMEDS::Study::_nil(); -} - - -_PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint) +_PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint) { SALOMEDSClient_AttributeParameter* AP = NULL; if(theSavePoint >= 0) { @@ -936,8 +986,8 @@ _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID return _PTR(AttributeParameter)(AP); } -_PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const string& theID, - const string& theModuleName, int theSavePoint) +_PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID, + const std::string& theModuleName, int theSavePoint) { SALOMEDSClient_AttributeParameter* AP = NULL; if(theSavePoint > 0) { @@ -951,3 +1001,19 @@ _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const string& theID } return _PTR(AttributeParameter)(AP); } + +void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify) +{ + if(CORBA::is_nil(_corba_impl)) + return; + + _corba_impl->attach(theObserver,modify); +} + +void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver) +{ + if(CORBA::is_nil(_corba_impl)) + return; + + _corba_impl->detach(theObserver); +}