1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_Study_i.cxx
21 // Author : Sergey RUIN
25 #include "utilities.h"
26 #include "SALOMEDS_Study_i.hxx"
27 #include "SALOMEDS_UseCaseIterator_i.hxx"
28 #include "SALOMEDS_GenericAttribute_i.hxx"
29 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
30 #include "SALOMEDS_AttributeParameter_i.hxx"
31 #include "SALOMEDS_ChildIterator_i.hxx"
32 #include "SALOMEDS_Driver_i.hxx"
33 #include "SALOMEDS.hxx"
35 #include "SALOMEDSImpl_SObject.hxx"
36 #include "SALOMEDSImpl_SComponent.hxx"
37 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
38 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
39 #include "SALOMEDSImpl_AttributeParameter.hxx"
40 #include "SALOMEDSImpl_ChildIterator.hxx"
41 #include "SALOMEDSImpl_IParameters.hxx"
43 #include "DF_Label.hxx"
44 #include "DF_Attribute.hxx"
49 #include <sys/types.h>
57 //============================================================================
58 /*! Function : SALOMEDS_Study_i
59 * Purpose : SALOMEDS_Study_i constructor
61 //============================================================================
62 SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDSImpl_Study* theImpl,
65 _orb = CORBA::ORB::_duplicate(orb);
68 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
71 //============================================================================
72 /*! Function : ~SALOMEDS_Study_i
73 * Purpose : SALOMEDS_Study_i destructor
75 //============================================================================
76 SALOMEDS_Study_i::~SALOMEDS_Study_i()
80 //============================================================================
81 /*! Function : GetPersistentReference
82 * Purpose : Get persistent reference of study (idem URL())
84 //============================================================================
85 char* SALOMEDS_Study_i::GetPersistentReference()
87 SALOMEDS::Locker lock;
88 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
90 //============================================================================
91 /*! Function : GetTransientReference
92 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
94 //============================================================================
95 char* SALOMEDS_Study_i::GetTransientReference()
97 SALOMEDS::Locker lock;
98 return CORBA::string_dup(_impl->GetTransientReference().c_str());
101 //============================================================================
102 /*! Function : IsEmpty
103 * Purpose : Detect if study is empty
105 //============================================================================
106 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
108 SALOMEDS::Locker lock;
109 return _impl->IsEmpty();
112 //============================================================================
113 /*! Function : FindComponent
114 * Purpose : Find a Component with ComponentDataType = aComponentName
116 //============================================================================
117 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
119 SALOMEDS::Locker lock;
121 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(string(aComponentName));
122 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
124 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
128 //============================================================================
129 /*! Function : FindComponentID
130 * Purpose : Find a Component from it's ID
132 //============================================================================
133 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
135 SALOMEDS::Locker lock;
137 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(string((char*)aComponentID));
138 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
140 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
144 //============================================================================
145 /*! Function : FindObject
146 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
148 //============================================================================
149 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
151 SALOMEDS::Locker lock;
153 SALOMEDSImpl_SObject aSO = _impl->FindObject(string((char*)anObjectName));
154 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
156 if(aSO.IsComponent()) {
157 SALOMEDSImpl_SComponent aSCO = aSO;
158 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
162 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
167 //============================================================================
168 /*! Function : FindObjectID
169 * Purpose : Find an Object with ID = anObjectID
171 //============================================================================
172 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
174 SALOMEDS::Locker lock;
176 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(string((char*)anObjectID));
177 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
178 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
182 //============================================================================
183 /*! Function : CreateObjectID
184 * Purpose : Creates an Object with ID = anObjectID
186 //============================================================================
187 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
189 SALOMEDS::Locker lock;
191 if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
193 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
194 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
196 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
200 //============================================================================
201 /*! Function : FindObjectByName
202 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
203 * : with ComponentDataType = aComponentName
205 //============================================================================
206 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
207 const char* aComponentName )
209 SALOMEDS::Locker lock;
211 vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(string((char*)anObjectName),
212 string((char*)aComponentName));
213 int aLength = aSeq.size();
214 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
215 listSO->length(aLength);
216 for(int i = 0; i<aLength; i++) {
217 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSeq[i], _orb);
220 return listSO._retn() ;
223 //============================================================================
224 /*! Function : FindObjectIOR
225 * Purpose : Find an Object with IOR = anObjectIOR
227 //============================================================================
228 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
230 SALOMEDS::Locker lock;
232 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(string((char*)anObjectIOR));
233 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
235 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
239 //============================================================================
240 /*! Function : FindObjectByPath
241 * Purpose : Find an Object by its path = thePath
243 //============================================================================
244 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
246 SALOMEDS::Locker lock;
248 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(string((char*)thePath));
249 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
251 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
255 //============================================================================
256 /*! Function : GetObjectPath
259 //============================================================================
260 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
262 SALOMEDS::Locker lock;
265 if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.c_str());
266 SALOMEDSImpl_SObject aSO;
267 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
269 if(!CORBA::is_nil(aSObj)) {
270 aSO = _impl->FindObjectID(aSObj->GetID());
273 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
276 if(aSO.IsNull()) return CORBA::string_dup(aPath.c_str());
278 aPath = _impl->GetObjectPath(aSO);
279 return CORBA::string_dup(aPath.c_str());
283 //============================================================================
284 /*! Function : SetContext
285 * Purpose : Sets the current context
287 //============================================================================
288 void SALOMEDS_Study_i::SetContext(const char* thePath)
290 SALOMEDS::Locker lock;
292 _impl->SetContext(string((char*)thePath));
293 if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
294 throw SALOMEDS::Study::StudyInvalidContext();
297 //============================================================================
298 /*! Function : GetContext
299 * Purpose : Gets the current context
301 //============================================================================
302 char* SALOMEDS_Study_i::GetContext()
304 SALOMEDS::Locker lock;
306 if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
307 return CORBA::string_dup(_impl->GetContext().c_str());
310 //============================================================================
311 /*! Function : GetObjectNames
312 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
314 //============================================================================
315 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
317 SALOMEDS::Locker lock;
319 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
321 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
322 throw SALOMEDS::Study::StudyInvalidContext();
324 vector<string> aSeq = _impl->GetObjectNames(string((char*)theContext));
325 if (_impl->GetErrorCode() == "InvalidContext")
326 throw SALOMEDS::Study::StudyInvalidContext();
328 int aLength = aSeq.size();
329 aResult->length(aLength);
330 for (int anIndex = 0; anIndex < aLength; anIndex++) {
331 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
334 return aResult._retn();
337 //============================================================================
338 /*! Function : GetDirectoryNames
339 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
341 //============================================================================
342 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
344 SALOMEDS::Locker lock;
346 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
348 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
349 throw SALOMEDS::Study::StudyInvalidContext();
351 vector<string> aSeq = _impl->GetDirectoryNames(string((char*)theContext));
352 if (_impl->GetErrorCode() == "InvalidContext")
353 throw SALOMEDS::Study::StudyInvalidContext();
355 int aLength = aSeq.size();
356 aResult->length(aLength);
357 for (int anIndex = 0; anIndex < aLength; anIndex++) {
358 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
361 return aResult._retn();
364 //============================================================================
365 /*! Function : GetFileNames
366 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
368 //============================================================================
369 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
371 SALOMEDS::Locker lock;
373 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
375 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
376 throw SALOMEDS::Study::StudyInvalidContext();
378 vector<string> aSeq = _impl->GetFileNames(string((char*)theContext));
379 if (_impl->GetErrorCode() == "InvalidContext")
380 throw SALOMEDS::Study::StudyInvalidContext();
382 int aLength = aSeq.size();
383 aResult->length(aLength);
384 for (int anIndex = 0; anIndex < aLength; anIndex++) {
385 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
388 return aResult._retn();
391 //============================================================================
392 /*! Function : GetComponentNames
393 * Purpose : method to get all components names
394 * SRN: Note, theContext can be any, it doesn't matter
396 //============================================================================
397 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
399 SALOMEDS::Locker lock;
401 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
403 vector<string> aSeq = _impl->GetComponentNames(string((char*)theContext));
405 int aLength = aSeq.size();
406 aResult->length(aLength);
407 for(int anIndex = 0; anIndex < aLength; anIndex++) {
408 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
411 return aResult._retn();
414 //============================================================================
415 /*! Function : NewChildIterator
416 * Purpose : Create a ChildIterator from an SObject
418 //============================================================================
419 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
421 SALOMEDS::Locker lock;
423 SALOMEDSImpl_SObject aSO = _impl->GetSObject(theSO->GetID());
424 SALOMEDSImpl_ChildIterator anItr(aSO);
427 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
428 SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this());
434 //============================================================================
435 /*! Function : NewComponentIterator
436 * Purpose : Create a SComponentIterator
438 //============================================================================
439 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
441 SALOMEDS::Locker lock;
442 SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
448 //============================================================================
449 /*! Function : NewBuilder
450 * Purpose : Create a StudyBuilder
452 //============================================================================
453 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
455 SALOMEDS::Locker lock;
456 return _builder->_this();
459 //============================================================================
461 * Purpose : get study name
463 //============================================================================
464 char* SALOMEDS_Study_i::Name()
466 SALOMEDS::Locker lock;
467 return CORBA::string_dup(_impl->Name().c_str());
470 //============================================================================
472 * Purpose : set study name
474 //============================================================================
475 void SALOMEDS_Study_i::Name(const char* name)
477 SALOMEDS::Locker lock;
478 _impl->Name(string((char*)name));
481 //============================================================================
482 /*! Function : IsSaved
483 * Purpose : get if study has been saved
485 //============================================================================
486 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
488 SALOMEDS::Locker lock;
489 return _impl->IsSaved();
492 //============================================================================
493 /*! Function : IsSaved
494 * Purpose : set if study has been saved
496 //============================================================================
497 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
499 SALOMEDS::Locker lock;
500 _impl->IsSaved(save);
503 //============================================================================
504 /*! Function : IsModified
505 * Purpose : Detect if a Study has been modified since it has been saved
507 //============================================================================
508 CORBA::Boolean SALOMEDS_Study_i::IsModified()
510 SALOMEDS::Locker lock;
511 return _impl->IsModified();
514 //============================================================================
515 /*! Function : Modified
516 * Purpose : Sets a Modified flag of a Study to True
518 //============================================================================
519 void SALOMEDS_Study_i::Modified()
521 SALOMEDS::Locker lock;
522 return _impl->Modify();
526 //============================================================================
528 * Purpose : get URL of the study (persistent reference of the study)
530 //============================================================================
531 char* SALOMEDS_Study_i::URL()
533 SALOMEDS::Locker lock;
534 return CORBA::string_dup(_impl->URL().c_str());
537 //============================================================================
539 * Purpose : set URL of the study (persistent reference of the study)
541 //============================================================================
542 void SALOMEDS_Study_i::URL(const char* url)
544 SALOMEDS::Locker lock;
545 _impl->URL(string((char*)url));
549 CORBA::Short SALOMEDS_Study_i::StudyId()
551 SALOMEDS::Locker lock;
552 return _impl->StudyId();
555 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
557 SALOMEDS::Locker lock;
561 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
563 SALOMEDS::Locker lock;
564 _impl->UpdateIORLabelMap(string((char*)anIOR), string((char*)anEntry));
567 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
569 SALOMEDS::Locker lock;
571 SALOMEDSImpl_AttributeIOR* Att = NULL;
572 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
573 char* IOR = CORBA::string_dup(Att->Value().c_str());
574 CORBA::Object_var obj = orb->string_to_object(IOR);
575 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
576 ASSERT(!CORBA::is_nil(aStudy));
577 return SALOMEDS::Study::_duplicate(aStudy);
579 MESSAGE("GetStudy: Problem to get study");
581 return SALOMEDS::Study::_nil();
584 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
586 SALOMEDS::Locker lock;
587 SALOMEDSImpl_Study::IORUpdated(theAttribute);
590 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
592 SALOMEDS::Locker lock;
594 SALOMEDS::GenericAttribute_ptr aTarget;
595 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
596 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
598 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
604 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
606 SALOMEDS::Locker lock;
608 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
609 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
610 return SP->AttributeStudyProperties::_this();
613 char* SALOMEDS_Study_i::GetLastModificationDate()
615 SALOMEDS::Locker lock;
616 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
619 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
621 SALOMEDS::Locker lock;
623 vector<string> aSeq = _impl->GetModificationsDate();
624 int aLength = aSeq.size();
625 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
626 aDates->length(aLength);
628 for(int anIndex = 0; anIndex < aLength; anIndex++) {
629 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
631 return aDates._retn();
636 //============================================================================
637 /*! Function : GetUseCaseBuilder
638 * Purpose : Returns a UseCase builder
640 //============================================================================
641 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
643 SALOMEDS::Locker lock;
644 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
645 return UCBuilder->_this();
649 //============================================================================
653 //============================================================================
654 void SALOMEDS_Study_i::Close()
656 SALOMEDS::Locker lock;
660 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
661 for (; itcomponent->More(); itcomponent->Next()) {
662 SALOMEDS::SComponent_var sco = itcomponent->Value();
663 MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType());
664 // if there is an associated Engine call its method for closing
665 CORBA::String_var IOREngine;
666 if (sco->ComponentIOR(IOREngine)) {
667 // we have found the associated engine to write the data
668 MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType());
669 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
670 if (!CORBA::is_nil(obj)) {
671 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
673 if (!anEngine->_is_nil()) {
675 anEngine->Close(sco);
685 //============================================================================
686 /*! Function : AddPostponed
689 //============================================================================
690 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
692 SALOMEDS::Locker lock;
696 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
698 SALOMEDS::Locker lock;
702 //============================================================================
703 /*! Function : RemovePostponed
706 //============================================================================
708 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/)
710 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
713 SALOMEDS::Locker lock;
715 vector<string> anIORs = _impl->GetIORs();
716 int i, aSize = (int)anIORs.size();
718 for(i = 0; i < aSize; i++) {
720 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
721 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
722 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
729 //============================================================================
730 /*! Function : UndoPostponed
733 //============================================================================
735 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
737 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
740 SALOMEDS::Locker lock;
745 //============================================================================
746 /*! Function : DumpStudy
749 //============================================================================
750 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
751 const char* theBaseName,
752 CORBA::Boolean isPublished)
754 SALOMEDS::Locker lock;
756 string aPath((char*)thePath), aBaseName((char*)theBaseName);
757 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
758 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
763 //============================================================================
764 /*! Function : GetCommonParameters
767 //============================================================================
768 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
770 SALOMEDS::Locker lock;
772 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
773 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
774 return SP->AttributeParameter::_this();
777 //============================================================================
778 /*! Function : GetCommonModuleParameters
781 //============================================================================
782 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
783 const char* theModuleName,
784 CORBA::Long theSavePoint)
786 SALOMEDS::Locker lock;
788 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
789 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
790 return SP->AttributeParameter::_this();
793 //============================================================================
794 /*! Function : SetStudyLock
797 //============================================================================
798 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
800 SALOMEDS::Locker lock;
801 _impl->SetStudyLock(theLockerID);
804 //============================================================================
805 /*! Function : IsStudyLocked
808 //============================================================================
809 bool SALOMEDS_Study_i::IsStudyLocked()
811 SALOMEDS::Locker lock;
812 return _impl->IsStudyLocked();
815 //============================================================================
816 /*! Function : UnLockStudy
819 //============================================================================
820 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
822 SALOMEDS::Locker lock;
823 _impl->UnLockStudy(theLockerID);
826 //============================================================================
827 /*! Function : GetLockerID
830 //============================================================================
831 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
833 SALOMEDS::Locker lock;
835 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
837 vector<string> aSeq = _impl->GetLockerID();
839 int aLength = aSeq.size();
840 aResult->length(aLength);
841 for(int anIndex = 0; anIndex < aLength; anIndex++) {
842 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
844 return aResult._retn();
847 //============================================================================
848 /*! Function : GetDefaultScript
851 //============================================================================
852 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
854 SALOMEDS::Locker lock;
856 string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
857 return CORBA::string_dup(script.c_str());
860 //============================================================================
861 /*! Function : EnableUseCaseAutoFilling
864 //============================================================================
865 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
867 _impl->EnableUseCaseAutoFilling(isEnabled);
868 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
871 builder->SetOnAddSObject(_impl->GetCallback());
872 builder->SetOnRemoveSObject(_impl->GetCallback());
875 builder->SetOnAddSObject(NULL);
876 builder->SetOnRemoveSObject(NULL);
881 //===========================================================================
883 //===========================================================================
884 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
887 long pid = (long)_getpid();
889 long pid = (long)getpid();
891 isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
892 return ((CORBA::LongLong)_impl);