1 // Copyright (C) 2007-2021 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"
54 #include "SALOME_Fake_NamingService.hxx"
61 #include <sys/types.h>
65 UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception)
66 UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection)
68 static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
70 static PortableServer::POA_var _poa;
71 static SALOMEDS::Study_var _study;
74 * Return a unique study obj but servant is embeded here.
77 SALOMEDS::Study_ptr KERNEL::getStudyServantSA()
79 if(CORBA::is_nil(_study))
81 _study = retrieveNewStudyServantSA();
83 return SALOMEDS::Study::_duplicate(_study);
86 SALOMEDS::Study_var KERNEL::retrieveNewStudyServantSA()
88 CORBA::ORB_ptr orb = KERNEL::getORB();
89 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
90 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
91 if(CORBA::is_nil(_poa))
93 SALOME_Fake_NamingService *ns = new SALOME_Fake_NamingService;
94 SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb,ns);
95 SALOMEDS::Study_var study = servant->_this();
96 servant->_remove_ref();
100 void KERNEL::killStudyServantSA()
102 if( ! CORBA::is_nil(_study) )
104 PortableServer::ServantBase *serv = nullptr;
107 serv = _poa->reference_to_servant(_study);
108 PortableServer::ObjectId_var anObjectId = _poa->servant_to_id(serv);
109 _poa->deactivate_object(anObjectId);
115 _study = SALOMEDS::Study::_nil();
119 * If a study is already built and activated elsewhere (for example in GUI context)
121 void KERNEL::setStudyServantSA(SALOMEDS::Study_var study, PortableServer::POA_var poa)
124 setStudyServantSA(study);
127 void KERNEL::setStudyServantSA(SALOMEDS::Study_var study)
129 killStudyServantSA();
135 class Notifier: public SALOMEDSImpl_AbstractCallback
138 Notifier(CORBA::ORB_ptr orb)
140 _orb = CORBA::ORB::_duplicate(orb);
143 //============================================================================
144 /*! Function : addSO_Notification
145 * Purpose : This function tells all the observers that a SO has been added
147 //============================================================================
149 virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject)
151 std::string anID=theSObject.GetID();
152 const char* cID=anID.c_str();
153 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
155 it->first->notifyObserverID(cID,1);
157 return true; // NGE return always true but can be modified if needed
160 //============================================================================
161 /*! Function : removeSO_Notification
162 * Purpose : This function tells all the observers that a SO has been removed
164 //============================================================================
166 virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject)
168 std::string anID=theSObject.GetID();
169 const char* cID=anID.c_str();
170 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
172 it->first->notifyObserverID(cID,2);
174 return true; // NGE return always true but can be modified if needed
177 //============================================================================
178 /*! Function : modifySO_Notification
179 * Purpose : This function tells all the observers that a SO has been modified
181 //============================================================================
183 virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason)
185 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
189 std::string anID=theSObject.GetID();
190 const char* cID=anID.c_str();
191 it->first->notifyObserverID(cID,reason);
194 return true; // NGE return always true but can be modified if needed
197 //============================================================================
198 /*! Function : modifyNB_Notification
199 * Purpose : This function tells all the observers that
200 * a NoteBook variable has been added/modified/removed.
202 //============================================================================
204 virtual bool modifyNB_Notification(const char* theVarName)
206 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
208 it->first->notifyObserverID(theVarName,6);
210 return true; // NGE return always true but can be modified if needed
213 //============================================================================
214 /*! Function : attach
215 * Purpose : register an Observer
217 //============================================================================
219 virtual void attach(SALOMEDS::Observer_ptr theObs, bool modify)
221 myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
224 //============================================================================
225 /*! Function : detach
226 * Purpose : unregister an Observer
228 //============================================================================
230 virtual void detach(SALOMEDS::Observer_ptr theObs)
232 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
234 if ( it->first->_is_equivalent(theObs) ) {
235 myObservers.erase( it );
242 typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
243 typedef ObsList::iterator ObsListIter;
248 class GenObjRegister: public SALOMEDSImpl_AbstractCallback
251 GenObjRegister(CORBA::ORB_ptr orb)
253 _orb = CORBA::ORB::_duplicate(orb);
255 virtual void RegisterGenObj (const std::string& theIOR)
259 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
260 if ( obj->_non_existent() ) return;
261 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
262 if(! CORBA::is_nil(gobj) )
267 catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
271 virtual void UnRegisterGenObj(const std::string& theIOR)
275 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
276 if ( obj->_non_existent() ) return;
277 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
278 if(! CORBA::is_nil(gobj) )
283 catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
293 //================================================================================
295 * \brief emitMessageOneWay to SALOME::Session
297 //================================================================================
299 void sendMessageToGUIGivenSession(SALOME::Session_ptr session, const char* msg )
301 if ( !CORBA::is_nil(session) ) {
303 session->emitMessageOneWay( msg );
308 //================================================================================
310 * \brief emitMessageOneWay to SALOME::Session
312 //================================================================================
314 void sendMessageToGUI(SALOME_NamingService_Abstract *aNamingService, const char* msg)
316 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
317 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
318 sendMessageToGUIGivenSession(aSession,msg);
321 } // namespace SALOMEDS
323 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME_NamingService_Abstract *ns)
325 _ns = ns==nullptr?KERNEL::getNamingService():ns;
326 _orb = CORBA::ORB::_duplicate(orb);
327 _impl = new SALOMEDSImpl_Study();
328 _factory = new SALOMEDS_DriverFactory_i(_orb,_ns);
330 CORBA::Object_var obj = _ns->Resolve("/Kernel/Session");
331 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
335 //============================================================================
336 /*! Function : SALOMEDS_Study_i
337 * Purpose : SALOMEDS_Study_i constructor
339 //============================================================================
340 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME::Session_ptr session)
342 _ns = KERNEL::getNamingService();
343 _orb = CORBA::ORB::_duplicate(orb);
344 _impl = new SALOMEDSImpl_Study();
345 _factory = new SALOMEDS_DriverFactory_i(_orb,!CORBA::is_nil(session));
351 //============================================================================
352 /*! Function : ~SALOMEDS_Study_i
353 * Purpose : SALOMEDS_Study_i destructor
355 //============================================================================
356 SALOMEDS_Study_i::~SALOMEDS_Study_i()
361 //_ns is owned by SALOMEDS_Study_i only if IsTrueNS() returns false
367 void SALOMEDS_Study_i::Init()
369 CORBA::Object_var obj = _ns->Resolve("/Kernel/Session");
370 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
374 //============================================================================
376 * Purpose : Initialize study components
378 //============================================================================
379 void SALOMEDS_Study_i::Init(SALOME::Session_ptr session)
382 //throw SALOMEDS::Study::StudyInvalidReference();
385 SALOMEDS::Locker lock;
387 if ( !_impl->GetDocument() )
390 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
391 _notifier = new SALOMEDS::Notifier(_orb);
392 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
395 _impl->setNotifier(_notifier);
396 _impl->setGenObjRegister( _genObjRegister );
398 // Notify GUI that study was created
399 SALOMEDS::sendMessageToGUIGivenSession( session, "studyCreated" );
401 // update desktop title with new study name
402 NameChanged(session);
405 //============================================================================
407 * Purpose : Clear study components
409 //============================================================================
410 void SALOMEDS_Study_i::Clear()
415 SALOMEDS::Locker lock;
417 //delete the builder servant
418 PortableServer::POA_var poa=_default_POA();
419 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
420 poa->deactivate_object(anObjectId.in());
421 _builder->_remove_ref();
425 if (_impl->GetDocument()) {
426 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
427 for (; itcomponent->More(); itcomponent->Next()) {
428 SALOMEDS::SComponent_var sco = itcomponent->Value();
429 CORBA::String_var compodatatype=sco->ComponentDataType();
430 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
431 // if there is an associated Engine call its method for closing
432 CORBA::String_var IOREngine;
433 if (sco->ComponentIOR(IOREngine)) {
434 // we have found the associated engine to write the data
435 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
436 //_narrow can throw a corba exception
438 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
439 if (!CORBA::is_nil(obj)) {
440 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
441 if (!anEngine->_is_nil()) {
443 anEngine->Close(sco);
448 catch (CORBA::Exception&) {
454 //Does not need any more this iterator
455 itcomponent->UnRegister();
458 // Notify GUI that study is cleared
459 SALOMEDS::sendMessageToGUI( _ns, "studyCleared" );
462 _impl->setNotifier(0);
464 delete _genObjRegister;
470 //============================================================================
472 \brief Get default POA for the servant object.
474 This function is implicitly called from "_this()" function.
475 Default POA can be set via the constructor.
477 \return reference to the default POA for the servant
479 //============================================================================
480 PortableServer::POA_ptr SALOMEDS_Study_i::_default_POA()
482 PortableServer::POA_ptr poa = GetThePOA();
483 MESSAGE("SALOMEDS_Study_i::_default_POA: " << poa);
484 return PortableServer::POA::_duplicate(poa);
487 //============================================================================
489 * Purpose : Open a Study from it's persistent reference
491 //============================================================================
492 bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
498 SALOMEDS::Locker lock;
500 Unexpect aCatch(SalomeException);
501 MESSAGE("Begin of SALOMEDS_Study_i::Open");
502 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
503 bool res = _impl->Open( aUrl );
505 // update desktop title with new study name
507 SALOMEDS::sendMessageToGUI( _ns, "connect_to_study" );
510 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
514 //============================================================================
515 /*! Function : CanOpen
516 * Purpose : Check that a Study can be opened
518 //============================================================================
519 bool SALOMEDS_Study_i::CanOpen(const wchar_t* aWUrl)
521 SALOMEDS::Locker lock;
523 Unexpect aCatch(SalomeException);
524 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
526 return SALOMEDSImpl_Study().Open( aUrl );
529 PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA()
534 void SALOMEDS_Study_i::SetThePOA(PortableServer::POA_ptr thePOA)
536 _poa = PortableServer::POA::_duplicate(thePOA);
539 //============================================================================
541 * Purpose : Save a Study to it's persistent reference
543 //============================================================================
544 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
546 SALOMEDS::Locker lock;
548 throw SALOMEDS::Study::StudyInvalidReference();
549 return _impl->Save(_factory, theMultiFile, theASCII);
552 //=============================================================================
553 /*! Function : SaveAs
554 * Purpose : Save a study to the persistent reference aUrl
556 //============================================================================
557 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const wchar_t* aWUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
559 SALOMEDS::Locker lock;
561 throw SALOMEDS::Study::StudyInvalidReference();
563 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
564 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
567 //============================================================================
568 /*! Function : CanCopy
571 //============================================================================
572 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
574 SALOMEDS::Locker lock;
576 throw SALOMEDS::Study::StudyInvalidReference();
578 CORBA::String_var anID = theObject->GetID();
579 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
581 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
582 bool ret = _impl->CanCopy(anObject, aDriver);
587 //============================================================================
591 //============================================================================
592 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
594 SALOMEDS::Locker lock;
596 throw SALOMEDS::Study::StudyInvalidReference();
598 CORBA::String_var anID = theObject->GetID();
599 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
601 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
602 bool ret = _impl->Copy(anObject, aDriver);
607 //============================================================================
608 /*! Function : CanPaste
611 //============================================================================
612 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
614 SALOMEDS::Locker lock;
616 throw SALOMEDS::Study::StudyInvalidReference();
618 CORBA::String_var anID = theObject->GetID();
619 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
621 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
622 bool ret = _impl->CanPaste(anObject, aDriver);
627 //============================================================================
631 //============================================================================
632 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
635 SALOMEDS::Locker lock;
637 Unexpect aCatch(LockProtection);
639 CORBA::String_var anID = theObject->GetID();
640 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
641 SALOMEDSImpl_SObject aNewSO;
644 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
645 aNewSO = _impl->Paste(anObject, aDriver);
649 throw SALOMEDS::StudyBuilder::LockProtection();
652 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
656 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
658 SALOMEDS_Driver_i* driver = NULL;
660 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
662 std::string IOREngine = aSCO.GetIOR();
663 if(!IOREngine.empty()) {
664 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
665 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
666 driver = new SALOMEDS_Driver_i(Engine, orb);
673 //============================================================================
674 /*! Function : GetPersistentReference
675 * Purpose : Get persistent reference of study (idem URL())
677 //============================================================================
678 char* SALOMEDS_Study_i::GetPersistentReference()
680 SALOMEDS::Locker lock;
682 throw SALOMEDS::Study::StudyInvalidReference();
683 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
686 //============================================================================
687 /*! Function : IsEmpty
688 * Purpose : Detect if study is empty
690 //============================================================================
691 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
693 SALOMEDS::Locker lock;
695 throw SALOMEDS::Study::StudyInvalidReference();
696 return _impl->IsEmpty();
699 //============================================================================
700 /*! Function : FindComponent
701 * Purpose : Find a Component with ComponentDataType = aComponentName
703 //============================================================================
704 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
706 SALOMEDS::Locker lock;
709 throw SALOMEDS::Study::StudyInvalidReference();
711 SALOMEDS::SComponent_var sco;
713 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
714 if (!aCompImpl.IsNull())
715 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
720 //============================================================================
721 /*! Function : FindComponentID
722 * Purpose : Find a Component from it's ID
724 //============================================================================
725 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
727 SALOMEDS::Locker lock;
730 throw SALOMEDS::Study::StudyInvalidReference();
732 SALOMEDS::SComponent_var sco;
734 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
735 if (!aCompImpl.IsNull())
736 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
741 //============================================================================
742 /*! Function : FindObject
743 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
745 //============================================================================
746 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
748 SALOMEDS::Locker lock;
751 throw SALOMEDS::Study::StudyInvalidReference();
753 SALOMEDS::SObject_var so;
755 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
757 if (aSO.IsComponent()) {
758 SALOMEDSImpl_SComponent aSCO = aSO;
759 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
762 so = SALOMEDS_SObject_i::New(aSO, _orb);
769 //============================================================================
770 /*! Function : FindObjectID
771 * Purpose : Find an Object with ID = anObjectID
773 //============================================================================
774 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
776 SALOMEDS::Locker lock;
779 throw SALOMEDS::Study::StudyInvalidReference();
781 SALOMEDS::SObject_var so;
783 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
785 so = SALOMEDS_SObject_i::New(aSO, _orb);
790 //============================================================================
791 /*! Function : CreateObjectID
792 * Purpose : Creates an Object with ID = anObjectID
794 //============================================================================
795 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
797 SALOMEDS::Locker lock;
800 throw SALOMEDS::Study::StudyInvalidReference();
802 SALOMEDS::SObject_var so;
804 if (anObjectID && strlen(anObjectID) > 0) {
805 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
807 so = SALOMEDS_SObject_i::New(aSO, _orb);
813 //============================================================================
814 /*! Function : FindObjectByName
815 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
816 * : with ComponentDataType = aComponentName
818 //============================================================================
819 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
820 const char* aComponentName )
822 SALOMEDS::Locker lock;
825 throw SALOMEDS::Study::StudyInvalidReference();
827 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
828 std::string((char*)aComponentName));
830 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
831 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
832 listSO->length(aLength);
833 for (int i = 0; i < aLength; i++) {
834 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
838 return listSO._retn();
841 //============================================================================
842 /*! Function : FindObjectIOR
843 * Purpose : Find an Object with IOR = anObjectIOR
845 //============================================================================
846 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
848 SALOMEDS::Locker lock;
851 throw SALOMEDS::Study::StudyInvalidReference();
853 SALOMEDS::SObject_var so;
855 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
857 so = SALOMEDS_SObject_i::New(aSO, _orb);
862 //============================================================================
863 /*! Function : FindObjectByPath
864 * Purpose : Find an Object by its path = thePath
866 //============================================================================
867 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
869 SALOMEDS::Locker lock;
872 throw SALOMEDS::Study::StudyInvalidReference();
874 SALOMEDS::SObject_var so;
876 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
878 so = SALOMEDS_SObject_i::New (aSO, _orb);
883 //============================================================================
884 /*! Function : GetObjectPath
887 //============================================================================
888 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
890 SALOMEDS::Locker lock;
893 throw SALOMEDS::Study::StudyInvalidReference();
895 std::string aPath = "";
897 if (!CORBA::is_nil(theObject)) {
898 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
899 SALOMEDSImpl_SObject aSO;
901 if (!CORBA::is_nil(aSObj)) {
902 aSO = _impl->FindObjectID(aSObj->GetID());
905 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
909 aPath = _impl->GetObjectPath(aSO);
913 return CORBA::string_dup(aPath.c_str());
916 //============================================================================
917 /*! Function : NewChildIterator
918 * Purpose : Create a ChildIterator from an SObject
920 //============================================================================
921 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
923 SALOMEDS::Locker lock;
926 throw SALOMEDS::Study::StudyInvalidReference();
928 CORBA::String_var anID = theSO->GetID();
929 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
930 SALOMEDSImpl_ChildIterator anItr(aSO);
931 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
932 SALOMEDS::ChildIterator_var it = it_servant->_this();
938 //============================================================================
939 /*! Function : NewComponentIterator
940 * Purpose : Create a SComponentIterator
942 //============================================================================
943 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
945 SALOMEDS::Locker lock;
948 throw SALOMEDS::Study::StudyInvalidReference();
950 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
952 SALOMEDS::SComponentIterator_var it = it_servant->_this();
958 //============================================================================
959 /*! Function : NewBuilder
960 * Purpose : Create a StudyBuilder
962 //============================================================================
963 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
965 SALOMEDS::Locker lock;
968 throw SALOMEDS::Study::StudyInvalidReference();
970 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
975 //============================================================================
977 * Purpose : get study name
979 //============================================================================
980 wchar_t* SALOMEDS_Study_i::Name()
982 SALOMEDS::Locker lock;
983 // Name is specified as IDL attribute: user exception cannot be raised
984 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->Name()));
987 //============================================================================
989 * Purpose : set study name
991 //============================================================================
992 void SALOMEDS_Study_i::Name(const wchar_t* wname)
994 SALOMEDS::Locker lock;
995 // Name is specified as IDL attribute: user exception cannot be raised
996 _impl->Name(Kernel_Utils::encode_s(wname));
999 //============================================================================
1000 /*! Function : IsSaved
1001 * Purpose : get if study has been saved
1003 //============================================================================
1004 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1006 SALOMEDS::Locker lock;
1007 // IsSaved is specified as IDL attribute: user exception cannot be raised
1008 return (!_closed) ? _impl->IsSaved() : false;
1011 //============================================================================
1012 /*! Function : IsSaved
1013 * Purpose : set if study has been saved
1015 //============================================================================
1016 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1018 SALOMEDS::Locker lock;
1019 // IsSaved is specified as IDL attribute: user exception cannot be raised
1021 _impl->IsSaved(save);
1024 //============================================================================
1025 /*! Function : IsModified
1026 * Purpose : Detect if a Study has been modified since it has been saved
1028 //============================================================================
1029 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1031 SALOMEDS::Locker lock;
1034 throw SALOMEDS::Study::StudyInvalidReference();
1036 return _impl->IsModified();
1039 //============================================================================
1040 /*! Function : Modified
1041 * Purpose : Sets a Modified flag of a Study to True
1043 //============================================================================
1044 void SALOMEDS_Study_i::Modified()
1046 SALOMEDS::Locker lock;
1049 throw SALOMEDS::Study::StudyInvalidReference();
1054 //============================================================================
1056 * Purpose : get URL of the study (persistent reference of the study)
1058 //============================================================================
1059 wchar_t* SALOMEDS_Study_i::URL()
1061 SALOMEDS::Locker lock;
1062 // URL is specified as IDL attribute: user exception cannot be raised
1063 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->URL()));
1066 //============================================================================
1068 * Purpose : set URL of the study (persistent reference of the study)
1070 //============================================================================
1071 void SALOMEDS_Study_i::URL(const wchar_t* wurl)
1073 SALOMEDS::Locker lock;
1074 // URL is specified as IDL attribute: user exception cannot be raised
1075 _impl->URL(Kernel_Utils::encode_s(wurl));
1077 // update desktop title with new study name
1078 CORBA::Object_var obj = _ns->Resolve("/Kernel/Session");
1079 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1080 NameChanged(aSession);
1083 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1085 SALOMEDS::Locker lock;
1088 throw SALOMEDS::Study::StudyInvalidReference();
1090 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1093 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1095 SALOMEDS::Locker lock;
1096 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1099 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1101 SALOMEDS::Locker lock;
1104 throw SALOMEDS::Study::StudyInvalidReference();
1106 SALOMEDS::GenericAttribute_ptr aTarget;
1107 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1108 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1110 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1116 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1118 SALOMEDS::Locker lock;
1121 throw SALOMEDS::Study::StudyInvalidReference();
1123 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1124 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1125 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1126 return aProp._retn();
1129 char* SALOMEDS_Study_i::GetLastModificationDate()
1131 SALOMEDS::Locker lock;
1134 throw SALOMEDS::Study::StudyInvalidReference();
1136 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1139 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1141 SALOMEDS::Locker lock;
1144 throw SALOMEDS::Study::StudyInvalidReference();
1146 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1148 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1150 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1151 aDates->length(aLength);
1152 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1153 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1156 return aDates._retn();
1159 //============================================================================
1160 /*! Function : GetUseCaseBuilder
1161 * Purpose : Returns a UseCase builder
1163 //============================================================================
1164 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1166 SALOMEDS::Locker lock;
1169 throw SALOMEDS::Study::StudyInvalidReference();
1171 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1172 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1176 //============================================================================
1177 /*! Function : AddPostponed
1180 //============================================================================
1181 void SALOMEDS_Study_i::AddPostponed(const char* /*theIOR*/)
1183 SALOMEDS::Locker lock;
1187 void SALOMEDS_Study_i::AddCreatedPostponed(const char* /*theIOR*/)
1189 SALOMEDS::Locker lock;
1193 //============================================================================
1194 /*! Function : RemovePostponed
1197 //============================================================================
1198 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1200 SALOMEDS::Locker lock;
1203 throw SALOMEDS::Study::StudyInvalidReference();
1205 std::vector<std::string> anIORs = _impl->GetIORs();
1206 int i, aSize = (int)anIORs.size();
1208 for (i = 0; i < aSize; i++) {
1210 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1211 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1212 //rnv: To avoid double deletion of the Salome Generic Objects:
1213 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1214 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1215 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1222 //============================================================================
1223 /*! Function : UndoPostponed
1226 //============================================================================
1227 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long /*theWay*/)
1229 SALOMEDS::Locker lock;
1234 //============================================================================
1235 /*! Function : DumpStudy
1238 //============================================================================
1239 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1240 const char* theBaseName,
1241 CORBA::Boolean isPublished,
1242 CORBA::Boolean isMultiFile)
1244 SALOMEDS::Locker lock;
1247 throw SALOMEDS::Study::StudyInvalidReference();
1249 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1252 std::unique_ptr<SALOMEDS_DriverFactory_i> factory( new SALOMEDS_DriverFactory_i(_orb,_factory->getNS()) );
1253 ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory.get());
1258 //============================================================================
1259 /*! Function : GetDumpPath
1262 //============================================================================
1263 char* SALOMEDS_Study_i::GetDumpPath()
1265 return CORBA::string_dup(_impl->GetDumpPath().c_str());
1268 //============================================================================
1269 /*! Function : GetCommonParameters
1272 //============================================================================
1273 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1275 SALOMEDS::Locker lock;
1278 throw SALOMEDS::Study::StudyInvalidReference();
1280 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1281 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1282 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1284 return aParam._retn();
1287 //============================================================================
1288 /*! Function : GetCommonModuleParameters
1291 //============================================================================
1292 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1293 const char* theModuleName,
1294 CORBA::Long theSavePoint)
1296 SALOMEDS::Locker lock;
1299 throw SALOMEDS::Study::StudyInvalidReference();
1301 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1302 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1303 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1305 return aParam._retn();
1308 //============================================================================
1309 /*! Function : SetStudyLock
1312 //============================================================================
1313 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1315 SALOMEDS::Locker lock;
1318 throw SALOMEDS::Study::StudyInvalidReference();
1320 _impl->SetStudyLock(theLockerID);
1323 //============================================================================
1324 /*! Function : IsStudyLocked
1327 //============================================================================
1328 bool SALOMEDS_Study_i::IsStudyLocked()
1330 SALOMEDS::Locker lock;
1333 throw SALOMEDS::Study::StudyInvalidReference();
1335 return _impl->IsStudyLocked();
1338 //============================================================================
1339 /*! Function : UnLockStudy
1342 //============================================================================
1343 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1345 SALOMEDS::Locker lock;
1348 throw SALOMEDS::Study::StudyInvalidReference();
1350 _impl->UnLockStudy(theLockerID);
1353 //============================================================================
1354 /*! Function : GetLockerID
1357 //============================================================================
1358 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1360 SALOMEDS::Locker lock;
1363 throw SALOMEDS::Study::StudyInvalidReference();
1365 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1367 std::vector<std::string> aSeq = _impl->GetLockerID();
1369 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1370 aResult->length(aLength);
1371 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1372 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1375 return aResult._retn();
1377 //============================================================================
1378 /*! Function : SetReal
1381 //============================================================================
1382 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1385 throw SALOMEDS::Study::StudyInvalidReference();
1388 _impl->SetVariable(std::string(theVarName),
1390 SALOMEDSImpl_GenericVariable::REAL_VAR);
1392 _notifier->modifyNB_Notification(theVarName);
1395 //============================================================================
1396 /*! Function : SetInteger
1399 //============================================================================
1400 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1403 throw SALOMEDS::Study::StudyInvalidReference();
1405 _impl->SetVariable(std::string(theVarName),
1407 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1409 _notifier->modifyNB_Notification(theVarName);
1412 //============================================================================
1413 /*! Function : SetBoolean
1416 //============================================================================
1417 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1420 throw SALOMEDS::Study::StudyInvalidReference();
1422 _impl->SetVariable(std::string(theVarName),
1424 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1426 _notifier->modifyNB_Notification(theVarName);
1429 //============================================================================
1430 /*! Function : SetString
1433 //============================================================================
1434 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1437 throw SALOMEDS::Study::StudyInvalidReference();
1439 _impl->SetStringVariable(std::string(theVarName),
1441 SALOMEDSImpl_GenericVariable::STRING_VAR);
1443 _notifier->modifyNB_Notification(theVarName);
1446 //============================================================================
1447 /*! Function : SetStringAsDouble
1450 //============================================================================
1451 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1454 throw SALOMEDS::Study::StudyInvalidReference();
1456 _impl->SetStringVariableAsDouble(std::string(theVarName),
1458 SALOMEDSImpl_GenericVariable::STRING_VAR);
1461 //============================================================================
1462 /*! Function : GetReal
1465 //============================================================================
1466 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1469 throw SALOMEDS::Study::StudyInvalidReference();
1471 return _impl->GetVariableValue(std::string(theVarName));
1474 //============================================================================
1475 /*! Function : GetInteger
1478 //============================================================================
1479 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1482 throw SALOMEDS::Study::StudyInvalidReference();
1484 return (long)_impl->GetVariableValue(std::string(theVarName));
1487 //============================================================================
1488 /*! Function : GetBoolean
1491 //============================================================================
1492 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1495 throw SALOMEDS::Study::StudyInvalidReference();
1497 return (bool)_impl->GetVariableValue(std::string(theVarName));
1500 //============================================================================
1501 /*! Function : GetString
1504 //============================================================================
1505 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1508 throw SALOMEDS::Study::StudyInvalidReference();
1510 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1513 //============================================================================
1514 /*! Function : IsReal
1517 //============================================================================
1518 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1521 throw SALOMEDS::Study::StudyInvalidReference();
1523 return _impl->IsTypeOf(std::string(theVarName),
1524 SALOMEDSImpl_GenericVariable::REAL_VAR);
1527 //============================================================================
1528 /*! Function : IsInteger
1531 //============================================================================
1532 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1535 throw SALOMEDS::Study::StudyInvalidReference();
1537 return _impl->IsTypeOf(std::string(theVarName),
1538 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1541 //============================================================================
1542 /*! Function : IsBoolean
1545 //============================================================================
1546 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1549 throw SALOMEDS::Study::StudyInvalidReference();
1551 return _impl->IsTypeOf(std::string(theVarName),
1552 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1555 //============================================================================
1556 /*! Function : IsString
1559 //============================================================================
1560 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1563 throw SALOMEDS::Study::StudyInvalidReference();
1565 return _impl->IsTypeOf(std::string(theVarName),
1566 SALOMEDSImpl_GenericVariable::STRING_VAR);
1569 //============================================================================
1570 /*! Function : IsVariable
1573 //============================================================================
1574 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1577 throw SALOMEDS::Study::StudyInvalidReference();
1579 return _impl->IsVariable(std::string(theVarName));
1582 //============================================================================
1583 /*! Function : GetVariableNames
1586 //============================================================================
1587 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1590 throw SALOMEDS::Study::StudyInvalidReference();
1592 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1594 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1596 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1597 aResult->length(aLen);
1598 for (int anInd = 0; anInd < aLen; anInd++)
1599 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1601 return aResult._retn();
1604 //============================================================================
1605 /*! Function : RemoveVariable
1608 //============================================================================
1609 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1612 throw SALOMEDS::Study::StudyInvalidReference();
1614 bool res = _impl->RemoveVariable(std::string(theVarName));
1615 if (res && _notifier)
1616 _notifier->modifyNB_Notification(theVarName);
1621 //============================================================================
1622 /*! Function : RenameVariable
1625 //============================================================================
1626 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1629 throw SALOMEDS::Study::StudyInvalidReference();
1631 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1632 if (res && _notifier)
1633 _notifier->modifyNB_Notification(theVarName);
1638 //============================================================================
1639 /*! Function : IsVariableUsed
1642 //============================================================================
1643 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1646 throw SALOMEDS::Study::StudyInvalidReference();
1648 return _impl->IsVariableUsed(std::string(theVarName));
1652 //============================================================================
1653 /*! Function : ParseVariables
1656 //============================================================================
1657 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1660 throw SALOMEDS::Study::StudyInvalidReference();
1662 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1664 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1666 int aSectionsLen = (int)aSections.size(); //!< TODO: conversion from size_t to int
1667 aResult->length(aSectionsLen);
1669 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1670 std::vector<std::string> aVarNames = aSections[aSectionInd];
1672 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1674 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1675 aList->length(aLen);
1677 for (int anInd = 0; anInd < aLen; anInd++)
1678 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1680 aResult[aSectionInd] = aList;
1683 return aResult._retn();
1686 //============================================================================
1687 /*! Function : GetDefaultScript
1690 //============================================================================
1691 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1693 SALOMEDS::Locker lock;
1696 throw SALOMEDS::Study::StudyInvalidReference();
1698 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1699 return CORBA::string_dup(script.c_str());
1702 //============================================================================
1703 /*! Function : EnableUseCaseAutoFilling
1706 //============================================================================
1707 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1710 throw SALOMEDS::Study::StudyInvalidReference();
1712 _impl->EnableUseCaseAutoFilling(isEnabled);
1713 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1716 builder->SetOnAddSObject(_impl->GetCallback());
1717 builder->SetOnRemoveSObject(_impl->GetCallback());
1720 builder->SetOnAddSObject(NULL);
1721 builder->SetOnRemoveSObject(NULL);
1727 CORBA::Long SALOMEDS_Study_i::getPID()
1730 return (CORBA::Long)_getpid();
1732 return (CORBA::Long)getpid();
1736 void SALOMEDS_Study_i::ShutdownWithExit()
1738 exit( EXIT_SUCCESS );
1741 void SALOMEDS_Study_i::Shutdown()
1743 if(!CORBA::is_nil(_orb))
1745 _closed = true; // force 'closed' flag to avoid terminating
1748 //============================================================================
1749 /*! Function : attach
1750 * Purpose : This function attach an observer to the study
1752 //============================================================================
1753 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1756 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1760 //============================================================================
1761 /*! Function : detach
1762 * Purpose : This function detaches an observer from the study
1764 //============================================================================
1765 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1768 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1771 //===========================================================================
1772 // PRIVATE FUNCTIONS
1773 //===========================================================================
1774 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1777 long pid = (long)_getpid();
1779 long pid = (long)getpid();
1781 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1782 return reinterpret_cast<CORBA::LongLong>(_impl);
1785 void SALOMEDS_Study_i::NameChanged(SALOME::Session_ptr session)
1788 SALOMEDS::sendMessageToGUIGivenSession(session,"studyNameChanged" );