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_StudyManager_i.hxx"
29 #include "SALOMEDS_UseCaseIterator_i.hxx"
30 #include "SALOMEDS_GenericAttribute_i.hxx"
31 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
32 #include "SALOMEDS_AttributeParameter_i.hxx"
33 #include "SALOMEDS_ChildIterator_i.hxx"
34 #include "SALOMEDS_Driver_i.hxx"
35 #include "SALOMEDS_StudyBuilder.hxx"
36 #include "SALOMEDS.hxx"
38 #include "SALOMEDSImpl_SObject.hxx"
39 #include "SALOMEDSImpl_SComponent.hxx"
40 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
42 #include "SALOMEDSImpl_AttributeParameter.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_IParameters.hxx"
46 #include "DF_Label.hxx"
47 #include "DF_Attribute.hxx"
49 #include "Basics_Utils.hxx"
54 #include <sys/types.h>
60 std::map<SALOMEDSImpl_Study* , SALOMEDS_Study_i*> SALOMEDS_Study_i::_mapOfStudies;
62 //============================================================================
63 /*! Function : SALOMEDS_Study_i
64 * Purpose : SALOMEDS_Study_i constructor
66 //============================================================================
67 SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDSImpl_Study* theImpl,
70 _orb = CORBA::ORB::_duplicate(orb);
73 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
76 //============================================================================
77 /*! Function : ~SALOMEDS_Study_i
78 * Purpose : SALOMEDS_Study_i destructor
80 //============================================================================
81 SALOMEDS_Study_i::~SALOMEDS_Study_i()
83 //delete the builder servant
84 PortableServer::POA_var poa=_builder->_default_POA();
85 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
86 poa->deactivate_object(anObjectId.in());
87 _builder->_remove_ref();
89 //delete implementation
91 _mapOfStudies.erase(_impl);
94 //============================================================================
95 /*! Function : GetPersistentReference
96 * Purpose : Get persistent reference of study (idem URL())
98 //============================================================================
99 char* SALOMEDS_Study_i::GetPersistentReference()
101 SALOMEDS::Locker lock;
102 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
104 //============================================================================
105 /*! Function : GetTransientReference
106 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
108 //============================================================================
109 char* SALOMEDS_Study_i::GetTransientReference()
111 SALOMEDS::Locker lock;
112 return CORBA::string_dup(_impl->GetTransientReference().c_str());
115 //============================================================================
116 /*! Function : IsEmpty
117 * Purpose : Detect if study is empty
119 //============================================================================
120 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
122 SALOMEDS::Locker lock;
123 return _impl->IsEmpty();
126 //============================================================================
127 /*! Function : FindComponent
128 * Purpose : Find a Component with ComponentDataType = aComponentName
130 //============================================================================
131 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
133 SALOMEDS::Locker lock;
135 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(string(aComponentName));
136 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
138 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
142 //============================================================================
143 /*! Function : FindComponentID
144 * Purpose : Find a Component from it's ID
146 //============================================================================
147 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
149 SALOMEDS::Locker lock;
151 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(string((char*)aComponentID));
152 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
154 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
158 //============================================================================
159 /*! Function : FindObject
160 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
162 //============================================================================
163 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
165 SALOMEDS::Locker lock;
167 SALOMEDSImpl_SObject aSO = _impl->FindObject(string((char*)anObjectName));
168 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
170 if(aSO.IsComponent()) {
171 SALOMEDSImpl_SComponent aSCO = aSO;
172 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
176 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
181 //============================================================================
182 /*! Function : FindObjectID
183 * Purpose : Find an Object with ID = anObjectID
185 //============================================================================
186 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
188 SALOMEDS::Locker lock;
190 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(string((char*)anObjectID));
191 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
192 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
196 //============================================================================
197 /*! Function : CreateObjectID
198 * Purpose : Creates an Object with ID = anObjectID
200 //============================================================================
201 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
203 SALOMEDS::Locker lock;
205 if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
207 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
208 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
210 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
214 //============================================================================
215 /*! Function : FindObjectByName
216 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
217 * : with ComponentDataType = aComponentName
219 //============================================================================
220 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
221 const char* aComponentName )
223 SALOMEDS::Locker lock;
225 vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(string((char*)anObjectName),
226 string((char*)aComponentName));
227 int aLength = aSeq.size();
228 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
229 listSO->length(aLength);
230 for(int i = 0; i<aLength; i++) {
231 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSeq[i], _orb);
234 return listSO._retn() ;
237 //============================================================================
238 /*! Function : FindObjectIOR
239 * Purpose : Find an Object with IOR = anObjectIOR
241 //============================================================================
242 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
244 SALOMEDS::Locker lock;
246 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(string((char*)anObjectIOR));
247 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
249 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
253 //============================================================================
254 /*! Function : FindObjectByPath
255 * Purpose : Find an Object by its path = thePath
257 //============================================================================
258 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
260 SALOMEDS::Locker lock;
262 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(string((char*)thePath));
263 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
265 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
269 //============================================================================
270 /*! Function : GetObjectPath
273 //============================================================================
274 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
276 SALOMEDS::Locker lock;
279 if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.c_str());
280 SALOMEDSImpl_SObject aSO;
281 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
283 if(!CORBA::is_nil(aSObj)) {
284 aSO = _impl->FindObjectID(aSObj->GetID());
287 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
290 if(aSO.IsNull()) return CORBA::string_dup(aPath.c_str());
292 aPath = _impl->GetObjectPath(aSO);
293 return CORBA::string_dup(aPath.c_str());
297 //============================================================================
298 /*! Function : SetContext
299 * Purpose : Sets the current context
301 //============================================================================
302 void SALOMEDS_Study_i::SetContext(const char* thePath)
304 SALOMEDS::Locker lock;
306 _impl->SetContext(string((char*)thePath));
307 if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
308 throw SALOMEDS::Study::StudyInvalidContext();
311 //============================================================================
312 /*! Function : GetContext
313 * Purpose : Gets the current context
315 //============================================================================
316 char* SALOMEDS_Study_i::GetContext()
318 SALOMEDS::Locker lock;
320 if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
321 return CORBA::string_dup(_impl->GetContext().c_str());
324 //============================================================================
325 /*! Function : GetObjectNames
326 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
328 //============================================================================
329 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
331 SALOMEDS::Locker lock;
333 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
335 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
336 throw SALOMEDS::Study::StudyInvalidContext();
338 vector<string> aSeq = _impl->GetObjectNames(string((char*)theContext));
339 if (_impl->GetErrorCode() == "InvalidContext")
340 throw SALOMEDS::Study::StudyInvalidContext();
342 int aLength = aSeq.size();
343 aResult->length(aLength);
344 for (int anIndex = 0; anIndex < aLength; anIndex++) {
345 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
348 return aResult._retn();
351 //============================================================================
352 /*! Function : GetDirectoryNames
353 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
355 //============================================================================
356 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
358 SALOMEDS::Locker lock;
360 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
362 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
363 throw SALOMEDS::Study::StudyInvalidContext();
365 vector<string> aSeq = _impl->GetDirectoryNames(string((char*)theContext));
366 if (_impl->GetErrorCode() == "InvalidContext")
367 throw SALOMEDS::Study::StudyInvalidContext();
369 int aLength = aSeq.size();
370 aResult->length(aLength);
371 for (int anIndex = 0; anIndex < aLength; anIndex++) {
372 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
375 return aResult._retn();
378 //============================================================================
379 /*! Function : GetFileNames
380 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
382 //============================================================================
383 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
385 SALOMEDS::Locker lock;
387 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
389 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
390 throw SALOMEDS::Study::StudyInvalidContext();
392 vector<string> aSeq = _impl->GetFileNames(string((char*)theContext));
393 if (_impl->GetErrorCode() == "InvalidContext")
394 throw SALOMEDS::Study::StudyInvalidContext();
396 int aLength = aSeq.size();
397 aResult->length(aLength);
398 for (int anIndex = 0; anIndex < aLength; anIndex++) {
399 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
402 return aResult._retn();
405 //============================================================================
406 /*! Function : GetComponentNames
407 * Purpose : method to get all components names
408 * SRN: Note, theContext can be any, it doesn't matter
410 //============================================================================
411 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
413 SALOMEDS::Locker lock;
415 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
417 vector<string> aSeq = _impl->GetComponentNames(string((char*)theContext));
419 int aLength = aSeq.size();
420 aResult->length(aLength);
421 for(int anIndex = 0; anIndex < aLength; anIndex++) {
422 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
425 return aResult._retn();
428 //============================================================================
429 /*! Function : NewChildIterator
430 * Purpose : Create a ChildIterator from an SObject
432 //============================================================================
433 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
435 SALOMEDS::Locker lock;
437 CORBA::String_var anID=theSO->GetID();
438 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
439 SALOMEDSImpl_ChildIterator anItr(aSO);
442 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
444 return it_servant->_this();
448 //============================================================================
449 /*! Function : NewComponentIterator
450 * Purpose : Create a SComponentIterator
452 //============================================================================
453 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
455 SALOMEDS::Locker lock;
456 SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
462 //============================================================================
463 /*! Function : NewBuilder
464 * Purpose : Create a StudyBuilder
466 //============================================================================
467 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
469 SALOMEDS::Locker lock;
470 return _builder->_this();
473 //============================================================================
475 * Purpose : get study name
477 //============================================================================
478 char* SALOMEDS_Study_i::Name()
480 SALOMEDS::Locker lock;
481 return CORBA::string_dup(_impl->Name().c_str());
484 //============================================================================
486 * Purpose : set study name
488 //============================================================================
489 void SALOMEDS_Study_i::Name(const char* name)
491 SALOMEDS::Locker lock;
492 _impl->Name(string((char*)name));
495 //============================================================================
496 /*! Function : IsSaved
497 * Purpose : get if study has been saved
499 //============================================================================
500 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
502 SALOMEDS::Locker lock;
503 return _impl->IsSaved();
506 //============================================================================
507 /*! Function : IsSaved
508 * Purpose : set if study has been saved
510 //============================================================================
511 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
513 SALOMEDS::Locker lock;
514 _impl->IsSaved(save);
517 //============================================================================
518 /*! Function : IsModified
519 * Purpose : Detect if a Study has been modified since it has been saved
521 //============================================================================
522 CORBA::Boolean SALOMEDS_Study_i::IsModified()
524 SALOMEDS::Locker lock;
525 return _impl->IsModified();
528 //============================================================================
529 /*! Function : Modified
530 * Purpose : Sets a Modified flag of a Study to True
532 //============================================================================
533 void SALOMEDS_Study_i::Modified()
535 SALOMEDS::Locker lock;
536 return _impl->Modify();
540 //============================================================================
542 * Purpose : get URL of the study (persistent reference of the study)
544 //============================================================================
545 char* SALOMEDS_Study_i::URL()
547 SALOMEDS::Locker lock;
548 return CORBA::string_dup(_impl->URL().c_str());
551 //============================================================================
553 * Purpose : set URL of the study (persistent reference of the study)
555 //============================================================================
556 void SALOMEDS_Study_i::URL(const char* url)
558 SALOMEDS::Locker lock;
559 _impl->URL(string((char*)url));
563 CORBA::Short SALOMEDS_Study_i::StudyId()
565 SALOMEDS::Locker lock;
566 return _impl->StudyId();
569 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
571 SALOMEDS::Locker lock;
575 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
577 SALOMEDS::Locker lock;
578 _impl->UpdateIORLabelMap(string((char*)anIOR), string((char*)anEntry));
581 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
583 SALOMEDS::Locker lock;
585 SALOMEDSImpl_AttributeIOR* Att = NULL;
586 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
587 char* IOR = CORBA::string_dup(Att->Value().c_str());
588 CORBA::Object_var obj = orb->string_to_object(IOR);
589 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
590 ASSERT(!CORBA::is_nil(aStudy));
591 return SALOMEDS::Study::_duplicate(aStudy);
593 MESSAGE("GetStudy: Problem to get study");
595 return SALOMEDS::Study::_nil();
598 SALOMEDS_Study_i* SALOMEDS_Study_i::GetStudyServant(SALOMEDSImpl_Study* aStudyImpl, CORBA::ORB_ptr orb)
600 if (_mapOfStudies.find(aStudyImpl) != _mapOfStudies.end())
601 return _mapOfStudies[aStudyImpl];
604 SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, orb);
605 _mapOfStudies[aStudyImpl]=Study_servant;
606 return Study_servant;
610 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
612 SALOMEDS::Locker lock;
613 SALOMEDSImpl_Study::IORUpdated(theAttribute);
616 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
618 SALOMEDS::Locker lock;
620 SALOMEDS::GenericAttribute_ptr aTarget;
621 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
622 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
624 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
630 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
632 SALOMEDS::Locker lock;
634 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
635 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
636 return SP->AttributeStudyProperties::_this();
639 char* SALOMEDS_Study_i::GetLastModificationDate()
641 SALOMEDS::Locker lock;
642 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
645 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
647 SALOMEDS::Locker lock;
649 vector<string> aSeq = _impl->GetModificationsDate();
650 int aLength = aSeq.size();
651 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
652 aDates->length(aLength);
654 for(int anIndex = 0; anIndex < aLength; anIndex++) {
655 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
657 return aDates._retn();
662 //============================================================================
663 /*! Function : GetUseCaseBuilder
664 * Purpose : Returns a UseCase builder
666 //============================================================================
667 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
669 SALOMEDS::Locker lock;
670 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
671 return UCBuilder->_this();
675 //============================================================================
679 //============================================================================
680 void SALOMEDS_Study_i::Close()
682 SALOMEDS::Locker lock;
686 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
687 for (; itcomponent->More(); itcomponent->Next()) {
688 SALOMEDS::SComponent_var sco = itcomponent->Value();
689 CORBA::String_var compodatatype=sco->ComponentDataType();
690 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
691 // if there is an associated Engine call its method for closing
692 CORBA::String_var IOREngine;
693 if (sco->ComponentIOR(IOREngine)) {
694 // we have found the associated engine to write the data
695 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
696 //_narrow can throw a corba exception
699 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
700 if (!CORBA::is_nil(obj))
702 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
703 if (!anEngine->_is_nil())
706 anEngine->Close(sco);
711 catch (CORBA::Exception&)
717 //Does not need any more this iterator
718 itcomponent->Destroy();
724 //============================================================================
725 /*! Function : AddPostponed
728 //============================================================================
729 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
731 SALOMEDS::Locker lock;
735 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
737 SALOMEDS::Locker lock;
741 //============================================================================
742 /*! Function : RemovePostponed
745 //============================================================================
747 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/)
749 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
752 SALOMEDS::Locker lock;
754 vector<string> anIORs = _impl->GetIORs();
755 int i, aSize = (int)anIORs.size();
757 for(i = 0; i < aSize; i++) {
759 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
760 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
761 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
768 //============================================================================
769 /*! Function : UndoPostponed
772 //============================================================================
774 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
776 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
779 SALOMEDS::Locker lock;
784 //============================================================================
785 /*! Function : DumpStudy
788 //============================================================================
789 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
790 const char* theBaseName,
791 CORBA::Boolean isPublished)
793 SALOMEDS::Locker lock;
795 string aPath((char*)thePath), aBaseName((char*)theBaseName);
796 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
797 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
802 //============================================================================
803 /*! Function : GetCommonParameters
806 //============================================================================
807 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
809 SALOMEDS::Locker lock;
811 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
812 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
813 return SP->AttributeParameter::_this();
816 //============================================================================
817 /*! Function : GetCommonModuleParameters
820 //============================================================================
821 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
822 const char* theModuleName,
823 CORBA::Long theSavePoint)
825 SALOMEDS::Locker lock;
827 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
828 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
829 return SP->AttributeParameter::_this();
832 //============================================================================
833 /*! Function : SetStudyLock
836 //============================================================================
837 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
839 SALOMEDS::Locker lock;
840 _impl->SetStudyLock(theLockerID);
843 //============================================================================
844 /*! Function : IsStudyLocked
847 //============================================================================
848 bool SALOMEDS_Study_i::IsStudyLocked()
850 SALOMEDS::Locker lock;
851 return _impl->IsStudyLocked();
854 //============================================================================
855 /*! Function : UnLockStudy
858 //============================================================================
859 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
861 SALOMEDS::Locker lock;
862 _impl->UnLockStudy(theLockerID);
865 //============================================================================
866 /*! Function : GetLockerID
869 //============================================================================
870 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
872 SALOMEDS::Locker lock;
874 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
876 vector<string> aSeq = _impl->GetLockerID();
878 int aLength = aSeq.size();
879 aResult->length(aLength);
880 for(int anIndex = 0; anIndex < aLength; anIndex++) {
881 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
883 return aResult._retn();
886 //============================================================================
887 /*! Function : GetDefaultScript
890 //============================================================================
891 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
893 SALOMEDS::Locker lock;
895 string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
896 return CORBA::string_dup(script.c_str());
899 //============================================================================
900 /*! Function : EnableUseCaseAutoFilling
903 //============================================================================
904 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
906 _impl->EnableUseCaseAutoFilling(isEnabled);
907 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
910 builder->SetOnAddSObject(_impl->GetCallback());
911 builder->SetOnRemoveSObject(_impl->GetCallback());
914 builder->SetOnAddSObject(NULL);
915 builder->SetOnRemoveSObject(NULL);
920 //===========================================================================
922 //===========================================================================
923 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
926 long pid = (long)_getpid();
928 long pid = (long)getpid();
930 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
931 return reinterpret_cast<CORBA::LongLong>(_impl);
934 SALOME::GenericObj_ptr SALOMEDS_Study_i::FindObjectByInternalEntry( const char* theComponent, const char* theEntry )
936 SALOME::GenericObj_ptr aRes;
937 SALOMEDS::StudyBuilder_ptr aBuilder = NewBuilder();
938 SALOMEDS::SComponent_ptr aSComponent = FindComponent( theComponent );
940 if( !CORBA::is_nil( aSComponent ) )
942 SALOMEDS::GenericAttribute_ptr anAttr;
943 if( aBuilder->FindAttribute( aSComponent, anAttr, "AttributeIOR" ) )
945 SALOMEDS::AttributeIOR_ptr anAttrIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
946 CORBA::Object_var aCompObj = _orb->string_to_object( anAttrIOR->Value() );
947 Engines::Component_var aComponent = Engines::Component::_narrow( aCompObj );
948 aRes = aComponent->FindObjectByInternalEntry( theEntry );
954 SALOME::Notebook_ptr SALOMEDS_Study_i::GetNotebook()
956 if( CORBA::is_nil( myNotebook ) )
958 SALOME_Notebook* aNb = new SALOME_Notebook( _this() );
959 myNotebook = aNb->_this();
962 return myNotebook._retn();