1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_Study.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
29 #include "SALOMEDS_Study.hxx"
31 #include "SALOMEDS.hxx"
32 #include "SALOMEDS_SComponent.hxx"
33 #include "SALOMEDS_SObject.hxx"
34 #include "SALOMEDS_StudyBuilder.hxx"
35 #include "SALOMEDS_ChildIterator.hxx"
36 #include "SALOMEDS_SComponentIterator.hxx"
37 #include "SALOMEDS_AttributeStudyProperties.hxx"
38 #include "SALOMEDS_AttributeParameter.hxx"
39 #include "SALOMEDS_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_SComponent.hxx"
42 #include "SALOMEDSImpl_SObject.hxx"
43 #include "SALOMEDSImpl_StudyBuilder.hxx"
44 #include "SALOMEDSImpl_ChildIterator.hxx"
45 #include "SALOMEDSImpl_SComponentIterator.hxx"
46 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
47 #include "SALOMEDSImpl_AttributeParameter.hxx"
48 #include "SALOMEDSImpl_GenericVariable.hxx"
49 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
51 #include <SALOME_KernelServices.hxx>
53 #include "SALOMEDS_Driver_i.hxx"
54 #include "SALOMEDS_Study_i.hxx"
56 #include "Utils_ORB_INIT.hxx"
57 #include "Utils_SINGLETON.hxx"
59 #include "Basics_Utils.hxx"
64 #include <sys/types.h>
68 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
71 _local_impl = theStudy;
72 _corba_impl = SALOMEDS::Study::_nil();
76 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
79 long pid = (long)_getpid();
81 long pid = (long)getpid();
84 long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
86 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
87 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
91 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
97 SALOMEDS_Study::~SALOMEDS_Study()
101 void SALOMEDS_Study::InitORB()
103 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
104 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
105 _orb = init(0 , 0 ) ;
108 void SALOMEDS_Study::Init()
110 if(CORBA::is_nil(_corba_impl))
116 void SALOMEDS_Study::Clear()
118 if(CORBA::is_nil(_corba_impl))
121 _corba_impl->Clear();
124 bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
126 if(CORBA::is_nil(_corba_impl))
129 if (!_corba_impl->Open(theStudyUrl.c_str()))
135 bool SALOMEDS_Study::Save(bool theMultiFile)
137 //SRN: Pure CORBA save as the save operation require CORBA in any case
138 return _corba_impl->Save(theMultiFile);
141 bool SALOMEDS_Study::SaveASCII(bool theMultiFile)
143 //SRN: Pure CORBA save as the save operation require CORBA in any case
144 return _corba_impl->SaveASCII(theMultiFile);
147 bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile)
149 //SRN: Pure CORBA save as the save operation require CORBA in any case
150 return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile);
153 bool SALOMEDS_Study::SaveAsASCII(const std::string& theUrl, bool theMultiFile)
155 //SRN: Pure CORBA save as the save operation require CORBA in any case
156 return _corba_impl->SaveAsASCII((char*)theUrl.c_str(), theMultiFile);
159 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
161 SALOMEDS_Driver_i* driver = NULL;
163 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
165 std::string IOREngine = aSCO.GetIOR();
166 if(!IOREngine.empty()) {
167 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
168 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
169 driver = new SALOMEDS_Driver_i(Engine, orb);
176 bool SALOMEDS_Study::CanCopy(const _PTR(SObject)& theSO)
178 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
182 SALOMEDS::Locker lock;
184 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
185 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
186 ret = _local_impl->CanCopy(aSO_impl, aDriver);
190 ret = _corba_impl->CanCopy(aSO->GetCORBAImpl());
196 bool SALOMEDS_Study::Copy(const _PTR(SObject)& theSO)
198 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
201 SALOMEDS::Locker lock;
203 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
204 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
205 ret = _local_impl->Copy(aSO_impl, aDriver);
209 ret = _corba_impl->Copy(aSO->GetCORBAImpl());
214 bool SALOMEDS_Study::CanPaste(const _PTR(SObject)& theSO)
216 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
220 SALOMEDS::Locker lock;
222 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
223 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
224 ret = _local_impl->CanPaste(aSO_impl, aDriver);
228 ret = _corba_impl->CanPaste(aSO->GetCORBAImpl());
234 _PTR(SObject) SALOMEDS_Study::Paste(const _PTR(SObject)& theSO)
236 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
237 SALOMEDSClient_SObject* aResult = NULL;
240 SALOMEDS::Locker lock;
242 SALOMEDSImpl_SObject aSO_impl = *(aSO->GetLocalImpl());
243 SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb);
244 SALOMEDSImpl_SObject aNewSO = _local_impl->Paste(aSO_impl, aDriver);
246 if(aNewSO.IsNull()) return _PTR(SObject)(aResult);
247 aResult = new SALOMEDS_SObject(aNewSO);
250 SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl());
251 if(CORBA::is_nil(aNewSO)) return _PTR(SObject)(aResult);
252 aResult = new SALOMEDS_SObject(aNewSO);
255 return _PTR(SObject)(aResult);
258 std::string SALOMEDS_Study::GetPersistentReference()
262 SALOMEDS::Locker lock;
263 aRef = _local_impl->GetPersistentReference();
265 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
269 std::string SALOMEDS_Study::GetTransientReference()
273 SALOMEDS::Locker lock;
274 aRef = _local_impl->GetTransientReference();
276 else aRef = _corba_impl->GetTransientReference();
280 bool SALOMEDS_Study::IsEmpty()
284 SALOMEDS::Locker lock;
285 ret = _local_impl->IsEmpty();
287 else ret = _corba_impl->IsEmpty();
291 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
293 SALOMEDSClient_SComponent* aSCO = NULL;
295 SALOMEDS::Locker lock;
297 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
298 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
299 aSCO = new SALOMEDS_SComponent(aSCO_impl);
302 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.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(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
311 SALOMEDSClient_SComponent* aSCO = NULL;
313 SALOMEDS::Locker lock;
315 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
316 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
317 aSCO = new SALOMEDS_SComponent(aSCO_impl);
320 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
321 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
322 aSCO = new SALOMEDS_SComponent(aSCO_impl);
324 return _PTR(SComponent)(aSCO);
327 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
329 SALOMEDSClient_SObject* aSO = NULL;
332 SALOMEDS::Locker lock;
334 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
335 if (!aSO_impl) return _PTR(SObject)(aSO);
336 if(aSO_impl.IsComponent()) {
337 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
338 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
340 aSO = new SALOMEDS_SObject(aSO_impl);
343 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
344 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
345 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
346 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
347 aSO = new SALOMEDS_SObject(aSO_impl);
350 return _PTR(SObject)(aSO);
353 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
354 const std::string& aComponentName)
356 std::vector<_PTR(SObject)> aVector;
360 SALOMEDS::Locker lock;
362 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
363 aLength = aSeq.size();
364 for (i = 0; i< aLength; i++)
365 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
368 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
369 (char*)aComponentName.c_str());
370 aLength = aSeq->length();
371 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
377 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
379 SALOMEDSClient_SObject* aSO = NULL;
381 SALOMEDS::Locker lock;
383 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
384 if(!aSO_impl) return _PTR(SObject)(aSO);
385 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
388 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
389 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
390 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
392 return _PTR(SObject)(aSO);
395 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
397 SALOMEDSClient_SObject* aSO = NULL;
399 SALOMEDS::Locker lock;
400 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
401 if(!aSO_impl) return _PTR(SObject)(aSO);
402 aSO = new SALOMEDS_SObject(aSO_impl);
405 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.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::FindObjectIOR(const std::string& anObjectIOR)
414 SALOMEDSClient_SObject* aSO = NULL;
416 SALOMEDS::Locker lock;
418 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
419 if (!aSO_impl) return _PTR(SObject)(aSO);
420 aSO = new SALOMEDS_SObject(aSO_impl);
423 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.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 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
432 SALOMEDSClient_SObject* aSO = NULL;
434 SALOMEDS::Locker lock;
436 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
437 if (!aSO_impl) return _PTR(SObject)(aSO);
438 aSO = new SALOMEDS_SObject(aSO_impl);
441 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
442 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
443 aSO = new SALOMEDS_SObject(aSO_impl);
445 return _PTR(SObject)(aSO);
448 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
450 if(!theSO) return "";
451 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
454 SALOMEDS::Locker lock;
455 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
457 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
461 void SALOMEDS_Study::SetContext(const std::string& thePath)
464 SALOMEDS::Locker lock;
465 _local_impl->SetContext(thePath);
467 else _corba_impl->SetContext((char*)thePath.c_str());
470 std::string SALOMEDS_Study::GetContext()
474 SALOMEDS::Locker lock;
475 aPath = _local_impl->GetContext();
477 else aPath = _corba_impl->GetContext();
481 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
483 std::vector<std::string> aVector;
486 SALOMEDS::Locker lock;
487 aVector = _local_impl->GetObjectNames(theContext);
490 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
491 aLength = aSeq->length();
492 for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
497 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
499 std::vector<std::string> aVector;
502 SALOMEDS::Locker lock;
503 aVector = _local_impl->GetDirectoryNames(theContext);
506 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
507 aLength = aSeq->length();
508 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
513 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
515 std::vector<std::string> aVector;
518 SALOMEDS::Locker lock;
519 aVector = _local_impl->GetFileNames(theContext);
522 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
523 aLength = aSeq->length();
525 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
530 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
532 std::vector<std::string> aVector;
535 SALOMEDS::Locker lock;
536 aVector = _local_impl->GetComponentNames(theContext);
539 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
540 aLength = aSeq->length();
541 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
546 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
548 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
549 SALOMEDSClient_ChildIterator* aCI = NULL;
551 SALOMEDS::Locker lock;
552 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
553 aCI = new SALOMEDS_ChildIterator(aCIimpl);
556 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
557 aCI = new SALOMEDS_ChildIterator(aCIimpl);
560 return _PTR(ChildIterator)(aCI);
563 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
565 SALOMEDSClient_SComponentIterator* aCI = NULL;
567 SALOMEDS::Locker lock;
569 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
570 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
573 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
574 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
577 return _PTR(SComponentIterator)(aCI);
580 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
582 SALOMEDSClient_StudyBuilder* aSB = NULL;
584 SALOMEDS::Locker lock;
586 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
587 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
590 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
591 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
594 return _PTR(StudyBuilder)(aSB);
597 std::string SALOMEDS_Study::Name()
601 SALOMEDS::Locker lock;
602 aName = _local_impl->Name();
604 else aName = _corba_impl->Name();
608 bool SALOMEDS_Study::IsSaved()
612 SALOMEDS::Locker lock;
613 isSaved = _local_impl->IsSaved();
615 else isSaved = _corba_impl->IsSaved();
619 void SALOMEDS_Study::IsSaved(bool save)
622 SALOMEDS::Locker lock;
623 _local_impl->IsSaved(save);
625 else _corba_impl->IsSaved(save);
628 bool SALOMEDS_Study::IsModified()
632 SALOMEDS::Locker lock;
633 isModified = _local_impl->IsModified();
635 else isModified = _corba_impl->IsModified();
639 void SALOMEDS_Study::Modified()
642 SALOMEDS::Locker lock;
643 _local_impl->Modify();
645 else _corba_impl->Modified();
649 std::string SALOMEDS_Study::URL()
653 SALOMEDS::Locker lock;
654 aURL = _local_impl->URL();
656 else aURL = _corba_impl->URL();
660 void SALOMEDS_Study::URL(const std::string& url)
663 SALOMEDS::Locker lock;
664 _local_impl->URL(url);
666 else _corba_impl->URL((char*)url.c_str());
669 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
671 std::vector<_PTR(SObject)> aVector;
672 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
675 SALOMEDS::Locker lock;
677 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
679 aLength = aSeq.size();
680 for (i = 0; i < aLength; i++)
681 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
685 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
686 aLength = aSeq->length();
687 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
692 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
694 SALOMEDSClient_AttributeStudyProperties* aProp;
696 SALOMEDS::Locker lock;
697 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
699 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
700 return _PTR(AttributeStudyProperties)(aProp);
703 std::string SALOMEDS_Study::GetLastModificationDate()
707 SALOMEDS::Locker lock;
708 aDate = _local_impl->GetLastModificationDate();
710 else aDate = _corba_impl->GetLastModificationDate();
714 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
716 std::vector<std::string> aVector;
719 SALOMEDS::Locker lock;
720 aVector = _local_impl->GetModificationsDate();
723 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
724 aLength = aSeq->length();
725 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
730 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
732 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
734 SALOMEDS::Locker lock;
736 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
737 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
740 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
741 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
744 return _PTR(UseCaseBuilder)(aUB);
747 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
749 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
750 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
753 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
754 const std::string& theBaseName,
758 //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
759 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
760 bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
764 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
767 SALOMEDS::Locker lock;
768 _local_impl->SetStudyLock(theLockerID.c_str());
770 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
773 bool SALOMEDS_Study::IsStudyLocked()
777 SALOMEDS::Locker lock;
778 isLocked = _local_impl->IsStudyLocked();
780 else isLocked = _corba_impl->IsStudyLocked();
784 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
786 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
787 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
790 std::vector<std::string> SALOMEDS_Study::GetLockerID()
792 std::vector<std::string> aVector;
795 SALOMEDS::Locker lock;
796 aVector = _local_impl->GetLockerID();
799 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
800 aLength = aSeq->length();
801 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
807 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
810 SALOMEDS::Locker lock;
811 _local_impl->SetVariable(theVarName,
813 SALOMEDSImpl_GenericVariable::REAL_VAR);
816 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
819 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
822 SALOMEDS::Locker lock;
823 _local_impl->SetVariable(theVarName,
825 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
828 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
831 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
834 SALOMEDS::Locker lock;
835 _local_impl->SetVariable(theVarName,
837 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
840 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
843 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
846 SALOMEDS::Locker lock;
847 _local_impl->SetStringVariable(theVarName,
849 SALOMEDSImpl_GenericVariable::STRING_VAR);
852 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
855 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
858 SALOMEDS::Locker lock;
859 _local_impl->SetStringVariableAsDouble(theVarName,
861 SALOMEDSImpl_GenericVariable::STRING_VAR);
864 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
867 double SALOMEDS_Study::GetReal(const std::string& theVarName)
871 SALOMEDS::Locker lock;
872 aResult = _local_impl->GetVariableValue(theVarName);
875 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
879 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
883 SALOMEDS::Locker lock;
884 aResult = (int) _local_impl->GetVariableValue(theVarName);
887 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
891 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
895 SALOMEDS::Locker lock;
896 aResult = (bool) _local_impl->GetVariableValue(theVarName);
899 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
903 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
907 SALOMEDS::Locker lock;
908 aResult = _local_impl->GetStringVariableValue(theVarName);
911 aResult = _corba_impl->GetString((char*)theVarName.c_str());
915 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
919 SALOMEDS::Locker lock;
920 aResult = _local_impl->IsTypeOf(theVarName,
921 SALOMEDSImpl_GenericVariable::REAL_VAR);
924 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
928 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
932 SALOMEDS::Locker lock;
933 aResult = _local_impl->IsTypeOf(theVarName,
934 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
937 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
941 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
945 SALOMEDS::Locker lock;
946 aResult = _local_impl->IsTypeOf(theVarName,
947 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
950 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
954 bool SALOMEDS_Study::IsString(const std::string& theVarName)
958 SALOMEDS::Locker lock;
959 aResult = _local_impl->IsTypeOf(theVarName,
960 SALOMEDSImpl_GenericVariable::STRING_VAR);
963 aResult = _corba_impl->IsString((char*)theVarName.c_str());
967 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
971 SALOMEDS::Locker lock;
972 aResult = _local_impl->IsVariable(theVarName);
975 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
979 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
981 std::vector<std::string> aVector;
983 SALOMEDS::Locker lock;
984 aVector = _local_impl->GetVariableNames();
987 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
988 int aLength = aSeq->length();
989 for (int i = 0; i < aLength; i++)
990 aVector.push_back( std::string(aSeq[i].in()) );
995 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
999 SALOMEDS::Locker lock;
1000 aResult = _local_impl->RemoveVariable(theVarName);
1003 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
1007 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
1011 SALOMEDS::Locker lock;
1012 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
1015 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
1019 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
1023 SALOMEDS::Locker lock;
1024 aResult = _local_impl->IsVariableUsed(theVarName);
1027 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
1031 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
1033 std::vector< std::vector<std::string> > aResult;
1035 SALOMEDS::Locker lock;
1036 aResult = _local_impl->ParseVariables(theVars);
1039 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
1040 for (int i = 0, n = aSeq->length(); i < n; i++) {
1041 std::vector<std::string> aVector;
1042 SALOMEDS::ListOfStrings aSection = aSeq[i];
1043 for (int j = 0, m = aSection.length(); j < m; j++) {
1044 aVector.push_back( std::string(aSection[j].in()) );
1046 aResult.push_back( aVector );
1052 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
1054 return _orb->object_to_string(theObject);
1057 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
1059 return _orb->string_to_object(theIOR.c_str());
1062 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
1065 SALOMEDS::Locker lock;
1067 if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
1068 std::string anIOR = _local_impl->GetTransientReference();
1069 SALOMEDS::Study_var aStudy;
1070 if (!_local_impl->IsError() && anIOR != "") {
1071 aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
1074 SALOME_NamingService* namingService = KERNEL::getNamingService();
1075 CORBA::Object_var obj = namingService->Resolve("/Study");
1076 aStudy = SALOMEDS::Study::_narrow(obj);
1077 _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
1079 _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
1080 return aStudy._retn();
1083 return SALOMEDS::Study::_duplicate(_corba_impl);
1086 return SALOMEDS::Study::_nil();
1090 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
1092 SALOMEDSClient_AttributeParameter* AP = NULL;
1093 if(theSavePoint >= 0) {
1095 SALOMEDS::Locker lock;
1096 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
1099 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
1102 return _PTR(AttributeParameter)(AP);
1105 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
1106 const std::string& theModuleName, int theSavePoint)
1108 SALOMEDSClient_AttributeParameter* AP = NULL;
1109 if(theSavePoint > 0) {
1111 SALOMEDS::Locker lock;
1112 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1115 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1118 return _PTR(AttributeParameter)(AP);
1121 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1123 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1124 _corba_impl->attach(theObserver,modify);
1127 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1129 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1130 _corba_impl->detach(theObserver);