1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_Study.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
29 #include "SALOMEDS_Study.hxx"
31 #include "SALOMEDS.hxx"
32 #include "SALOMEDS_SComponent.hxx"
33 #include "SALOMEDS_SObject.hxx"
34 #include "SALOMEDS_StudyBuilder.hxx"
35 #include "SALOMEDS_ChildIterator.hxx"
36 #include "SALOMEDS_SComponentIterator.hxx"
37 #include "SALOMEDS_AttributeStudyProperties.hxx"
38 #include "SALOMEDS_AttributeParameter.hxx"
39 #include "SALOMEDS_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_SComponent.hxx"
42 #include "SALOMEDSImpl_SObject.hxx"
43 #include "SALOMEDSImpl_StudyBuilder.hxx"
44 #include "SALOMEDSImpl_ChildIterator.hxx"
45 #include "SALOMEDSImpl_SComponentIterator.hxx"
46 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
47 #include "SALOMEDSImpl_AttributeParameter.hxx"
48 #include "SALOMEDSImpl_GenericVariable.hxx"
49 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
51 #include "SALOMEDS_Driver_i.hxx"
52 #include "SALOMEDS_Study_i.hxx"
54 #include "Utils_ORB_INIT.hxx"
55 #include "Utils_SINGLETON.hxx"
57 #include "Basics_Utils.hxx"
62 #include <sys/types.h>
66 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
69 _local_impl = theStudy;
70 _corba_impl = SALOMEDS::Study::_nil();
74 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
77 long pid = (long)_getpid();
79 long pid = (long)getpid();
82 long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
84 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
85 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
89 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
95 SALOMEDS_Study::~SALOMEDS_Study()
99 std::string SALOMEDS_Study::GetPersistentReference()
103 SALOMEDS::Locker lock;
104 aRef = _local_impl->GetPersistentReference();
106 else aRef = (CORBA::String_var)_corba_impl->GetPersistentReference();
110 std::string SALOMEDS_Study::GetTransientReference()
114 SALOMEDS::Locker lock;
115 aRef = _local_impl->GetTransientReference();
117 else aRef = _corba_impl->GetTransientReference();
121 bool SALOMEDS_Study::IsEmpty()
125 SALOMEDS::Locker lock;
126 ret = _local_impl->IsEmpty();
128 else ret = _corba_impl->IsEmpty();
132 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
134 SALOMEDSClient_SComponent* aSCO = NULL;
136 SALOMEDS::Locker lock;
138 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
139 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
140 aSCO = new SALOMEDS_SComponent(aSCO_impl);
143 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
144 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
145 aSCO = new SALOMEDS_SComponent(aSCO_impl);
147 return _PTR(SComponent)(aSCO);
150 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
152 SALOMEDSClient_SComponent* aSCO = NULL;
154 SALOMEDS::Locker lock;
156 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
157 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
158 aSCO = new SALOMEDS_SComponent(aSCO_impl);
161 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
162 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
163 aSCO = new SALOMEDS_SComponent(aSCO_impl);
165 return _PTR(SComponent)(aSCO);
168 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
170 SALOMEDSClient_SObject* aSO = NULL;
173 SALOMEDS::Locker lock;
175 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
176 if (!aSO_impl) return _PTR(SObject)(aSO);
177 if(aSO_impl.IsComponent()) {
178 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
179 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
181 aSO = new SALOMEDS_SObject(aSO_impl);
184 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
185 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
186 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
187 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
188 aSO = new SALOMEDS_SObject(aSO_impl);
191 return _PTR(SObject)(aSO);
194 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
195 const std::string& aComponentName)
197 std::vector<_PTR(SObject)> aVector;
201 SALOMEDS::Locker lock;
203 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
204 aLength = aSeq.size();
205 for (i = 0; i< aLength; i++)
206 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
209 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
210 (char*)aComponentName.c_str());
211 aLength = aSeq->length();
212 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
218 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
220 SALOMEDSClient_SObject* aSO = NULL;
222 SALOMEDS::Locker lock;
224 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
225 if(!aSO_impl) return _PTR(SObject)(aSO);
226 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
229 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
230 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
231 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
233 return _PTR(SObject)(aSO);
236 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
238 SALOMEDSClient_SObject* aSO = NULL;
240 SALOMEDS::Locker lock;
241 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
242 if(!aSO_impl) return _PTR(SObject)(aSO);
243 aSO = new SALOMEDS_SObject(aSO_impl);
246 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
247 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
248 aSO = new SALOMEDS_SObject(aSO_impl);
250 return _PTR(SObject)(aSO);
253 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
255 SALOMEDSClient_SObject* aSO = NULL;
257 SALOMEDS::Locker lock;
259 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
260 if (!aSO_impl) return _PTR(SObject)(aSO);
261 aSO = new SALOMEDS_SObject(aSO_impl);
264 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
265 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
266 aSO = new SALOMEDS_SObject(aSO_impl);
268 return _PTR(SObject)(aSO);
271 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
273 SALOMEDSClient_SObject* aSO = NULL;
275 SALOMEDS::Locker lock;
277 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
278 if (!aSO_impl) return _PTR(SObject)(aSO);
279 aSO = new SALOMEDS_SObject(aSO_impl);
282 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
283 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
284 aSO = new SALOMEDS_SObject(aSO_impl);
286 return _PTR(SObject)(aSO);
289 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
291 if(!theSO) return "";
292 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
295 SALOMEDS::Locker lock;
296 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
298 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
302 void SALOMEDS_Study::SetContext(const std::string& thePath)
305 SALOMEDS::Locker lock;
306 _local_impl->SetContext(thePath);
308 else _corba_impl->SetContext((char*)thePath.c_str());
311 std::string SALOMEDS_Study::GetContext()
315 SALOMEDS::Locker lock;
316 aPath = _local_impl->GetContext();
318 else aPath = _corba_impl->GetContext();
322 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
324 std::vector<std::string> aVector;
327 SALOMEDS::Locker lock;
328 aVector = _local_impl->GetObjectNames(theContext);
331 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
332 aLength = aSeq->length();
333 for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
338 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
340 std::vector<std::string> aVector;
343 SALOMEDS::Locker lock;
344 aVector = _local_impl->GetDirectoryNames(theContext);
347 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
348 aLength = aSeq->length();
349 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
354 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
356 std::vector<std::string> aVector;
359 SALOMEDS::Locker lock;
360 aVector = _local_impl->GetFileNames(theContext);
363 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
364 aLength = aSeq->length();
366 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
371 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
373 std::vector<std::string> aVector;
376 SALOMEDS::Locker lock;
377 aVector = _local_impl->GetComponentNames(theContext);
380 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
381 aLength = aSeq->length();
382 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
387 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
389 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
390 SALOMEDSClient_ChildIterator* aCI = NULL;
392 SALOMEDS::Locker lock;
393 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
394 aCI = new SALOMEDS_ChildIterator(aCIimpl);
397 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
398 aCI = new SALOMEDS_ChildIterator(aCIimpl);
401 return _PTR(ChildIterator)(aCI);
404 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
406 SALOMEDSClient_SComponentIterator* aCI = NULL;
408 SALOMEDS::Locker lock;
410 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
411 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
414 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
415 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
418 return _PTR(SComponentIterator)(aCI);
421 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
423 SALOMEDSClient_StudyBuilder* aSB = NULL;
425 SALOMEDS::Locker lock;
427 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
428 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
431 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
432 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
435 return _PTR(StudyBuilder)(aSB);
438 std::string SALOMEDS_Study::Name()
442 SALOMEDS::Locker lock;
443 aName = _local_impl->Name();
445 else aName = Kernel_Utils::encode_s(_corba_impl->Name());
449 void SALOMEDS_Study::Name(const std::string& theName)
452 SALOMEDS::Locker lock;
453 _local_impl->Name(theName);
455 else _corba_impl->Name(Kernel_Utils::decode_s(theName));
458 bool SALOMEDS_Study::IsSaved()
462 SALOMEDS::Locker lock;
463 isSaved = _local_impl->IsSaved();
465 else isSaved = _corba_impl->IsSaved();
469 void SALOMEDS_Study::IsSaved(bool save)
472 SALOMEDS::Locker lock;
473 _local_impl->IsSaved(save);
475 else _corba_impl->IsSaved(save);
478 bool SALOMEDS_Study::IsModified()
482 SALOMEDS::Locker lock;
483 isModified = _local_impl->IsModified();
485 else isModified = _corba_impl->IsModified();
489 void SALOMEDS_Study::Modified()
492 SALOMEDS::Locker lock;
493 _local_impl->Modify();
495 else _corba_impl->Modified();
499 std::string SALOMEDS_Study::URL()
503 SALOMEDS::Locker lock;
504 aURL = _local_impl->URL();
507 aURL = Kernel_Utils::encode_s(_corba_impl->URL());
511 void SALOMEDS_Study::URL(const std::string& url)
514 SALOMEDS::Locker lock;
515 _local_impl->URL(url);
517 else _corba_impl->URL(Kernel_Utils::decode_s(url));
520 int SALOMEDS_Study::StudyId()
524 SALOMEDS::Locker lock;
525 anID = _local_impl->StudyId();
527 else anID = _corba_impl->StudyId();
531 void SALOMEDS_Study::StudyId(int id)
534 SALOMEDS::Locker lock;
535 _local_impl->StudyId(id);
537 else _corba_impl->StudyId(id);
540 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
542 std::vector<_PTR(SObject)> aVector;
543 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
546 SALOMEDS::Locker lock;
548 std::vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindDependances(*(aSO->GetLocalImpl()));
550 aLength = aSeq.size();
551 for (i = 0; i < aLength; i++)
552 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
556 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
557 aLength = aSeq->length();
558 for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
563 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
565 SALOMEDSClient_AttributeStudyProperties* aProp;
567 SALOMEDS::Locker lock;
568 aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
570 else aProp = new SALOMEDS_AttributeStudyProperties((SALOMEDS::AttributeStudyProperties_var)_corba_impl->GetProperties());
571 return _PTR(AttributeStudyProperties)(aProp);
574 std::string SALOMEDS_Study::GetLastModificationDate()
578 SALOMEDS::Locker lock;
579 aDate = _local_impl->GetLastModificationDate();
581 else aDate = _corba_impl->GetLastModificationDate();
585 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
587 std::vector<std::string> aVector;
590 SALOMEDS::Locker lock;
591 aVector = _local_impl->GetModificationsDate();
594 SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
595 aLength = aSeq->length();
596 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
601 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
603 SALOMEDSClient_UseCaseBuilder* aUB = NULL;
605 SALOMEDS::Locker lock;
607 SALOMEDSImpl_UseCaseBuilder* aUBimpl = _local_impl->GetUseCaseBuilder();
608 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
611 SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
612 aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
615 return _PTR(UseCaseBuilder)(aUB);
618 void SALOMEDS_Study::Close()
621 SALOMEDS::Locker lock;
622 _local_impl->Close();
624 else _corba_impl->Close();
627 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
629 if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
630 else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
633 bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
634 const std::string& theBaseName,
638 //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
639 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
640 bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
644 void SALOMEDS_Study::SetStudyLock(const std::string& theLockerID)
647 SALOMEDS::Locker lock;
648 _local_impl->SetStudyLock(theLockerID.c_str());
650 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
653 bool SALOMEDS_Study::IsStudyLocked()
657 SALOMEDS::Locker lock;
658 isLocked = _local_impl->IsStudyLocked();
660 else isLocked = _corba_impl->IsStudyLocked();
664 void SALOMEDS_Study::UnLockStudy(const std::string& theLockerID)
666 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
667 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
670 std::vector<std::string> SALOMEDS_Study::GetLockerID()
672 std::vector<std::string> aVector;
675 SALOMEDS::Locker lock;
676 aVector = _local_impl->GetLockerID();
679 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
680 aLength = aSeq->length();
681 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
687 void SALOMEDS_Study::SetReal(const std::string& theVarName, const double theValue)
690 SALOMEDS::Locker lock;
691 _local_impl->SetVariable(theVarName,
693 SALOMEDSImpl_GenericVariable::REAL_VAR);
696 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
699 void SALOMEDS_Study::SetInteger(const std::string& theVarName, const int theValue)
702 SALOMEDS::Locker lock;
703 _local_impl->SetVariable(theVarName,
705 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
708 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
711 void SALOMEDS_Study::SetBoolean(const std::string& theVarName, const bool theValue)
714 SALOMEDS::Locker lock;
715 _local_impl->SetVariable(theVarName,
717 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
720 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
723 void SALOMEDS_Study::SetString(const std::string& theVarName, const std::string& theValue)
726 SALOMEDS::Locker lock;
727 _local_impl->SetStringVariable(theVarName,
729 SALOMEDSImpl_GenericVariable::STRING_VAR);
732 _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str());
735 void SALOMEDS_Study::SetStringAsDouble(const std::string& theVarName, const double theValue)
738 SALOMEDS::Locker lock;
739 _local_impl->SetStringVariableAsDouble(theVarName,
741 SALOMEDSImpl_GenericVariable::STRING_VAR);
744 _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue);
747 double SALOMEDS_Study::GetReal(const std::string& theVarName)
751 SALOMEDS::Locker lock;
752 aResult = _local_impl->GetVariableValue(theVarName);
755 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
759 int SALOMEDS_Study::GetInteger(const std::string& theVarName)
763 SALOMEDS::Locker lock;
764 aResult = (int) _local_impl->GetVariableValue(theVarName);
767 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
771 bool SALOMEDS_Study::GetBoolean(const std::string& theVarName)
775 SALOMEDS::Locker lock;
776 aResult = (bool) _local_impl->GetVariableValue(theVarName);
779 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
783 std::string SALOMEDS_Study::GetString(const std::string& theVarName)
787 SALOMEDS::Locker lock;
788 aResult = _local_impl->GetStringVariableValue(theVarName);
791 aResult = _corba_impl->GetString((char*)theVarName.c_str());
795 bool SALOMEDS_Study::IsReal(const std::string& theVarName)
799 SALOMEDS::Locker lock;
800 aResult = _local_impl->IsTypeOf(theVarName,
801 SALOMEDSImpl_GenericVariable::REAL_VAR);
804 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
808 bool SALOMEDS_Study::IsInteger(const std::string& theVarName)
812 SALOMEDS::Locker lock;
813 aResult = _local_impl->IsTypeOf(theVarName,
814 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
817 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
821 bool SALOMEDS_Study::IsBoolean(const std::string& theVarName)
825 SALOMEDS::Locker lock;
826 aResult = _local_impl->IsTypeOf(theVarName,
827 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
830 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
834 bool SALOMEDS_Study::IsString(const std::string& theVarName)
838 SALOMEDS::Locker lock;
839 aResult = _local_impl->IsTypeOf(theVarName,
840 SALOMEDSImpl_GenericVariable::STRING_VAR);
843 aResult = _corba_impl->IsString((char*)theVarName.c_str());
847 bool SALOMEDS_Study::IsVariable(const std::string& theVarName)
851 SALOMEDS::Locker lock;
852 aResult = _local_impl->IsVariable(theVarName);
855 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
859 std::vector<std::string> SALOMEDS_Study::GetVariableNames()
861 std::vector<std::string> aVector;
863 SALOMEDS::Locker lock;
864 aVector = _local_impl->GetVariableNames();
867 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
868 int aLength = aSeq->length();
869 for (int i = 0; i < aLength; i++)
870 aVector.push_back( std::string(aSeq[i].in()) );
875 bool SALOMEDS_Study::RemoveVariable(const std::string& theVarName)
879 SALOMEDS::Locker lock;
880 aResult = _local_impl->RemoveVariable(theVarName);
883 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
887 bool SALOMEDS_Study::RenameVariable(const std::string& theVarName, const std::string& theNewVarName)
891 SALOMEDS::Locker lock;
892 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
895 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
899 bool SALOMEDS_Study::IsVariableUsed(const std::string& theVarName)
903 SALOMEDS::Locker lock;
904 aResult = _local_impl->IsVariableUsed(theVarName);
907 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
911 std::vector< std::vector<std::string> > SALOMEDS_Study::ParseVariables(const std::string& theVars)
913 std::vector< std::vector<std::string> > aResult;
915 SALOMEDS::Locker lock;
916 aResult = _local_impl->ParseVariables(theVars);
919 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
920 for (int i = 0, n = aSeq->length(); i < n; i++) {
921 std::vector<std::string> aVector;
922 SALOMEDS::ListOfStrings aSection = aSeq[i];
923 for (int j = 0, m = aSection.length(); j < m; j++) {
924 aVector.push_back( std::string(aSection[j].in()) );
926 aResult.push_back( aVector );
932 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
934 return _orb->object_to_string(theObject);
937 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
939 return _orb->string_to_object(theIOR.c_str());
942 void SALOMEDS_Study::init_orb()
944 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
945 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
946 _orb = init(0 , 0 ) ;
949 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
952 SALOMEDS::Locker lock;
954 if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
955 std::string anIOR = _local_impl->GetTransientReference();
956 SALOMEDS::Study_var aStudy;
957 if (!_local_impl->IsError() && anIOR != "") {
958 aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
961 SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
962 aStudy = aStudy_servant->_this();
963 _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
965 _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
966 return aStudy._retn();
969 return SALOMEDS::Study::_duplicate(_corba_impl);
972 return SALOMEDS::Study::_nil();
976 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const std::string& theID, int theSavePoint)
978 SALOMEDSClient_AttributeParameter* AP = NULL;
979 if(theSavePoint >= 0) {
981 SALOMEDS::Locker lock;
982 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
985 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
988 return _PTR(AttributeParameter)(AP);
991 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& theID,
992 const std::string& theModuleName, int theSavePoint)
994 SALOMEDSClient_AttributeParameter* AP = NULL;
995 if(theSavePoint > 0) {
997 SALOMEDS::Locker lock;
998 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1001 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
1004 return _PTR(AttributeParameter)(AP);
1007 void SALOMEDS_Study::attach(SALOMEDS::Observer_ptr theObserver,bool modify)
1009 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1010 _corba_impl->attach(theObserver,modify);
1013 void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
1015 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
1016 _corba_impl->detach(theObserver);