1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // File : SALOMEDS_Study_i.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
29 #include "SALOMEDS_Study_i.hxx"
30 #include "SALOMEDS_UseCaseIterator_i.hxx"
31 #include "SALOMEDS_GenericAttribute_i.hxx"
32 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
33 #include "SALOMEDS_AttributeParameter_i.hxx"
34 #include "SALOMEDS_ChildIterator_i.hxx"
35 #include "SALOMEDS_Driver_i.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"
45 #include "SALOMEDSImpl_Callback.hxx"
47 #include "DF_Label.hxx"
48 #include "DF_Attribute.hxx"
50 #include "Utils_ExceptHandlers.hxx"
52 #include "Basics_Utils.hxx"
53 #include "SALOME_KernelServices.hxx"
58 #include <sys/types.h>
62 UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
63 UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
65 static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
69 class Notifier: public SALOMEDSImpl_AbstractCallback
72 Notifier(CORBA::ORB_ptr orb)
74 _orb = CORBA::ORB::_duplicate(orb);
77 //============================================================================
78 /*! Function : addSO_Notification
79 * Purpose : This function tells all the observers that a SO has been added
81 //============================================================================
83 virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject)
85 std::string anID=theSObject.GetID();
86 const char* cID=anID.c_str();
87 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
89 it->first->notifyObserverID(cID,1);
91 return true; // NGE return always true but can be modified if needed
94 //============================================================================
95 /*! Function : removeSO_Notification
96 * Purpose : This function tells all the observers that a SO has been removed
98 //============================================================================
100 virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject)
102 std::string anID=theSObject.GetID();
103 const char* cID=anID.c_str();
104 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
106 it->first->notifyObserverID(cID,2);
108 return true; // NGE return always true but can be modified if needed
111 //============================================================================
112 /*! Function : modifySO_Notification
113 * Purpose : This function tells all the observers that a SO has been modified
115 //============================================================================
117 virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason)
119 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
123 std::string anID=theSObject.GetID();
124 const char* cID=anID.c_str();
125 it->first->notifyObserverID(cID,reason);
128 return true; // NGE return always true but can be modified if needed
131 //============================================================================
132 /*! Function : modifyNB_Notification
133 * Purpose : This function tells all the observers that
134 * a NoteBook variable has been added/modified/removed.
136 //============================================================================
138 virtual bool modifyNB_Notification(const char* theVarName)
140 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
142 it->first->notifyObserverID(theVarName,6);
144 return true; // NGE return always true but can be modified if needed
147 //============================================================================
148 /*! Function : attach
149 * Purpose : register an Observer
151 //============================================================================
153 virtual void attach(SALOMEDS::Observer_ptr theObs, bool modify)
155 myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
158 //============================================================================
159 /*! Function : detach
160 * Purpose : unregister an Observer
162 //============================================================================
164 virtual void detach(SALOMEDS::Observer_ptr theObs)
166 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
168 if ( it->first->_is_equivalent(theObs) ) {
169 myObservers.erase( it );
176 typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
177 typedef ObsList::iterator ObsListIter;
182 class GenObjRegister: public SALOMEDSImpl_AbstractCallback
185 GenObjRegister(CORBA::ORB_ptr orb)
187 _orb = CORBA::ORB::_duplicate(orb);
189 virtual void RegisterGenObj (const std::string& theIOR)
193 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
194 if ( obj->_non_existent() ) return;
195 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
196 if(! CORBA::is_nil(gobj) )
201 catch(const CORBA::Exception& e)
205 virtual void UnRegisterGenObj(const std::string& theIOR)
209 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
210 if ( obj->_non_existent() ) return;
211 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
212 if(! CORBA::is_nil(gobj) )
217 catch(const CORBA::Exception& e)
226 } // namespace SALOMEDS
228 //============================================================================
229 /*! Function : SALOMEDS_Study_i
230 * Purpose : SALOMEDS_Study_i constructor
232 //============================================================================
233 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb)
235 _orb = CORBA::ORB::_duplicate(orb);
236 _impl = new SALOMEDSImpl_Study();
237 _factory = new SALOMEDS_DriverFactory_i(_orb);
242 //============================================================================
243 /*! Function : ~SALOMEDS_Study_i
244 * Purpose : SALOMEDS_Study_i destructor
246 //============================================================================
247 SALOMEDS_Study_i::~SALOMEDS_Study_i()
254 //============================================================================
256 * Purpose : Initialize study components
258 //============================================================================
259 void SALOMEDS_Study_i::Init()
261 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
262 _notifier = new SALOMEDS::Notifier(_orb);
263 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
266 _impl->setNotifier(_notifier);
267 _impl->setGenObjRegister( _genObjRegister );
269 // Notify GUI that study was created
270 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
271 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
272 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
273 if ( !CORBA::is_nil(aSession) ) {
274 std::stringstream ss;
275 ss << "studyCreated";
276 std::string str = ss.str();
278 aSession->emitMessageOneWay(str.c_str());
283 //============================================================================
285 * Purpose : Clear study components
287 //============================================================================
288 void SALOMEDS_Study_i::Clear()
290 //delete the builder servant
291 PortableServer::POA_var poa=_builder->_default_POA();
292 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
293 poa->deactivate_object(anObjectId.in());
294 _builder->_remove_ref();
297 _impl->setNotifier(0);
299 delete _genObjRegister;
301 SALOMEDS::Locker lock;
304 throw SALOMEDS::Study::StudyInvalidReference();
308 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
309 for (; itcomponent->More(); itcomponent->Next()) {
310 SALOMEDS::SComponent_var sco = itcomponent->Value();
311 CORBA::String_var compodatatype=sco->ComponentDataType();
312 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
313 // if there is an associated Engine call its method for closing
314 CORBA::String_var IOREngine;
315 if (sco->ComponentIOR(IOREngine)) {
316 // we have found the associated engine to write the data
317 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
318 //_narrow can throw a corba exception
320 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
321 if (!CORBA::is_nil(obj)) {
322 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
323 if (!anEngine->_is_nil()) {
325 anEngine->Close(sco);
330 catch (CORBA::Exception&) {
336 //Does not need any more this iterator
337 itcomponent->UnRegister();
339 // Notify GUI that study is cleared
340 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
341 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
342 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
343 if ( !CORBA::is_nil(aSession) ) {
344 std::stringstream ss;
345 ss << "studyCleared";
346 std::string str = ss.str();
348 aSession->emitMessageOneWay(str.c_str());
355 //============================================================================
357 * Purpose : Open a Study from it's persistent reference
359 //============================================================================
360 bool SALOMEDS_Study_i::Open(const char* aUrl)
361 throw(SALOME::SALOME_Exception)
363 SALOMEDS::Locker lock;
365 Unexpect aCatch(SalomeException);
366 MESSAGE("Begin of SALOMEDS_Study_i::Open");
368 bool res = _impl->Open(std::string(aUrl));
371 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
375 //============================================================================
377 * Purpose : Save a Study to it's persistent reference
379 //============================================================================
380 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
382 SALOMEDS::Locker lock;
383 return _impl->Save(_factory, theMultiFile);
386 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
388 SALOMEDS::Locker lock;
389 return _impl->SaveASCII(_factory, theMultiFile);
392 //=============================================================================
393 /*! Function : SaveAs
394 * Purpose : Save a study to the persistent reference aUrl
396 //============================================================================
397 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
399 SALOMEDS::Locker lock;
400 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
403 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
405 SALOMEDS::Locker lock;
406 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
409 //============================================================================
410 /*! Function : CanCopy
413 //============================================================================
414 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
416 SALOMEDS::Locker lock;
418 CORBA::String_var anID = theObject->GetID();
419 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
421 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
422 bool ret = _impl->CanCopy(anObject, aDriver);
427 //============================================================================
431 //============================================================================
432 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
434 SALOMEDS::Locker lock;
436 CORBA::String_var anID = theObject->GetID();
437 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
439 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
440 bool ret = _impl->Copy(anObject, aDriver);
445 //============================================================================
446 /*! Function : CanPaste
449 //============================================================================
450 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
452 SALOMEDS::Locker lock;
454 CORBA::String_var anID = theObject->GetID();
455 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
457 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
458 bool ret = _impl->CanPaste(anObject, aDriver);
463 //============================================================================
467 //============================================================================
468 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
469 throw(SALOMEDS::StudyBuilder::LockProtection)
471 SALOMEDS::Locker lock;
473 Unexpect aCatch(LockProtection);
475 CORBA::String_var anID = theObject->GetID();
476 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
477 SALOMEDSImpl_SObject aNewSO;
480 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
481 aNewSO = _impl->Paste(anObject, aDriver);
485 throw SALOMEDS::StudyBuilder::LockProtection();
488 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
492 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
494 SALOMEDS_Driver_i* driver = NULL;
496 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
498 std::string IOREngine = aSCO.GetIOR();
499 if(!IOREngine.empty()) {
500 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
501 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
502 driver = new SALOMEDS_Driver_i(Engine, orb);
509 //============================================================================
510 /*! Function : GetPersistentReference
511 * Purpose : Get persistent reference of study (idem URL())
513 //============================================================================
514 char* SALOMEDS_Study_i::GetPersistentReference()
516 SALOMEDS::Locker lock;
518 throw SALOMEDS::Study::StudyInvalidReference();
519 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
521 //============================================================================
522 /*! Function : GetTransientReference
523 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
525 //============================================================================
526 char* SALOMEDS_Study_i::GetTransientReference()
528 SALOMEDS::Locker lock;
530 throw SALOMEDS::Study::StudyInvalidReference();
531 return CORBA::string_dup(_impl->GetTransientReference().c_str());
534 //============================================================================
535 /*! Function : IsEmpty
536 * Purpose : Detect if study is empty
538 //============================================================================
539 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
541 SALOMEDS::Locker lock;
543 throw SALOMEDS::Study::StudyInvalidReference();
544 return _impl->IsEmpty();
547 //============================================================================
548 /*! Function : FindComponent
549 * Purpose : Find a Component with ComponentDataType = aComponentName
551 //============================================================================
552 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
554 SALOMEDS::Locker lock;
557 throw SALOMEDS::Study::StudyInvalidReference();
559 SALOMEDS::SComponent_var sco;
561 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
562 if (!aCompImpl.IsNull())
563 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
568 //============================================================================
569 /*! Function : FindComponentID
570 * Purpose : Find a Component from it's ID
572 //============================================================================
573 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
575 SALOMEDS::Locker lock;
578 throw SALOMEDS::Study::StudyInvalidReference();
580 SALOMEDS::SComponent_var sco;
582 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
583 if (!aCompImpl.IsNull())
584 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
589 //============================================================================
590 /*! Function : FindObject
591 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
593 //============================================================================
594 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
596 SALOMEDS::Locker lock;
599 throw SALOMEDS::Study::StudyInvalidReference();
601 SALOMEDS::SObject_var so;
603 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
605 if (aSO.IsComponent()) {
606 SALOMEDSImpl_SComponent aSCO = aSO;
607 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
610 so = SALOMEDS_SObject_i::New(aSO, _orb);
617 //============================================================================
618 /*! Function : FindObjectID
619 * Purpose : Find an Object with ID = anObjectID
621 //============================================================================
622 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
624 SALOMEDS::Locker lock;
627 throw SALOMEDS::Study::StudyInvalidReference();
629 SALOMEDS::SObject_var so;
631 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
633 so = SALOMEDS_SObject_i::New(aSO, _orb);
638 //============================================================================
639 /*! Function : CreateObjectID
640 * Purpose : Creates an Object with ID = anObjectID
642 //============================================================================
643 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
645 SALOMEDS::Locker lock;
648 throw SALOMEDS::Study::StudyInvalidReference();
650 SALOMEDS::SObject_var so;
652 if (anObjectID && strlen(anObjectID) > 0) {
653 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
655 so = SALOMEDS_SObject_i::New(aSO, _orb);
661 //============================================================================
662 /*! Function : FindObjectByName
663 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
664 * : with ComponentDataType = aComponentName
666 //============================================================================
667 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
668 const char* aComponentName )
670 SALOMEDS::Locker lock;
673 throw SALOMEDS::Study::StudyInvalidReference();
675 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
676 std::string((char*)aComponentName));
678 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
679 int aLength = aSeq.size();
680 listSO->length(aLength);
681 for (int i = 0; i < aLength; i++) {
682 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
686 return listSO._retn();
689 //============================================================================
690 /*! Function : FindObjectIOR
691 * Purpose : Find an Object with IOR = anObjectIOR
693 //============================================================================
694 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
696 SALOMEDS::Locker lock;
699 throw SALOMEDS::Study::StudyInvalidReference();
701 SALOMEDS::SObject_var so;
703 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
705 so = SALOMEDS_SObject_i::New(aSO, _orb);
710 //============================================================================
711 /*! Function : FindObjectByPath
712 * Purpose : Find an Object by its path = thePath
714 //============================================================================
715 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
717 SALOMEDS::Locker lock;
720 throw SALOMEDS::Study::StudyInvalidReference();
722 SALOMEDS::SObject_var so;
724 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
726 so = SALOMEDS_SObject_i::New (aSO, _orb);
731 //============================================================================
732 /*! Function : GetObjectPath
735 //============================================================================
736 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
738 SALOMEDS::Locker lock;
741 throw SALOMEDS::Study::StudyInvalidReference();
743 std::string aPath = "";
745 if (!CORBA::is_nil(theObject)) {
746 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
747 SALOMEDSImpl_SObject aSO;
749 if (!CORBA::is_nil(aSObj)) {
750 aSO = _impl->FindObjectID(aSObj->GetID());
753 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
757 aPath = _impl->GetObjectPath(aSO);
761 return CORBA::string_dup(aPath.c_str());
765 //============================================================================
766 /*! Function : SetContext
767 * Purpose : Sets the current context
769 //============================================================================
770 void SALOMEDS_Study_i::SetContext(const char* thePath)
772 SALOMEDS::Locker lock;
775 throw SALOMEDS::Study::StudyInvalidReference();
777 _impl->SetContext(std::string((char*)thePath));
778 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
779 throw SALOMEDS::Study::StudyInvalidContext();
782 //============================================================================
783 /*! Function : GetContext
784 * Purpose : Gets the current context
786 //============================================================================
787 char* SALOMEDS_Study_i::GetContext()
789 SALOMEDS::Locker lock;
792 throw SALOMEDS::Study::StudyInvalidReference();
794 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
796 return CORBA::string_dup(_impl->GetContext().c_str());
799 //============================================================================
800 /*! Function : GetObjectNames
801 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
803 //============================================================================
804 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
806 SALOMEDS::Locker lock;
809 throw SALOMEDS::Study::StudyInvalidReference();
811 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
813 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
814 throw SALOMEDS::Study::StudyInvalidContext();
816 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
817 if (_impl->GetErrorCode() == "InvalidContext")
818 throw SALOMEDS::Study::StudyInvalidContext();
820 int aLength = aSeq.size();
821 aResult->length(aLength);
822 for (int anIndex = 0; anIndex < aLength; anIndex++) {
823 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
826 return aResult._retn();
829 //============================================================================
830 /*! Function : GetDirectoryNames
831 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
833 //============================================================================
834 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
836 SALOMEDS::Locker lock;
839 throw SALOMEDS::Study::StudyInvalidReference();
841 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
843 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
844 throw SALOMEDS::Study::StudyInvalidContext();
846 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
847 if (_impl->GetErrorCode() == "InvalidContext")
848 throw SALOMEDS::Study::StudyInvalidContext();
850 int aLength = aSeq.size();
851 aResult->length(aLength);
852 for (int anIndex = 0; anIndex < aLength; anIndex++) {
853 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
856 return aResult._retn();
859 //============================================================================
860 /*! Function : GetFileNames
861 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
863 //============================================================================
864 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
866 SALOMEDS::Locker lock;
869 throw SALOMEDS::Study::StudyInvalidReference();
871 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
873 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
874 throw SALOMEDS::Study::StudyInvalidContext();
876 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
877 if (_impl->GetErrorCode() == "InvalidContext")
878 throw SALOMEDS::Study::StudyInvalidContext();
880 int aLength = aSeq.size();
881 aResult->length(aLength);
882 for (int anIndex = 0; anIndex < aLength; anIndex++) {
883 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
886 return aResult._retn();
889 //============================================================================
890 /*! Function : GetComponentNames
891 * Purpose : method to get all components names
892 * SRN: Note, theContext can be any, it doesn't matter
894 //============================================================================
895 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
897 SALOMEDS::Locker lock;
900 throw SALOMEDS::Study::StudyInvalidReference();
902 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
904 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
906 int aLength = aSeq.size();
907 aResult->length(aLength);
908 for(int anIndex = 0; anIndex < aLength; anIndex++) {
909 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
912 return aResult._retn();
915 //============================================================================
916 /*! Function : NewChildIterator
917 * Purpose : Create a ChildIterator from an SObject
919 //============================================================================
920 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
922 SALOMEDS::Locker lock;
925 throw SALOMEDS::Study::StudyInvalidReference();
927 CORBA::String_var anID = theSO->GetID();
928 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
929 SALOMEDSImpl_ChildIterator anItr(aSO);
930 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
931 SALOMEDS::ChildIterator_var it = it_servant->_this();
937 //============================================================================
938 /*! Function : NewComponentIterator
939 * Purpose : Create a SComponentIterator
941 //============================================================================
942 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
944 SALOMEDS::Locker lock;
947 throw SALOMEDS::Study::StudyInvalidReference();
949 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
951 SALOMEDS::SComponentIterator_var it = it_servant->_this();
957 //============================================================================
958 /*! Function : NewBuilder
959 * Purpose : Create a StudyBuilder
961 //============================================================================
962 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
964 SALOMEDS::Locker lock;
967 throw SALOMEDS::Study::StudyInvalidReference();
969 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
974 //============================================================================
976 * Purpose : get study name
978 //============================================================================
979 char* SALOMEDS_Study_i::Name()
981 SALOMEDS::Locker lock;
982 // Name is specified as IDL attribute: user exception cannot be raised
983 return CORBA::string_dup(_impl->Name().c_str());
986 //============================================================================
987 /*! Function : IsSaved
988 * Purpose : get if study has been saved
990 //============================================================================
991 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
993 SALOMEDS::Locker lock;
994 // IsSaved is specified as IDL attribute: user exception cannot be raised
995 return (!_closed) ? _impl->IsSaved() : false;
998 //============================================================================
999 /*! Function : IsSaved
1000 * Purpose : set if study has been saved
1002 //============================================================================
1003 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1005 SALOMEDS::Locker lock;
1006 // IsSaved is specified as IDL attribute: user exception cannot be raised
1008 _impl->IsSaved(save);
1011 //============================================================================
1012 /*! Function : IsModified
1013 * Purpose : Detect if a Study has been modified since it has been saved
1015 //============================================================================
1016 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1018 SALOMEDS::Locker lock;
1021 throw SALOMEDS::Study::StudyInvalidReference();
1023 return _impl->IsModified();
1026 //============================================================================
1027 /*! Function : Modified
1028 * Purpose : Sets a Modified flag of a Study to True
1030 //============================================================================
1031 void SALOMEDS_Study_i::Modified()
1033 SALOMEDS::Locker lock;
1036 throw SALOMEDS::Study::StudyInvalidReference();
1041 //============================================================================
1043 * Purpose : get URL of the study (persistent reference of the study)
1045 //============================================================================
1046 char* SALOMEDS_Study_i::URL()
1048 SALOMEDS::Locker lock;
1049 // URL is specified as IDL attribute: user exception cannot be raised
1050 return CORBA::string_dup(_impl->URL().c_str());
1053 //============================================================================
1055 * Purpose : set URL of the study (persistent reference of the study)
1057 //============================================================================
1058 void SALOMEDS_Study_i::URL(const char* url)
1060 SALOMEDS::Locker lock;
1061 // URL is specified as IDL attribute: user exception cannot be raised
1062 _impl->URL(std::string((char*)url));
1065 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1067 SALOMEDS::Locker lock;
1070 throw SALOMEDS::Study::StudyInvalidReference();
1072 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1075 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1077 SALOMEDS::Locker lock;
1079 SALOMEDSImpl_AttributeIOR* Att = NULL;
1080 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1081 char* IOR = CORBA::string_dup(Att->Value().c_str());
1082 CORBA::Object_var obj = orb->string_to_object(IOR);
1083 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1084 ASSERT(!CORBA::is_nil(aStudy));
1085 return SALOMEDS::Study::_duplicate(aStudy);
1087 MESSAGE("GetStudy: Problem to get study");
1089 return SALOMEDS::Study::_nil();
1092 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1094 SALOMEDS::Locker lock;
1095 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1098 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1100 SALOMEDS::Locker lock;
1103 throw SALOMEDS::Study::StudyInvalidReference();
1105 SALOMEDS::GenericAttribute_ptr aTarget;
1106 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1107 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1109 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1115 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1117 SALOMEDS::Locker lock;
1120 throw SALOMEDS::Study::StudyInvalidReference();
1122 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1123 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1124 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1125 return aProp._retn();
1128 char* SALOMEDS_Study_i::GetLastModificationDate()
1130 SALOMEDS::Locker lock;
1133 throw SALOMEDS::Study::StudyInvalidReference();
1135 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1138 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1140 SALOMEDS::Locker lock;
1143 throw SALOMEDS::Study::StudyInvalidReference();
1145 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1147 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1149 int aLength = aSeq.size();
1150 aDates->length(aLength);
1151 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1152 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1155 return aDates._retn();
1158 //============================================================================
1159 /*! Function : GetUseCaseBuilder
1160 * Purpose : Returns a UseCase builder
1162 //============================================================================
1163 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1165 SALOMEDS::Locker lock;
1168 throw SALOMEDS::Study::StudyInvalidReference();
1170 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1171 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1175 //============================================================================
1176 /*! Function : AddPostponed
1179 //============================================================================
1180 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1182 SALOMEDS::Locker lock;
1186 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1188 SALOMEDS::Locker lock;
1192 //============================================================================
1193 /*! Function : RemovePostponed
1196 //============================================================================
1197 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1199 SALOMEDS::Locker lock;
1202 throw SALOMEDS::Study::StudyInvalidReference();
1204 std::vector<std::string> anIORs = _impl->GetIORs();
1205 int i, aSize = (int)anIORs.size();
1207 for (i = 0; i < aSize; i++) {
1209 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1210 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1211 //rnv: To avoid double deletion of the Salome Generic Objects:
1212 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1213 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1214 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1221 //============================================================================
1222 /*! Function : UndoPostponed
1225 //============================================================================
1226 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1228 SALOMEDS::Locker lock;
1233 //============================================================================
1234 /*! Function : DumpStudy
1237 //============================================================================
1238 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1239 const char* theBaseName,
1240 CORBA::Boolean isPublished,
1241 CORBA::Boolean isMultiFile)
1243 SALOMEDS::Locker lock;
1246 throw SALOMEDS::Study::StudyInvalidReference();
1248 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1249 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1250 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1256 //============================================================================
1257 /*! Function : GetCommonParameters
1260 //============================================================================
1261 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1263 SALOMEDS::Locker lock;
1266 throw SALOMEDS::Study::StudyInvalidReference();
1268 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1269 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1270 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1272 return aParam._retn();
1275 //============================================================================
1276 /*! Function : GetCommonModuleParameters
1279 //============================================================================
1280 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1281 const char* theModuleName,
1282 CORBA::Long theSavePoint)
1284 SALOMEDS::Locker lock;
1287 throw SALOMEDS::Study::StudyInvalidReference();
1289 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1290 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1291 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1293 return aParam._retn();
1296 //============================================================================
1297 /*! Function : SetStudyLock
1300 //============================================================================
1301 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1303 SALOMEDS::Locker lock;
1306 throw SALOMEDS::Study::StudyInvalidReference();
1308 _impl->SetStudyLock(theLockerID);
1311 //============================================================================
1312 /*! Function : IsStudyLocked
1315 //============================================================================
1316 bool SALOMEDS_Study_i::IsStudyLocked()
1318 SALOMEDS::Locker lock;
1321 throw SALOMEDS::Study::StudyInvalidReference();
1323 return _impl->IsStudyLocked();
1326 //============================================================================
1327 /*! Function : UnLockStudy
1330 //============================================================================
1331 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1333 SALOMEDS::Locker lock;
1336 throw SALOMEDS::Study::StudyInvalidReference();
1338 _impl->UnLockStudy(theLockerID);
1341 //============================================================================
1342 /*! Function : GetLockerID
1345 //============================================================================
1346 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1348 SALOMEDS::Locker lock;
1351 throw SALOMEDS::Study::StudyInvalidReference();
1353 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1355 std::vector<std::string> aSeq = _impl->GetLockerID();
1357 int aLength = aSeq.size();
1358 aResult->length(aLength);
1359 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1360 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1363 return aResult._retn();
1365 //============================================================================
1366 /*! Function : SetReal
1369 //============================================================================
1370 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1373 throw SALOMEDS::Study::StudyInvalidReference();
1376 _impl->SetVariable(std::string(theVarName),
1378 SALOMEDSImpl_GenericVariable::REAL_VAR);
1380 _notifier->modifyNB_Notification(theVarName);
1383 //============================================================================
1384 /*! Function : SetInteger
1387 //============================================================================
1388 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1391 throw SALOMEDS::Study::StudyInvalidReference();
1393 _impl->SetVariable(std::string(theVarName),
1395 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1397 _notifier->modifyNB_Notification(theVarName);
1400 //============================================================================
1401 /*! Function : SetBoolean
1404 //============================================================================
1405 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1408 throw SALOMEDS::Study::StudyInvalidReference();
1410 _impl->SetVariable(std::string(theVarName),
1412 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1414 _notifier->modifyNB_Notification(theVarName);
1417 //============================================================================
1418 /*! Function : SetString
1421 //============================================================================
1422 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1425 throw SALOMEDS::Study::StudyInvalidReference();
1427 _impl->SetStringVariable(std::string(theVarName),
1429 SALOMEDSImpl_GenericVariable::STRING_VAR);
1431 _notifier->modifyNB_Notification(theVarName);
1434 //============================================================================
1435 /*! Function : SetStringAsDouble
1438 //============================================================================
1439 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1442 throw SALOMEDS::Study::StudyInvalidReference();
1444 _impl->SetStringVariableAsDouble(std::string(theVarName),
1446 SALOMEDSImpl_GenericVariable::STRING_VAR);
1449 //============================================================================
1450 /*! Function : GetReal
1453 //============================================================================
1454 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1457 throw SALOMEDS::Study::StudyInvalidReference();
1459 return _impl->GetVariableValue(std::string(theVarName));
1462 //============================================================================
1463 /*! Function : GetInteger
1466 //============================================================================
1467 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1470 throw SALOMEDS::Study::StudyInvalidReference();
1472 return (long)_impl->GetVariableValue(std::string(theVarName));
1475 //============================================================================
1476 /*! Function : GetBoolean
1479 //============================================================================
1480 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1483 throw SALOMEDS::Study::StudyInvalidReference();
1485 return (bool)_impl->GetVariableValue(std::string(theVarName));
1488 //============================================================================
1489 /*! Function : GetString
1492 //============================================================================
1493 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1496 throw SALOMEDS::Study::StudyInvalidReference();
1498 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1501 //============================================================================
1502 /*! Function : IsReal
1505 //============================================================================
1506 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1509 throw SALOMEDS::Study::StudyInvalidReference();
1511 return _impl->IsTypeOf(std::string(theVarName),
1512 SALOMEDSImpl_GenericVariable::REAL_VAR);
1515 //============================================================================
1516 /*! Function : IsInteger
1519 //============================================================================
1520 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1523 throw SALOMEDS::Study::StudyInvalidReference();
1525 return _impl->IsTypeOf(std::string(theVarName),
1526 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1529 //============================================================================
1530 /*! Function : IsBoolean
1533 //============================================================================
1534 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1537 throw SALOMEDS::Study::StudyInvalidReference();
1539 return _impl->IsTypeOf(std::string(theVarName),
1540 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1543 //============================================================================
1544 /*! Function : IsString
1547 //============================================================================
1548 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1551 throw SALOMEDS::Study::StudyInvalidReference();
1553 return _impl->IsTypeOf(std::string(theVarName),
1554 SALOMEDSImpl_GenericVariable::STRING_VAR);
1557 //============================================================================
1558 /*! Function : IsVariable
1561 //============================================================================
1562 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1565 throw SALOMEDS::Study::StudyInvalidReference();
1567 return _impl->IsVariable(std::string(theVarName));
1570 //============================================================================
1571 /*! Function : GetVariableNames
1574 //============================================================================
1575 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1578 throw SALOMEDS::Study::StudyInvalidReference();
1580 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1582 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1584 int aLen = aVarNames.size();
1585 aResult->length(aLen);
1586 for (int anInd = 0; anInd < aLen; anInd++)
1587 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1589 return aResult._retn();
1592 //============================================================================
1593 /*! Function : RemoveVariable
1596 //============================================================================
1597 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1600 throw SALOMEDS::Study::StudyInvalidReference();
1602 bool res = _impl->RemoveVariable(std::string(theVarName));
1603 if (res && _notifier)
1604 _notifier->modifyNB_Notification(theVarName);
1609 //============================================================================
1610 /*! Function : RenameVariable
1613 //============================================================================
1614 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1617 throw SALOMEDS::Study::StudyInvalidReference();
1619 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1620 if (res && _notifier)
1621 _notifier->modifyNB_Notification(theVarName);
1626 //============================================================================
1627 /*! Function : IsVariableUsed
1630 //============================================================================
1631 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1634 throw SALOMEDS::Study::StudyInvalidReference();
1636 return _impl->IsVariableUsed(std::string(theVarName));
1640 //============================================================================
1641 /*! Function : ParseVariables
1644 //============================================================================
1645 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1648 throw SALOMEDS::Study::StudyInvalidReference();
1650 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1652 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1654 int aSectionsLen = aSections.size();
1655 aResult->length(aSectionsLen);
1657 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1658 std::vector<std::string> aVarNames = aSections[aSectionInd];
1660 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1662 int aLen = aVarNames.size();
1663 aList->length(aLen);
1665 for (int anInd = 0; anInd < aLen; anInd++)
1666 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1668 aResult[aSectionInd] = aList;
1671 return aResult._retn();
1674 //============================================================================
1675 /*! Function : GetDefaultScript
1678 //============================================================================
1679 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1681 SALOMEDS::Locker lock;
1684 throw SALOMEDS::Study::StudyInvalidReference();
1686 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1687 return CORBA::string_dup(script.c_str());
1690 //============================================================================
1691 /*! Function : EnableUseCaseAutoFilling
1694 //============================================================================
1695 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1698 throw SALOMEDS::Study::StudyInvalidReference();
1700 _impl->EnableUseCaseAutoFilling(isEnabled);
1701 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1704 builder->SetOnAddSObject(_impl->GetCallback());
1705 builder->SetOnRemoveSObject(_impl->GetCallback());
1708 builder->SetOnAddSObject(NULL);
1709 builder->SetOnRemoveSObject(NULL);
1715 CORBA::Long SALOMEDS_Study_i::getPID()
1718 return (CORBA::Long)_getpid();
1720 return (CORBA::Long)getpid();
1724 void SALOMEDS_Study_i::ShutdownWithExit()
1726 exit( EXIT_SUCCESS );
1729 void SALOMEDS_Study_i::Shutdown()
1731 if(!CORBA::is_nil(_orb))
1735 //============================================================================
1736 /*! Function : attach
1737 * Purpose : This function attach an observer to the study
1739 //============================================================================
1740 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1743 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1747 //============================================================================
1748 /*! Function : detach
1749 * Purpose : This function detaches an observer from the study
1751 //============================================================================
1752 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1755 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1758 //===========================================================================
1759 // PRIVATE FUNCTIONS
1760 //===========================================================================
1761 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1764 long pid = (long)_getpid();
1766 long pid = (long)getpid();
1768 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1769 return reinterpret_cast<CORBA::LongLong>(_impl);