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 //SRN: Pure CORBA save as the save operation require CORBA in any case
138 return _corba_impl->Save(theMultiFile, theASCII);
141 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
143 //SRN: Pure CORBA save as the save operation require CORBA in any case
144 return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile, theASCII);
147 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
149 SALOMEDS_Driver_i* driver = NULL;
151 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
153 std::string IOREngine = aSCO.GetIOR();
154 if(!IOREngine.empty()) {
155 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
156 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
157 driver = new SALOMEDS_Driver_i(Engine, orb);
164 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
166 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
170 SALOMEDS::Locker lock;
172 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
173 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
174 ret = _local_impl->CanCopy(aSO_impl, aDriver);
178 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
184 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
186 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
189 SALOMEDS::Locker lock;
191 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
192 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
193 ret = _local_impl->Copy(aSO_impl, aDriver);
197 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
202 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
204 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
208 SALOMEDS::Locker lock;
210 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
211 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
212 ret = _local_impl->CanPaste(aSO_impl, aDriver);
216 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
222 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
224 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
225 SALOMEDSClient_SObject* aResult = NULL;
228 SALOMEDS::Locker lock;
230 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
231 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
232 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
234 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
235 aResult = new SALOMEDS_SObject(aNewSO);
238 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
239 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
240 aResult = new SALOMEDS_SObject(aNewSO);
243 return _PTR(SObject)(aResult);
246 std::string SALOMEDS_Study::GetPersistentReference()
250 SALOMEDS::Locker lock;
251 aRef = _local_impl->GetPersistentReference();
253 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
257 std::string SALOMEDS_Study::GetTransientReference()
261 SALOMEDS::Locker lock;
262 aRef = _local_impl->GetTransientReference();
264 else aRef = _corba_impl->GetTransientReference();
268 bool SALOMEDS_Study::IsEmpty()
272 SALOMEDS::Locker lock;
273 ret = _local_impl->IsEmpty();
275 else ret = _corba_impl->IsEmpty();
279 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
281 SALOMEDSClient_SComponent* aSCO = NULL;
283 SALOMEDS::Locker lock;
285 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
286 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
287 aSCO = new SALOMEDS_SComponent(aSCO_impl);
290 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
291 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
292 aSCO = new SALOMEDS_SComponent(aSCO_impl);
294 return _PTR(SComponent)(aSCO);
297 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
299 SALOMEDSClient_SComponent* aSCO = NULL;
301 SALOMEDS::Locker lock;
303 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
304 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
305 aSCO = new SALOMEDS_SComponent(aSCO_impl);
308 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
309 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
310 aSCO = new SALOMEDS_SComponent(aSCO_impl);
312 return _PTR(SComponent)(aSCO);
315 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
317 SALOMEDSClient_SObject* aSO = NULL;
320 SALOMEDS::Locker lock;
322 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
323 if (!aSO_impl) return _PTR(SObject)(aSO);
324 if(aSO_impl.IsComponent()) {
325 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
326 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
328 aSO = new SALOMEDS_SObject(aSO_impl);
331 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
332 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
333 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
334 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
335 aSO = new SALOMEDS_SObject(aSO_impl);
338 return _PTR(SObject)(aSO);
341 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
342 const std::string& aComponentName)
344 std::vector<_PTR(SObject)> aVector;
348 SALOMEDS::Locker lock;
350 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
351 aLength = aSeq.size();
352 for (i = 0; i< aLength; i++)
353 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
356 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
357 (char*)aComponentName.c_str());
358 aLength = aSeq->length();
359 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
365 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
367 SALOMEDSClient_SObject* aSO = NULL;
369 SALOMEDS::Locker lock;
371 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
372 if(!aSO_impl) return _PTR(SObject)(aSO);
373 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
376 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
377 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
378 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
380 return _PTR(SObject)(aSO);
383 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
385 SALOMEDSClient_SObject* aSO = NULL;
387 SALOMEDS::Locker lock;
388 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
389 if(!aSO_impl) return _PTR(SObject)(aSO);
390 aSO = new SALOMEDS_SObject(aSO_impl);
393 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
394 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
395 aSO = new SALOMEDS_SObject(aSO_impl);
397 return _PTR(SObject)(aSO);
400 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
402 SALOMEDSClient_SObject* aSO = NULL;
404 SALOMEDS::Locker lock;
406 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
407 if (!aSO_impl) return _PTR(SObject)(aSO);
408 aSO = new SALOMEDS_SObject(aSO_impl);
411 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
412 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
413 aSO = new SALOMEDS_SObject(aSO_impl);
415 return _PTR(SObject)(aSO);
418 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
420 SALOMEDSClient_SObject* aSO = NULL;
422 SALOMEDS::Locker lock;
424 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
425 if (!aSO_impl) return _PTR(SObject)(aSO);
426 aSO = new SALOMEDS_SObject(aSO_impl);
429 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
430 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
431 aSO = new SALOMEDS_SObject(aSO_impl);
433 return _PTR(SObject)(aSO);
436 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
438 if(!theSO) return "";
439 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
442 SALOMEDS::Locker lock;
443 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
445 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
449 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
451 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
452 SALOMEDSClient_ChildIterator* aCI = NULL;
454 SALOMEDS::Locker lock;
455 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
456 aCI = new SALOMEDS_ChildIterator(aCIimpl);
459 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
460 aCI = new SALOMEDS_ChildIterator(aCIimpl);
463 return _PTR(ChildIterator)(aCI);
466 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
468 SALOMEDSClient_SComponentIterator* aCI = NULL;
470 SALOMEDS::Locker lock;
472 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
473 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
476 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
477 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
480 return _PTR(SComponentIterator)(aCI);
483 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
485 SALOMEDSClient_StudyBuilder* aSB = NULL;
487 SALOMEDS::Locker lock;
489 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
490 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
493 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
494 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
497 return _PTR(StudyBuilder)(aSB);
500 std::string SALOMEDS_Study::Name()
504 SALOMEDS::Locker lock;
505 aName = _local_impl->Name();
507 else aName = _corba_impl->Name();
511 bool SALOMEDS_Study::IsSaved()
515 SALOMEDS::Locker lock;
516 isSaved = _local_impl->IsSaved();
518 else isSaved = _corba_impl->IsSaved();
522 void SALOMEDS_Study::IsSaved(bool save)
525 SALOMEDS::Locker lock;
526 _local_impl->IsSaved(save);
528 else _corba_impl->IsSaved(save);
531 bool SALOMEDS_Study::IsModified()
535 SALOMEDS::Locker lock;
536 isModified = _local_impl->IsModified();
538 else isModified = _corba_impl->IsModified();
542 void SALOMEDS_Study::Modified()
545 SALOMEDS::Locker lock;
546 _local_impl->Modify();
548 else _corba_impl->Modified();
552 std::string SALOMEDS_Study::URL()
556 SALOMEDS::Locker lock;
557 aURL = _local_impl->URL();
559 else aURL = _corba_impl->URL();
563 void SALOMEDS_Study::URL(const std::string& url)
566 SALOMEDS::Locker lock;
567 _local_impl->URL(url);
569 else _corba_impl->URL((char*)url.c_str());
572 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
574 std::vector<_PTR(SObject)> aVector;
575 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
578 SALOMEDS::Locker lock;
580 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
582 aLength = aSeq.size();
583 for (i = 0; i < aLength; i++)
584 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
588 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
589 aLength = aSeq->length();
590 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
595 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
597 SALOMEDSClient_AttributeStudyProperties* aProp;
599 SALOMEDS::Locker lock;
600 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
602 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
603 return _PTR(AttributeStudyProperties)(aProp);
606 std::string SALOMEDS_Study::GetLastModificationDate()
610 SALOMEDS::Locker lock;
611 aDate = _local_impl->GetLastModificationDate();
613 else aDate = _corba_impl->GetLastModificationDate();
617 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
619 std::vector<std::string> aVector;
622 SALOMEDS::Locker lock;
623 aVector = _local_impl->GetModificationsDate();
626 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
627 aLength = aSeq->length();
628 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
633 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
635 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
637 SALOMEDS::Locker lock;
639 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
640 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
643 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
644 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
647 return _PTR(UseCaseBuilder)(aUB);
650 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
652 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
653 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
656 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
657 const std::string& theBaseName,
661 //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
662 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
663 bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
667 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
670 SALOMEDS::Locker lock;
671 _local_impl->SetStudyLock(theLockerID.c_str());
673 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
676 bool SALOMEDS_Study::IsStudyLocked()
680 SALOMEDS::Locker lock;
681 isLocked = _local_impl->IsStudyLocked();
683 else isLocked = _corba_impl->IsStudyLocked();
687 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
689 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
690 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
693 std::vector<std::string> SALOMEDS_Study::GetLockerID()
695 std::vector<std::string> aVector;
698 SALOMEDS::Locker lock;
699 aVector = _local_impl->GetLockerID();
702 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
703 aLength = aSeq->length();
704 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
710 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
713 SALOMEDS::Locker lock;
714 _local_impl->SetVariable(theVarName,
716 SALOMEDSImpl_GenericVariable::REAL_VAR);
719 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
722 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
725 SALOMEDS::Locker lock;
726 _local_impl->SetVariable(theVarName,
728 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
731 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
734 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
737 SALOMEDS::Locker lock;
738 _local_impl->SetVariable(theVarName,
740 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
743 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
746 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
749 SALOMEDS::Locker lock;
750 _local_impl->SetStringVariable(theVarName,
752 SALOMEDSImpl_GenericVariable::STRING_VAR);
755 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
758 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
761 SALOMEDS::Locker lock;
762 _local_impl->SetStringVariableAsDouble(theVarName,
764 SALOMEDSImpl_GenericVariable::STRING_VAR);
767 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
770 double SALOMEDS_Study::GetReal(const std::string& theVarName)
774 SALOMEDS::Locker lock;
775 aResult = _local_impl->GetVariableValue(theVarName);
778 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
782 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
786 SALOMEDS::Locker lock;
787 aResult = (int) _local_impl->GetVariableValue(theVarName);
790 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
794 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
798 SALOMEDS::Locker lock;
799 aResult = (bool) _local_impl->GetVariableValue(theVarName);
802 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
806 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
810 SALOMEDS::Locker lock;
811 aResult = _local_impl->GetStringVariableValue(theVarName);
814 aResult = _corba_impl->GetString((char*)theVarName.c_str());
818 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
822 SALOMEDS::Locker lock;
823 aResult = _local_impl->IsTypeOf(theVarName,
824 SALOMEDSImpl_GenericVariable::REAL_VAR);
827 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
831 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
835 SALOMEDS::Locker lock;
836 aResult = _local_impl->IsTypeOf(theVarName,
837 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
840 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
844 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
848 SALOMEDS::Locker lock;
849 aResult = _local_impl->IsTypeOf(theVarName,
850 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
853 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
857 bool SALOMEDS_Study::IsString(const std::string& theVarName)
861 SALOMEDS::Locker lock;
862 aResult = _local_impl->IsTypeOf(theVarName,
863 SALOMEDSImpl_GenericVariable::STRING_VAR);
866 aResult = _corba_impl->IsString((char*)theVarName.c_str());
870 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
874 SALOMEDS::Locker lock;
875 aResult = _local_impl->IsVariable(theVarName);
878 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
882 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
884 std::vector<std::string> aVector;
886 SALOMEDS::Locker lock;
887 aVector = _local_impl->GetVariableNames();
890 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
891 int aLength = aSeq->length();
892 for (int i = 0; i < aLength; i++)
893 aVector.push_back( std::string(aSeq[i].in()) );
898 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
902 SALOMEDS::Locker lock;
903 aResult = _local_impl->RemoveVariable(theVarName);
906 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
910 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
914 SALOMEDS::Locker lock;
915 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
918 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
922 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
926 SALOMEDS::Locker lock;
927 aResult = _local_impl->IsVariableUsed(theVarName);
930 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
934 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
936 std::vector< std::vector<std::string> > aResult;
938 SALOMEDS::Locker lock;
939 aResult = _local_impl->ParseVariables(theVars);
942 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
943 for (int i = 0, n = aSeq->length(); i < n; i++) {
944 std::vector<std::string> aVector;
945 SALOMEDS::ListOfStrings aSection = aSeq[i];
946 for (int j = 0, m = aSection.length(); j < m; j++) {
947 aVector.push_back( std::string(aSection[j].in()) );
949 aResult.push_back( aVector );
955 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
957 return _orb->object_to_string(theObject);
960 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
962 return _orb->string_to_object(theIOR.c_str());
965 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
968 SALOMEDS::Locker lock;
970 if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
971 std::string anIOR = _local_impl->GetTransientReference();
972 SALOMEDS::Study_var aStudy;
973 if (!_local_impl->IsError() && anIOR != "") {
974 aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
977 SALOME_NamingService* namingService = KERNEL::getNamingService();
978 CORBA::Object_var obj = namingService->Resolve("/Study");
979 aStudy = SALOMEDS::Study::_narrow(obj);
980 _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
982 _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
983 return aStudy._retn();
986 return SALOMEDS::Study::_duplicate(_corba_impl);
989 return SALOMEDS::Study::_nil();
993 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
995 SALOMEDSClient_AttributeParameter* AP = NULL;
996 if(theSavePoint >= 0) {
998 SALOMEDS::Locker lock;
999 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
1002 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
1005 return _PTR(AttributeParameter)(AP);
1008 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
1009 const std::string& theModuleName, int theSavePoint)
1011 SALOMEDSClient_AttributeParameter* AP = NULL;
1012 if(theSavePoint > 0) {
1014 SALOMEDS::Locker lock;
1015 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1018 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1021 return _PTR(AttributeParameter)(AP);
1024 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1026 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1027 _corba_impl->attach(theObserver,modify);
1030 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1032 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1033 _corba_impl->detach(theObserver);