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.hxx"
37 #include "SALOMEDSImpl_SObject.hxx"
38 #include "SALOMEDSImpl_SComponent.hxx"
39 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
40 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
41 #include "SALOMEDSImpl_AttributeParameter.hxx"
42 #include "SALOMEDSImpl_ChildIterator.hxx"
43 #include "SALOMEDSImpl_IParameters.hxx"
45 #include "DF_Label.hxx"
46 #include "DF_Attribute.hxx"
48 #include "Basics_Utils.hxx"
53 #include <sys/types.h>
59 std::map<SALOMEDSImpl_Study* , SALOMEDS_Study_i*> SALOMEDS_Study_i::_mapOfStudies;
61 //============================================================================
62 /*! Function : SALOMEDS_Study_i
63 * Purpose : SALOMEDS_Study_i constructor
65 //============================================================================
66 SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDSImpl_Study* theImpl,
69 _orb = CORBA::ORB::_duplicate(orb);
72 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
75 //============================================================================
76 /*! Function : ~SALOMEDS_Study_i
77 * Purpose : SALOMEDS_Study_i destructor
79 //============================================================================
80 SALOMEDS_Study_i::~SALOMEDS_Study_i()
82 //delete the builder servant
83 PortableServer::POA_var poa=_builder->_default_POA();
84 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
85 poa->deactivate_object(anObjectId.in());
86 _builder->_remove_ref();
87 //delete implementation
91 //============================================================================
92 /*! Function : GetPersistentReference
93 * Purpose : Get persistent reference of study (idem URL())
95 //============================================================================
96 char* SALOMEDS_Study_i::GetPersistentReference()
98 SALOMEDS::Locker lock;
99 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
101 //============================================================================
102 /*! Function : GetTransientReference
103 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
105 //============================================================================
106 char* SALOMEDS_Study_i::GetTransientReference()
108 SALOMEDS::Locker lock;
109 return CORBA::string_dup(_impl->GetTransientReference().c_str());
112 //============================================================================
113 /*! Function : IsEmpty
114 * Purpose : Detect if study is empty
116 //============================================================================
117 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
119 SALOMEDS::Locker lock;
120 return _impl->IsEmpty();
123 //============================================================================
124 /*! Function : FindComponent
125 * Purpose : Find a Component with ComponentDataType = aComponentName
127 //============================================================================
128 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
130 SALOMEDS::Locker lock;
132 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(string(aComponentName));
133 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
135 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
139 //============================================================================
140 /*! Function : FindComponentID
141 * Purpose : Find a Component from it's ID
143 //============================================================================
144 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
146 SALOMEDS::Locker lock;
148 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(string((char*)aComponentID));
149 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
151 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
155 //============================================================================
156 /*! Function : FindObject
157 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
159 //============================================================================
160 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
162 SALOMEDS::Locker lock;
164 SALOMEDSImpl_SObject aSO = _impl->FindObject(string((char*)anObjectName));
165 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
167 if(aSO.IsComponent()) {
168 SALOMEDSImpl_SComponent aSCO = aSO;
169 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
173 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
178 //============================================================================
179 /*! Function : FindObjectID
180 * Purpose : Find an Object with ID = anObjectID
182 //============================================================================
183 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
185 SALOMEDS::Locker lock;
187 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(string((char*)anObjectID));
188 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
189 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
193 //============================================================================
194 /*! Function : CreateObjectID
195 * Purpose : Creates an Object with ID = anObjectID
197 //============================================================================
198 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
200 SALOMEDS::Locker lock;
202 if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
204 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
205 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
207 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
211 //============================================================================
212 /*! Function : FindObjectByName
213 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
214 * : with ComponentDataType = aComponentName
216 //============================================================================
217 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
218 const char* aComponentName )
220 SALOMEDS::Locker lock;
222 vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(string((char*)anObjectName),
223 string((char*)aComponentName));
224 int aLength = aSeq.size();
225 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
226 listSO->length(aLength);
227 for(int i = 0; i<aLength; i++) {
228 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSeq[i], _orb);
231 return listSO._retn() ;
234 //============================================================================
235 /*! Function : FindObjectIOR
236 * Purpose : Find an Object with IOR = anObjectIOR
238 //============================================================================
239 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
241 SALOMEDS::Locker lock;
243 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(string((char*)anObjectIOR));
244 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
246 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
250 //============================================================================
251 /*! Function : FindObjectByPath
252 * Purpose : Find an Object by its path = thePath
254 //============================================================================
255 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
257 SALOMEDS::Locker lock;
259 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(string((char*)thePath));
260 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
262 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
266 //============================================================================
267 /*! Function : GetObjectPath
270 //============================================================================
271 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
273 SALOMEDS::Locker lock;
276 if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.c_str());
277 SALOMEDSImpl_SObject aSO;
278 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
280 if(!CORBA::is_nil(aSObj)) {
281 aSO = _impl->FindObjectID(aSObj->GetID());
284 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
287 if(aSO.IsNull()) return CORBA::string_dup(aPath.c_str());
289 aPath = _impl->GetObjectPath(aSO);
290 return CORBA::string_dup(aPath.c_str());
294 //============================================================================
295 /*! Function : SetContext
296 * Purpose : Sets the current context
298 //============================================================================
299 void SALOMEDS_Study_i::SetContext(const char* thePath)
301 SALOMEDS::Locker lock;
303 _impl->SetContext(string((char*)thePath));
304 if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
305 throw SALOMEDS::Study::StudyInvalidContext();
308 //============================================================================
309 /*! Function : GetContext
310 * Purpose : Gets the current context
312 //============================================================================
313 char* SALOMEDS_Study_i::GetContext()
315 SALOMEDS::Locker lock;
317 if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
318 return CORBA::string_dup(_impl->GetContext().c_str());
321 //============================================================================
322 /*! Function : GetObjectNames
323 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
325 //============================================================================
326 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
328 SALOMEDS::Locker lock;
330 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
332 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
333 throw SALOMEDS::Study::StudyInvalidContext();
335 vector<string> aSeq = _impl->GetObjectNames(string((char*)theContext));
336 if (_impl->GetErrorCode() == "InvalidContext")
337 throw SALOMEDS::Study::StudyInvalidContext();
339 int aLength = aSeq.size();
340 aResult->length(aLength);
341 for (int anIndex = 0; anIndex < aLength; anIndex++) {
342 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
345 return aResult._retn();
348 //============================================================================
349 /*! Function : GetDirectoryNames
350 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
352 //============================================================================
353 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
355 SALOMEDS::Locker lock;
357 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
359 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
360 throw SALOMEDS::Study::StudyInvalidContext();
362 vector<string> aSeq = _impl->GetDirectoryNames(string((char*)theContext));
363 if (_impl->GetErrorCode() == "InvalidContext")
364 throw SALOMEDS::Study::StudyInvalidContext();
366 int aLength = aSeq.size();
367 aResult->length(aLength);
368 for (int anIndex = 0; anIndex < aLength; anIndex++) {
369 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
372 return aResult._retn();
375 //============================================================================
376 /*! Function : GetFileNames
377 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
379 //============================================================================
380 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
382 SALOMEDS::Locker lock;
384 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
386 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
387 throw SALOMEDS::Study::StudyInvalidContext();
389 vector<string> aSeq = _impl->GetFileNames(string((char*)theContext));
390 if (_impl->GetErrorCode() == "InvalidContext")
391 throw SALOMEDS::Study::StudyInvalidContext();
393 int aLength = aSeq.size();
394 aResult->length(aLength);
395 for (int anIndex = 0; anIndex < aLength; anIndex++) {
396 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
399 return aResult._retn();
402 //============================================================================
403 /*! Function : GetComponentNames
404 * Purpose : method to get all components names
405 * SRN: Note, theContext can be any, it doesn't matter
407 //============================================================================
408 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
410 SALOMEDS::Locker lock;
412 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
414 vector<string> aSeq = _impl->GetComponentNames(string((char*)theContext));
416 int aLength = aSeq.size();
417 aResult->length(aLength);
418 for(int anIndex = 0; anIndex < aLength; anIndex++) {
419 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
422 return aResult._retn();
425 //============================================================================
426 /*! Function : NewChildIterator
427 * Purpose : Create a ChildIterator from an SObject
429 //============================================================================
430 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
432 SALOMEDS::Locker lock;
434 CORBA::String_var anID=theSO->GetID();
435 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
436 SALOMEDSImpl_ChildIterator anItr(aSO);
439 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
441 return it_servant->_this();
445 //============================================================================
446 /*! Function : NewComponentIterator
447 * Purpose : Create a SComponentIterator
449 //============================================================================
450 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
452 SALOMEDS::Locker lock;
453 SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
459 //============================================================================
460 /*! Function : NewBuilder
461 * Purpose : Create a StudyBuilder
463 //============================================================================
464 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
466 SALOMEDS::Locker lock;
467 return _builder->_this();
470 //============================================================================
472 * Purpose : get study name
474 //============================================================================
475 char* SALOMEDS_Study_i::Name()
477 SALOMEDS::Locker lock;
478 return CORBA::string_dup(_impl->Name().c_str());
481 //============================================================================
483 * Purpose : set study name
485 //============================================================================
486 void SALOMEDS_Study_i::Name(const char* name)
488 SALOMEDS::Locker lock;
489 _impl->Name(string((char*)name));
492 //============================================================================
493 /*! Function : IsSaved
494 * Purpose : get if study has been saved
496 //============================================================================
497 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
499 SALOMEDS::Locker lock;
500 return _impl->IsSaved();
503 //============================================================================
504 /*! Function : IsSaved
505 * Purpose : set if study has been saved
507 //============================================================================
508 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
510 SALOMEDS::Locker lock;
511 _impl->IsSaved(save);
514 //============================================================================
515 /*! Function : IsModified
516 * Purpose : Detect if a Study has been modified since it has been saved
518 //============================================================================
519 CORBA::Boolean SALOMEDS_Study_i::IsModified()
521 SALOMEDS::Locker lock;
522 return _impl->IsModified();
525 //============================================================================
526 /*! Function : Modified
527 * Purpose : Sets a Modified flag of a Study to True
529 //============================================================================
530 void SALOMEDS_Study_i::Modified()
532 SALOMEDS::Locker lock;
533 return _impl->Modify();
537 //============================================================================
539 * Purpose : get URL of the study (persistent reference of the study)
541 //============================================================================
542 char* SALOMEDS_Study_i::URL()
544 SALOMEDS::Locker lock;
545 return CORBA::string_dup(_impl->URL().c_str());
548 //============================================================================
550 * Purpose : set URL of the study (persistent reference of the study)
552 //============================================================================
553 void SALOMEDS_Study_i::URL(const char* url)
555 SALOMEDS::Locker lock;
556 _impl->URL(string((char*)url));
560 CORBA::Short SALOMEDS_Study_i::StudyId()
562 SALOMEDS::Locker lock;
563 return _impl->StudyId();
566 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
568 SALOMEDS::Locker lock;
572 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
574 SALOMEDS::Locker lock;
575 _impl->UpdateIORLabelMap(string((char*)anIOR), string((char*)anEntry));
578 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
580 SALOMEDS::Locker lock;
582 SALOMEDSImpl_AttributeIOR* Att = NULL;
583 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
584 char* IOR = CORBA::string_dup(Att->Value().c_str());
585 CORBA::Object_var obj = orb->string_to_object(IOR);
586 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
587 ASSERT(!CORBA::is_nil(aStudy));
588 return SALOMEDS::Study::_duplicate(aStudy);
590 MESSAGE("GetStudy: Problem to get study");
592 return SALOMEDS::Study::_nil();
595 SALOMEDS_Study_i* SALOMEDS_Study_i::GetStudyServant(SALOMEDSImpl_Study* aStudyImpl, CORBA::ORB_ptr orb)
597 if (_mapOfStudies.find(aStudyImpl) != _mapOfStudies.end())
598 return _mapOfStudies[aStudyImpl];
601 SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, orb);
602 _mapOfStudies[aStudyImpl]=Study_servant;
603 return Study_servant;
607 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
609 SALOMEDS::Locker lock;
610 SALOMEDSImpl_Study::IORUpdated(theAttribute);
613 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
615 SALOMEDS::Locker lock;
617 SALOMEDS::GenericAttribute_ptr aTarget;
618 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
619 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
621 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
627 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
629 SALOMEDS::Locker lock;
631 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
632 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
633 return SP->AttributeStudyProperties::_this();
636 char* SALOMEDS_Study_i::GetLastModificationDate()
638 SALOMEDS::Locker lock;
639 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
642 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
644 SALOMEDS::Locker lock;
646 vector<string> aSeq = _impl->GetModificationsDate();
647 int aLength = aSeq.size();
648 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
649 aDates->length(aLength);
651 for(int anIndex = 0; anIndex < aLength; anIndex++) {
652 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
654 return aDates._retn();
659 //============================================================================
660 /*! Function : GetUseCaseBuilder
661 * Purpose : Returns a UseCase builder
663 //============================================================================
664 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
666 SALOMEDS::Locker lock;
667 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
668 return UCBuilder->_this();
672 //============================================================================
676 //============================================================================
677 void SALOMEDS_Study_i::Close()
679 SALOMEDS::Locker lock;
683 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
684 for (; itcomponent->More(); itcomponent->Next()) {
685 SALOMEDS::SComponent_var sco = itcomponent->Value();
686 CORBA::String_var compodatatype=sco->ComponentDataType();
687 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
688 // if there is an associated Engine call its method for closing
689 CORBA::String_var IOREngine;
690 if (sco->ComponentIOR(IOREngine)) {
691 // we have found the associated engine to write the data
692 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
693 //_narrow can throw a corba exception
696 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
697 if (!CORBA::is_nil(obj))
699 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
700 if (!anEngine->_is_nil())
703 anEngine->Close(sco);
708 catch (CORBA::Exception&)
714 //Does not need any more this iterator
715 itcomponent->Destroy();
721 //============================================================================
722 /*! Function : AddPostponed
725 //============================================================================
726 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
728 SALOMEDS::Locker lock;
732 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
734 SALOMEDS::Locker lock;
738 //============================================================================
739 /*! Function : RemovePostponed
742 //============================================================================
744 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/)
746 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
749 SALOMEDS::Locker lock;
751 vector<string> anIORs = _impl->GetIORs();
752 int i, aSize = (int)anIORs.size();
754 for(i = 0; i < aSize; i++) {
756 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
757 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
758 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
765 //============================================================================
766 /*! Function : UndoPostponed
769 //============================================================================
771 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
773 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
776 SALOMEDS::Locker lock;
781 //============================================================================
782 /*! Function : DumpStudy
785 //============================================================================
786 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
787 const char* theBaseName,
788 CORBA::Boolean isPublished)
790 SALOMEDS::Locker lock;
792 string aPath((char*)thePath), aBaseName((char*)theBaseName);
793 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
794 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
799 //============================================================================
800 /*! Function : GetCommonParameters
803 //============================================================================
804 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
806 SALOMEDS::Locker lock;
808 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
809 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
810 return SP->AttributeParameter::_this();
813 //============================================================================
814 /*! Function : GetCommonModuleParameters
817 //============================================================================
818 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
819 const char* theModuleName,
820 CORBA::Long theSavePoint)
822 SALOMEDS::Locker lock;
824 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
825 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
826 return SP->AttributeParameter::_this();
829 //============================================================================
830 /*! Function : SetStudyLock
833 //============================================================================
834 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
836 SALOMEDS::Locker lock;
837 _impl->SetStudyLock(theLockerID);
840 //============================================================================
841 /*! Function : IsStudyLocked
844 //============================================================================
845 bool SALOMEDS_Study_i::IsStudyLocked()
847 SALOMEDS::Locker lock;
848 return _impl->IsStudyLocked();
851 //============================================================================
852 /*! Function : UnLockStudy
855 //============================================================================
856 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
858 SALOMEDS::Locker lock;
859 _impl->UnLockStudy(theLockerID);
862 //============================================================================
863 /*! Function : GetLockerID
866 //============================================================================
867 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
869 SALOMEDS::Locker lock;
871 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
873 vector<string> aSeq = _impl->GetLockerID();
875 int aLength = aSeq.size();
876 aResult->length(aLength);
877 for(int anIndex = 0; anIndex < aLength; anIndex++) {
878 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
880 return aResult._retn();
882 //============================================================================
883 /*! Function : SetReal
886 //============================================================================
887 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
889 _impl->SetVariable(string(theVarName),
891 SALOMEDSImpl_GenericVariable::REAL_VAR);
894 //============================================================================
895 /*! Function : SetInteger
898 //============================================================================
899 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
901 _impl->SetVariable(string(theVarName),
903 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
906 //============================================================================
907 /*! Function : SetBoolean
910 //============================================================================
911 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
913 _impl->SetVariable(string(theVarName),
915 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
918 //============================================================================
919 /*! Function : GetReal
922 //============================================================================
923 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
925 return _impl->GetVariableValue(string(theVarName));
928 //============================================================================
929 /*! Function : GetInteger
932 //============================================================================
933 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
935 return (int)_impl->GetVariableValue(string(theVarName));
938 //============================================================================
939 /*! Function : GetBoolean
942 //============================================================================
943 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
945 return (bool)_impl->GetVariableValue(string(theVarName));
948 //============================================================================
949 /*! Function : IsReal
952 //============================================================================
953 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
955 return _impl->IsTypeOf(string(theVarName),
956 SALOMEDSImpl_GenericVariable::REAL_VAR);
959 //============================================================================
960 /*! Function : IsInteger
963 //============================================================================
964 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
966 return _impl->IsTypeOf(string(theVarName),
967 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
970 //============================================================================
971 /*! Function : IsBoolean
974 //============================================================================
975 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
977 return _impl->IsTypeOf(string(theVarName),
978 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
981 //============================================================================
982 /*! Function : IsVariable
985 //============================================================================
986 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
988 return _impl->IsVariable(string(theVarName));
991 //============================================================================
992 /*! Function : GetVariableNames
995 //============================================================================
996 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
998 vector<string> aVarNames = _impl->GetVariableNames();
999 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1001 int aLen = aVarNames.size();
1002 aResult->length(aLen);
1004 for (int anInd = 0; anInd < aLen; anInd++)
1005 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1007 return aResult._retn();
1010 //============================================================================
1011 /*! Function : RemoveVariable
1014 //============================================================================
1015 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1017 return _impl->RemoveVariable(string(theVarName));
1020 //============================================================================
1021 /*! Function : RenameVariable
1024 //============================================================================
1025 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1027 return _impl->RenameVariable(string(theVarName), string(theNewVarName));
1030 //============================================================================
1031 /*! Function : IsVariableUsed
1034 //============================================================================
1035 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1037 return _impl->IsVariableUsed(string(theVarName));
1041 //============================================================================
1042 /*! Function : ParseVariables
1045 //============================================================================
1046 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1048 vector< vector<string> > aSections = _impl->ParseVariables(string(theVarName));
1050 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1052 int aSectionsLen = aSections.size();
1053 aResult->length(aSectionsLen);
1055 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1056 vector<string> aVarNames = aSections[aSectionInd];
1058 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1060 int aLen = aVarNames.size();
1061 aList->length(aLen);
1063 for (int anInd = 0; anInd < aLen; anInd++)
1064 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1066 aResult[aSectionInd] = aList;
1069 return aResult._retn();
1072 //============================================================================
1073 /*! Function : GetDefaultScript
1076 //============================================================================
1077 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1079 SALOMEDS::Locker lock;
1081 string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1082 return CORBA::string_dup(script.c_str());
1085 //============================================================================
1086 /*! Function : EnableUseCaseAutoFilling
1089 //============================================================================
1090 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1092 _impl->EnableUseCaseAutoFilling(isEnabled);
1093 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1096 builder->SetOnAddSObject(_impl->GetCallback());
1097 builder->SetOnRemoveSObject(_impl->GetCallback());
1100 builder->SetOnAddSObject(NULL);
1101 builder->SetOnRemoveSObject(NULL);
1106 //===========================================================================
1107 // PRIVATE FUNCTIONS
1108 //===========================================================================
1109 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1112 long pid = (long)_getpid();
1114 long pid = (long)getpid();
1116 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1117 return reinterpret_cast<CORBA::LongLong>(_impl);