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 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
671 if (!CORBA::is_nil(obj)) {
672 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
674 if (!anEngine->_is_nil()) {
676 anEngine->Close(sco);
686 //============================================================================
687 /*! Function : AddPostponed
690 //============================================================================
691 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
693 SALOMEDS::Locker lock;
697 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
699 SALOMEDS::Locker lock;
703 //============================================================================
704 /*! Function : RemovePostponed
707 //============================================================================
709 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/)
711 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
714 SALOMEDS::Locker lock;
716 vector<string> anIORs = _impl->GetIORs();
717 int i, aSize = (int)anIORs.size();
719 for(i = 0; i < aSize; i++) {
721 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
722 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
723 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
730 //============================================================================
731 /*! Function : UndoPostponed
734 //============================================================================
736 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
738 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
741 SALOMEDS::Locker lock;
746 //============================================================================
747 /*! Function : DumpStudy
750 //============================================================================
751 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
752 const char* theBaseName,
753 CORBA::Boolean isPublished)
755 SALOMEDS::Locker lock;
757 string aPath((char*)thePath), aBaseName((char*)theBaseName);
758 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
759 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
764 //============================================================================
765 /*! Function : GetCommonParameters
768 //============================================================================
769 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
771 SALOMEDS::Locker lock;
773 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
774 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
775 return SP->AttributeParameter::_this();
778 //============================================================================
779 /*! Function : GetCommonModuleParameters
782 //============================================================================
783 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
784 const char* theModuleName,
785 CORBA::Long theSavePoint)
787 SALOMEDS::Locker lock;
789 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
790 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
791 return SP->AttributeParameter::_this();
794 //============================================================================
795 /*! Function : SetStudyLock
798 //============================================================================
799 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
801 SALOMEDS::Locker lock;
802 _impl->SetStudyLock(theLockerID);
805 //============================================================================
806 /*! Function : IsStudyLocked
809 //============================================================================
810 bool SALOMEDS_Study_i::IsStudyLocked()
812 SALOMEDS::Locker lock;
813 return _impl->IsStudyLocked();
816 //============================================================================
817 /*! Function : UnLockStudy
820 //============================================================================
821 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
823 SALOMEDS::Locker lock;
824 _impl->UnLockStudy(theLockerID);
827 //============================================================================
828 /*! Function : GetLockerID
831 //============================================================================
832 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
834 SALOMEDS::Locker lock;
836 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
838 vector<string> aSeq = _impl->GetLockerID();
840 int aLength = aSeq.size();
841 aResult->length(aLength);
842 for(int anIndex = 0; anIndex < aLength; anIndex++) {
843 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
845 return aResult._retn();
847 //============================================================================
848 /*! Function : SetReal
851 //============================================================================
852 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
854 _impl->SetVariable(string(theVarName),
856 SALOMEDSImpl_GenericVariable::REAL_VAR);
859 //============================================================================
860 /*! Function : SetInteger
863 //============================================================================
864 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
866 _impl->SetVariable(string(theVarName),
868 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
871 //============================================================================
872 /*! Function : SetBoolean
875 //============================================================================
876 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
878 _impl->SetVariable(string(theVarName),
880 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
883 //============================================================================
884 /*! Function : GetReal
887 //============================================================================
888 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
890 return _impl->GetVariableValue(string(theVarName));
893 //============================================================================
894 /*! Function : GetInteger
897 //============================================================================
898 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
900 return (int)_impl->GetVariableValue(string(theVarName));
903 //============================================================================
904 /*! Function : GetBoolean
907 //============================================================================
908 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
910 return (bool)_impl->GetVariableValue(string(theVarName));
913 //============================================================================
914 /*! Function : IsReal
917 //============================================================================
918 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
920 return _impl->IsTypeOf(string(theVarName),
921 SALOMEDSImpl_GenericVariable::REAL_VAR);
924 //============================================================================
925 /*! Function : IsInteger
928 //============================================================================
929 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
931 return _impl->IsTypeOf(string(theVarName),
932 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
935 //============================================================================
936 /*! Function : IsBoolean
939 //============================================================================
940 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
942 return _impl->IsTypeOf(string(theVarName),
943 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
946 //============================================================================
947 /*! Function : IsVariable
950 //============================================================================
951 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
953 return _impl->IsVariable(string(theVarName));
956 //============================================================================
957 /*! Function : GetVariableNames
960 //============================================================================
961 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
963 vector<string> aVarNames = _impl->GetVariableNames();
964 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
966 int aLen = aVarNames.size();
967 aResult->length(aLen);
969 for (int anInd = 0; anInd < aLen; anInd++)
970 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
972 return aResult._retn();
975 //============================================================================
976 /*! Function : RemoveVariable
979 //============================================================================
980 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
982 return _impl->RemoveVariable(string(theVarName));
985 //============================================================================
986 /*! Function : RenameVariable
989 //============================================================================
990 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
992 return _impl->RenameVariable(string(theVarName), string(theNewVarName));
995 //============================================================================
996 /*! Function : IsVariableUsed
999 //============================================================================
1000 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1002 return _impl->IsVariableUsed(string(theVarName));
1006 //============================================================================
1007 /*! Function : ParseVariables
1010 //============================================================================
1011 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1013 vector< vector<string> > aSections = _impl->ParseVariables(string(theVarName));
1015 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1017 int aSectionsLen = aSections.size();
1018 aResult->length(aSectionsLen);
1020 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1021 vector<string> aVarNames = aSections[aSectionInd];
1023 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1025 int aLen = aVarNames.size();
1026 aList->length(aLen);
1028 for (int anInd = 0; anInd < aLen; anInd++)
1029 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1031 aResult[aSectionInd] = aList;
1034 return aResult._retn();
1037 //============================================================================
1038 /*! Function : GetDefaultScript
1041 //============================================================================
1042 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1044 SALOMEDS::Locker lock;
1046 string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1047 return CORBA::string_dup(script.c_str());
1050 //============================================================================
1051 /*! Function : EnableUseCaseAutoFilling
1054 //============================================================================
1055 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1057 _impl->EnableUseCaseAutoFilling(isEnabled);
1058 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1061 builder->SetOnAddSObject(_impl->GetCallback());
1062 builder->SetOnRemoveSObject(_impl->GetCallback());
1065 builder->SetOnAddSObject(NULL);
1066 builder->SetOnRemoveSObject(NULL);
1071 //===========================================================================
1072 // PRIVATE FUNCTIONS
1073 //===========================================================================
1074 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1077 long pid = (long)_getpid();
1079 long pid = (long)getpid();
1081 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1082 return reinterpret_cast<CORBA::LongLong>(_impl);