1 // Copyright (C) 2007-2008 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.
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
22 // File : SALOMEDS_Study.cxx
23 // Author : Sergey RUIN
26 #include "utilities.h"
28 #include "SALOMEDS_Study.hxx"
30 #include "SALOMEDS.hxx"
31 #include "SALOMEDS_SComponent.hxx"
32 #include "SALOMEDS_SObject.hxx"
33 #include "SALOMEDS_StudyBuilder.hxx"
34 #include "SALOMEDS_ChildIterator.hxx"
35 #include "SALOMEDS_SComponentIterator.hxx"
36 #include "SALOMEDS_AttributeStudyProperties.hxx"
37 #include "SALOMEDS_AttributeParameter.hxx"
38 #include "SALOMEDS_UseCaseBuilder.hxx"
40 #include "SALOMEDSImpl_SComponent.hxx"
41 #include "SALOMEDSImpl_SObject.hxx"
42 #include "SALOMEDSImpl_StudyBuilder.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_SComponentIterator.hxx"
45 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
46 #include "SALOMEDSImpl_AttributeParameter.hxx"
47 #include "SALOMEDSImpl_GenericVariable.hxx"
48 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
50 #include "SALOMEDS_Driver_i.hxx"
51 #include "SALOMEDS_Study_i.hxx"
53 #include "Utils_ORB_INIT.hxx"
54 #include "Utils_SINGLETON.hxx"
56 #include "Basics_Utils.hxx"
61 #include <sys/types.h>
67 SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
70 _local_impl = theStudy;
71 _corba_impl = SALOMEDS::Study::_nil();
75 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
78 long pid = (long)_getpid();
80 long pid = (long)getpid();
83 long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
85 _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
86 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
90 _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
96 SALOMEDS_Study::~SALOMEDS_Study()
100 std::string SALOMEDS_Study::GetPersistentReference()
104 SALOMEDS::Locker lock;
105 aRef = _local_impl->GetPersistentReference();
107 else aRef = _corba_impl->GetPersistentReference();
111 std::string SALOMEDS_Study::GetTransientReference()
115 SALOMEDS::Locker lock;
116 aRef = _local_impl->GetTransientReference();
118 else aRef = _corba_impl->GetTransientReference();
122 bool SALOMEDS_Study::IsEmpty()
126 SALOMEDS::Locker lock;
127 ret = _local_impl->IsEmpty();
129 else ret = _corba_impl->IsEmpty();
133 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
135 SALOMEDSClient_SComponent* aSCO = NULL;
137 SALOMEDS::Locker lock;
139 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponent(aComponentName);
140 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
141 aSCO = new SALOMEDS_SComponent(aSCO_impl);
144 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
145 if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
146 aSCO = new SALOMEDS_SComponent(aSCO_impl);
148 return _PTR(SComponent)(aSCO);
151 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
153 SALOMEDSClient_SComponent* aSCO = NULL;
155 SALOMEDS::Locker lock;
157 SALOMEDSImpl_SComponent aSCO_impl = _local_impl->FindComponentID(aComponentID);
158 if (!aSCO_impl) return _PTR(SComponent)(aSCO);
159 aSCO = new SALOMEDS_SComponent(aSCO_impl);
162 SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
163 if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
164 aSCO = new SALOMEDS_SComponent(aSCO_impl);
166 return _PTR(SComponent)(aSCO);
169 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
171 SALOMEDSClient_SObject* aSO = NULL;
174 SALOMEDS::Locker lock;
176 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObject(anObjectName);
177 if (!aSO_impl) return _PTR(SObject)(aSO);
178 if(aSO_impl.IsComponent()) {
179 SALOMEDSImpl_SComponent aSCO_impl = aSO_impl;
180 return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
182 aSO = new SALOMEDS_SObject(aSO_impl);
185 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
186 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
187 SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
188 if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
189 aSO = new SALOMEDS_SObject(aSO_impl);
192 return _PTR(SObject)(aSO);
195 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
196 const std::string& aComponentName)
198 std::vector<_PTR(SObject)> aVector;
202 SALOMEDS::Locker lock;
204 vector<SALOMEDSImpl_SObject> aSeq = _local_impl->FindObjectByName(anObjectName, aComponentName);
205 aLength = aSeq.size();
206 for (i = 0; i< aLength; i++)
207 aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
210 SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(),
211 (char*)aComponentName.c_str());
212 aLength = aSeq->length();
213 for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
219 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
221 SALOMEDSClient_SObject* aSO = NULL;
223 SALOMEDS::Locker lock;
225 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectID(anObjectID);
226 if(!aSO_impl) return _PTR(SObject)(aSO);
227 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
230 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
231 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
232 return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
234 return _PTR(SObject)(aSO);
237 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
239 SALOMEDSClient_SObject* aSO = NULL;
241 SALOMEDS::Locker lock;
242 SALOMEDSImpl_SObject aSO_impl = _local_impl->CreateObjectID(anObjectID);
243 if(!aSO_impl) return _PTR(SObject)(aSO);
244 aSO = new SALOMEDS_SObject(aSO_impl);
247 SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
248 if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
249 aSO = new SALOMEDS_SObject(aSO_impl);
251 return _PTR(SObject)(aSO);
254 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
256 SALOMEDSClient_SObject* aSO = NULL;
258 SALOMEDS::Locker lock;
260 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectIOR(anObjectIOR);
261 if (!aSO_impl) return _PTR(SObject)(aSO);
262 aSO = new SALOMEDS_SObject(aSO_impl);
265 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
266 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
267 aSO = new SALOMEDS_SObject(aSO_impl);
269 return _PTR(SObject)(aSO);
272 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
274 SALOMEDSClient_SObject* aSO = NULL;
276 SALOMEDS::Locker lock;
278 SALOMEDSImpl_SObject aSO_impl = _local_impl->FindObjectByPath(thePath);
279 if (!aSO_impl) return _PTR(SObject)(aSO);
280 aSO = new SALOMEDS_SObject(aSO_impl);
283 SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
284 if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
285 aSO = new SALOMEDS_SObject(aSO_impl);
287 return _PTR(SObject)(aSO);
290 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
292 if(!theSO) return "";
293 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
296 SALOMEDS::Locker lock;
297 aPath = _local_impl->GetObjectPath(*(aSO->GetLocalImpl()));
299 else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
303 void SALOMEDS_Study::SetContext(const std::string& thePath)
306 SALOMEDS::Locker lock;
307 _local_impl->SetContext(thePath);
309 else _corba_impl->SetContext((char*)thePath.c_str());
312 std::string SALOMEDS_Study::GetContext()
316 SALOMEDS::Locker lock;
317 aPath = _local_impl->GetContext();
319 else aPath = _corba_impl->GetContext();
323 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
325 std::vector<std::string> aVector;
328 SALOMEDS::Locker lock;
329 aVector = _local_impl->GetObjectNames(theContext);
332 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
333 aLength = aSeq->length();
334 for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
339 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
341 std::vector<std::string> aVector;
344 SALOMEDS::Locker lock;
345 aVector = _local_impl->GetDirectoryNames(theContext);
348 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
349 aLength = aSeq->length();
350 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
355 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
357 std::vector<std::string> aVector;
360 SALOMEDS::Locker lock;
361 aVector = _local_impl->GetFileNames(theContext);
364 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
365 aLength = aSeq->length();
367 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
372 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
374 std::vector<std::string> aVector;
377 SALOMEDS::Locker lock;
378 aVector = _local_impl->GetComponentNames(theContext);
381 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
382 aLength = aSeq->length();
383 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
388 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
390 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
391 SALOMEDSClient_ChildIterator* aCI = NULL;
393 SALOMEDS::Locker lock;
394 SALOMEDSImpl_ChildIterator aCIimpl = _local_impl->NewChildIterator(*(aSO->GetLocalImpl()));
395 aCI = new SALOMEDS_ChildIterator(aCIimpl);
398 SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
399 aCI = new SALOMEDS_ChildIterator(aCIimpl);
402 return _PTR(ChildIterator)(aCI);
405 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
407 SALOMEDSClient_SComponentIterator* aCI = NULL;
409 SALOMEDS::Locker lock;
411 SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
412 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
415 SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
416 aCI = new SALOMEDS_SComponentIterator(aCIimpl);
419 return _PTR(SComponentIterator)(aCI);
422 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
424 SALOMEDSClient_StudyBuilder* aSB = NULL;
426 SALOMEDS::Locker lock;
428 SALOMEDSImpl_StudyBuilder* aSBimpl = _local_impl->NewBuilder();
429 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
432 SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
433 aSB = new SALOMEDS_StudyBuilder(aSBimpl);
436 return _PTR(StudyBuilder)(aSB);
439 std::string SALOMEDS_Study::Name()
443 SALOMEDS::Locker lock;
444 aName = _local_impl->Name();
446 else aName = _corba_impl->Name();
450 void SALOMEDS_Study::Name(const std::string& theName)
453 SALOMEDS::Locker lock;
454 _local_impl->Name(theName);
456 else _corba_impl->Name((char*)theName.c_str());
459 bool SALOMEDS_Study::IsSaved()
463 SALOMEDS::Locker lock;
464 isSaved = _local_impl->IsSaved();
466 else isSaved = _corba_impl->IsSaved();
470 void SALOMEDS_Study::IsSaved(bool save)
473 SALOMEDS::Locker lock;
474 _local_impl->IsSaved(save);
476 else _corba_impl->IsSaved(save);
479 bool SALOMEDS_Study::IsModified()
483 SALOMEDS::Locker lock;
484 isModified = _local_impl->IsModified();
486 else isModified = _corba_impl->IsModified();
490 void SALOMEDS_Study::Modified()
493 SALOMEDS::Locker lock;
494 _local_impl->Modify();
496 else _corba_impl->Modified();
500 std::string SALOMEDS_Study::URL()
504 SALOMEDS::Locker lock;
505 aURL = _local_impl->URL();
507 else aURL = _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((char*)url.c_str());
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 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(_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 string& thePath, const string& theBaseName, bool isPublished)
635 //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
636 if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
637 bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished);
641 void SALOMEDS_Study::SetStudyLock(const string& theLockerID)
644 SALOMEDS::Locker lock;
645 _local_impl->SetStudyLock(theLockerID.c_str());
647 else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
650 bool SALOMEDS_Study::IsStudyLocked()
654 SALOMEDS::Locker lock;
655 isLocked = _local_impl->IsStudyLocked();
657 else isLocked = _corba_impl->IsStudyLocked();
661 void SALOMEDS_Study::UnLockStudy(const string& theLockerID)
663 if(_isLocal) _local_impl->UnLockStudy(theLockerID.c_str());
664 else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
667 vector<string> SALOMEDS_Study::GetLockerID()
669 std::vector<std::string> aVector;
672 SALOMEDS::Locker lock;
673 aVector = _local_impl->GetLockerID();
676 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
677 aLength = aSeq->length();
678 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
684 void SALOMEDS_Study::SetReal(const string& theVarName, const double theValue)
687 SALOMEDS::Locker lock;
688 _local_impl->SetVariable(theVarName,
690 SALOMEDSImpl_GenericVariable::REAL_VAR);
693 _corba_impl->SetReal((char*)theVarName.c_str(),theValue);
696 void SALOMEDS_Study::SetInteger(const string& theVarName, const int theValue)
699 SALOMEDS::Locker lock;
700 _local_impl->SetVariable(theVarName,
702 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
705 _corba_impl->SetInteger((char*)theVarName.c_str(),theValue);
708 void SALOMEDS_Study::SetBoolean(const string& theVarName, const bool theValue)
711 SALOMEDS::Locker lock;
712 _local_impl->SetVariable(theVarName,
714 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
717 _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue);
720 double SALOMEDS_Study::GetReal(const string& theVarName)
724 SALOMEDS::Locker lock;
725 aResult = _local_impl->GetVariableValue(theVarName);
728 aResult = _corba_impl->GetReal((char*)theVarName.c_str());
732 int SALOMEDS_Study::GetInteger(const string& theVarName)
736 SALOMEDS::Locker lock;
737 aResult = (int) _local_impl->GetVariableValue(theVarName);
740 aResult = _corba_impl->GetInteger((char*)theVarName.c_str());
744 bool SALOMEDS_Study::GetBoolean(const string& theVarName)
748 SALOMEDS::Locker lock;
749 aResult = (bool) _local_impl->GetVariableValue(theVarName);
752 aResult = _corba_impl->GetBoolean((char*)theVarName.c_str());
756 bool SALOMEDS_Study::IsReal(const string& theVarName)
760 SALOMEDS::Locker lock;
761 aResult = _local_impl->IsTypeOf(theVarName,
762 SALOMEDSImpl_GenericVariable::REAL_VAR);
765 aResult = _corba_impl->IsReal((char*)theVarName.c_str());
769 bool SALOMEDS_Study::IsInteger(const string& theVarName)
773 SALOMEDS::Locker lock;
774 aResult = _local_impl->IsTypeOf(theVarName,
775 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
778 aResult = _corba_impl->IsInteger((char*)theVarName.c_str());
782 bool SALOMEDS_Study::IsBoolean(const string& theVarName)
786 SALOMEDS::Locker lock;
787 aResult = _local_impl->IsTypeOf(theVarName,
788 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
791 aResult = _corba_impl->IsBoolean((char*)theVarName.c_str());
795 bool SALOMEDS_Study::IsVariable(const string& theVarName)
799 SALOMEDS::Locker lock;
800 aResult = _local_impl->IsVariable(theVarName);
803 aResult = _corba_impl->IsVariable((char*)theVarName.c_str());
807 vector<string> SALOMEDS_Study::GetVariableNames()
809 vector<string> aVector;
811 SALOMEDS::Locker lock;
812 aVector = _local_impl->GetVariableNames();
815 SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames();
816 int aLength = aSeq->length();
817 for (int i = 0; i < aLength; i++)
818 aVector.push_back( string(aSeq[i].in()) );
823 bool SALOMEDS_Study::RemoveVariable(const string& theVarName)
827 SALOMEDS::Locker lock;
828 aResult = _local_impl->RemoveVariable(theVarName);
831 aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
835 bool SALOMEDS_Study::RenameVariable(const string& theVarName, const string& theNewVarName)
839 SALOMEDS::Locker lock;
840 aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
843 aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
847 bool SALOMEDS_Study::IsVariableUsed(const string& theVarName)
851 SALOMEDS::Locker lock;
852 aResult = _local_impl->IsVariableUsed(theVarName);
855 aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
859 vector< vector<string> > SALOMEDS_Study::ParseVariables(const string& theVars)
861 vector< vector<string> > aResult;
863 SALOMEDS::Locker lock;
864 aResult = _local_impl->ParseVariables(theVars);
867 SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
868 for (int i = 0, n = aSeq->length(); i < n; i++) {
869 vector<string> aVector;
870 SALOMEDS::ListOfStrings aSection = aSeq[i];
871 for (int j = 0, m = aSection.length(); j < m; j++) {
872 aVector.push_back( string(aSection[j].in()) );
874 aResult.push_back( aVector );
880 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
882 return _orb->object_to_string(theObject);
885 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
887 return _orb->string_to_object(theIOR.c_str());
890 void SALOMEDS_Study::init_orb()
892 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
893 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
894 _orb = init(0 , 0 ) ;
897 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
900 SALOMEDS::Locker lock;
902 if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
903 std::string anIOR = _local_impl->GetTransientReference();
904 SALOMEDS::Study_var aStudy;
905 if (!_local_impl->IsError() && anIOR != "") {
906 aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
909 SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
910 aStudy = aStudy_servant->_this();
911 _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
913 _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
914 return aStudy._retn();
917 return SALOMEDS::Study::_duplicate(_corba_impl);
920 return SALOMEDS::Study::_nil();
924 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint)
926 SALOMEDSClient_AttributeParameter* AP = NULL;
927 if(theSavePoint >= 0) {
929 SALOMEDS::Locker lock;
930 AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
933 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
936 return _PTR(AttributeParameter)(AP);
939 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const string& theID,
940 const string& theModuleName, int theSavePoint)
942 SALOMEDSClient_AttributeParameter* AP = NULL;
943 if(theSavePoint > 0) {
945 SALOMEDS::Locker lock;
946 AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
949 AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
952 return _PTR(AttributeParameter)(AP);