1 // Copyright (C) 2007-2021 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"
58 #include "Basics_Utils.hxx"
63 #include <sys/types.h>
67 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
70 _local_impl = theStudy;
71 _corba_impl = SALOMEDS::Study::_nil();
73 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
78 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
81 long pid = (long)_getpid();
83 long pid = (long)getpid();
86 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
88 CORBA::LongLong addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
90 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
91 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
95 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
101 SALOMEDS_Study::~SALOMEDS_Study()
105 void SALOMEDS_Study::InitORB()
107 _orb = KERNEL::GetRefToORB();
110 void SALOMEDS_Study::Init()
112 if(CORBA::is_nil(_corba_impl))
118 void SALOMEDS_Study::Clear()
120 if(CORBA::is_nil(_corba_impl))
123 _corba_impl->Clear();
126 bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
128 if(CORBA::is_nil(_corba_impl))
130 std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
132 return _corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() );
135 bool SALOMEDS_Study::CanOpen(const std::string& theStudyUrl)
137 if(CORBA::is_nil(_corba_impl))
139 std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
141 return _corba_impl->CanOpen( (wchar_t*)wtheStudyUrl.c_str() );
144 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
146 if(CORBA::is_nil(_corba_impl))
149 return _corba_impl->Save(theMultiFile, theASCII);
152 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
154 if(CORBA::is_nil(_corba_impl))
157 return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), theMultiFile, theASCII);
160 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
162 SALOMEDS_Driver_i* driver = NULL;
164 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
166 std::string IOREngine = aSCO.GetIOR();
167 if(!IOREngine.empty()) {
168 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
169 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
170 driver = new SALOMEDS_Driver_i(Engine, orb);
177 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
179 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
183 SALOMEDS::Locker lock;
185 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
186 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
187 ret = _local_impl->CanCopy(aSO_impl, aDriver);
191 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
197 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
199 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
202 SALOMEDS::Locker lock;
204 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
205 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
206 ret = _local_impl->Copy(aSO_impl, aDriver);
210 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
215 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
217 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
221 SALOMEDS::Locker lock;
223 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
224 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
225 ret = _local_impl->CanPaste(aSO_impl, aDriver);
229 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
235 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
237 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
238 SALOMEDSClient_SObject* aResult = NULL;
241 SALOMEDS::Locker lock;
243 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
244 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
245 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
247 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
248 aResult = new SALOMEDS_SObject(aNewSO);
251 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
252 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
253 aResult = new SALOMEDS_SObject(aNewSO);
256 return _PTR(SObject)(aResult);
259 std::string SALOMEDS_Study::GetPersistentReference()
263 SALOMEDS::Locker lock;
264 aRef = _local_impl->GetPersistentReference();
266 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
270 bool SALOMEDS_Study::IsEmpty()
274 SALOMEDS::Locker lock;
275 ret = _local_impl->IsEmpty();
277 else ret = _corba_impl->IsEmpty();
281 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
283 SALOMEDSClient_SComponent* aSCO = NULL;
285 SALOMEDS::Locker lock;
287 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
288 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
289 aSCO = new SALOMEDS_SComponent(aSCO_impl);
292 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
293 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
294 aSCO = new SALOMEDS_SComponent(aSCO_impl);
296 return _PTR(SComponent)(aSCO);
299 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
301 SALOMEDSClient_SComponent* aSCO = NULL;
303 SALOMEDS::Locker lock;
305 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
306 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
307 aSCO = new SALOMEDS_SComponent(aSCO_impl);
310 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
311 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
312 aSCO = new SALOMEDS_SComponent(aSCO_impl);
314 return _PTR(SComponent)(aSCO);
317 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
319 SALOMEDSClient_SObject* aSO = NULL;
322 SALOMEDS::Locker lock;
324 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
325 if (!aSO_impl) return _PTR(SObject)(aSO);
326 if(aSO_impl.IsComponent()) {
327 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
328 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
330 aSO = new SALOMEDS_SObject(aSO_impl);
333 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
334 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
335 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
336 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
337 aSO = new SALOMEDS_SObject(aSO_impl);
340 return _PTR(SObject)(aSO);
343 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
344 const std::string& aComponentName)
346 std::vector<_PTR(SObject)> aVector;
350 SALOMEDS::Locker lock;
352 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
353 aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
354 for (i = 0; i< aLength; i++)
355 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
358 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
359 (char*)aComponentName.c_str());
360 aLength = aSeq->length();
361 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
367 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
369 SALOMEDSClient_SObject* aSO = NULL;
371 SALOMEDS::Locker lock;
373 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
374 if(!aSO_impl) return _PTR(SObject)(aSO);
375 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
378 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
379 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
380 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
382 return _PTR(SObject)(aSO);
385 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
387 SALOMEDSClient_SObject* aSO = NULL;
389 SALOMEDS::Locker lock;
390 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
391 if(!aSO_impl) return _PTR(SObject)(aSO);
392 aSO = new SALOMEDS_SObject(aSO_impl);
395 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
396 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
397 aSO = new SALOMEDS_SObject(aSO_impl);
399 return _PTR(SObject)(aSO);
402 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
404 SALOMEDSClient_SObject* aSO = NULL;
406 SALOMEDS::Locker lock;
408 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
409 if (!aSO_impl) return _PTR(SObject)(aSO);
410 aSO = new SALOMEDS_SObject(aSO_impl);
413 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
414 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
415 aSO = new SALOMEDS_SObject(aSO_impl);
417 return _PTR(SObject)(aSO);
420 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
422 SALOMEDSClient_SObject* aSO = NULL;
424 SALOMEDS::Locker lock;
426 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
427 if (!aSO_impl) return _PTR(SObject)(aSO);
428 aSO = new SALOMEDS_SObject(aSO_impl);
431 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
432 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
433 aSO = new SALOMEDS_SObject(aSO_impl);
435 return _PTR(SObject)(aSO);
438 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
440 if(!theSO) return "";
441 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
444 SALOMEDS::Locker lock;
445 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
447 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
451 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
453 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
454 SALOMEDSClient_ChildIterator* aCI = NULL;
456 SALOMEDS::Locker lock;
457 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
458 aCI = new SALOMEDS_ChildIterator(aCIimpl);
461 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
462 aCI = new SALOMEDS_ChildIterator(aCIimpl);
465 return _PTR(ChildIterator)(aCI);
468 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
470 SALOMEDSClient_SComponentIterator* aCI = NULL;
472 SALOMEDS::Locker lock;
474 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
475 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
478 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
479 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
482 return _PTR(SComponentIterator)(aCI);
485 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
487 SALOMEDSClient_StudyBuilder* aSB = NULL;
489 SALOMEDS::Locker lock;
491 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
492 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
495 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
496 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
499 return _PTR(StudyBuilder)(aSB);
502 std::string SALOMEDS_Study::Name()
506 SALOMEDS::Locker lock;
507 aName = _local_impl->Name();
509 else aName = Kernel_Utils::encode_s(_corba_impl->Name());
513 void SALOMEDS_Study::Name(const std::string& theName)
516 SALOMEDS::Locker lock;
517 _local_impl->Name(theName);
519 else _corba_impl->Name(Kernel_Utils::decode_s(theName));
522 bool SALOMEDS_Study::IsSaved()
526 SALOMEDS::Locker lock;
527 isSaved = _local_impl->IsSaved();
529 else isSaved = _corba_impl->IsSaved();
533 void SALOMEDS_Study::IsSaved(bool save)
536 SALOMEDS::Locker lock;
537 _local_impl->IsSaved(save);
539 else _corba_impl->IsSaved(save);
542 bool SALOMEDS_Study::IsModified()
546 SALOMEDS::Locker lock;
547 isModified = _local_impl->IsModified();
549 else isModified = _corba_impl->IsModified();
553 void SALOMEDS_Study::Modified()
556 SALOMEDS::Locker lock;
557 _local_impl->Modify();
559 else _corba_impl->Modified();
563 std::string SALOMEDS_Study::URL()
567 SALOMEDS::Locker lock;
568 aURL = _local_impl->URL();
571 aURL = Kernel_Utils::encode_s(_corba_impl->URL());
575 void SALOMEDS_Study::URL(const std::string& url)
578 SALOMEDS::Locker lock;
579 _local_impl->URL(url);
581 else _corba_impl->URL(Kernel_Utils::decode_s(url));
584 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
586 std::vector<_PTR(SObject)> aVector;
587 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
590 SALOMEDS::Locker lock;
592 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
594 aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
595 for (i = 0; i < aLength; i++)
596 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
600 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
601 aLength = aSeq->length();
602 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
607 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
609 SALOMEDSClient_AttributeStudyProperties* aProp;
611 SALOMEDS::Locker lock;
612 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
614 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
615 return _PTR(AttributeStudyProperties)(aProp);
618 std::string SALOMEDS_Study::GetLastModificationDate()
622 SALOMEDS::Locker lock;
623 aDate = _local_impl->GetLastModificationDate();
625 else aDate = _corba_impl->GetLastModificationDate();
629 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
631 std::vector<std::string> aVector;
634 SALOMEDS::Locker lock;
635 aVector = _local_impl->GetModificationsDate();
638 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
639 aLength = aSeq->length();
640 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
645 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
647 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
649 SALOMEDS::Locker lock;
651 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
652 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
655 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
656 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
659 return _PTR(UseCaseBuilder)(aUB);
662 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
664 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
665 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
668 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
669 const std::string& theBaseName,
673 if(CORBA::is_nil(_corba_impl))
676 return _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
679 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
682 SALOMEDS::Locker lock;
683 _local_impl->SetStudyLock(theLockerID.c_str());
685 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
688 bool SALOMEDS_Study::IsStudyLocked()
692 SALOMEDS::Locker lock;
693 isLocked = _local_impl->IsStudyLocked();
695 else isLocked = _corba_impl->IsStudyLocked();
699 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
701 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
702 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
705 std::vector<std::string> SALOMEDS_Study::GetLockerID()
707 std::vector<std::string> aVector;
710 SALOMEDS::Locker lock;
711 aVector = _local_impl->GetLockerID();
714 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
715 aLength = aSeq->length();
716 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
722 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
725 SALOMEDS::Locker lock;
726 _local_impl->SetVariable(theVarName,
728 SALOMEDSImpl_GenericVariable::REAL_VAR);
731 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
734 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
737 SALOMEDS::Locker lock;
738 _local_impl->SetVariable(theVarName,
740 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
743 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
746 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
749 SALOMEDS::Locker lock;
750 _local_impl->SetVariable(theVarName,
752 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
755 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
758 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
761 SALOMEDS::Locker lock;
762 _local_impl->SetStringVariable(theVarName,
764 SALOMEDSImpl_GenericVariable::STRING_VAR);
767 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
770 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
773 SALOMEDS::Locker lock;
774 _local_impl->SetStringVariableAsDouble(theVarName,
776 SALOMEDSImpl_GenericVariable::STRING_VAR);
779 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
782 double SALOMEDS_Study::GetReal(const std::string& theVarName)
786 SALOMEDS::Locker lock;
787 aResult = _local_impl->GetVariableValue(theVarName);
790 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
794 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
798 SALOMEDS::Locker lock;
799 aResult = (int) _local_impl->GetVariableValue(theVarName);
802 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
806 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
810 SALOMEDS::Locker lock;
811 aResult = (bool) _local_impl->GetVariableValue(theVarName);
814 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
818 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
822 SALOMEDS::Locker lock;
823 aResult = _local_impl->GetStringVariableValue(theVarName);
826 aResult = _corba_impl->GetString((char*)theVarName.c_str());
830 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
834 SALOMEDS::Locker lock;
835 aResult = _local_impl->IsTypeOf(theVarName,
836 SALOMEDSImpl_GenericVariable::REAL_VAR);
839 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
843 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
847 SALOMEDS::Locker lock;
848 aResult = _local_impl->IsTypeOf(theVarName,
849 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
852 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
856 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
860 SALOMEDS::Locker lock;
861 aResult = _local_impl->IsTypeOf(theVarName,
862 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
865 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
869 bool SALOMEDS_Study::IsString(const std::string& theVarName)
873 SALOMEDS::Locker lock;
874 aResult = _local_impl->IsTypeOf(theVarName,
875 SALOMEDSImpl_GenericVariable::STRING_VAR);
878 aResult = _corba_impl->IsString((char*)theVarName.c_str());
882 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
886 SALOMEDS::Locker lock;
887 aResult = _local_impl->IsVariable(theVarName);
890 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
894 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
896 std::vector<std::string> aVector;
898 SALOMEDS::Locker lock;
899 aVector = _local_impl->GetVariableNames();
902 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
903 int aLength = aSeq->length();
904 for (int i = 0; i < aLength; i++)
905 aVector.push_back( std::string(aSeq[i].in()) );
910 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
914 SALOMEDS::Locker lock;
915 aResult = _local_impl->RemoveVariable(theVarName);
918 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
922 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
926 SALOMEDS::Locker lock;
927 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
930 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
934 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
938 SALOMEDS::Locker lock;
939 aResult = _local_impl->IsVariableUsed(theVarName);
942 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
946 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
948 std::vector< std::vector<std::string> > aResult;
950 SALOMEDS::Locker lock;
951 aResult = _local_impl->ParseVariables(theVars);
954 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
955 for (int i = 0, n = aSeq->length(); i < n; i++) {
956 std::vector<std::string> aVector;
957 SALOMEDS::ListOfStrings aSection = aSeq[i];
958 for (int j = 0, m = aSection.length(); j < m; j++) {
959 aVector.push_back( std::string(aSection[j].in()) );
961 aResult.push_back( aVector );
967 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
969 return _orb->object_to_string(theObject);
972 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
974 return _orb->string_to_object(theIOR.c_str());
977 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
979 SALOMEDSClient_AttributeParameter* AP = NULL;
980 if(theSavePoint >= 0) {
982 SALOMEDS::Locker lock;
983 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
986 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
989 return _PTR(AttributeParameter)(AP);
992 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
993 const std::string& theModuleName, int theSavePoint)
995 SALOMEDSClient_AttributeParameter* AP = NULL;
996 if(theSavePoint > 0) {
998 SALOMEDS::Locker lock;
999 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1002 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1005 return _PTR(AttributeParameter)(AP);
1008 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1010 if(CORBA::is_nil(_corba_impl))
1013 _corba_impl->attach(theObserver,modify);
1016 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1018 if(CORBA::is_nil(_corba_impl))
1021 _corba_impl->detach(theObserver);