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_i.cxx
23 // Author : Sergey RUIN
26 #include "utilities.h"
27 #include "SALOMEDS_Study_i.hxx"
28 #include "SALOMEDS_UseCaseIterator_i.hxx"
29 #include "SALOMEDS_GenericAttribute_i.hxx"
30 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
31 #include "SALOMEDS_AttributeParameter_i.hxx"
32 #include "SALOMEDS_ChildIterator_i.hxx"
33 #include "SALOMEDS_Driver_i.hxx"
34 #include "SALOMEDS.hxx"
36 #include "SALOMEDSImpl_SObject.hxx"
37 #include "SALOMEDSImpl_SComponent.hxx"
38 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
39 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
40 #include "SALOMEDSImpl_AttributeParameter.hxx"
41 #include "SALOMEDSImpl_ChildIterator.hxx"
42 #include "SALOMEDSImpl_IParameters.hxx"
44 #include "DF_Label.hxx"
45 #include "DF_Attribute.hxx"
47 #include "Basics_Utils.hxx"
52 #include <sys/types.h>
58 //============================================================================
59 /*! Function : SALOMEDS_Study_i
60 * Purpose : SALOMEDS_Study_i constructor
62 //============================================================================
63 SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDSImpl_Study* theImpl,
66 _orb = CORBA::ORB::_duplicate(orb);
69 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
72 //============================================================================
73 /*! Function : ~SALOMEDS_Study_i
74 * Purpose : SALOMEDS_Study_i destructor
76 //============================================================================
77 SALOMEDS_Study_i::~SALOMEDS_Study_i()
81 //============================================================================
82 /*! Function : GetPersistentReference
83 * Purpose : Get persistent reference of study (idem URL())
85 //============================================================================
86 char* SALOMEDS_Study_i::GetPersistentReference()
88 SALOMEDS::Locker lock;
89 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
91 //============================================================================
92 /*! Function : GetTransientReference
93 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
95 //============================================================================
96 char* SALOMEDS_Study_i::GetTransientReference()
98 SALOMEDS::Locker lock;
99 return CORBA::string_dup(_impl->GetTransientReference().c_str());
102 //============================================================================
103 /*! Function : IsEmpty
104 * Purpose : Detect if study is empty
106 //============================================================================
107 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
109 SALOMEDS::Locker lock;
110 return _impl->IsEmpty();
113 //============================================================================
114 /*! Function : FindComponent
115 * Purpose : Find a Component with ComponentDataType = aComponentName
117 //============================================================================
118 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
120 SALOMEDS::Locker lock;
122 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(string(aComponentName));
123 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
125 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
129 //============================================================================
130 /*! Function : FindComponentID
131 * Purpose : Find a Component from it's ID
133 //============================================================================
134 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
136 SALOMEDS::Locker lock;
138 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(string((char*)aComponentID));
139 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
141 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
145 //============================================================================
146 /*! Function : FindObject
147 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
149 //============================================================================
150 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
152 SALOMEDS::Locker lock;
154 SALOMEDSImpl_SObject aSO = _impl->FindObject(string((char*)anObjectName));
155 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
157 if(aSO.IsComponent()) {
158 SALOMEDSImpl_SComponent aSCO = aSO;
159 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
163 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
168 //============================================================================
169 /*! Function : FindObjectID
170 * Purpose : Find an Object with ID = anObjectID
172 //============================================================================
173 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
175 SALOMEDS::Locker lock;
177 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(string((char*)anObjectID));
178 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
179 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
183 //============================================================================
184 /*! Function : CreateObjectID
185 * Purpose : Creates an Object with ID = anObjectID
187 //============================================================================
188 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
190 SALOMEDS::Locker lock;
192 if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
194 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
195 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
197 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
201 //============================================================================
202 /*! Function : FindObjectByName
203 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
204 * : with ComponentDataType = aComponentName
206 //============================================================================
207 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
208 const char* aComponentName )
210 SALOMEDS::Locker lock;
212 vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(string((char*)anObjectName),
213 string((char*)aComponentName));
214 int aLength = aSeq.size();
215 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
216 listSO->length(aLength);
217 for(int i = 0; i<aLength; i++) {
218 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSeq[i], _orb);
221 return listSO._retn() ;
224 //============================================================================
225 /*! Function : FindObjectIOR
226 * Purpose : Find an Object with IOR = anObjectIOR
228 //============================================================================
229 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
231 SALOMEDS::Locker lock;
233 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(string((char*)anObjectIOR));
234 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
236 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
240 //============================================================================
241 /*! Function : FindObjectByPath
242 * Purpose : Find an Object by its path = thePath
244 //============================================================================
245 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
247 SALOMEDS::Locker lock;
249 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(string((char*)thePath));
250 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
252 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
256 //============================================================================
257 /*! Function : GetObjectPath
260 //============================================================================
261 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
263 SALOMEDS::Locker lock;
266 if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.c_str());
267 SALOMEDSImpl_SObject aSO;
268 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
270 if(!CORBA::is_nil(aSObj)) {
271 aSO = _impl->FindObjectID(aSObj->GetID());
274 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
277 if(aSO.IsNull()) return CORBA::string_dup(aPath.c_str());
279 aPath = _impl->GetObjectPath(aSO);
280 return CORBA::string_dup(aPath.c_str());
284 //============================================================================
285 /*! Function : SetContext
286 * Purpose : Sets the current context
288 //============================================================================
289 void SALOMEDS_Study_i::SetContext(const char* thePath)
291 SALOMEDS::Locker lock;
293 _impl->SetContext(string((char*)thePath));
294 if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
295 throw SALOMEDS::Study::StudyInvalidContext();
298 //============================================================================
299 /*! Function : GetContext
300 * Purpose : Gets the current context
302 //============================================================================
303 char* SALOMEDS_Study_i::GetContext()
305 SALOMEDS::Locker lock;
307 if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
308 return CORBA::string_dup(_impl->GetContext().c_str());
311 //============================================================================
312 /*! Function : GetObjectNames
313 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
315 //============================================================================
316 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
318 SALOMEDS::Locker lock;
320 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
322 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
323 throw SALOMEDS::Study::StudyInvalidContext();
325 vector<string> aSeq = _impl->GetObjectNames(string((char*)theContext));
326 if (_impl->GetErrorCode() == "InvalidContext")
327 throw SALOMEDS::Study::StudyInvalidContext();
329 int aLength = aSeq.size();
330 aResult->length(aLength);
331 for (int anIndex = 0; anIndex < aLength; anIndex++) {
332 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
335 return aResult._retn();
338 //============================================================================
339 /*! Function : GetDirectoryNames
340 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
342 //============================================================================
343 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
345 SALOMEDS::Locker lock;
347 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
349 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
350 throw SALOMEDS::Study::StudyInvalidContext();
352 vector<string> aSeq = _impl->GetDirectoryNames(string((char*)theContext));
353 if (_impl->GetErrorCode() == "InvalidContext")
354 throw SALOMEDS::Study::StudyInvalidContext();
356 int aLength = aSeq.size();
357 aResult->length(aLength);
358 for (int anIndex = 0; anIndex < aLength; anIndex++) {
359 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
362 return aResult._retn();
365 //============================================================================
366 /*! Function : GetFileNames
367 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
369 //============================================================================
370 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
372 SALOMEDS::Locker lock;
374 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
376 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
377 throw SALOMEDS::Study::StudyInvalidContext();
379 vector<string> aSeq = _impl->GetFileNames(string((char*)theContext));
380 if (_impl->GetErrorCode() == "InvalidContext")
381 throw SALOMEDS::Study::StudyInvalidContext();
383 int aLength = aSeq.size();
384 aResult->length(aLength);
385 for (int anIndex = 0; anIndex < aLength; anIndex++) {
386 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
389 return aResult._retn();
392 //============================================================================
393 /*! Function : GetComponentNames
394 * Purpose : method to get all components names
395 * SRN: Note, theContext can be any, it doesn't matter
397 //============================================================================
398 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
400 SALOMEDS::Locker lock;
402 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
404 vector<string> aSeq = _impl->GetComponentNames(string((char*)theContext));
406 int aLength = aSeq.size();
407 aResult->length(aLength);
408 for(int anIndex = 0; anIndex < aLength; anIndex++) {
409 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
412 return aResult._retn();
415 //============================================================================
416 /*! Function : NewChildIterator
417 * Purpose : Create a ChildIterator from an SObject
419 //============================================================================
420 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
422 SALOMEDS::Locker lock;
424 SALOMEDSImpl_SObject aSO = _impl->GetSObject(theSO->GetID());
425 SALOMEDSImpl_ChildIterator anItr(aSO);
428 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
429 SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this());
435 //============================================================================
436 /*! Function : NewComponentIterator
437 * Purpose : Create a SComponentIterator
439 //============================================================================
440 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
442 SALOMEDS::Locker lock;
443 SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
449 //============================================================================
450 /*! Function : NewBuilder
451 * Purpose : Create a StudyBuilder
453 //============================================================================
454 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
456 SALOMEDS::Locker lock;
457 return _builder->_this();
460 //============================================================================
462 * Purpose : get study name
464 //============================================================================
465 char* SALOMEDS_Study_i::Name()
467 SALOMEDS::Locker lock;
468 return CORBA::string_dup(_impl->Name().c_str());
471 //============================================================================
473 * Purpose : set study name
475 //============================================================================
476 void SALOMEDS_Study_i::Name(const char* name)
478 SALOMEDS::Locker lock;
479 _impl->Name(string((char*)name));
482 //============================================================================
483 /*! Function : IsSaved
484 * Purpose : get if study has been saved
486 //============================================================================
487 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
489 SALOMEDS::Locker lock;
490 return _impl->IsSaved();
493 //============================================================================
494 /*! Function : IsSaved
495 * Purpose : set if study has been saved
497 //============================================================================
498 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
500 SALOMEDS::Locker lock;
501 _impl->IsSaved(save);
504 //============================================================================
505 /*! Function : IsModified
506 * Purpose : Detect if a Study has been modified since it has been saved
508 //============================================================================
509 CORBA::Boolean SALOMEDS_Study_i::IsModified()
511 SALOMEDS::Locker lock;
512 return _impl->IsModified();
515 //============================================================================
516 /*! Function : Modified
517 * Purpose : Sets a Modified flag of a Study to True
519 //============================================================================
520 void SALOMEDS_Study_i::Modified()
522 SALOMEDS::Locker lock;
523 return _impl->Modify();
527 //============================================================================
529 * Purpose : get URL of the study (persistent reference of the study)
531 //============================================================================
532 char* SALOMEDS_Study_i::URL()
534 SALOMEDS::Locker lock;
535 return CORBA::string_dup(_impl->URL().c_str());
538 //============================================================================
540 * Purpose : set URL of the study (persistent reference of the study)
542 //============================================================================
543 void SALOMEDS_Study_i::URL(const char* url)
545 SALOMEDS::Locker lock;
546 _impl->URL(string((char*)url));
550 CORBA::Short SALOMEDS_Study_i::StudyId()
552 SALOMEDS::Locker lock;
553 return _impl->StudyId();
556 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
558 SALOMEDS::Locker lock;
562 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
564 SALOMEDS::Locker lock;
565 _impl->UpdateIORLabelMap(string((char*)anIOR), string((char*)anEntry));
568 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
570 SALOMEDS::Locker lock;
572 SALOMEDSImpl_AttributeIOR* Att = NULL;
573 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
574 char* IOR = CORBA::string_dup(Att->Value().c_str());
575 CORBA::Object_var obj = orb->string_to_object(IOR);
576 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
577 ASSERT(!CORBA::is_nil(aStudy));
578 return SALOMEDS::Study::_duplicate(aStudy);
580 MESSAGE("GetStudy: Problem to get study");
582 return SALOMEDS::Study::_nil();
585 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
587 SALOMEDS::Locker lock;
588 SALOMEDSImpl_Study::IORUpdated(theAttribute);
591 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
593 SALOMEDS::Locker lock;
595 SALOMEDS::GenericAttribute_ptr aTarget;
596 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
597 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
599 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
605 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
607 SALOMEDS::Locker lock;
609 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
610 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
611 return SP->AttributeStudyProperties::_this();
614 char* SALOMEDS_Study_i::GetLastModificationDate()
616 SALOMEDS::Locker lock;
617 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
620 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
622 SALOMEDS::Locker lock;
624 vector<string> aSeq = _impl->GetModificationsDate();
625 int aLength = aSeq.size();
626 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
627 aDates->length(aLength);
629 for(int anIndex = 0; anIndex < aLength; anIndex++) {
630 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
632 return aDates._retn();
637 //============================================================================
638 /*! Function : GetUseCaseBuilder
639 * Purpose : Returns a UseCase builder
641 //============================================================================
642 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
644 SALOMEDS::Locker lock;
645 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
646 return UCBuilder->_this();
650 //============================================================================
654 //============================================================================
655 void SALOMEDS_Study_i::Close()
657 SALOMEDS::Locker lock;
661 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
662 for (; itcomponent->More(); itcomponent->Next()) {
663 SALOMEDS::SComponent_var sco = itcomponent->Value();
664 MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType());
665 // if there is an associated Engine call its method for closing
666 CORBA::String_var IOREngine;
667 if (sco->ComponentIOR(IOREngine)) {
668 // we have found the associated engine to write the data
669 MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType());
670 //_narrow can throw a corba exception
673 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
674 if (!CORBA::is_nil(obj))
676 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
677 if (!anEngine->_is_nil())
680 anEngine->Close(sco);
685 catch (CORBA::Exception&)
693 //============================================================================
694 /*! Function : AddPostponed
697 //============================================================================
698 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
700 SALOMEDS::Locker lock;
704 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
706 SALOMEDS::Locker lock;
710 //============================================================================
711 /*! Function : RemovePostponed
714 //============================================================================
716 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/)
718 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
721 SALOMEDS::Locker lock;
723 vector<string> anIORs = _impl->GetIORs();
724 int i, aSize = (int)anIORs.size();
726 for(i = 0; i < aSize; i++) {
728 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
729 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
730 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
737 //============================================================================
738 /*! Function : UndoPostponed
741 //============================================================================
743 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
745 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
748 SALOMEDS::Locker lock;
753 //============================================================================
754 /*! Function : DumpStudy
757 //============================================================================
758 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
759 const char* theBaseName,
760 CORBA::Boolean isPublished)
762 SALOMEDS::Locker lock;
764 string aPath((char*)thePath), aBaseName((char*)theBaseName);
765 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
766 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
771 //============================================================================
772 /*! Function : GetCommonParameters
775 //============================================================================
776 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
778 SALOMEDS::Locker lock;
780 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
781 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
782 return SP->AttributeParameter::_this();
785 //============================================================================
786 /*! Function : GetCommonModuleParameters
789 //============================================================================
790 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
791 const char* theModuleName,
792 CORBA::Long theSavePoint)
794 SALOMEDS::Locker lock;
796 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
797 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
798 return SP->AttributeParameter::_this();
801 //============================================================================
802 /*! Function : SetStudyLock
805 //============================================================================
806 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
808 SALOMEDS::Locker lock;
809 _impl->SetStudyLock(theLockerID);
812 //============================================================================
813 /*! Function : IsStudyLocked
816 //============================================================================
817 bool SALOMEDS_Study_i::IsStudyLocked()
819 SALOMEDS::Locker lock;
820 return _impl->IsStudyLocked();
823 //============================================================================
824 /*! Function : UnLockStudy
827 //============================================================================
828 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
830 SALOMEDS::Locker lock;
831 _impl->UnLockStudy(theLockerID);
834 //============================================================================
835 /*! Function : GetLockerID
838 //============================================================================
839 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
841 SALOMEDS::Locker lock;
843 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
845 vector<string> aSeq = _impl->GetLockerID();
847 int aLength = aSeq.size();
848 aResult->length(aLength);
849 for(int anIndex = 0; anIndex < aLength; anIndex++) {
850 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
852 return aResult._retn();
854 //============================================================================
855 /*! Function : SetReal
858 //============================================================================
859 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
861 _impl->SetVariable(string(theVarName),
863 SALOMEDSImpl_GenericVariable::REAL_VAR);
866 //============================================================================
867 /*! Function : SetInteger
870 //============================================================================
871 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
873 _impl->SetVariable(string(theVarName),
875 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
878 //============================================================================
879 /*! Function : SetBoolean
882 //============================================================================
883 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
885 _impl->SetVariable(string(theVarName),
887 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
890 //============================================================================
891 /*! Function : GetReal
894 //============================================================================
895 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
897 return _impl->GetVariableValue(string(theVarName));
900 //============================================================================
901 /*! Function : GetInteger
904 //============================================================================
905 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
907 return (int)_impl->GetVariableValue(string(theVarName));
910 //============================================================================
911 /*! Function : GetBoolean
914 //============================================================================
915 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
917 return (bool)_impl->GetVariableValue(string(theVarName));
920 //============================================================================
921 /*! Function : IsReal
924 //============================================================================
925 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
927 return _impl->IsTypeOf(string(theVarName),
928 SALOMEDSImpl_GenericVariable::REAL_VAR);
931 //============================================================================
932 /*! Function : IsInteger
935 //============================================================================
936 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
938 return _impl->IsTypeOf(string(theVarName),
939 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
942 //============================================================================
943 /*! Function : IsBoolean
946 //============================================================================
947 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
949 return _impl->IsTypeOf(string(theVarName),
950 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
953 //============================================================================
954 /*! Function : IsVariable
957 //============================================================================
958 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
960 return _impl->IsVariable(string(theVarName));
963 //============================================================================
964 /*! Function : GetVariableNames
967 //============================================================================
968 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
970 vector<string> aVarNames = _impl->GetVariableNames();
971 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
973 int aLen = aVarNames.size();
974 aResult->length(aLen);
976 for (int anInd = 0; anInd < aLen; anInd++)
977 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
979 return aResult._retn();
982 //============================================================================
983 /*! Function : RemoveVariable
986 //============================================================================
987 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
989 return _impl->RemoveVariable(string(theVarName));
992 //============================================================================
993 /*! Function : RenameVariable
996 //============================================================================
997 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
999 return _impl->RenameVariable(string(theVarName), string(theNewVarName));
1002 //============================================================================
1003 /*! Function : IsVariableUsed
1006 //============================================================================
1007 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1009 return _impl->IsVariableUsed(string(theVarName));
1013 //============================================================================
1014 /*! Function : ParseVariables
1017 //============================================================================
1018 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1020 vector< vector<string> > aSections = _impl->ParseVariables(string(theVarName));
1022 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1024 int aSectionsLen = aSections.size();
1025 aResult->length(aSectionsLen);
1027 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1028 vector<string> aVarNames = aSections[aSectionInd];
1030 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1032 int aLen = aVarNames.size();
1033 aList->length(aLen);
1035 for (int anInd = 0; anInd < aLen; anInd++)
1036 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1038 aResult[aSectionInd] = aList;
1041 return aResult._retn();
1044 //============================================================================
1045 /*! Function : GetDefaultScript
1048 //============================================================================
1049 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1051 SALOMEDS::Locker lock;
1053 string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1054 return CORBA::string_dup(script.c_str());
1057 //============================================================================
1058 /*! Function : EnableUseCaseAutoFilling
1061 //============================================================================
1062 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1064 _impl->EnableUseCaseAutoFilling(isEnabled);
1065 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1068 builder->SetOnAddSObject(_impl->GetCallback());
1069 builder->SetOnRemoveSObject(_impl->GetCallback());
1072 builder->SetOnAddSObject(NULL);
1073 builder->SetOnRemoveSObject(NULL);
1078 //===========================================================================
1079 // PRIVATE FUNCTIONS
1080 //===========================================================================
1081 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1084 long pid = (long)_getpid();
1086 long pid = (long)getpid();
1088 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1089 return reinterpret_cast<CORBA::LongLong>(_impl);