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))
128 std::wstring wtheStudyUrl = std::wstring(theStudyUrl.begin(), theStudyUrl.end());
130 if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) )
136 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
138 if(CORBA::is_nil(_corba_impl))
141 return _corba_impl->Save(theMultiFile, theASCII);
144 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
146 if(CORBA::is_nil(_corba_impl))
149 return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), theMultiFile, theASCII);
152 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
154 SALOMEDS_Driver_i* driver = NULL;
156 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
158 std::string IOREngine = aSCO.GetIOR();
159 if(!IOREngine.empty()) {
160 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
161 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
162 driver = new SALOMEDS_Driver_i(Engine, orb);
169 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
171 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
175 SALOMEDS::Locker lock;
177 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
178 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
179 ret = _local_impl->CanCopy(aSO_impl, aDriver);
183 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
189 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
191 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
194 SALOMEDS::Locker lock;
196 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
197 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
198 ret = _local_impl->Copy(aSO_impl, aDriver);
202 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
207 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
209 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
213 SALOMEDS::Locker lock;
215 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
216 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
217 ret = _local_impl->CanPaste(aSO_impl, aDriver);
221 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
227 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
229 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
230 SALOMEDSClient_SObject* aResult = NULL;
233 SALOMEDS::Locker lock;
235 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
236 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
237 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
239 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
240 aResult = new SALOMEDS_SObject(aNewSO);
243 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
244 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
245 aResult = new SALOMEDS_SObject(aNewSO);
248 return _PTR(SObject)(aResult);
251 std::string SALOMEDS_Study::GetPersistentReference()
255 SALOMEDS::Locker lock;
256 aRef = _local_impl->GetPersistentReference();
258 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
262 bool SALOMEDS_Study::IsEmpty()
266 SALOMEDS::Locker lock;
267 ret = _local_impl->IsEmpty();
269 else ret = _corba_impl->IsEmpty();
273 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
275 SALOMEDSClient_SComponent* aSCO = NULL;
277 SALOMEDS::Locker lock;
279 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
280 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
281 aSCO = new SALOMEDS_SComponent(aSCO_impl);
284 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
285 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
286 aSCO = new SALOMEDS_SComponent(aSCO_impl);
288 return _PTR(SComponent)(aSCO);
291 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
293 SALOMEDSClient_SComponent* aSCO = NULL;
295 SALOMEDS::Locker lock;
297 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
298 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
299 aSCO = new SALOMEDS_SComponent(aSCO_impl);
302 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
303 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
304 aSCO = new SALOMEDS_SComponent(aSCO_impl);
306 return _PTR(SComponent)(aSCO);
309 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
311 SALOMEDSClient_SObject* aSO = NULL;
314 SALOMEDS::Locker lock;
316 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
317 if (!aSO_impl) return _PTR(SObject)(aSO);
318 if(aSO_impl.IsComponent()) {
319 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
320 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
322 aSO = new SALOMEDS_SObject(aSO_impl);
325 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
326 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
327 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
328 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
329 aSO = new SALOMEDS_SObject(aSO_impl);
332 return _PTR(SObject)(aSO);
335 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
336 const std::string& aComponentName)
338 std::vector<_PTR(SObject)> aVector;
342 SALOMEDS::Locker lock;
344 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
345 aLength = aSeq.size();
346 for (i = 0; i< aLength; i++)
347 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
350 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
351 (char*)aComponentName.c_str());
352 aLength = aSeq->length();
353 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
359 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
361 SALOMEDSClient_SObject* aSO = NULL;
363 SALOMEDS::Locker lock;
365 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
366 if(!aSO_impl) return _PTR(SObject)(aSO);
367 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
370 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
371 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
372 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
374 return _PTR(SObject)(aSO);
377 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
379 SALOMEDSClient_SObject* aSO = NULL;
381 SALOMEDS::Locker lock;
382 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
383 if(!aSO_impl) return _PTR(SObject)(aSO);
384 aSO = new SALOMEDS_SObject(aSO_impl);
387 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
388 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
389 aSO = new SALOMEDS_SObject(aSO_impl);
391 return _PTR(SObject)(aSO);
394 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
396 SALOMEDSClient_SObject* aSO = NULL;
398 SALOMEDS::Locker lock;
400 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
401 if (!aSO_impl) return _PTR(SObject)(aSO);
402 aSO = new SALOMEDS_SObject(aSO_impl);
405 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
406 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
407 aSO = new SALOMEDS_SObject(aSO_impl);
409 return _PTR(SObject)(aSO);
412 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
414 SALOMEDSClient_SObject* aSO = NULL;
416 SALOMEDS::Locker lock;
418 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
419 if (!aSO_impl) return _PTR(SObject)(aSO);
420 aSO = new SALOMEDS_SObject(aSO_impl);
423 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
424 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
425 aSO = new SALOMEDS_SObject(aSO_impl);
427 return _PTR(SObject)(aSO);
430 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
432 if(!theSO) return "";
433 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
436 SALOMEDS::Locker lock;
437 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
439 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
443 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
445 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
446 SALOMEDSClient_ChildIterator* aCI = NULL;
448 SALOMEDS::Locker lock;
449 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
450 aCI = new SALOMEDS_ChildIterator(aCIimpl);
453 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
454 aCI = new SALOMEDS_ChildIterator(aCIimpl);
457 return _PTR(ChildIterator)(aCI);
460 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
462 SALOMEDSClient_SComponentIterator* aCI = NULL;
464 SALOMEDS::Locker lock;
466 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
467 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
470 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
471 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
474 return _PTR(SComponentIterator)(aCI);
477 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
479 SALOMEDSClient_StudyBuilder* aSB = NULL;
481 SALOMEDS::Locker lock;
483 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
484 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
487 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
488 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
491 return _PTR(StudyBuilder)(aSB);
494 std::string SALOMEDS_Study::Name()
498 SALOMEDS::Locker lock;
499 aName = _local_impl->Name();
501 else aName = Kernel_Utils::encode_s(_corba_impl->Name());
505 void SALOMEDS_Study::Name(const std::string& theName)
508 SALOMEDS::Locker lock;
509 _local_impl->Name(theName);
511 else _corba_impl->Name(Kernel_Utils::decode_s(theName));
514 bool SALOMEDS_Study::IsSaved()
518 SALOMEDS::Locker lock;
519 isSaved = _local_impl->IsSaved();
521 else isSaved = _corba_impl->IsSaved();
525 void SALOMEDS_Study::IsSaved(bool save)
528 SALOMEDS::Locker lock;
529 _local_impl->IsSaved(save);
531 else _corba_impl->IsSaved(save);
534 bool SALOMEDS_Study::IsModified()
538 SALOMEDS::Locker lock;
539 isModified = _local_impl->IsModified();
541 else isModified = _corba_impl->IsModified();
545 void SALOMEDS_Study::Modified()
548 SALOMEDS::Locker lock;
549 _local_impl->Modify();
551 else _corba_impl->Modified();
555 std::string SALOMEDS_Study::URL()
559 SALOMEDS::Locker lock;
560 aURL = _local_impl->URL();
563 aURL = Kernel_Utils::encode_s(_corba_impl->URL());
567 void SALOMEDS_Study::URL(const std::string& url)
570 SALOMEDS::Locker lock;
571 _local_impl->URL(url);
573 else _corba_impl->URL(Kernel_Utils::decode_s(url));
576 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
578 std::vector<_PTR(SObject)> aVector;
579 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
582 SALOMEDS::Locker lock;
584 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
586 aLength = aSeq.size();
587 for (i = 0; i < aLength; i++)
588 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
592 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
593 aLength = aSeq->length();
594 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
599 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
601 SALOMEDSClient_AttributeStudyProperties* aProp;
603 SALOMEDS::Locker lock;
604 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
606 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
607 return _PTR(AttributeStudyProperties)(aProp);
610 std::string SALOMEDS_Study::GetLastModificationDate()
614 SALOMEDS::Locker lock;
615 aDate = _local_impl->GetLastModificationDate();
617 else aDate = _corba_impl->GetLastModificationDate();
621 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
623 std::vector<std::string> aVector;
626 SALOMEDS::Locker lock;
627 aVector = _local_impl->GetModificationsDate();
630 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
631 aLength = aSeq->length();
632 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
637 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
639 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
641 SALOMEDS::Locker lock;
643 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
644 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
647 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
648 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
651 return _PTR(UseCaseBuilder)(aUB);
654 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
656 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
657 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
660 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
661 const std::string& theBaseName,
665 if(CORBA::is_nil(_corba_impl))
668 return _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
671 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
674 SALOMEDS::Locker lock;
675 _local_impl->SetStudyLock(theLockerID.c_str());
677 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
680 bool SALOMEDS_Study::IsStudyLocked()
684 SALOMEDS::Locker lock;
685 isLocked = _local_impl->IsStudyLocked();
687 else isLocked = _corba_impl->IsStudyLocked();
691 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
693 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
694 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
697 std::vector<std::string> SALOMEDS_Study::GetLockerID()
699 std::vector<std::string> aVector;
702 SALOMEDS::Locker lock;
703 aVector = _local_impl->GetLockerID();
706 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
707 aLength = aSeq->length();
708 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
714 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
717 SALOMEDS::Locker lock;
718 _local_impl->SetVariable(theVarName,
720 SALOMEDSImpl_GenericVariable::REAL_VAR);
723 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
726 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
729 SALOMEDS::Locker lock;
730 _local_impl->SetVariable(theVarName,
732 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
735 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
738 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
741 SALOMEDS::Locker lock;
742 _local_impl->SetVariable(theVarName,
744 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
747 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
750 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
753 SALOMEDS::Locker lock;
754 _local_impl->SetStringVariable(theVarName,
756 SALOMEDSImpl_GenericVariable::STRING_VAR);
759 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
762 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
765 SALOMEDS::Locker lock;
766 _local_impl->SetStringVariableAsDouble(theVarName,
768 SALOMEDSImpl_GenericVariable::STRING_VAR);
771 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
774 double SALOMEDS_Study::GetReal(const std::string& theVarName)
778 SALOMEDS::Locker lock;
779 aResult = _local_impl->GetVariableValue(theVarName);
782 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
786 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
790 SALOMEDS::Locker lock;
791 aResult = (int) _local_impl->GetVariableValue(theVarName);
794 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
798 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
802 SALOMEDS::Locker lock;
803 aResult = (bool) _local_impl->GetVariableValue(theVarName);
806 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
810 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
814 SALOMEDS::Locker lock;
815 aResult = _local_impl->GetStringVariableValue(theVarName);
818 aResult = _corba_impl->GetString((char*)theVarName.c_str());
822 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
826 SALOMEDS::Locker lock;
827 aResult = _local_impl->IsTypeOf(theVarName,
828 SALOMEDSImpl_GenericVariable::REAL_VAR);
831 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
835 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
839 SALOMEDS::Locker lock;
840 aResult = _local_impl->IsTypeOf(theVarName,
841 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
844 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
848 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
852 SALOMEDS::Locker lock;
853 aResult = _local_impl->IsTypeOf(theVarName,
854 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
857 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
861 bool SALOMEDS_Study::IsString(const std::string& theVarName)
865 SALOMEDS::Locker lock;
866 aResult = _local_impl->IsTypeOf(theVarName,
867 SALOMEDSImpl_GenericVariable::STRING_VAR);
870 aResult = _corba_impl->IsString((char*)theVarName.c_str());
874 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
878 SALOMEDS::Locker lock;
879 aResult = _local_impl->IsVariable(theVarName);
882 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
886 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
888 std::vector<std::string> aVector;
890 SALOMEDS::Locker lock;
891 aVector = _local_impl->GetVariableNames();
894 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
895 int aLength = aSeq->length();
896 for (int i = 0; i < aLength; i++)
897 aVector.push_back( std::string(aSeq[i].in()) );
902 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
906 SALOMEDS::Locker lock;
907 aResult = _local_impl->RemoveVariable(theVarName);
910 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
914 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
918 SALOMEDS::Locker lock;
919 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
922 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
926 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
930 SALOMEDS::Locker lock;
931 aResult = _local_impl->IsVariableUsed(theVarName);
934 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
938 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
940 std::vector< std::vector<std::string> > aResult;
942 SALOMEDS::Locker lock;
943 aResult = _local_impl->ParseVariables(theVars);
946 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
947 for (int i = 0, n = aSeq->length(); i < n; i++) {
948 std::vector<std::string> aVector;
949 SALOMEDS::ListOfStrings aSection = aSeq[i];
950 for (int j = 0, m = aSection.length(); j < m; j++) {
951 aVector.push_back( std::string(aSection[j].in()) );
953 aResult.push_back( aVector );
959 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
961 return _orb->object_to_string(theObject);
964 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
966 return _orb->string_to_object(theIOR.c_str());
969 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
971 SALOMEDSClient_AttributeParameter* AP = NULL;
972 if(theSavePoint >= 0) {
974 SALOMEDS::Locker lock;
975 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
978 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
981 return _PTR(AttributeParameter)(AP);
984 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
985 const std::string& theModuleName, int theSavePoint)
987 SALOMEDSClient_AttributeParameter* AP = NULL;
988 if(theSavePoint > 0) {
990 SALOMEDS::Locker lock;
991 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
994 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
997 return _PTR(AttributeParameter)(AP);
1000 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1002 if(CORBA::is_nil(_corba_impl))
1005 _corba_impl->attach(theObserver,modify);
1008 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1010 if(CORBA::is_nil(_corba_impl))
1013 _corba_impl->detach(theObserver);