1 // Copyright (C) 2007-2020 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();
74 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
79 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
82 long pid = (long)_getpid();
84 long pid = (long)getpid();
87 pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
89 CORBA::LongLong addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
91 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
92 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
96 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
102 SALOMEDS_Study::~SALOMEDS_Study()
106 void SALOMEDS_Study::InitORB()
108 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
109 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
110 _orb = init(0 , 0 ) ;
113 void SALOMEDS_Study::Init()
115 if(CORBA::is_nil(_corba_impl))
121 void SALOMEDS_Study::Clear()
123 if(CORBA::is_nil(_corba_impl))
126 _corba_impl->Clear();
129 bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
131 if(CORBA::is_nil(_corba_impl))
133 std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
135 return _corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() );
138 bool SALOMEDS_Study::CanOpen(const std::string& theStudyUrl)
140 if(CORBA::is_nil(_corba_impl))
142 std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
144 return _corba_impl->CanOpen( (wchar_t*)wtheStudyUrl.c_str() );
147 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
149 if(CORBA::is_nil(_corba_impl))
152 return _corba_impl->Save(theMultiFile, theASCII);
155 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
157 if(CORBA::is_nil(_corba_impl))
160 return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), theMultiFile, theASCII);
163 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
165 SALOMEDS_Driver_i* driver = NULL;
167 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
169 std::string IOREngine = aSCO.GetIOR();
170 if(!IOREngine.empty()) {
171 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
172 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
173 driver = new SALOMEDS_Driver_i(Engine, orb);
180 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
182 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
186 SALOMEDS::Locker lock;
188 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
189 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
190 ret = _local_impl->CanCopy(aSO_impl, aDriver);
194 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
200 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
202 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
205 SALOMEDS::Locker lock;
207 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
208 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
209 ret = _local_impl->Copy(aSO_impl, aDriver);
213 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
218 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
220 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
224 SALOMEDS::Locker lock;
226 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
227 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
228 ret = _local_impl->CanPaste(aSO_impl, aDriver);
232 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
238 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
240 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
241 SALOMEDSClient_SObject* aResult = NULL;
244 SALOMEDS::Locker lock;
246 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
247 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
248 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
250 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
251 aResult = new SALOMEDS_SObject(aNewSO);
254 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
255 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
256 aResult = new SALOMEDS_SObject(aNewSO);
259 return _PTR(SObject)(aResult);
262 std::string SALOMEDS_Study::GetPersistentReference()
266 SALOMEDS::Locker lock;
267 aRef = _local_impl->GetPersistentReference();
269 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
273 bool SALOMEDS_Study::IsEmpty()
277 SALOMEDS::Locker lock;
278 ret = _local_impl->IsEmpty();
280 else ret = _corba_impl->IsEmpty();
284 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
286 SALOMEDSClient_SComponent* aSCO = NULL;
288 SALOMEDS::Locker lock;
290 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
291 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
292 aSCO = new SALOMEDS_SComponent(aSCO_impl);
295 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
296 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
297 aSCO = new SALOMEDS_SComponent(aSCO_impl);
299 return _PTR(SComponent)(aSCO);
302 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
304 SALOMEDSClient_SComponent* aSCO = NULL;
306 SALOMEDS::Locker lock;
308 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
309 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
310 aSCO = new SALOMEDS_SComponent(aSCO_impl);
313 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
314 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
315 aSCO = new SALOMEDS_SComponent(aSCO_impl);
317 return _PTR(SComponent)(aSCO);
320 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
322 SALOMEDSClient_SObject* aSO = NULL;
325 SALOMEDS::Locker lock;
327 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
328 if (!aSO_impl) return _PTR(SObject)(aSO);
329 if(aSO_impl.IsComponent()) {
330 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
331 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
333 aSO = new SALOMEDS_SObject(aSO_impl);
336 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
337 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
338 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
339 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
340 aSO = new SALOMEDS_SObject(aSO_impl);
343 return _PTR(SObject)(aSO);
346 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
347 const std::string& aComponentName)
349 std::vector<_PTR(SObject)> aVector;
353 SALOMEDS::Locker lock;
355 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
356 aLength = aSeq.size();
357 for (i = 0; i< aLength; i++)
358 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
361 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
362 (char*)aComponentName.c_str());
363 aLength = aSeq->length();
364 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
370 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
372 SALOMEDSClient_SObject* aSO = NULL;
374 SALOMEDS::Locker lock;
376 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
377 if(!aSO_impl) return _PTR(SObject)(aSO);
378 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
381 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
382 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
383 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
385 return _PTR(SObject)(aSO);
388 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
390 SALOMEDSClient_SObject* aSO = NULL;
392 SALOMEDS::Locker lock;
393 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
394 if(!aSO_impl) return _PTR(SObject)(aSO);
395 aSO = new SALOMEDS_SObject(aSO_impl);
398 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
399 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
400 aSO = new SALOMEDS_SObject(aSO_impl);
402 return _PTR(SObject)(aSO);
405 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
407 SALOMEDSClient_SObject* aSO = NULL;
409 SALOMEDS::Locker lock;
411 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
412 if (!aSO_impl) return _PTR(SObject)(aSO);
413 aSO = new SALOMEDS_SObject(aSO_impl);
416 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
417 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
418 aSO = new SALOMEDS_SObject(aSO_impl);
420 return _PTR(SObject)(aSO);
423 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
425 SALOMEDSClient_SObject* aSO = NULL;
427 SALOMEDS::Locker lock;
429 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
430 if (!aSO_impl) return _PTR(SObject)(aSO);
431 aSO = new SALOMEDS_SObject(aSO_impl);
434 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
435 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
436 aSO = new SALOMEDS_SObject(aSO_impl);
438 return _PTR(SObject)(aSO);
441 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
443 if(!theSO) return "";
444 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
447 SALOMEDS::Locker lock;
448 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
450 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
454 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
456 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
457 SALOMEDSClient_ChildIterator* aCI = NULL;
459 SALOMEDS::Locker lock;
460 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
461 aCI = new SALOMEDS_ChildIterator(aCIimpl);
464 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
465 aCI = new SALOMEDS_ChildIterator(aCIimpl);
468 return _PTR(ChildIterator)(aCI);
471 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
473 SALOMEDSClient_SComponentIterator* aCI = NULL;
475 SALOMEDS::Locker lock;
477 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
478 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
481 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
482 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
485 return _PTR(SComponentIterator)(aCI);
488 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
490 SALOMEDSClient_StudyBuilder* aSB = NULL;
492 SALOMEDS::Locker lock;
494 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
495 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
498 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
499 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
502 return _PTR(StudyBuilder)(aSB);
505 std::string SALOMEDS_Study::Name()
509 SALOMEDS::Locker lock;
510 aName = _local_impl->Name();
512 else aName = Kernel_Utils::encode_s(_corba_impl->Name());
516 void SALOMEDS_Study::Name(const std::string& theName)
519 SALOMEDS::Locker lock;
520 _local_impl->Name(theName);
522 else _corba_impl->Name(Kernel_Utils::decode_s(theName));
525 bool SALOMEDS_Study::IsSaved()
529 SALOMEDS::Locker lock;
530 isSaved = _local_impl->IsSaved();
532 else isSaved = _corba_impl->IsSaved();
536 void SALOMEDS_Study::IsSaved(bool save)
539 SALOMEDS::Locker lock;
540 _local_impl->IsSaved(save);
542 else _corba_impl->IsSaved(save);
545 bool SALOMEDS_Study::IsModified()
549 SALOMEDS::Locker lock;
550 isModified = _local_impl->IsModified();
552 else isModified = _corba_impl->IsModified();
556 void SALOMEDS_Study::Modified()
559 SALOMEDS::Locker lock;
560 _local_impl->Modify();
562 else _corba_impl->Modified();
566 std::string SALOMEDS_Study::URL()
570 SALOMEDS::Locker lock;
571 aURL = _local_impl->URL();
574 aURL = Kernel_Utils::encode_s(_corba_impl->URL());
578 void SALOMEDS_Study::URL(const std::string& url)
581 SALOMEDS::Locker lock;
582 _local_impl->URL(url);
584 else _corba_impl->URL(Kernel_Utils::decode_s(url));
587 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
589 std::vector<_PTR(SObject)> aVector;
590 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
593 SALOMEDS::Locker lock;
595 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
597 aLength = aSeq.size();
598 for (i = 0; i < aLength; i++)
599 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
603 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
604 aLength = aSeq->length();
605 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
610 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
612 SALOMEDSClient_AttributeStudyProperties* aProp;
614 SALOMEDS::Locker lock;
615 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
617 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
618 return _PTR(AttributeStudyProperties)(aProp);
621 std::string SALOMEDS_Study::GetLastModificationDate()
625 SALOMEDS::Locker lock;
626 aDate = _local_impl->GetLastModificationDate();
628 else aDate = _corba_impl->GetLastModificationDate();
632 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
634 std::vector<std::string> aVector;
637 SALOMEDS::Locker lock;
638 aVector = _local_impl->GetModificationsDate();
641 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
642 aLength = aSeq->length();
643 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
648 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
650 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
652 SALOMEDS::Locker lock;
654 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
655 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
658 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
659 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
662 return _PTR(UseCaseBuilder)(aUB);
665 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
667 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
668 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
671 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
672 const std::string& theBaseName,
676 if(CORBA::is_nil(_corba_impl))
679 return _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
682 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
685 SALOMEDS::Locker lock;
686 _local_impl->SetStudyLock(theLockerID.c_str());
688 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
691 bool SALOMEDS_Study::IsStudyLocked()
695 SALOMEDS::Locker lock;
696 isLocked = _local_impl->IsStudyLocked();
698 else isLocked = _corba_impl->IsStudyLocked();
702 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
704 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
705 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
708 std::vector<std::string> SALOMEDS_Study::GetLockerID()
710 std::vector<std::string> aVector;
713 SALOMEDS::Locker lock;
714 aVector = _local_impl->GetLockerID();
717 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
718 aLength = aSeq->length();
719 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
725 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
728 SALOMEDS::Locker lock;
729 _local_impl->SetVariable(theVarName,
731 SALOMEDSImpl_GenericVariable::REAL_VAR);
734 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
737 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
740 SALOMEDS::Locker lock;
741 _local_impl->SetVariable(theVarName,
743 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
746 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
749 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
752 SALOMEDS::Locker lock;
753 _local_impl->SetVariable(theVarName,
755 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
758 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
761 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
764 SALOMEDS::Locker lock;
765 _local_impl->SetStringVariable(theVarName,
767 SALOMEDSImpl_GenericVariable::STRING_VAR);
770 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
773 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
776 SALOMEDS::Locker lock;
777 _local_impl->SetStringVariableAsDouble(theVarName,
779 SALOMEDSImpl_GenericVariable::STRING_VAR);
782 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
785 double SALOMEDS_Study::GetReal(const std::string& theVarName)
789 SALOMEDS::Locker lock;
790 aResult = _local_impl->GetVariableValue(theVarName);
793 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
797 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
801 SALOMEDS::Locker lock;
802 aResult = (int) _local_impl->GetVariableValue(theVarName);
805 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
809 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
813 SALOMEDS::Locker lock;
814 aResult = (bool) _local_impl->GetVariableValue(theVarName);
817 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
821 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
825 SALOMEDS::Locker lock;
826 aResult = _local_impl->GetStringVariableValue(theVarName);
829 aResult = _corba_impl->GetString((char*)theVarName.c_str());
833 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
837 SALOMEDS::Locker lock;
838 aResult = _local_impl->IsTypeOf(theVarName,
839 SALOMEDSImpl_GenericVariable::REAL_VAR);
842 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
846 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
850 SALOMEDS::Locker lock;
851 aResult = _local_impl->IsTypeOf(theVarName,
852 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
855 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
859 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
863 SALOMEDS::Locker lock;
864 aResult = _local_impl->IsTypeOf(theVarName,
865 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
868 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
872 bool SALOMEDS_Study::IsString(const std::string& theVarName)
876 SALOMEDS::Locker lock;
877 aResult = _local_impl->IsTypeOf(theVarName,
878 SALOMEDSImpl_GenericVariable::STRING_VAR);
881 aResult = _corba_impl->IsString((char*)theVarName.c_str());
885 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
889 SALOMEDS::Locker lock;
890 aResult = _local_impl->IsVariable(theVarName);
893 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
897 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
899 std::vector<std::string> aVector;
901 SALOMEDS::Locker lock;
902 aVector = _local_impl->GetVariableNames();
905 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
906 int aLength = aSeq->length();
907 for (int i = 0; i < aLength; i++)
908 aVector.push_back( std::string(aSeq[i].in()) );
913 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
917 SALOMEDS::Locker lock;
918 aResult = _local_impl->RemoveVariable(theVarName);
921 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
925 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
929 SALOMEDS::Locker lock;
930 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
933 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
937 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
941 SALOMEDS::Locker lock;
942 aResult = _local_impl->IsVariableUsed(theVarName);
945 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
949 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
951 std::vector< std::vector<std::string> > aResult;
953 SALOMEDS::Locker lock;
954 aResult = _local_impl->ParseVariables(theVars);
957 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
958 for (int i = 0, n = aSeq->length(); i < n; i++) {
959 std::vector<std::string> aVector;
960 SALOMEDS::ListOfStrings aSection = aSeq[i];
961 for (int j = 0, m = aSection.length(); j < m; j++) {
962 aVector.push_back( std::string(aSection[j].in()) );
964 aResult.push_back( aVector );
970 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
972 return _orb->object_to_string(theObject);
975 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
977 return _orb->string_to_object(theIOR.c_str());
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))
1016 _corba_impl->attach(theObserver,modify);
1019 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1021 if(CORBA::is_nil(_corba_impl))
1024 _corba_impl->detach(theObserver);