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::Init()
103 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
104 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
105 _orb = init(0 , 0 ) ;
108 void SALOMEDS_Study::Clear()
111 SALOMEDS::Locker lock;
112 _local_impl->Clear();
115 _corba_impl->Clear();
118 bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
120 if(CORBA::is_nil(_corba_impl))
123 if (!_corba_impl->Open(theStudyUrl.c_str()))
129 bool SALOMEDS_Study::Save(bool theMultiFile)
131 //SRN: Pure CORBA save as the save operation require CORBA in any case
132 return _corba_impl->Save(theMultiFile);
135 bool SALOMEDS_Study::SaveASCII(bool theMultiFile)
137 //SRN: Pure CORBA save as the save operation require CORBA in any case
138 return _corba_impl->SaveASCII(theMultiFile);
141 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile)
143 //SRN: Pure CORBA save as the save operation require CORBA in any case
144 return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile);
147 bool SALOMEDS_Study::SaveAsASCII(const std::string& theUrl, bool theMultiFile)
149 //SRN: Pure CORBA save as the save operation require CORBA in any case
150 return _corba_impl->SaveAsASCII((char*)theUrl.c_str(), theMultiFile);
153 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
155 SALOMEDS_Driver_i* driver = NULL;
157 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
159 std::string IOREngine = aSCO.GetIOR();
160 if(!IOREngine.empty()) {
161 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
162 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
163 driver = new SALOMEDS_Driver_i(Engine, orb);
170 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
172 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
176 SALOMEDS::Locker lock;
178 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
179 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
180 ret = _local_impl->CanCopy(aSO_impl, aDriver);
184 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
190 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
192 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
195 SALOMEDS::Locker lock;
197 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
198 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
199 ret = _local_impl->Copy(aSO_impl, aDriver);
203 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
208 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
210 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
214 SALOMEDS::Locker lock;
216 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
217 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
218 ret = _local_impl->CanPaste(aSO_impl, aDriver);
222 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
228 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
230 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
231 SALOMEDSClient_SObject* aResult = NULL;
234 SALOMEDS::Locker lock;
236 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
237 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
238 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
240 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
241 aResult = new SALOMEDS_SObject(aNewSO);
244 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
245 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
246 aResult = new SALOMEDS_SObject(aNewSO);
249 return _PTR(SObject)(aResult);
252 std::string SALOMEDS_Study::GetPersistentReference()
256 SALOMEDS::Locker lock;
257 aRef = _local_impl->GetPersistentReference();
259 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
263 std::string SALOMEDS_Study::GetTransientReference()
267 SALOMEDS::Locker lock;
268 aRef = _local_impl->GetTransientReference();
270 else aRef = _corba_impl->GetTransientReference();
274 bool SALOMEDS_Study::IsEmpty()
278 SALOMEDS::Locker lock;
279 ret = _local_impl->IsEmpty();
281 else ret = _corba_impl->IsEmpty();
285 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
287 SALOMEDSClient_SComponent* aSCO = NULL;
289 SALOMEDS::Locker lock;
291 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
292 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
293 aSCO = new SALOMEDS_SComponent(aSCO_impl);
296 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
297 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
298 aSCO = new SALOMEDS_SComponent(aSCO_impl);
300 return _PTR(SComponent)(aSCO);
303 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
305 SALOMEDSClient_SComponent* aSCO = NULL;
307 SALOMEDS::Locker lock;
309 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
310 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
311 aSCO = new SALOMEDS_SComponent(aSCO_impl);
314 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
315 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
316 aSCO = new SALOMEDS_SComponent(aSCO_impl);
318 return _PTR(SComponent)(aSCO);
321 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
323 SALOMEDSClient_SObject* aSO = NULL;
326 SALOMEDS::Locker lock;
328 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
329 if (!aSO_impl) return _PTR(SObject)(aSO);
330 if(aSO_impl.IsComponent()) {
331 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
332 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
334 aSO = new SALOMEDS_SObject(aSO_impl);
337 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
338 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
339 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
340 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
341 aSO = new SALOMEDS_SObject(aSO_impl);
344 return _PTR(SObject)(aSO);
347 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
348 const std::string& aComponentName)
350 std::vector<_PTR(SObject)> aVector;
354 SALOMEDS::Locker lock;
356 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
357 aLength = aSeq.size();
358 for (i = 0; i< aLength; i++)
359 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
362 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
363 (char*)aComponentName.c_str());
364 aLength = aSeq->length();
365 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
371 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
373 SALOMEDSClient_SObject* aSO = NULL;
375 SALOMEDS::Locker lock;
377 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
378 if(!aSO_impl) return _PTR(SObject)(aSO);
379 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
382 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
383 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
384 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
386 return _PTR(SObject)(aSO);
389 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
391 SALOMEDSClient_SObject* aSO = NULL;
393 SALOMEDS::Locker lock;
394 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
395 if(!aSO_impl) return _PTR(SObject)(aSO);
396 aSO = new SALOMEDS_SObject(aSO_impl);
399 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
400 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
401 aSO = new SALOMEDS_SObject(aSO_impl);
403 return _PTR(SObject)(aSO);
406 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
408 SALOMEDSClient_SObject* aSO = NULL;
410 SALOMEDS::Locker lock;
412 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
413 if (!aSO_impl) return _PTR(SObject)(aSO);
414 aSO = new SALOMEDS_SObject(aSO_impl);
417 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
418 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
419 aSO = new SALOMEDS_SObject(aSO_impl);
421 return _PTR(SObject)(aSO);
424 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
426 SALOMEDSClient_SObject* aSO = NULL;
428 SALOMEDS::Locker lock;
430 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
431 if (!aSO_impl) return _PTR(SObject)(aSO);
432 aSO = new SALOMEDS_SObject(aSO_impl);
435 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
436 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
437 aSO = new SALOMEDS_SObject(aSO_impl);
439 return _PTR(SObject)(aSO);
442 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
444 if(!theSO) return "";
445 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
448 SALOMEDS::Locker lock;
449 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
451 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
455 void SALOMEDS_Study::SetContext(const std::string& thePath)
458 SALOMEDS::Locker lock;
459 _local_impl->SetContext(thePath);
461 else _corba_impl->SetContext((char*)thePath.c_str());
464 std::string SALOMEDS_Study::GetContext()
468 SALOMEDS::Locker lock;
469 aPath = _local_impl->GetContext();
471 else aPath = _corba_impl->GetContext();
475 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
477 std::vector<std::string> aVector;
480 SALOMEDS::Locker lock;
481 aVector = _local_impl->GetObjectNames(theContext);
484 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
485 aLength = aSeq->length();
486 for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
491 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
493 std::vector<std::string> aVector;
496 SALOMEDS::Locker lock;
497 aVector = _local_impl->GetDirectoryNames(theContext);
500 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
501 aLength = aSeq->length();
502 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
507 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
509 std::vector<std::string> aVector;
512 SALOMEDS::Locker lock;
513 aVector = _local_impl->GetFileNames(theContext);
516 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
517 aLength = aSeq->length();
519 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
524 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
526 std::vector<std::string> aVector;
529 SALOMEDS::Locker lock;
530 aVector = _local_impl->GetComponentNames(theContext);
533 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
534 aLength = aSeq->length();
535 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
540 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
542 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
543 SALOMEDSClient_ChildIterator* aCI = NULL;
545 SALOMEDS::Locker lock;
546 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
547 aCI = new SALOMEDS_ChildIterator(aCIimpl);
550 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
551 aCI = new SALOMEDS_ChildIterator(aCIimpl);
554 return _PTR(ChildIterator)(aCI);
557 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
559 SALOMEDSClient_SComponentIterator* aCI = NULL;
561 SALOMEDS::Locker lock;
563 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
564 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
567 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
568 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
571 return _PTR(SComponentIterator)(aCI);
574 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
576 SALOMEDSClient_StudyBuilder* aSB = NULL;
578 SALOMEDS::Locker lock;
580 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
581 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
584 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
585 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
588 return _PTR(StudyBuilder)(aSB);
591 std::string SALOMEDS_Study::Name()
595 SALOMEDS::Locker lock;
596 aName = _local_impl->Name();
598 else aName = _corba_impl->Name();
602 bool SALOMEDS_Study::IsSaved()
606 SALOMEDS::Locker lock;
607 isSaved = _local_impl->IsSaved();
609 else isSaved = _corba_impl->IsSaved();
613 void SALOMEDS_Study::IsSaved(bool save)
616 SALOMEDS::Locker lock;
617 _local_impl->IsSaved(save);
619 else _corba_impl->IsSaved(save);
622 bool SALOMEDS_Study::IsModified()
626 SALOMEDS::Locker lock;
627 isModified = _local_impl->IsModified();
629 else isModified = _corba_impl->IsModified();
633 void SALOMEDS_Study::Modified()
636 SALOMEDS::Locker lock;
637 _local_impl->Modify();
639 else _corba_impl->Modified();
643 std::string SALOMEDS_Study::URL()
647 SALOMEDS::Locker lock;
648 aURL = _local_impl->URL();
650 else aURL = _corba_impl->URL();
654 void SALOMEDS_Study::URL(const std::string& url)
657 SALOMEDS::Locker lock;
658 _local_impl->URL(url);
660 else _corba_impl->URL((char*)url.c_str());
663 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
665 std::vector<_PTR(SObject)> aVector;
666 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
669 SALOMEDS::Locker lock;
671 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
673 aLength = aSeq.size();
674 for (i = 0; i < aLength; i++)
675 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
679 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
680 aLength = aSeq->length();
681 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
686 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
688 SALOMEDSClient_AttributeStudyProperties* aProp;
690 SALOMEDS::Locker lock;
691 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
693 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
694 return _PTR(AttributeStudyProperties)(aProp);
697 std::string SALOMEDS_Study::GetLastModificationDate()
701 SALOMEDS::Locker lock;
702 aDate = _local_impl->GetLastModificationDate();
704 else aDate = _corba_impl->GetLastModificationDate();
708 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
710 std::vector<std::string> aVector;
713 SALOMEDS::Locker lock;
714 aVector = _local_impl->GetModificationsDate();
717 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
718 aLength = aSeq->length();
719 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
724 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
726 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
728 SALOMEDS::Locker lock;
730 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
731 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
734 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
735 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
738 return _PTR(UseCaseBuilder)(aUB);
741 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
743 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
744 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
747 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
748 const std::string& theBaseName,
752 //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
753 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
754 bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
758 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
761 SALOMEDS::Locker lock;
762 _local_impl->SetStudyLock(theLockerID.c_str());
764 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
767 bool SALOMEDS_Study::IsStudyLocked()
771 SALOMEDS::Locker lock;
772 isLocked = _local_impl->IsStudyLocked();
774 else isLocked = _corba_impl->IsStudyLocked();
778 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
780 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
781 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
784 std::vector<std::string> SALOMEDS_Study::GetLockerID()
786 std::vector<std::string> aVector;
789 SALOMEDS::Locker lock;
790 aVector = _local_impl->GetLockerID();
793 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
794 aLength = aSeq->length();
795 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
801 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
804 SALOMEDS::Locker lock;
805 _local_impl->SetVariable(theVarName,
807 SALOMEDSImpl_GenericVariable::REAL_VAR);
810 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
813 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
816 SALOMEDS::Locker lock;
817 _local_impl->SetVariable(theVarName,
819 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
822 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
825 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
828 SALOMEDS::Locker lock;
829 _local_impl->SetVariable(theVarName,
831 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
834 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
837 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
840 SALOMEDS::Locker lock;
841 _local_impl->SetStringVariable(theVarName,
843 SALOMEDSImpl_GenericVariable::STRING_VAR);
846 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
849 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
852 SALOMEDS::Locker lock;
853 _local_impl->SetStringVariableAsDouble(theVarName,
855 SALOMEDSImpl_GenericVariable::STRING_VAR);
858 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
861 double SALOMEDS_Study::GetReal(const std::string& theVarName)
865 SALOMEDS::Locker lock;
866 aResult = _local_impl->GetVariableValue(theVarName);
869 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
873 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
877 SALOMEDS::Locker lock;
878 aResult = (int) _local_impl->GetVariableValue(theVarName);
881 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
885 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
889 SALOMEDS::Locker lock;
890 aResult = (bool) _local_impl->GetVariableValue(theVarName);
893 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
897 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
901 SALOMEDS::Locker lock;
902 aResult = _local_impl->GetStringVariableValue(theVarName);
905 aResult = _corba_impl->GetString((char*)theVarName.c_str());
909 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
913 SALOMEDS::Locker lock;
914 aResult = _local_impl->IsTypeOf(theVarName,
915 SALOMEDSImpl_GenericVariable::REAL_VAR);
918 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
922 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
926 SALOMEDS::Locker lock;
927 aResult = _local_impl->IsTypeOf(theVarName,
928 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
931 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
935 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
939 SALOMEDS::Locker lock;
940 aResult = _local_impl->IsTypeOf(theVarName,
941 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
944 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
948 bool SALOMEDS_Study::IsString(const std::string& theVarName)
952 SALOMEDS::Locker lock;
953 aResult = _local_impl->IsTypeOf(theVarName,
954 SALOMEDSImpl_GenericVariable::STRING_VAR);
957 aResult = _corba_impl->IsString((char*)theVarName.c_str());
961 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
965 SALOMEDS::Locker lock;
966 aResult = _local_impl->IsVariable(theVarName);
969 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
973 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
975 std::vector<std::string> aVector;
977 SALOMEDS::Locker lock;
978 aVector = _local_impl->GetVariableNames();
981 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
982 int aLength = aSeq->length();
983 for (int i = 0; i < aLength; i++)
984 aVector.push_back( std::string(aSeq[i].in()) );
989 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
993 SALOMEDS::Locker lock;
994 aResult = _local_impl->RemoveVariable(theVarName);
997 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
1001 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
1005 SALOMEDS::Locker lock;
1006 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
1009 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
1013 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
1017 SALOMEDS::Locker lock;
1018 aResult = _local_impl->IsVariableUsed(theVarName);
1021 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
1025 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
1027 std::vector< std::vector<std::string> > aResult;
1029 SALOMEDS::Locker lock;
1030 aResult = _local_impl->ParseVariables(theVars);
1033 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
1034 for (int i = 0, n = aSeq->length(); i < n; i++) {
1035 std::vector<std::string> aVector;
1036 SALOMEDS::ListOfStrings aSection = aSeq[i];
1037 for (int j = 0, m = aSection.length(); j < m; j++) {
1038 aVector.push_back( std::string(aSection[j].in()) );
1040 aResult.push_back( aVector );
1046 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
1048 return _orb->object_to_string(theObject);
1051 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
1053 return _orb->string_to_object(theIOR.c_str());
1056 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
1059 SALOMEDS::Locker lock;
1061 if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
1062 std::string anIOR = _local_impl->GetTransientReference();
1063 SALOMEDS::Study_var aStudy;
1064 if (!_local_impl->IsError() && anIOR != "") {
1065 aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
1068 SALOME_NamingService* namingService = KERNEL::getNamingService();
1069 CORBA::Object_var obj = namingService->Resolve("/Study");
1070 aStudy = SALOMEDS::Study::_narrow(obj);
1071 _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
1073 _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
1074 return aStudy._retn();
1077 return SALOMEDS::Study::_duplicate(_corba_impl);
1080 return SALOMEDS::Study::_nil();
1084 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
1086 SALOMEDSClient_AttributeParameter* AP = NULL;
1087 if(theSavePoint >= 0) {
1089 SALOMEDS::Locker lock;
1090 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
1093 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
1096 return _PTR(AttributeParameter)(AP);
1099 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
1100 const std::string& theModuleName, int theSavePoint)
1102 SALOMEDSClient_AttributeParameter* AP = NULL;
1103 if(theSavePoint > 0) {
1105 SALOMEDS::Locker lock;
1106 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1109 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1112 return _PTR(AttributeParameter)(AP);
1115 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1117 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1118 _corba_impl->attach(theObserver,modify);
1121 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1123 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1124 _corba_impl->detach(theObserver);