1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_Study.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
29 #include "SALOMEDS_Study.hxx"
31 #include "SALOMEDS.hxx"
32 #include "SALOMEDS_SComponent.hxx"
33 #include "SALOMEDS_SObject.hxx"
34 #include "SALOMEDS_StudyBuilder.hxx"
35 #include "SALOMEDS_ChildIterator.hxx"
36 #include "SALOMEDS_SComponentIterator.hxx"
37 #include "SALOMEDS_AttributeStudyProperties.hxx"
38 #include "SALOMEDS_AttributeParameter.hxx"
39 #include "SALOMEDS_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_SComponent.hxx"
42 #include "SALOMEDSImpl_SObject.hxx"
43 #include "SALOMEDSImpl_StudyBuilder.hxx"
44 #include "SALOMEDSImpl_ChildIterator.hxx"
45 #include "SALOMEDSImpl_SComponentIterator.hxx"
46 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
47 #include "SALOMEDSImpl_AttributeParameter.hxx"
48 #include "SALOMEDSImpl_GenericVariable.hxx"
49 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
51 #include <SALOME_KernelServices.hxx>
53 #include "SALOMEDS_Driver_i.hxx"
54 #include "SALOMEDS_Study_i.hxx"
56 #include "Utils_ORB_INIT.hxx"
57 #include "Utils_SINGLETON.hxx"
59 #include "Basics_Utils.hxx"
64 #include <sys/types.h>
68 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
71 _local_impl = theStudy;
72 _corba_impl = SALOMEDS::Study::_nil();
74 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
79 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
82 long pid = (long)_getpid();
84 long pid = (long)getpid();
87 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
89 CORBA::LongLong addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
91 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
92 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
96 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
102 SALOMEDS_Study::~SALOMEDS_Study()
106 void SALOMEDS_Study::InitORB()
108 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
109 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
110 _orb = init(0 , 0 ) ;
113 void SALOMEDS_Study::Init()
115 if(CORBA::is_nil(_corba_impl))
121 void SALOMEDS_Study::Clear()
123 if(CORBA::is_nil(_corba_impl))
126 _corba_impl->Clear();
129 bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
131 if(CORBA::is_nil(_corba_impl))
133 std::wstring wtheStudyUrl = std::wstring(theStudyUrl.begin(), theStudyUrl.end());
135 if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) )
141 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
143 if(CORBA::is_nil(_corba_impl))
146 return _corba_impl->Save(theMultiFile, theASCII);
149 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
151 if(CORBA::is_nil(_corba_impl))
154 return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), theMultiFile, theASCII);
157 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
159 SALOMEDS_Driver_i* driver = NULL;
161 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
163 std::string IOREngine = aSCO.GetIOR();
164 if(!IOREngine.empty()) {
165 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
166 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
167 driver = new SALOMEDS_Driver_i(Engine, orb);
174 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
176 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
180 SALOMEDS::Locker lock;
182 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
183 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
184 ret = _local_impl->CanCopy(aSO_impl, aDriver);
188 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
194 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
196 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
199 SALOMEDS::Locker lock;
201 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
202 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
203 ret = _local_impl->Copy(aSO_impl, aDriver);
207 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
212 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
214 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
218 SALOMEDS::Locker lock;
220 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
221 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
222 ret = _local_impl->CanPaste(aSO_impl, aDriver);
226 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
232 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
234 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
235 SALOMEDSClient_SObject* aResult = NULL;
238 SALOMEDS::Locker lock;
240 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
241 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
242 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
244 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
245 aResult = new SALOMEDS_SObject(aNewSO);
248 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
249 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
250 aResult = new SALOMEDS_SObject(aNewSO);
253 return _PTR(SObject)(aResult);
256 std::string SALOMEDS_Study::GetPersistentReference()
260 SALOMEDS::Locker lock;
261 aRef = _local_impl->GetPersistentReference();
263 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
267 bool SALOMEDS_Study::IsEmpty()
271 SALOMEDS::Locker lock;
272 ret = _local_impl->IsEmpty();
274 else ret = _corba_impl->IsEmpty();
278 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
280 SALOMEDSClient_SComponent* aSCO = NULL;
282 SALOMEDS::Locker lock;
284 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
285 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
286 aSCO = new SALOMEDS_SComponent(aSCO_impl);
289 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
290 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
291 aSCO = new SALOMEDS_SComponent(aSCO_impl);
293 return _PTR(SComponent)(aSCO);
296 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
298 SALOMEDSClient_SComponent* aSCO = NULL;
300 SALOMEDS::Locker lock;
302 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
303 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
304 aSCO = new SALOMEDS_SComponent(aSCO_impl);
307 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
308 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
309 aSCO = new SALOMEDS_SComponent(aSCO_impl);
311 return _PTR(SComponent)(aSCO);
314 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
316 SALOMEDSClient_SObject* aSO = NULL;
319 SALOMEDS::Locker lock;
321 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
322 if (!aSO_impl) return _PTR(SObject)(aSO);
323 if(aSO_impl.IsComponent()) {
324 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
325 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
327 aSO = new SALOMEDS_SObject(aSO_impl);
330 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
331 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
332 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
333 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
334 aSO = new SALOMEDS_SObject(aSO_impl);
337 return _PTR(SObject)(aSO);
340 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
341 const std::string& aComponentName)
343 std::vector<_PTR(SObject)> aVector;
347 SALOMEDS::Locker lock;
349 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
350 aLength = aSeq.size();
351 for (i = 0; i< aLength; i++)
352 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
355 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
356 (char*)aComponentName.c_str());
357 aLength = aSeq->length();
358 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
364 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
366 SALOMEDSClient_SObject* aSO = NULL;
368 SALOMEDS::Locker lock;
370 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
371 if(!aSO_impl) return _PTR(SObject)(aSO);
372 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
375 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
376 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
377 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
379 return _PTR(SObject)(aSO);
382 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
384 SALOMEDSClient_SObject* aSO = NULL;
386 SALOMEDS::Locker lock;
387 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
388 if(!aSO_impl) return _PTR(SObject)(aSO);
389 aSO = new SALOMEDS_SObject(aSO_impl);
392 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
393 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
394 aSO = new SALOMEDS_SObject(aSO_impl);
396 return _PTR(SObject)(aSO);
399 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
401 SALOMEDSClient_SObject* aSO = NULL;
403 SALOMEDS::Locker lock;
405 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
406 if (!aSO_impl) return _PTR(SObject)(aSO);
407 aSO = new SALOMEDS_SObject(aSO_impl);
410 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
411 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
412 aSO = new SALOMEDS_SObject(aSO_impl);
414 return _PTR(SObject)(aSO);
417 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
419 SALOMEDSClient_SObject* aSO = NULL;
421 SALOMEDS::Locker lock;
423 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
424 if (!aSO_impl) return _PTR(SObject)(aSO);
425 aSO = new SALOMEDS_SObject(aSO_impl);
428 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
429 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
430 aSO = new SALOMEDS_SObject(aSO_impl);
432 return _PTR(SObject)(aSO);
435 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
437 if(!theSO) return "";
438 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
441 SALOMEDS::Locker lock;
442 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
444 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
448 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
450 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
451 SALOMEDSClient_ChildIterator* aCI = NULL;
453 SALOMEDS::Locker lock;
454 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
455 aCI = new SALOMEDS_ChildIterator(aCIimpl);
458 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
459 aCI = new SALOMEDS_ChildIterator(aCIimpl);
462 return _PTR(ChildIterator)(aCI);
465 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
467 SALOMEDSClient_SComponentIterator* aCI = NULL;
469 SALOMEDS::Locker lock;
471 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
472 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
475 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
476 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
479 return _PTR(SComponentIterator)(aCI);
482 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
484 SALOMEDSClient_StudyBuilder* aSB = NULL;
486 SALOMEDS::Locker lock;
488 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
489 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
492 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
493 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
496 return _PTR(StudyBuilder)(aSB);
499 std::string SALOMEDS_Study::Name()
503 SALOMEDS::Locker lock;
504 aName = _local_impl->Name();
506 else aName = Kernel_Utils::encode_s(_corba_impl->Name());
510 void SALOMEDS_Study::Name(const std::string& theName)
513 SALOMEDS::Locker lock;
514 _local_impl->Name(theName);
516 else _corba_impl->Name(Kernel_Utils::decode_s(theName));
519 bool SALOMEDS_Study::IsSaved()
523 SALOMEDS::Locker lock;
524 isSaved = _local_impl->IsSaved();
526 else isSaved = _corba_impl->IsSaved();
530 void SALOMEDS_Study::IsSaved(bool save)
533 SALOMEDS::Locker lock;
534 _local_impl->IsSaved(save);
536 else _corba_impl->IsSaved(save);
539 bool SALOMEDS_Study::IsModified()
543 SALOMEDS::Locker lock;
544 isModified = _local_impl->IsModified();
546 else isModified = _corba_impl->IsModified();
550 void SALOMEDS_Study::Modified()
553 SALOMEDS::Locker lock;
554 _local_impl->Modify();
556 else _corba_impl->Modified();
560 std::string SALOMEDS_Study::URL()
564 SALOMEDS::Locker lock;
565 aURL = _local_impl->URL();
568 aURL = Kernel_Utils::encode_s(_corba_impl->URL());
572 void SALOMEDS_Study::URL(const std::string& url)
575 SALOMEDS::Locker lock;
576 _local_impl->URL(url);
578 else _corba_impl->URL(Kernel_Utils::decode_s(url));
581 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
583 std::vector<_PTR(SObject)> aVector;
584 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
587 SALOMEDS::Locker lock;
589 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
591 aLength = aSeq.size();
592 for (i = 0; i < aLength; i++)
593 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
597 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
598 aLength = aSeq->length();
599 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
604 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
606 SALOMEDSClient_AttributeStudyProperties* aProp;
608 SALOMEDS::Locker lock;
609 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
611 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
612 return _PTR(AttributeStudyProperties)(aProp);
615 std::string SALOMEDS_Study::GetLastModificationDate()
619 SALOMEDS::Locker lock;
620 aDate = _local_impl->GetLastModificationDate();
622 else aDate = _corba_impl->GetLastModificationDate();
626 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
628 std::vector<std::string> aVector;
631 SALOMEDS::Locker lock;
632 aVector = _local_impl->GetModificationsDate();
635 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
636 aLength = aSeq->length();
637 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
642 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
644 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
646 SALOMEDS::Locker lock;
648 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
649 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
652 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
653 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
656 return _PTR(UseCaseBuilder)(aUB);
659 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
661 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
662 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
665 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
666 const std::string& theBaseName,
670 if(CORBA::is_nil(_corba_impl))
673 return _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
676 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
679 SALOMEDS::Locker lock;
680 _local_impl->SetStudyLock(theLockerID.c_str());
682 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
685 bool SALOMEDS_Study::IsStudyLocked()
689 SALOMEDS::Locker lock;
690 isLocked = _local_impl->IsStudyLocked();
692 else isLocked = _corba_impl->IsStudyLocked();
696 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
698 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
699 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
702 std::vector<std::string> SALOMEDS_Study::GetLockerID()
704 std::vector<std::string> aVector;
707 SALOMEDS::Locker lock;
708 aVector = _local_impl->GetLockerID();
711 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
712 aLength = aSeq->length();
713 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
719 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
722 SALOMEDS::Locker lock;
723 _local_impl->SetVariable(theVarName,
725 SALOMEDSImpl_GenericVariable::REAL_VAR);
728 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
731 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
734 SALOMEDS::Locker lock;
735 _local_impl->SetVariable(theVarName,
737 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
740 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
743 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
746 SALOMEDS::Locker lock;
747 _local_impl->SetVariable(theVarName,
749 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
752 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
755 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
758 SALOMEDS::Locker lock;
759 _local_impl->SetStringVariable(theVarName,
761 SALOMEDSImpl_GenericVariable::STRING_VAR);
764 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
767 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
770 SALOMEDS::Locker lock;
771 _local_impl->SetStringVariableAsDouble(theVarName,
773 SALOMEDSImpl_GenericVariable::STRING_VAR);
776 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
779 double SALOMEDS_Study::GetReal(const std::string& theVarName)
783 SALOMEDS::Locker lock;
784 aResult = _local_impl->GetVariableValue(theVarName);
787 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
791 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
795 SALOMEDS::Locker lock;
796 aResult = (int) _local_impl->GetVariableValue(theVarName);
799 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
803 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
807 SALOMEDS::Locker lock;
808 aResult = (bool) _local_impl->GetVariableValue(theVarName);
811 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
815 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
819 SALOMEDS::Locker lock;
820 aResult = _local_impl->GetStringVariableValue(theVarName);
823 aResult = _corba_impl->GetString((char*)theVarName.c_str());
827 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
831 SALOMEDS::Locker lock;
832 aResult = _local_impl->IsTypeOf(theVarName,
833 SALOMEDSImpl_GenericVariable::REAL_VAR);
836 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
840 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
844 SALOMEDS::Locker lock;
845 aResult = _local_impl->IsTypeOf(theVarName,
846 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
849 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
853 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
857 SALOMEDS::Locker lock;
858 aResult = _local_impl->IsTypeOf(theVarName,
859 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
862 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
866 bool SALOMEDS_Study::IsString(const std::string& theVarName)
870 SALOMEDS::Locker lock;
871 aResult = _local_impl->IsTypeOf(theVarName,
872 SALOMEDSImpl_GenericVariable::STRING_VAR);
875 aResult = _corba_impl->IsString((char*)theVarName.c_str());
879 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
883 SALOMEDS::Locker lock;
884 aResult = _local_impl->IsVariable(theVarName);
887 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
891 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
893 std::vector<std::string> aVector;
895 SALOMEDS::Locker lock;
896 aVector = _local_impl->GetVariableNames();
899 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
900 int aLength = aSeq->length();
901 for (int i = 0; i < aLength; i++)
902 aVector.push_back( std::string(aSeq[i].in()) );
907 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
911 SALOMEDS::Locker lock;
912 aResult = _local_impl->RemoveVariable(theVarName);
915 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
919 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
923 SALOMEDS::Locker lock;
924 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
927 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
931 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
935 SALOMEDS::Locker lock;
936 aResult = _local_impl->IsVariableUsed(theVarName);
939 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
943 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
945 std::vector< std::vector<std::string> > aResult;
947 SALOMEDS::Locker lock;
948 aResult = _local_impl->ParseVariables(theVars);
951 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
952 for (int i = 0, n = aSeq->length(); i < n; i++) {
953 std::vector<std::string> aVector;
954 SALOMEDS::ListOfStrings aSection = aSeq[i];
955 for (int j = 0, m = aSection.length(); j < m; j++) {
956 aVector.push_back( std::string(aSection[j].in()) );
958 aResult.push_back( aVector );
964 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
966 return _orb->object_to_string(theObject);
969 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
971 return _orb->string_to_object(theIOR.c_str());
974 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
976 SALOMEDSClient_AttributeParameter* AP = NULL;
977 if(theSavePoint >= 0) {
979 SALOMEDS::Locker lock;
980 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
983 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
986 return _PTR(AttributeParameter)(AP);
989 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
990 const std::string& theModuleName, int theSavePoint)
992 SALOMEDSClient_AttributeParameter* AP = NULL;
993 if(theSavePoint > 0) {
995 SALOMEDS::Locker lock;
996 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
999 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1002 return _PTR(AttributeParameter)(AP);
1005 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1007 if(CORBA::is_nil(_corba_impl))
1010 _corba_impl->attach(theObserver,modify);
1013 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1015 if(CORBA::is_nil(_corba_impl))
1018 _corba_impl->detach(theObserver);