1 // Copyright (C) 2007-2023 CEA, EDF, 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();
421 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
422 poa->deactivate_object(anObjectId.in());
423 _builder->_remove_ref();
425 catch(const CORBA::OBJECT_NOT_EXIST&)
431 if (_impl->GetDocument()) {
432 std::unique_ptr<SALOMEDS_SComponentIterator_i> itcomponent ( NewComponentIteratorImpl() );
433 for (; itcomponent->More(); itcomponent->Next()) {
434 SALOMEDS::SComponent_var sco = itcomponent->Value();
435 CORBA::String_var compodatatype=sco->ComponentDataType();
436 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
437 // if there is an associated Engine call its method for closing
438 CORBA::String_var IOREngine;
439 if (sco->ComponentIOR(IOREngine)) {
440 // we have found the associated engine to write the data
441 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
442 //_narrow can throw a corba exception
444 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
445 if (!CORBA::is_nil(obj)) {
446 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
447 if (!anEngine->_is_nil()) {
449 anEngine->Close(sco);
454 catch (CORBA::Exception&) {
461 // Notify GUI that study is cleared
462 SALOMEDS::sendMessageToGUI( _ns, "studyCleared" );
465 _impl->setNotifier(0);
467 delete _genObjRegister;
473 //============================================================================
475 \brief Get default POA for the servant object.
477 This function is implicitly called from "_this()" function.
478 Default POA can be set via the constructor.
480 \return reference to the default POA for the servant
482 //============================================================================
483 PortableServer::POA_ptr SALOMEDS_Study_i::_default_POA()
485 PortableServer::POA_ptr poa = GetThePOA();
486 MESSAGE("SALOMEDS_Study_i::_default_POA: " << poa);
487 return PortableServer::POA::_duplicate(poa);
490 //============================================================================
492 * Purpose : Open a Study from it's persistent reference
494 //============================================================================
495 bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
501 SALOMEDS::Locker lock;
503 Unexpect aCatch(SalomeException);
504 MESSAGE("Begin of SALOMEDS_Study_i::Open");
505 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
506 bool res = _impl->Open( aUrl );
508 // update desktop title with new study name
510 SALOMEDS::sendMessageToGUI( _ns, "connect_to_study" );
513 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
517 //============================================================================
518 /*! Function : CanOpen
519 * Purpose : Check that a Study can be opened
521 //============================================================================
522 bool SALOMEDS_Study_i::CanOpen(const wchar_t* aWUrl)
524 SALOMEDS::Locker lock;
526 Unexpect aCatch(SalomeException);
527 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
529 return SALOMEDSImpl_Study().Open( aUrl );
532 PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA()
537 void SALOMEDS_Study_i::SetThePOA(PortableServer::POA_ptr thePOA)
539 _poa = PortableServer::POA::_duplicate(thePOA);
542 //============================================================================
544 * Purpose : Save a Study to it's persistent reference
546 //============================================================================
547 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
549 SALOMEDS::Locker lock;
551 throw SALOMEDS::Study::StudyInvalidReference();
552 return _impl->Save(_factory, theMultiFile, theASCII);
555 //=============================================================================
556 /*! Function : SaveAs
557 * Purpose : Save a study to the persistent reference aUrl
559 //============================================================================
560 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const wchar_t* aWUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
562 SALOMEDS::Locker lock;
564 throw SALOMEDS::Study::StudyInvalidReference();
566 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
567 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
570 //============================================================================
571 /*! Function : CanCopy
574 //============================================================================
575 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
577 SALOMEDS::Locker lock;
579 throw SALOMEDS::Study::StudyInvalidReference();
581 CORBA::String_var anID = theObject->GetID();
582 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
584 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
585 bool ret = _impl->CanCopy(anObject, aDriver);
590 //============================================================================
594 //============================================================================
595 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
597 SALOMEDS::Locker lock;
599 throw SALOMEDS::Study::StudyInvalidReference();
601 CORBA::String_var anID = theObject->GetID();
602 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
604 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
605 bool ret = _impl->Copy(anObject, aDriver);
610 //============================================================================
611 /*! Function : CanPaste
614 //============================================================================
615 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
617 SALOMEDS::Locker lock;
619 throw SALOMEDS::Study::StudyInvalidReference();
621 CORBA::String_var anID = theObject->GetID();
622 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
624 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
625 bool ret = _impl->CanPaste(anObject, aDriver);
630 //============================================================================
634 //============================================================================
635 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
638 SALOMEDS::Locker lock;
640 Unexpect aCatch(LockProtection);
642 CORBA::String_var anID = theObject->GetID();
643 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
644 SALOMEDSImpl_SObject aNewSO;
647 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
648 aNewSO = _impl->Paste(anObject, aDriver);
652 throw SALOMEDS::StudyBuilder::LockProtection();
655 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
659 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
661 SALOMEDS_Driver_i* driver = NULL;
663 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
665 std::string IOREngine = aSCO.GetIOR();
666 if(!IOREngine.empty()) {
667 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
668 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
669 driver = new SALOMEDS_Driver_i(Engine, orb);
676 //============================================================================
677 /*! Function : GetPersistentReference
678 * Purpose : Get persistent reference of study (idem URL())
680 //============================================================================
681 char* SALOMEDS_Study_i::GetPersistentReference()
683 SALOMEDS::Locker lock;
685 throw SALOMEDS::Study::StudyInvalidReference();
686 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
689 //============================================================================
690 /*! Function : IsEmpty
691 * Purpose : Detect if study is empty
693 //============================================================================
694 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
696 SALOMEDS::Locker lock;
698 throw SALOMEDS::Study::StudyInvalidReference();
699 return _impl->IsEmpty();
702 //============================================================================
703 /*! Function : FindComponent
704 * Purpose : Find a Component with ComponentDataType = aComponentName
706 //============================================================================
707 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
709 SALOMEDS::Locker lock;
712 throw SALOMEDS::Study::StudyInvalidReference();
714 SALOMEDS::SComponent_var sco;
716 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
717 if (!aCompImpl.IsNull())
718 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
723 //============================================================================
724 /*! Function : FindComponentID
725 * Purpose : Find a Component from it's ID
727 //============================================================================
728 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
730 SALOMEDS::Locker lock;
733 throw SALOMEDS::Study::StudyInvalidReference();
735 SALOMEDS::SComponent_var sco;
737 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
738 if (!aCompImpl.IsNull())
739 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
744 //============================================================================
745 /*! Function : FindObject
746 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
748 //============================================================================
749 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
751 SALOMEDS::Locker lock;
754 throw SALOMEDS::Study::StudyInvalidReference();
756 SALOMEDS::SObject_var so;
758 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
760 if (aSO.IsComponent()) {
761 SALOMEDSImpl_SComponent aSCO = aSO;
762 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
765 so = SALOMEDS_SObject_i::New(aSO, _orb);
772 //============================================================================
773 /*! Function : FindObjectID
774 * Purpose : Find an Object with ID = anObjectID
776 //============================================================================
777 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
779 SALOMEDS::Locker lock;
782 throw SALOMEDS::Study::StudyInvalidReference();
784 SALOMEDS::SObject_var so;
786 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
788 so = SALOMEDS_SObject_i::New(aSO, _orb);
793 //============================================================================
794 /*! Function : CreateObjectID
795 * Purpose : Creates an Object with ID = anObjectID
797 //============================================================================
798 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
800 SALOMEDS::Locker lock;
803 throw SALOMEDS::Study::StudyInvalidReference();
805 SALOMEDS::SObject_var so;
807 if (anObjectID && strlen(anObjectID) > 0) {
808 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
810 so = SALOMEDS_SObject_i::New(aSO, _orb);
816 //============================================================================
817 /*! Function : FindObjectByName
818 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
819 * : with ComponentDataType = aComponentName
821 //============================================================================
822 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
823 const char* aComponentName )
825 SALOMEDS::Locker lock;
828 throw SALOMEDS::Study::StudyInvalidReference();
830 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
831 std::string((char*)aComponentName));
833 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
834 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
835 listSO->length(aLength);
836 for (int i = 0; i < aLength; i++) {
837 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
841 return listSO._retn();
844 //============================================================================
845 /*! Function : FindObjectIOR
846 * Purpose : Find an Object with IOR = anObjectIOR
848 //============================================================================
849 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
851 SALOMEDS::Locker lock;
854 throw SALOMEDS::Study::StudyInvalidReference();
856 SALOMEDS::SObject_var so;
858 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
860 so = SALOMEDS_SObject_i::New(aSO, _orb);
865 //============================================================================
866 /*! Function : FindObjectByPath
867 * Purpose : Find an Object by its path = thePath
869 //============================================================================
870 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
872 SALOMEDS::Locker lock;
875 throw SALOMEDS::Study::StudyInvalidReference();
877 SALOMEDS::SObject_var so;
879 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
881 so = SALOMEDS_SObject_i::New (aSO, _orb);
886 //============================================================================
887 /*! Function : GetObjectPath
890 //============================================================================
891 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
893 SALOMEDS::Locker lock;
896 throw SALOMEDS::Study::StudyInvalidReference();
898 std::string aPath = "";
900 if (!CORBA::is_nil(theObject)) {
901 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
902 SALOMEDSImpl_SObject aSO;
904 if (!CORBA::is_nil(aSObj)) {
905 aSO = _impl->FindObjectID(aSObj->GetID());
908 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
912 aPath = _impl->GetObjectPath(aSO);
916 return CORBA::string_dup(aPath.c_str());
919 //============================================================================
920 /*! Function : NewChildIterator
921 * Purpose : Create a ChildIterator from an SObject
923 //============================================================================
924 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
926 SALOMEDS::Locker lock;
929 throw SALOMEDS::Study::StudyInvalidReference();
931 CORBA::String_var anID = theSO->GetID();
932 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
933 SALOMEDSImpl_ChildIterator anItr(aSO);
934 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
935 SALOMEDS::ChildIterator_var it = it_servant->_this();
941 SALOMEDS_SComponentIterator_i *SALOMEDS_Study_i::NewComponentIteratorImpl()
943 SALOMEDS::Locker lock;
946 throw SALOMEDS::Study::StudyInvalidReference();
948 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
953 //============================================================================
954 /*! Function : NewComponentIterator
955 * Purpose : Create a SComponentIterator
957 //============================================================================
958 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
960 SALOMEDS_SComponentIterator_i* it_servant = NewComponentIteratorImpl();
961 SALOMEDS::SComponentIterator_var it = it_servant->_this();
966 //============================================================================
967 /*! Function : NewBuilder
968 * Purpose : Create a StudyBuilder
970 //============================================================================
971 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
973 SALOMEDS::Locker lock;
976 throw SALOMEDS::Study::StudyInvalidReference();
978 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
983 //============================================================================
985 * Purpose : get study name
987 //============================================================================
988 wchar_t* SALOMEDS_Study_i::Name()
990 SALOMEDS::Locker lock;
991 // Name is specified as IDL attribute: user exception cannot be raised
992 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->Name()));
995 //============================================================================
997 * Purpose : set study name
999 //============================================================================
1000 void SALOMEDS_Study_i::Name(const wchar_t* wname)
1002 SALOMEDS::Locker lock;
1003 // Name is specified as IDL attribute: user exception cannot be raised
1004 _impl->Name(Kernel_Utils::encode_s(wname));
1007 //============================================================================
1008 /*! Function : IsSaved
1009 * Purpose : get if study has been saved
1011 //============================================================================
1012 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1014 SALOMEDS::Locker lock;
1015 // IsSaved is specified as IDL attribute: user exception cannot be raised
1016 return (!_closed) ? _impl->IsSaved() : false;
1019 //============================================================================
1020 /*! Function : IsSaved
1021 * Purpose : set if study has been saved
1023 //============================================================================
1024 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1026 SALOMEDS::Locker lock;
1027 // IsSaved is specified as IDL attribute: user exception cannot be raised
1029 _impl->IsSaved(save);
1032 //============================================================================
1033 /*! Function : IsModified
1034 * Purpose : Detect if a Study has been modified since it has been saved
1036 //============================================================================
1037 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1039 SALOMEDS::Locker lock;
1042 throw SALOMEDS::Study::StudyInvalidReference();
1044 return _impl->IsModified();
1047 //============================================================================
1048 /*! Function : Modified
1049 * Purpose : Sets a Modified flag of a Study to True
1051 //============================================================================
1052 void SALOMEDS_Study_i::Modified()
1054 SALOMEDS::Locker lock;
1057 throw SALOMEDS::Study::StudyInvalidReference();
1062 //============================================================================
1064 * Purpose : get URL of the study (persistent reference of the study)
1066 //============================================================================
1067 wchar_t* SALOMEDS_Study_i::URL()
1069 SALOMEDS::Locker lock;
1070 // URL is specified as IDL attribute: user exception cannot be raised
1071 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->URL()));
1074 //============================================================================
1076 * Purpose : set URL of the study (persistent reference of the study)
1078 //============================================================================
1079 void SALOMEDS_Study_i::URL(const wchar_t* wurl)
1081 SALOMEDS::Locker lock;
1082 // URL is specified as IDL attribute: user exception cannot be raised
1083 _impl->URL(Kernel_Utils::encode_s(wurl));
1085 // update desktop title with new study name
1086 CORBA::Object_var obj = _ns->Resolve("/Kernel/Session");
1087 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1088 NameChanged(aSession);
1091 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1093 SALOMEDS::Locker lock;
1096 throw SALOMEDS::Study::StudyInvalidReference();
1098 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1101 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1103 SALOMEDS::Locker lock;
1104 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1107 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1109 SALOMEDS::Locker lock;
1112 throw SALOMEDS::Study::StudyInvalidReference();
1114 SALOMEDS::GenericAttribute_ptr aTarget;
1115 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1116 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1118 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1124 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1126 SALOMEDS::Locker lock;
1129 throw SALOMEDS::Study::StudyInvalidReference();
1131 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1132 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1133 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1134 return aProp._retn();
1137 char* SALOMEDS_Study_i::GetLastModificationDate()
1139 SALOMEDS::Locker lock;
1142 throw SALOMEDS::Study::StudyInvalidReference();
1144 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1147 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1149 SALOMEDS::Locker lock;
1152 throw SALOMEDS::Study::StudyInvalidReference();
1154 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1156 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1158 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1159 aDates->length(aLength);
1160 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1161 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1164 return aDates._retn();
1167 //============================================================================
1168 /*! Function : GetUseCaseBuilder
1169 * Purpose : Returns a UseCase builder
1171 //============================================================================
1172 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1174 SALOMEDS::Locker lock;
1177 throw SALOMEDS::Study::StudyInvalidReference();
1179 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1180 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1184 //============================================================================
1185 /*! Function : AddPostponed
1188 //============================================================================
1189 void SALOMEDS_Study_i::AddPostponed(const char* /*theIOR*/)
1191 SALOMEDS::Locker lock;
1195 void SALOMEDS_Study_i::AddCreatedPostponed(const char* /*theIOR*/)
1197 SALOMEDS::Locker lock;
1201 //============================================================================
1202 /*! Function : RemovePostponed
1205 //============================================================================
1206 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1208 SALOMEDS::Locker lock;
1211 throw SALOMEDS::Study::StudyInvalidReference();
1213 std::vector<std::string> anIORs = _impl->GetIORs();
1214 int i, aSize = (int)anIORs.size();
1216 for (i = 0; i < aSize; i++) {
1218 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1219 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1220 //rnv: To avoid double deletion of the Salome Generic Objects:
1221 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1222 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1223 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1230 //============================================================================
1231 /*! Function : UndoPostponed
1234 //============================================================================
1235 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long /*theWay*/)
1237 SALOMEDS::Locker lock;
1242 //============================================================================
1243 /*! Function : DumpStudy
1246 //============================================================================
1247 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1248 const char* theBaseName,
1249 CORBA::Boolean isPublished,
1250 CORBA::Boolean isMultiFile)
1252 SALOMEDS::Locker lock;
1255 throw SALOMEDS::Study::StudyInvalidReference();
1257 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1260 std::unique_ptr<SALOMEDS_DriverFactory_i> factory( new SALOMEDS_DriverFactory_i(_orb,_factory->getNS()) );
1261 ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory.get());
1266 //============================================================================
1267 /*! Function : GetDumpPath
1270 //============================================================================
1271 char* SALOMEDS_Study_i::GetDumpPath()
1273 return CORBA::string_dup(_impl->GetDumpPath().c_str());
1276 //============================================================================
1277 /*! Function : GetCommonParameters
1280 //============================================================================
1281 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1283 SALOMEDS::Locker lock;
1286 throw SALOMEDS::Study::StudyInvalidReference();
1288 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1289 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1290 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1292 return aParam._retn();
1295 //============================================================================
1296 /*! Function : GetCommonModuleParameters
1299 //============================================================================
1300 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1301 const char* theModuleName,
1302 CORBA::Long theSavePoint)
1304 SALOMEDS::Locker lock;
1307 throw SALOMEDS::Study::StudyInvalidReference();
1309 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1310 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1311 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1313 return aParam._retn();
1316 //============================================================================
1317 /*! Function : SetStudyLock
1320 //============================================================================
1321 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1323 SALOMEDS::Locker lock;
1326 throw SALOMEDS::Study::StudyInvalidReference();
1328 _impl->SetStudyLock(theLockerID);
1331 //============================================================================
1332 /*! Function : IsStudyLocked
1335 //============================================================================
1336 bool SALOMEDS_Study_i::IsStudyLocked()
1338 SALOMEDS::Locker lock;
1341 throw SALOMEDS::Study::StudyInvalidReference();
1343 return _impl->IsStudyLocked();
1346 //============================================================================
1347 /*! Function : UnLockStudy
1350 //============================================================================
1351 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1353 SALOMEDS::Locker lock;
1356 throw SALOMEDS::Study::StudyInvalidReference();
1358 _impl->UnLockStudy(theLockerID);
1361 //============================================================================
1362 /*! Function : GetLockerID
1365 //============================================================================
1366 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1368 SALOMEDS::Locker lock;
1371 throw SALOMEDS::Study::StudyInvalidReference();
1373 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1375 std::vector<std::string> aSeq = _impl->GetLockerID();
1377 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1378 aResult->length(aLength);
1379 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1380 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1383 return aResult._retn();
1385 //============================================================================
1386 /*! Function : SetReal
1389 //============================================================================
1390 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1393 throw SALOMEDS::Study::StudyInvalidReference();
1396 _impl->SetVariable(std::string(theVarName),
1398 SALOMEDSImpl_GenericVariable::REAL_VAR);
1400 _notifier->modifyNB_Notification(theVarName);
1403 //============================================================================
1404 /*! Function : SetInteger
1407 //============================================================================
1408 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1411 throw SALOMEDS::Study::StudyInvalidReference();
1413 _impl->SetVariable(std::string(theVarName),
1415 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1417 _notifier->modifyNB_Notification(theVarName);
1420 //============================================================================
1421 /*! Function : SetBoolean
1424 //============================================================================
1425 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1428 throw SALOMEDS::Study::StudyInvalidReference();
1430 _impl->SetVariable(std::string(theVarName),
1432 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1434 _notifier->modifyNB_Notification(theVarName);
1437 //============================================================================
1438 /*! Function : SetString
1441 //============================================================================
1442 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1445 throw SALOMEDS::Study::StudyInvalidReference();
1447 _impl->SetStringVariable(std::string(theVarName),
1449 SALOMEDSImpl_GenericVariable::STRING_VAR);
1451 _notifier->modifyNB_Notification(theVarName);
1454 //============================================================================
1455 /*! Function : SetStringAsDouble
1458 //============================================================================
1459 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1462 throw SALOMEDS::Study::StudyInvalidReference();
1464 _impl->SetStringVariableAsDouble(std::string(theVarName),
1466 SALOMEDSImpl_GenericVariable::STRING_VAR);
1469 //============================================================================
1470 /*! Function : GetReal
1473 //============================================================================
1474 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1477 throw SALOMEDS::Study::StudyInvalidReference();
1479 return _impl->GetVariableValue(std::string(theVarName));
1482 //============================================================================
1483 /*! Function : GetInteger
1486 //============================================================================
1487 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1490 throw SALOMEDS::Study::StudyInvalidReference();
1492 return (long)_impl->GetVariableValue(std::string(theVarName));
1495 //============================================================================
1496 /*! Function : GetBoolean
1499 //============================================================================
1500 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1503 throw SALOMEDS::Study::StudyInvalidReference();
1505 return (bool)_impl->GetVariableValue(std::string(theVarName));
1508 //============================================================================
1509 /*! Function : GetString
1512 //============================================================================
1513 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1516 throw SALOMEDS::Study::StudyInvalidReference();
1518 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1521 //============================================================================
1522 /*! Function : IsReal
1525 //============================================================================
1526 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1529 throw SALOMEDS::Study::StudyInvalidReference();
1531 return _impl->IsTypeOf(std::string(theVarName),
1532 SALOMEDSImpl_GenericVariable::REAL_VAR);
1535 //============================================================================
1536 /*! Function : IsInteger
1539 //============================================================================
1540 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1543 throw SALOMEDS::Study::StudyInvalidReference();
1545 return _impl->IsTypeOf(std::string(theVarName),
1546 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1549 //============================================================================
1550 /*! Function : IsBoolean
1553 //============================================================================
1554 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1557 throw SALOMEDS::Study::StudyInvalidReference();
1559 return _impl->IsTypeOf(std::string(theVarName),
1560 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1563 //============================================================================
1564 /*! Function : IsString
1567 //============================================================================
1568 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1571 throw SALOMEDS::Study::StudyInvalidReference();
1573 return _impl->IsTypeOf(std::string(theVarName),
1574 SALOMEDSImpl_GenericVariable::STRING_VAR);
1577 //============================================================================
1578 /*! Function : IsVariable
1581 //============================================================================
1582 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1585 throw SALOMEDS::Study::StudyInvalidReference();
1587 return _impl->IsVariable(std::string(theVarName));
1590 //============================================================================
1591 /*! Function : GetVariableNames
1594 //============================================================================
1595 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1598 throw SALOMEDS::Study::StudyInvalidReference();
1600 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1602 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1604 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1605 aResult->length(aLen);
1606 for (int anInd = 0; anInd < aLen; anInd++)
1607 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1609 return aResult._retn();
1612 //============================================================================
1613 /*! Function : RemoveVariable
1616 //============================================================================
1617 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1620 throw SALOMEDS::Study::StudyInvalidReference();
1622 bool res = _impl->RemoveVariable(std::string(theVarName));
1623 if (res && _notifier)
1624 _notifier->modifyNB_Notification(theVarName);
1629 //============================================================================
1630 /*! Function : RenameVariable
1633 //============================================================================
1634 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1637 throw SALOMEDS::Study::StudyInvalidReference();
1639 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1640 if (res && _notifier)
1641 _notifier->modifyNB_Notification(theVarName);
1646 //============================================================================
1647 /*! Function : IsVariableUsed
1650 //============================================================================
1651 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1654 throw SALOMEDS::Study::StudyInvalidReference();
1656 return _impl->IsVariableUsed(std::string(theVarName));
1660 //============================================================================
1661 /*! Function : ParseVariables
1664 //============================================================================
1665 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1668 throw SALOMEDS::Study::StudyInvalidReference();
1670 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1672 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1674 int aSectionsLen = (int)aSections.size(); //!< TODO: conversion from size_t to int
1675 aResult->length(aSectionsLen);
1677 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1678 std::vector<std::string> aVarNames = aSections[aSectionInd];
1680 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1682 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1683 aList->length(aLen);
1685 for (int anInd = 0; anInd < aLen; anInd++)
1686 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1688 aResult[aSectionInd] = aList;
1691 return aResult._retn();
1694 //============================================================================
1695 /*! Function : GetDefaultScript
1698 //============================================================================
1699 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1701 SALOMEDS::Locker lock;
1704 throw SALOMEDS::Study::StudyInvalidReference();
1706 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1707 return CORBA::string_dup(script.c_str());
1710 //============================================================================
1711 /*! Function : EnableUseCaseAutoFilling
1714 //============================================================================
1715 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1718 throw SALOMEDS::Study::StudyInvalidReference();
1720 _impl->EnableUseCaseAutoFilling(isEnabled);
1721 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1724 builder->SetOnAddSObject(_impl->GetCallback());
1725 builder->SetOnRemoveSObject(_impl->GetCallback());
1728 builder->SetOnAddSObject(NULL);
1729 builder->SetOnRemoveSObject(NULL);
1735 CORBA::Long SALOMEDS_Study_i::getPID()
1738 return (CORBA::Long)_getpid();
1740 return (CORBA::Long)getpid();
1744 void SALOMEDS_Study_i::ShutdownWithExit()
1746 exit( EXIT_SUCCESS );
1749 void SALOMEDS_Study_i::Shutdown()
1751 if(!CORBA::is_nil(_orb))
1753 _closed = true; // force 'closed' flag to avoid terminating
1756 //============================================================================
1757 /*! Function : attach
1758 * Purpose : This function attach an observer to the study
1760 //============================================================================
1761 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1764 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1768 //============================================================================
1769 /*! Function : detach
1770 * Purpose : This function detaches an observer from the study
1772 //============================================================================
1773 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1776 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1779 //===========================================================================
1780 // PRIVATE FUNCTIONS
1781 //===========================================================================
1782 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1785 long pid = (long)_getpid();
1787 long pid = (long)getpid();
1789 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1790 return reinterpret_cast<CORBA::LongLong>(_impl);
1793 void SALOMEDS_Study_i::NameChanged(SALOME::Session_ptr session)
1796 SALOMEDS::sendMessageToGUIGivenSession(session,"studyNameChanged" );