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();
76 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
79 long pid = (long)_getpid();
81 long pid = (long)getpid();
84 long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
86 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
87 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
91 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
97 SALOMEDS_Study::~SALOMEDS_Study()
101 void SALOMEDS_Study::InitORB()
103 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
104 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
105 _orb = init(0 , 0 ) ;
108 void SALOMEDS_Study::Init()
110 if(CORBA::is_nil(_corba_impl))
116 void SALOMEDS_Study::Clear()
118 if(CORBA::is_nil(_corba_impl))
121 _corba_impl->Clear();
124 bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
126 if(CORBA::is_nil(_corba_impl))
129 if (!_corba_impl->Open(theStudyUrl.c_str()))
135 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
137 if(CORBA::is_nil(_corba_impl))
140 return _corba_impl->Save(theMultiFile, theASCII);
143 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
145 if(CORBA::is_nil(_corba_impl))
148 return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile, theASCII);
151 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
153 SALOMEDS_Driver_i* driver = NULL;
155 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
157 std::string IOREngine = aSCO.GetIOR();
158 if(!IOREngine.empty()) {
159 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
160 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
161 driver = new SALOMEDS_Driver_i(Engine, orb);
168 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
170 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
174 SALOMEDS::Locker lock;
176 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
177 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
178 ret = _local_impl->CanCopy(aSO_impl, aDriver);
182 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
188 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
190 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
193 SALOMEDS::Locker lock;
195 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
196 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
197 ret = _local_impl->Copy(aSO_impl, aDriver);
201 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
206 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
208 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
212 SALOMEDS::Locker lock;
214 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
215 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
216 ret = _local_impl->CanPaste(aSO_impl, aDriver);
220 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
226 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
228 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
229 SALOMEDSClient_SObject* aResult = NULL;
232 SALOMEDS::Locker lock;
234 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
235 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
236 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
238 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
239 aResult = new SALOMEDS_SObject(aNewSO);
242 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
243 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
244 aResult = new SALOMEDS_SObject(aNewSO);
247 return _PTR(SObject)(aResult);
250 std::string SALOMEDS_Study::GetPersistentReference()
254 SALOMEDS::Locker lock;
255 aRef = _local_impl->GetPersistentReference();
257 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
261 bool SALOMEDS_Study::IsEmpty()
265 SALOMEDS::Locker lock;
266 ret = _local_impl->IsEmpty();
268 else ret = _corba_impl->IsEmpty();
272 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
274 SALOMEDSClient_SComponent* aSCO = NULL;
276 SALOMEDS::Locker lock;
278 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
279 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
280 aSCO = new SALOMEDS_SComponent(aSCO_impl);
283 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
284 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
285 aSCO = new SALOMEDS_SComponent(aSCO_impl);
287 return _PTR(SComponent)(aSCO);
290 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
292 SALOMEDSClient_SComponent* aSCO = NULL;
294 SALOMEDS::Locker lock;
296 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
297 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
298 aSCO = new SALOMEDS_SComponent(aSCO_impl);
301 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
302 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
303 aSCO = new SALOMEDS_SComponent(aSCO_impl);
305 return _PTR(SComponent)(aSCO);
308 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
310 SALOMEDSClient_SObject* aSO = NULL;
313 SALOMEDS::Locker lock;
315 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
316 if (!aSO_impl) return _PTR(SObject)(aSO);
317 if(aSO_impl.IsComponent()) {
318 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
319 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
321 aSO = new SALOMEDS_SObject(aSO_impl);
324 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
325 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
326 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
327 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
328 aSO = new SALOMEDS_SObject(aSO_impl);
331 return _PTR(SObject)(aSO);
334 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
335 const std::string& aComponentName)
337 std::vector<_PTR(SObject)> aVector;
341 SALOMEDS::Locker lock;
343 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
344 aLength = aSeq.size();
345 for (i = 0; i< aLength; i++)
346 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
349 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
350 (char*)aComponentName.c_str());
351 aLength = aSeq->length();
352 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
358 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
360 SALOMEDSClient_SObject* aSO = NULL;
362 SALOMEDS::Locker lock;
364 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
365 if(!aSO_impl) return _PTR(SObject)(aSO);
366 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
369 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
370 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
371 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
373 return _PTR(SObject)(aSO);
376 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
378 SALOMEDSClient_SObject* aSO = NULL;
380 SALOMEDS::Locker lock;
381 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
382 if(!aSO_impl) return _PTR(SObject)(aSO);
383 aSO = new SALOMEDS_SObject(aSO_impl);
386 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
387 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
388 aSO = new SALOMEDS_SObject(aSO_impl);
390 return _PTR(SObject)(aSO);
393 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
395 SALOMEDSClient_SObject* aSO = NULL;
397 SALOMEDS::Locker lock;
399 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
400 if (!aSO_impl) return _PTR(SObject)(aSO);
401 aSO = new SALOMEDS_SObject(aSO_impl);
404 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
405 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
406 aSO = new SALOMEDS_SObject(aSO_impl);
408 return _PTR(SObject)(aSO);
411 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
413 SALOMEDSClient_SObject* aSO = NULL;
415 SALOMEDS::Locker lock;
417 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
418 if (!aSO_impl) return _PTR(SObject)(aSO);
419 aSO = new SALOMEDS_SObject(aSO_impl);
422 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
423 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
424 aSO = new SALOMEDS_SObject(aSO_impl);
426 return _PTR(SObject)(aSO);
429 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
431 if(!theSO) return "";
432 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
435 SALOMEDS::Locker lock;
436 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
438 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
442 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
444 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
445 SALOMEDSClient_ChildIterator* aCI = NULL;
447 SALOMEDS::Locker lock;
448 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
449 aCI = new SALOMEDS_ChildIterator(aCIimpl);
452 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
453 aCI = new SALOMEDS_ChildIterator(aCIimpl);
456 return _PTR(ChildIterator)(aCI);
459 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
461 SALOMEDSClient_SComponentIterator* aCI = NULL;
463 SALOMEDS::Locker lock;
465 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
466 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
469 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
470 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
473 return _PTR(SComponentIterator)(aCI);
476 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
478 SALOMEDSClient_StudyBuilder* aSB = NULL;
480 SALOMEDS::Locker lock;
482 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
483 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
486 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
487 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
490 return _PTR(StudyBuilder)(aSB);
493 std::string SALOMEDS_Study::Name()
497 SALOMEDS::Locker lock;
498 aName = _local_impl->Name();
500 else aName = _corba_impl->Name();
504 bool SALOMEDS_Study::IsSaved()
508 SALOMEDS::Locker lock;
509 isSaved = _local_impl->IsSaved();
511 else isSaved = _corba_impl->IsSaved();
515 void SALOMEDS_Study::IsSaved(bool save)
518 SALOMEDS::Locker lock;
519 _local_impl->IsSaved(save);
521 else _corba_impl->IsSaved(save);
524 bool SALOMEDS_Study::IsModified()
528 SALOMEDS::Locker lock;
529 isModified = _local_impl->IsModified();
531 else isModified = _corba_impl->IsModified();
535 void SALOMEDS_Study::Modified()
538 SALOMEDS::Locker lock;
539 _local_impl->Modify();
541 else _corba_impl->Modified();
545 std::string SALOMEDS_Study::URL()
549 SALOMEDS::Locker lock;
550 aURL = _local_impl->URL();
552 else aURL = _corba_impl->URL();
556 void SALOMEDS_Study::URL(const std::string& url)
559 SALOMEDS::Locker lock;
560 _local_impl->URL(url);
562 else _corba_impl->URL((char*)url.c_str());
565 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
567 std::vector<_PTR(SObject)> aVector;
568 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
571 SALOMEDS::Locker lock;
573 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
575 aLength = aSeq.size();
576 for (i = 0; i < aLength; i++)
577 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
581 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
582 aLength = aSeq->length();
583 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
588 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
590 SALOMEDSClient_AttributeStudyProperties* aProp;
592 SALOMEDS::Locker lock;
593 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
595 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
596 return _PTR(AttributeStudyProperties)(aProp);
599 std::string SALOMEDS_Study::GetLastModificationDate()
603 SALOMEDS::Locker lock;
604 aDate = _local_impl->GetLastModificationDate();
606 else aDate = _corba_impl->GetLastModificationDate();
610 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
612 std::vector<std::string> aVector;
615 SALOMEDS::Locker lock;
616 aVector = _local_impl->GetModificationsDate();
619 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
620 aLength = aSeq->length();
621 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
626 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
628 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
630 SALOMEDS::Locker lock;
632 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
633 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
636 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
637 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
640 return _PTR(UseCaseBuilder)(aUB);
643 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
645 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
646 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
649 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
650 const std::string& theBaseName,
654 if(CORBA::is_nil(_corba_impl))
657 return _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
660 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
663 SALOMEDS::Locker lock;
664 _local_impl->SetStudyLock(theLockerID.c_str());
666 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
669 bool SALOMEDS_Study::IsStudyLocked()
673 SALOMEDS::Locker lock;
674 isLocked = _local_impl->IsStudyLocked();
676 else isLocked = _corba_impl->IsStudyLocked();
680 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
682 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
683 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
686 std::vector<std::string> SALOMEDS_Study::GetLockerID()
688 std::vector<std::string> aVector;
691 SALOMEDS::Locker lock;
692 aVector = _local_impl->GetLockerID();
695 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
696 aLength = aSeq->length();
697 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
703 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
706 SALOMEDS::Locker lock;
707 _local_impl->SetVariable(theVarName,
709 SALOMEDSImpl_GenericVariable::REAL_VAR);
712 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
715 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
718 SALOMEDS::Locker lock;
719 _local_impl->SetVariable(theVarName,
721 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
724 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
727 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
730 SALOMEDS::Locker lock;
731 _local_impl->SetVariable(theVarName,
733 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
736 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
739 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
742 SALOMEDS::Locker lock;
743 _local_impl->SetStringVariable(theVarName,
745 SALOMEDSImpl_GenericVariable::STRING_VAR);
748 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
751 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
754 SALOMEDS::Locker lock;
755 _local_impl->SetStringVariableAsDouble(theVarName,
757 SALOMEDSImpl_GenericVariable::STRING_VAR);
760 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
763 double SALOMEDS_Study::GetReal(const std::string& theVarName)
767 SALOMEDS::Locker lock;
768 aResult = _local_impl->GetVariableValue(theVarName);
771 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
775 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
779 SALOMEDS::Locker lock;
780 aResult = (int) _local_impl->GetVariableValue(theVarName);
783 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
787 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
791 SALOMEDS::Locker lock;
792 aResult = (bool) _local_impl->GetVariableValue(theVarName);
795 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
799 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
803 SALOMEDS::Locker lock;
804 aResult = _local_impl->GetStringVariableValue(theVarName);
807 aResult = _corba_impl->GetString((char*)theVarName.c_str());
811 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
815 SALOMEDS::Locker lock;
816 aResult = _local_impl->IsTypeOf(theVarName,
817 SALOMEDSImpl_GenericVariable::REAL_VAR);
820 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
824 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
828 SALOMEDS::Locker lock;
829 aResult = _local_impl->IsTypeOf(theVarName,
830 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
833 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
837 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
841 SALOMEDS::Locker lock;
842 aResult = _local_impl->IsTypeOf(theVarName,
843 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
846 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
850 bool SALOMEDS_Study::IsString(const std::string& theVarName)
854 SALOMEDS::Locker lock;
855 aResult = _local_impl->IsTypeOf(theVarName,
856 SALOMEDSImpl_GenericVariable::STRING_VAR);
859 aResult = _corba_impl->IsString((char*)theVarName.c_str());
863 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
867 SALOMEDS::Locker lock;
868 aResult = _local_impl->IsVariable(theVarName);
871 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
875 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
877 std::vector<std::string> aVector;
879 SALOMEDS::Locker lock;
880 aVector = _local_impl->GetVariableNames();
883 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
884 int aLength = aSeq->length();
885 for (int i = 0; i < aLength; i++)
886 aVector.push_back( std::string(aSeq[i].in()) );
891 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
895 SALOMEDS::Locker lock;
896 aResult = _local_impl->RemoveVariable(theVarName);
899 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
903 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
907 SALOMEDS::Locker lock;
908 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
911 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
915 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
919 SALOMEDS::Locker lock;
920 aResult = _local_impl->IsVariableUsed(theVarName);
923 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
927 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
929 std::vector< std::vector<std::string> > aResult;
931 SALOMEDS::Locker lock;
932 aResult = _local_impl->ParseVariables(theVars);
935 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
936 for (int i = 0, n = aSeq->length(); i < n; i++) {
937 std::vector<std::string> aVector;
938 SALOMEDS::ListOfStrings aSection = aSeq[i];
939 for (int j = 0, m = aSection.length(); j < m; j++) {
940 aVector.push_back( std::string(aSection[j].in()) );
942 aResult.push_back( aVector );
948 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
950 return _orb->object_to_string(theObject);
953 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
955 return _orb->string_to_object(theIOR.c_str());
958 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
960 SALOMEDSClient_AttributeParameter* AP = NULL;
961 if(theSavePoint >= 0) {
963 SALOMEDS::Locker lock;
964 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
967 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
970 return _PTR(AttributeParameter)(AP);
973 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
974 const std::string& theModuleName, int theSavePoint)
976 SALOMEDSClient_AttributeParameter* AP = NULL;
977 if(theSavePoint > 0) {
979 SALOMEDS::Locker lock;
980 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
983 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
986 return _PTR(AttributeParameter)(AP);
989 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
991 if(CORBA::is_nil(_corba_impl))
994 _corba_impl->attach(theObserver,modify);
997 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
999 if(CORBA::is_nil(_corba_impl))
1002 _corba_impl->detach(theObserver);