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 "SALOMEDS_Driver_i.hxx"
52 #include "SALOMEDS_Study_i.hxx"
54 #include "Utils_ORB_INIT.hxx"
55 #include "Utils_SINGLETON.hxx"
57 #include "Basics_Utils.hxx"
62 #include <sys/types.h>
66 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
69 _local_impl = theStudy;
70 _corba_impl = SALOMEDS::Study::_nil();
72 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
77 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
80 long pid = (long)_getpid();
82 long pid = (long)getpid();
85 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
87 long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
89 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
90 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
94 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
100 SALOMEDS_Study::~SALOMEDS_Study()
104 std::string SALOMEDS_Study::GetPersistentReference()
108 SALOMEDS::Locker lock;
109 aRef = _local_impl->GetPersistentReference();
111 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
115 std::string SALOMEDS_Study::GetTransientReference()
119 SALOMEDS::Locker lock;
120 aRef = _local_impl->GetTransientReference();
122 else aRef = _corba_impl->GetTransientReference();
126 bool SALOMEDS_Study::IsEmpty()
130 SALOMEDS::Locker lock;
131 ret = _local_impl->IsEmpty();
133 else ret = _corba_impl->IsEmpty();
137 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
139 SALOMEDSClient_SComponent* aSCO = NULL;
141 SALOMEDS::Locker lock;
143 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
144 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
145 aSCO = new SALOMEDS_SComponent(aSCO_impl);
148 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
149 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
150 aSCO = new SALOMEDS_SComponent(aSCO_impl);
152 return _PTR(SComponent)(aSCO);
155 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
157 SALOMEDSClient_SComponent* aSCO = NULL;
159 SALOMEDS::Locker lock;
161 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
162 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
163 aSCO = new SALOMEDS_SComponent(aSCO_impl);
166 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
167 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
168 aSCO = new SALOMEDS_SComponent(aSCO_impl);
170 return _PTR(SComponent)(aSCO);
173 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
175 SALOMEDSClient_SObject* aSO = NULL;
178 SALOMEDS::Locker lock;
180 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
181 if (!aSO_impl) return _PTR(SObject)(aSO);
182 if(aSO_impl.IsComponent()) {
183 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
184 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
186 aSO = new SALOMEDS_SObject(aSO_impl);
189 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
190 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
191 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
192 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
193 aSO = new SALOMEDS_SObject(aSO_impl);
196 return _PTR(SObject)(aSO);
199 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
200 const std::string& aComponentName)
202 std::vector<_PTR(SObject)> aVector;
206 SALOMEDS::Locker lock;
208 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
209 aLength = aSeq.size();
210 for (i = 0; i< aLength; i++)
211 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
214 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
215 (char*)aComponentName.c_str());
216 aLength = aSeq->length();
217 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
223 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
225 SALOMEDSClient_SObject* aSO = NULL;
227 SALOMEDS::Locker lock;
229 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
230 if(!aSO_impl) return _PTR(SObject)(aSO);
231 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
234 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
235 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
236 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
238 return _PTR(SObject)(aSO);
241 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
243 SALOMEDSClient_SObject* aSO = NULL;
245 SALOMEDS::Locker lock;
246 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
247 if(!aSO_impl) return _PTR(SObject)(aSO);
248 aSO = new SALOMEDS_SObject(aSO_impl);
251 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
252 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
253 aSO = new SALOMEDS_SObject(aSO_impl);
255 return _PTR(SObject)(aSO);
258 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
260 SALOMEDSClient_SObject* aSO = NULL;
262 SALOMEDS::Locker lock;
264 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
265 if (!aSO_impl) return _PTR(SObject)(aSO);
266 aSO = new SALOMEDS_SObject(aSO_impl);
269 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
270 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
271 aSO = new SALOMEDS_SObject(aSO_impl);
273 return _PTR(SObject)(aSO);
276 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
278 SALOMEDSClient_SObject* aSO = NULL;
280 SALOMEDS::Locker lock;
282 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
283 if (!aSO_impl) return _PTR(SObject)(aSO);
284 aSO = new SALOMEDS_SObject(aSO_impl);
287 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
288 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
289 aSO = new SALOMEDS_SObject(aSO_impl);
291 return _PTR(SObject)(aSO);
294 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
296 if(!theSO) return "";
297 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
300 SALOMEDS::Locker lock;
301 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
303 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
307 void SALOMEDS_Study::SetContext(const std::string& thePath)
310 SALOMEDS::Locker lock;
311 _local_impl->SetContext(thePath);
313 else _corba_impl->SetContext((char*)thePath.c_str());
316 std::string SALOMEDS_Study::GetContext()
320 SALOMEDS::Locker lock;
321 aPath = _local_impl->GetContext();
323 else aPath = _corba_impl->GetContext();
327 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
329 std::vector<std::string> aVector;
332 SALOMEDS::Locker lock;
333 aVector = _local_impl->GetObjectNames(theContext);
336 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
337 aLength = aSeq->length();
338 for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
343 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
345 std::vector<std::string> aVector;
348 SALOMEDS::Locker lock;
349 aVector = _local_impl->GetDirectoryNames(theContext);
352 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
353 aLength = aSeq->length();
354 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
359 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
361 std::vector<std::string> aVector;
364 SALOMEDS::Locker lock;
365 aVector = _local_impl->GetFileNames(theContext);
368 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
369 aLength = aSeq->length();
371 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
376 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
378 std::vector<std::string> aVector;
381 SALOMEDS::Locker lock;
382 aVector = _local_impl->GetComponentNames(theContext);
385 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
386 aLength = aSeq->length();
387 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
392 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
394 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
395 SALOMEDSClient_ChildIterator* aCI = NULL;
397 SALOMEDS::Locker lock;
398 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
399 aCI = new SALOMEDS_ChildIterator(aCIimpl);
402 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
403 aCI = new SALOMEDS_ChildIterator(aCIimpl);
406 return _PTR(ChildIterator)(aCI);
409 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
411 SALOMEDSClient_SComponentIterator* aCI = NULL;
413 SALOMEDS::Locker lock;
415 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
416 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
419 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
420 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
423 return _PTR(SComponentIterator)(aCI);
426 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
428 SALOMEDSClient_StudyBuilder* aSB = NULL;
430 SALOMEDS::Locker lock;
432 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
433 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
436 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
437 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
440 return _PTR(StudyBuilder)(aSB);
443 std::string SALOMEDS_Study::Name()
447 SALOMEDS::Locker lock;
448 aName = _local_impl->Name();
450 else aName = _corba_impl->Name();
454 void SALOMEDS_Study::Name(const std::string& theName)
457 SALOMEDS::Locker lock;
458 _local_impl->Name(theName);
460 else _corba_impl->Name((char*)theName.c_str());
463 bool SALOMEDS_Study::IsSaved()
467 SALOMEDS::Locker lock;
468 isSaved = _local_impl->IsSaved();
470 else isSaved = _corba_impl->IsSaved();
474 void SALOMEDS_Study::IsSaved(bool save)
477 SALOMEDS::Locker lock;
478 _local_impl->IsSaved(save);
480 else _corba_impl->IsSaved(save);
483 bool SALOMEDS_Study::IsModified()
487 SALOMEDS::Locker lock;
488 isModified = _local_impl->IsModified();
490 else isModified = _corba_impl->IsModified();
494 void SALOMEDS_Study::Modified()
497 SALOMEDS::Locker lock;
498 _local_impl->Modify();
500 else _corba_impl->Modified();
504 std::string SALOMEDS_Study::URL()
508 SALOMEDS::Locker lock;
509 aURL = _local_impl->URL();
511 else aURL = _corba_impl->URL();
515 void SALOMEDS_Study::URL(const std::string& url)
518 SALOMEDS::Locker lock;
519 _local_impl->URL(url);
521 else _corba_impl->URL((char*)url.c_str());
524 int SALOMEDS_Study::StudyId()
528 SALOMEDS::Locker lock;
529 anID = _local_impl->StudyId();
531 else anID = _corba_impl->StudyId();
535 void SALOMEDS_Study::StudyId(int id)
538 SALOMEDS::Locker lock;
539 _local_impl->StudyId(id);
541 else _corba_impl->StudyId(id);
544 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
546 std::vector<_PTR(SObject)> aVector;
547 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
550 SALOMEDS::Locker lock;
552 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
554 aLength = aSeq.size();
555 for (i = 0; i < aLength; i++)
556 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
560 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
561 aLength = aSeq->length();
562 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
567 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
569 SALOMEDSClient_AttributeStudyProperties* aProp;
571 SALOMEDS::Locker lock;
572 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
574 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
575 return _PTR(AttributeStudyProperties)(aProp);
578 std::string SALOMEDS_Study::GetLastModificationDate()
582 SALOMEDS::Locker lock;
583 aDate = _local_impl->GetLastModificationDate();
585 else aDate = _corba_impl->GetLastModificationDate();
589 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
591 std::vector<std::string> aVector;
594 SALOMEDS::Locker lock;
595 aVector = _local_impl->GetModificationsDate();
598 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
599 aLength = aSeq->length();
600 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
605 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
607 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
609 SALOMEDS::Locker lock;
611 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
612 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
615 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
616 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
619 return _PTR(UseCaseBuilder)(aUB);
622 void SALOMEDS_Study::Close()
625 SALOMEDS::Locker lock;
626 _local_impl->Close();
628 else _corba_impl->Close();
631 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
633 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
634 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
637 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
638 const std::string& theBaseName,
642 //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
643 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
644 bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
648 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
651 SALOMEDS::Locker lock;
652 _local_impl->SetStudyLock(theLockerID.c_str());
654 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
657 bool SALOMEDS_Study::IsStudyLocked()
661 SALOMEDS::Locker lock;
662 isLocked = _local_impl->IsStudyLocked();
664 else isLocked = _corba_impl->IsStudyLocked();
668 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
670 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
671 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
674 std::vector<std::string> SALOMEDS_Study::GetLockerID()
676 std::vector<std::string> aVector;
679 SALOMEDS::Locker lock;
680 aVector = _local_impl->GetLockerID();
683 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
684 aLength = aSeq->length();
685 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
691 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
694 SALOMEDS::Locker lock;
695 _local_impl->SetVariable(theVarName,
697 SALOMEDSImpl_GenericVariable::REAL_VAR);
700 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
703 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
706 SALOMEDS::Locker lock;
707 _local_impl->SetVariable(theVarName,
709 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
712 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
715 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
718 SALOMEDS::Locker lock;
719 _local_impl->SetVariable(theVarName,
721 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
724 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
727 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
730 SALOMEDS::Locker lock;
731 _local_impl->SetStringVariable(theVarName,
733 SALOMEDSImpl_GenericVariable::STRING_VAR);
736 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
739 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
742 SALOMEDS::Locker lock;
743 _local_impl->SetStringVariableAsDouble(theVarName,
745 SALOMEDSImpl_GenericVariable::STRING_VAR);
748 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
751 double SALOMEDS_Study::GetReal(const std::string& theVarName)
755 SALOMEDS::Locker lock;
756 aResult = _local_impl->GetVariableValue(theVarName);
759 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
763 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
767 SALOMEDS::Locker lock;
768 aResult = (int) _local_impl->GetVariableValue(theVarName);
771 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
775 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
779 SALOMEDS::Locker lock;
780 aResult = (bool) _local_impl->GetVariableValue(theVarName);
783 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
787 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
791 SALOMEDS::Locker lock;
792 aResult = _local_impl->GetStringVariableValue(theVarName);
795 aResult = _corba_impl->GetString((char*)theVarName.c_str());
799 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
803 SALOMEDS::Locker lock;
804 aResult = _local_impl->IsTypeOf(theVarName,
805 SALOMEDSImpl_GenericVariable::REAL_VAR);
808 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
812 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
816 SALOMEDS::Locker lock;
817 aResult = _local_impl->IsTypeOf(theVarName,
818 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
821 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
825 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
829 SALOMEDS::Locker lock;
830 aResult = _local_impl->IsTypeOf(theVarName,
831 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
834 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
838 bool SALOMEDS_Study::IsString(const std::string& theVarName)
842 SALOMEDS::Locker lock;
843 aResult = _local_impl->IsTypeOf(theVarName,
844 SALOMEDSImpl_GenericVariable::STRING_VAR);
847 aResult = _corba_impl->IsString((char*)theVarName.c_str());
851 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
855 SALOMEDS::Locker lock;
856 aResult = _local_impl->IsVariable(theVarName);
859 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
863 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
865 std::vector<std::string> aVector;
867 SALOMEDS::Locker lock;
868 aVector = _local_impl->GetVariableNames();
871 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
872 int aLength = aSeq->length();
873 for (int i = 0; i < aLength; i++)
874 aVector.push_back( std::string(aSeq[i].in()) );
879 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
883 SALOMEDS::Locker lock;
884 aResult = _local_impl->RemoveVariable(theVarName);
887 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
891 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
895 SALOMEDS::Locker lock;
896 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
899 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
903 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
907 SALOMEDS::Locker lock;
908 aResult = _local_impl->IsVariableUsed(theVarName);
911 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
915 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
917 std::vector< std::vector<std::string> > aResult;
919 SALOMEDS::Locker lock;
920 aResult = _local_impl->ParseVariables(theVars);
923 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
924 for (int i = 0, n = aSeq->length(); i < n; i++) {
925 std::vector<std::string> aVector;
926 SALOMEDS::ListOfStrings aSection = aSeq[i];
927 for (int j = 0, m = aSection.length(); j < m; j++) {
928 aVector.push_back( std::string(aSection[j].in()) );
930 aResult.push_back( aVector );
936 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
938 return _orb->object_to_string(theObject);
941 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
943 return _orb->string_to_object(theIOR.c_str());
946 void SALOMEDS_Study::init_orb()
948 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
949 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
950 _orb = init(0 , 0 ) ;
953 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
956 SALOMEDS::Locker lock;
958 if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
959 std::string anIOR = _local_impl->GetTransientReference();
960 SALOMEDS::Study_var aStudy;
961 if (!_local_impl->IsError() && anIOR != "") {
962 aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
965 SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
966 aStudy = aStudy_servant->_this();
967 _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
969 _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
970 return aStudy._retn();
973 return SALOMEDS::Study::_duplicate(_corba_impl);
976 return SALOMEDS::Study::_nil();
980 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
982 SALOMEDSClient_AttributeParameter* AP = NULL;
983 if(theSavePoint >= 0) {
985 SALOMEDS::Locker lock;
986 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
989 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
992 return _PTR(AttributeParameter)(AP);
995 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
996 const std::string& theModuleName, int theSavePoint)
998 SALOMEDSClient_AttributeParameter* AP = NULL;
999 if(theSavePoint > 0) {
1001 SALOMEDS::Locker lock;
1002 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1005 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1008 return _PTR(AttributeParameter)(AP);
1011 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1013 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1014 _corba_impl->attach(theObserver,modify);
1017 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1019 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1020 _corba_impl->detach(theObserver);