1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_Study_i.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
29 #include "SALOMEDS_Study_i.hxx"
30 #include "SALOMEDS_UseCaseIterator_i.hxx"
31 #include "SALOMEDS_GenericAttribute_i.hxx"
32 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
33 #include "SALOMEDS_AttributeParameter_i.hxx"
34 #include "SALOMEDS_ChildIterator_i.hxx"
35 #include "SALOMEDS_Driver_i.hxx"
36 #include "SALOMEDS.hxx"
38 #include "SALOMEDSImpl_SObject.hxx"
39 #include "SALOMEDSImpl_SComponent.hxx"
40 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
42 #include "SALOMEDSImpl_AttributeParameter.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_IParameters.hxx"
45 #include "SALOMEDSImpl_Callback.hxx"
47 #include "DF_Label.hxx"
48 #include "DF_Attribute.hxx"
50 #include "Utils_ExceptHandlers.hxx"
52 #include "Basics_Utils.hxx"
53 #include "SALOME_KernelServices.hxx"
58 #include <sys/types.h>
62 UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception)
63 UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection)
65 static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
67 static PortableServer::POA_var _poa;
68 static SALOMEDS::Study_var _study;
71 * Return a unique study obj but servant is embeded here.
74 SALOMEDS::Study_ptr KERNEL::getStudyServantSA()
77 if(CORBA::is_nil(_study))
79 CORBA::ORB_ptr orb = KERNEL::getORB();
80 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
81 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
82 _poa = PortableServer::POA::_duplicate(poa);
83 SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb,SALOME::Session::_nil());
84 _study = servant->_this();
86 return SALOMEDS::Study::_duplicate(_study);
90 * If a study is already built and activated elsewhere (for example in GUI context)
92 void KERNEL::setStudyServantSA(SALOMEDS::Study_var study, PortableServer::POA_var poa)
94 if( ! CORBA::is_nil(_study) )
96 PortableServer::ServantBase *serv = nullptr;
99 serv = _poa->reference_to_servant(_study);
105 _study = study; _poa = poa;
110 class Notifier: public SALOMEDSImpl_AbstractCallback
113 Notifier(CORBA::ORB_ptr orb)
115 _orb = CORBA::ORB::_duplicate(orb);
118 //============================================================================
119 /*! Function : addSO_Notification
120 * Purpose : This function tells all the observers that a SO has been added
122 //============================================================================
124 virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject)
126 std::string anID=theSObject.GetID();
127 const char* cID=anID.c_str();
128 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
130 it->first->notifyObserverID(cID,1);
132 return true; // NGE return always true but can be modified if needed
135 //============================================================================
136 /*! Function : removeSO_Notification
137 * Purpose : This function tells all the observers that a SO has been removed
139 //============================================================================
141 virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject)
143 std::string anID=theSObject.GetID();
144 const char* cID=anID.c_str();
145 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
147 it->first->notifyObserverID(cID,2);
149 return true; // NGE return always true but can be modified if needed
152 //============================================================================
153 /*! Function : modifySO_Notification
154 * Purpose : This function tells all the observers that a SO has been modified
156 //============================================================================
158 virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason)
160 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
164 std::string anID=theSObject.GetID();
165 const char* cID=anID.c_str();
166 it->first->notifyObserverID(cID,reason);
169 return true; // NGE return always true but can be modified if needed
172 //============================================================================
173 /*! Function : modifyNB_Notification
174 * Purpose : This function tells all the observers that
175 * a NoteBook variable has been added/modified/removed.
177 //============================================================================
179 virtual bool modifyNB_Notification(const char* theVarName)
181 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
183 it->first->notifyObserverID(theVarName,6);
185 return true; // NGE return always true but can be modified if needed
188 //============================================================================
189 /*! Function : attach
190 * Purpose : register an Observer
192 //============================================================================
194 virtual void attach(SALOMEDS::Observer_ptr theObs, bool modify)
196 myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
199 //============================================================================
200 /*! Function : detach
201 * Purpose : unregister an Observer
203 //============================================================================
205 virtual void detach(SALOMEDS::Observer_ptr theObs)
207 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
209 if ( it->first->_is_equivalent(theObs) ) {
210 myObservers.erase( it );
217 typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
218 typedef ObsList::iterator ObsListIter;
223 class GenObjRegister: public SALOMEDSImpl_AbstractCallback
226 GenObjRegister(CORBA::ORB_ptr orb)
228 _orb = CORBA::ORB::_duplicate(orb);
230 virtual void RegisterGenObj (const std::string& theIOR)
234 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
235 if ( obj->_non_existent() ) return;
236 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
237 if(! CORBA::is_nil(gobj) )
242 catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
246 virtual void UnRegisterGenObj(const std::string& theIOR)
250 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
251 if ( obj->_non_existent() ) return;
252 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
253 if(! CORBA::is_nil(gobj) )
258 catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
268 //================================================================================
270 * \brief emitMessageOneWay to SALOME::Session
272 //================================================================================
274 void sendMessageToGUIGivenSession(SALOME::Session_ptr session, const char* msg )
276 if ( !CORBA::is_nil(session) ) {
278 session->emitMessageOneWay( msg );
283 //================================================================================
285 * \brief emitMessageOneWay to SALOME::Session
287 //================================================================================
289 void sendMessageToGUI(const char* msg )
291 SALOME_NamingService_Abstract *aNamingService = KERNEL::getNamingService();
292 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
293 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
294 sendMessageToGUIGivenSession(aSession,msg);
297 } // namespace SALOMEDS
299 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME_NamingService_Abstract *ns)
301 SALOME_NamingService_Abstract *aNamingService = ns==nullptr?KERNEL::getNamingService():ns;
302 _orb = CORBA::ORB::_duplicate(orb);
303 _impl = new SALOMEDSImpl_Study();
304 _factory = new SALOMEDS_DriverFactory_i(_orb,aNamingService);
306 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
307 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
311 //============================================================================
312 /*! Function : SALOMEDS_Study_i
313 * Purpose : SALOMEDS_Study_i constructor
315 //============================================================================
316 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME::Session_ptr session)
318 _orb = CORBA::ORB::_duplicate(orb);
319 _impl = new SALOMEDSImpl_Study();
320 _factory = new SALOMEDS_DriverFactory_i(_orb,!CORBA::is_nil(session));
326 //============================================================================
327 /*! Function : ~SALOMEDS_Study_i
328 * Purpose : SALOMEDS_Study_i destructor
330 //============================================================================
331 SALOMEDS_Study_i::~SALOMEDS_Study_i()
338 void SALOMEDS_Study_i::Init()
340 SALOME_NamingService_Abstract *aNamingService = KERNEL::getNamingService();
341 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
342 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
346 //============================================================================
348 * Purpose : Initialize study components
350 //============================================================================
351 void SALOMEDS_Study_i::Init(SALOME::Session_ptr session)
354 //throw SALOMEDS::Study::StudyInvalidReference();
357 SALOMEDS::Locker lock;
359 if ( !_impl->GetDocument() )
362 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
363 _notifier = new SALOMEDS::Notifier(_orb);
364 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
367 _impl->setNotifier(_notifier);
368 _impl->setGenObjRegister( _genObjRegister );
370 // Notify GUI that study was created
371 SALOMEDS::sendMessageToGUIGivenSession( session, "studyCreated" );
373 // update desktop title with new study name
374 NameChanged(session);
377 //============================================================================
379 * Purpose : Clear study components
381 //============================================================================
382 void SALOMEDS_Study_i::Clear()
387 SALOMEDS::Locker lock;
389 //delete the builder servant
390 PortableServer::POA_var poa=_default_POA();
391 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
392 poa->deactivate_object(anObjectId.in());
393 _builder->_remove_ref();
397 if (_impl->GetDocument()) {
398 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
399 for (; itcomponent->More(); itcomponent->Next()) {
400 SALOMEDS::SComponent_var sco = itcomponent->Value();
401 CORBA::String_var compodatatype=sco->ComponentDataType();
402 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
403 // if there is an associated Engine call its method for closing
404 CORBA::String_var IOREngine;
405 if (sco->ComponentIOR(IOREngine)) {
406 // we have found the associated engine to write the data
407 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
408 //_narrow can throw a corba exception
410 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
411 if (!CORBA::is_nil(obj)) {
412 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
413 if (!anEngine->_is_nil()) {
415 anEngine->Close(sco);
420 catch (CORBA::Exception&) {
426 //Does not need any more this iterator
427 itcomponent->UnRegister();
430 // Notify GUI that study is cleared
431 SALOMEDS::sendMessageToGUI( "studyCleared" );
434 _impl->setNotifier(0);
436 delete _genObjRegister;
442 //============================================================================
444 \brief Get default POA for the servant object.
446 This function is implicitly called from "_this()" function.
447 Default POA can be set via the constructor.
449 \return reference to the default POA for the servant
451 //============================================================================
452 PortableServer::POA_ptr SALOMEDS_Study_i::_default_POA()
454 PortableServer::POA_ptr poa = GetThePOA();
455 MESSAGE("SALOMEDS_Study_i::_default_POA: " << poa);
456 return PortableServer::POA::_duplicate(poa);
459 //============================================================================
461 * Purpose : Open a Study from it's persistent reference
463 //============================================================================
464 bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
470 SALOMEDS::Locker lock;
472 Unexpect aCatch(SalomeException);
473 MESSAGE("Begin of SALOMEDS_Study_i::Open");
474 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
475 bool res = _impl->Open( aUrl );
477 // update desktop title with new study name
479 SALOMEDS::sendMessageToGUI( "connect_to_study" );
482 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
486 //============================================================================
487 /*! Function : CanOpen
488 * Purpose : Check that a Study can be opened
490 //============================================================================
491 bool SALOMEDS_Study_i::CanOpen(const wchar_t* aWUrl)
493 SALOMEDS::Locker lock;
495 Unexpect aCatch(SalomeException);
496 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
498 return SALOMEDSImpl_Study().Open( aUrl );
501 PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA()
506 void SALOMEDS_Study_i::SetThePOA(PortableServer::POA_ptr thePOA)
508 _poa = PortableServer::POA::_duplicate(thePOA);
511 //============================================================================
513 * Purpose : Save a Study to it's persistent reference
515 //============================================================================
516 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
518 SALOMEDS::Locker lock;
520 throw SALOMEDS::Study::StudyInvalidReference();
521 return _impl->Save(_factory, theMultiFile, theASCII);
524 //=============================================================================
525 /*! Function : SaveAs
526 * Purpose : Save a study to the persistent reference aUrl
528 //============================================================================
529 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const wchar_t* aWUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
531 SALOMEDS::Locker lock;
533 throw SALOMEDS::Study::StudyInvalidReference();
535 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
536 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
539 //============================================================================
540 /*! Function : CanCopy
543 //============================================================================
544 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
546 SALOMEDS::Locker lock;
548 throw SALOMEDS::Study::StudyInvalidReference();
550 CORBA::String_var anID = theObject->GetID();
551 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
553 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
554 bool ret = _impl->CanCopy(anObject, aDriver);
559 //============================================================================
563 //============================================================================
564 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
566 SALOMEDS::Locker lock;
568 throw SALOMEDS::Study::StudyInvalidReference();
570 CORBA::String_var anID = theObject->GetID();
571 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
573 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
574 bool ret = _impl->Copy(anObject, aDriver);
579 //============================================================================
580 /*! Function : CanPaste
583 //============================================================================
584 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
586 SALOMEDS::Locker lock;
588 throw SALOMEDS::Study::StudyInvalidReference();
590 CORBA::String_var anID = theObject->GetID();
591 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
593 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
594 bool ret = _impl->CanPaste(anObject, aDriver);
599 //============================================================================
603 //============================================================================
604 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
607 SALOMEDS::Locker lock;
609 Unexpect aCatch(LockProtection);
611 CORBA::String_var anID = theObject->GetID();
612 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
613 SALOMEDSImpl_SObject aNewSO;
616 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
617 aNewSO = _impl->Paste(anObject, aDriver);
621 throw SALOMEDS::StudyBuilder::LockProtection();
624 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
628 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
630 SALOMEDS_Driver_i* driver = NULL;
632 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
634 std::string IOREngine = aSCO.GetIOR();
635 if(!IOREngine.empty()) {
636 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
637 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
638 driver = new SALOMEDS_Driver_i(Engine, orb);
645 //============================================================================
646 /*! Function : GetPersistentReference
647 * Purpose : Get persistent reference of study (idem URL())
649 //============================================================================
650 char* SALOMEDS_Study_i::GetPersistentReference()
652 SALOMEDS::Locker lock;
654 throw SALOMEDS::Study::StudyInvalidReference();
655 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
658 //============================================================================
659 /*! Function : IsEmpty
660 * Purpose : Detect if study is empty
662 //============================================================================
663 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
665 SALOMEDS::Locker lock;
667 throw SALOMEDS::Study::StudyInvalidReference();
668 return _impl->IsEmpty();
671 //============================================================================
672 /*! Function : FindComponent
673 * Purpose : Find a Component with ComponentDataType = aComponentName
675 //============================================================================
676 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
678 SALOMEDS::Locker lock;
681 throw SALOMEDS::Study::StudyInvalidReference();
683 SALOMEDS::SComponent_var sco;
685 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
686 if (!aCompImpl.IsNull())
687 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
692 //============================================================================
693 /*! Function : FindComponentID
694 * Purpose : Find a Component from it's ID
696 //============================================================================
697 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
699 SALOMEDS::Locker lock;
702 throw SALOMEDS::Study::StudyInvalidReference();
704 SALOMEDS::SComponent_var sco;
706 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
707 if (!aCompImpl.IsNull())
708 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
713 //============================================================================
714 /*! Function : FindObject
715 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
717 //============================================================================
718 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
720 SALOMEDS::Locker lock;
723 throw SALOMEDS::Study::StudyInvalidReference();
725 SALOMEDS::SObject_var so;
727 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
729 if (aSO.IsComponent()) {
730 SALOMEDSImpl_SComponent aSCO = aSO;
731 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
734 so = SALOMEDS_SObject_i::New(aSO, _orb);
741 //============================================================================
742 /*! Function : FindObjectID
743 * Purpose : Find an Object with ID = anObjectID
745 //============================================================================
746 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
748 SALOMEDS::Locker lock;
751 throw SALOMEDS::Study::StudyInvalidReference();
753 SALOMEDS::SObject_var so;
755 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
757 so = SALOMEDS_SObject_i::New(aSO, _orb);
762 //============================================================================
763 /*! Function : CreateObjectID
764 * Purpose : Creates an Object with ID = anObjectID
766 //============================================================================
767 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
769 SALOMEDS::Locker lock;
772 throw SALOMEDS::Study::StudyInvalidReference();
774 SALOMEDS::SObject_var so;
776 if (anObjectID && strlen(anObjectID) > 0) {
777 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
779 so = SALOMEDS_SObject_i::New(aSO, _orb);
785 //============================================================================
786 /*! Function : FindObjectByName
787 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
788 * : with ComponentDataType = aComponentName
790 //============================================================================
791 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
792 const char* aComponentName )
794 SALOMEDS::Locker lock;
797 throw SALOMEDS::Study::StudyInvalidReference();
799 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
800 std::string((char*)aComponentName));
802 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
803 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
804 listSO->length(aLength);
805 for (int i = 0; i < aLength; i++) {
806 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
810 return listSO._retn();
813 //============================================================================
814 /*! Function : FindObjectIOR
815 * Purpose : Find an Object with IOR = anObjectIOR
817 //============================================================================
818 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
820 SALOMEDS::Locker lock;
823 throw SALOMEDS::Study::StudyInvalidReference();
825 SALOMEDS::SObject_var so;
827 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
829 so = SALOMEDS_SObject_i::New(aSO, _orb);
834 //============================================================================
835 /*! Function : FindObjectByPath
836 * Purpose : Find an Object by its path = thePath
838 //============================================================================
839 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
841 SALOMEDS::Locker lock;
844 throw SALOMEDS::Study::StudyInvalidReference();
846 SALOMEDS::SObject_var so;
848 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
850 so = SALOMEDS_SObject_i::New (aSO, _orb);
855 //============================================================================
856 /*! Function : GetObjectPath
859 //============================================================================
860 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
862 SALOMEDS::Locker lock;
865 throw SALOMEDS::Study::StudyInvalidReference();
867 std::string aPath = "";
869 if (!CORBA::is_nil(theObject)) {
870 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
871 SALOMEDSImpl_SObject aSO;
873 if (!CORBA::is_nil(aSObj)) {
874 aSO = _impl->FindObjectID(aSObj->GetID());
877 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
881 aPath = _impl->GetObjectPath(aSO);
885 return CORBA::string_dup(aPath.c_str());
888 //============================================================================
889 /*! Function : NewChildIterator
890 * Purpose : Create a ChildIterator from an SObject
892 //============================================================================
893 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
895 SALOMEDS::Locker lock;
898 throw SALOMEDS::Study::StudyInvalidReference();
900 CORBA::String_var anID = theSO->GetID();
901 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
902 SALOMEDSImpl_ChildIterator anItr(aSO);
903 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
904 SALOMEDS::ChildIterator_var it = it_servant->_this();
910 //============================================================================
911 /*! Function : NewComponentIterator
912 * Purpose : Create a SComponentIterator
914 //============================================================================
915 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
917 SALOMEDS::Locker lock;
920 throw SALOMEDS::Study::StudyInvalidReference();
922 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
924 SALOMEDS::SComponentIterator_var it = it_servant->_this();
930 //============================================================================
931 /*! Function : NewBuilder
932 * Purpose : Create a StudyBuilder
934 //============================================================================
935 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
937 SALOMEDS::Locker lock;
940 throw SALOMEDS::Study::StudyInvalidReference();
942 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
947 //============================================================================
949 * Purpose : get study name
951 //============================================================================
952 wchar_t* SALOMEDS_Study_i::Name()
954 SALOMEDS::Locker lock;
955 // Name is specified as IDL attribute: user exception cannot be raised
956 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->Name()));
959 //============================================================================
961 * Purpose : set study name
963 //============================================================================
964 void SALOMEDS_Study_i::Name(const wchar_t* wname)
966 SALOMEDS::Locker lock;
967 // Name is specified as IDL attribute: user exception cannot be raised
968 _impl->Name(Kernel_Utils::encode_s(wname));
971 //============================================================================
972 /*! Function : IsSaved
973 * Purpose : get if study has been saved
975 //============================================================================
976 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
978 SALOMEDS::Locker lock;
979 // IsSaved is specified as IDL attribute: user exception cannot be raised
980 return (!_closed) ? _impl->IsSaved() : false;
983 //============================================================================
984 /*! Function : IsSaved
985 * Purpose : set if study has been saved
987 //============================================================================
988 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
990 SALOMEDS::Locker lock;
991 // IsSaved is specified as IDL attribute: user exception cannot be raised
993 _impl->IsSaved(save);
996 //============================================================================
997 /*! Function : IsModified
998 * Purpose : Detect if a Study has been modified since it has been saved
1000 //============================================================================
1001 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1003 SALOMEDS::Locker lock;
1006 throw SALOMEDS::Study::StudyInvalidReference();
1008 return _impl->IsModified();
1011 //============================================================================
1012 /*! Function : Modified
1013 * Purpose : Sets a Modified flag of a Study to True
1015 //============================================================================
1016 void SALOMEDS_Study_i::Modified()
1018 SALOMEDS::Locker lock;
1021 throw SALOMEDS::Study::StudyInvalidReference();
1026 //============================================================================
1028 * Purpose : get URL of the study (persistent reference of the study)
1030 //============================================================================
1031 wchar_t* SALOMEDS_Study_i::URL()
1033 SALOMEDS::Locker lock;
1034 // URL is specified as IDL attribute: user exception cannot be raised
1035 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->URL()));
1038 //============================================================================
1040 * Purpose : set URL of the study (persistent reference of the study)
1042 //============================================================================
1043 void SALOMEDS_Study_i::URL(const wchar_t* wurl)
1045 SALOMEDS::Locker lock;
1046 // URL is specified as IDL attribute: user exception cannot be raised
1047 _impl->URL(Kernel_Utils::encode_s(wurl));
1049 // update desktop title with new study name
1050 SALOME_NamingService_Abstract *aNamingService = KERNEL::getNamingService();
1051 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1052 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1053 NameChanged(aSession);
1056 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1058 SALOMEDS::Locker lock;
1061 throw SALOMEDS::Study::StudyInvalidReference();
1063 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1066 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1068 SALOMEDS::Locker lock;
1069 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1072 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1074 SALOMEDS::Locker lock;
1077 throw SALOMEDS::Study::StudyInvalidReference();
1079 SALOMEDS::GenericAttribute_ptr aTarget;
1080 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1081 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1083 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1089 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1091 SALOMEDS::Locker lock;
1094 throw SALOMEDS::Study::StudyInvalidReference();
1096 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1097 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1098 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1099 return aProp._retn();
1102 char* SALOMEDS_Study_i::GetLastModificationDate()
1104 SALOMEDS::Locker lock;
1107 throw SALOMEDS::Study::StudyInvalidReference();
1109 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1112 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1114 SALOMEDS::Locker lock;
1117 throw SALOMEDS::Study::StudyInvalidReference();
1119 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1121 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1123 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1124 aDates->length(aLength);
1125 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1126 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1129 return aDates._retn();
1132 //============================================================================
1133 /*! Function : GetUseCaseBuilder
1134 * Purpose : Returns a UseCase builder
1136 //============================================================================
1137 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1139 SALOMEDS::Locker lock;
1142 throw SALOMEDS::Study::StudyInvalidReference();
1144 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1145 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1149 //============================================================================
1150 /*! Function : AddPostponed
1153 //============================================================================
1154 void SALOMEDS_Study_i::AddPostponed(const char* /*theIOR*/)
1156 SALOMEDS::Locker lock;
1160 void SALOMEDS_Study_i::AddCreatedPostponed(const char* /*theIOR*/)
1162 SALOMEDS::Locker lock;
1166 //============================================================================
1167 /*! Function : RemovePostponed
1170 //============================================================================
1171 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1173 SALOMEDS::Locker lock;
1176 throw SALOMEDS::Study::StudyInvalidReference();
1178 std::vector<std::string> anIORs = _impl->GetIORs();
1179 int i, aSize = (int)anIORs.size();
1181 for (i = 0; i < aSize; i++) {
1183 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1184 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1185 //rnv: To avoid double deletion of the Salome Generic Objects:
1186 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1187 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1188 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1195 //============================================================================
1196 /*! Function : UndoPostponed
1199 //============================================================================
1200 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long /*theWay*/)
1202 SALOMEDS::Locker lock;
1207 //============================================================================
1208 /*! Function : DumpStudy
1211 //============================================================================
1212 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1213 const char* theBaseName,
1214 CORBA::Boolean isPublished,
1215 CORBA::Boolean isMultiFile)
1217 SALOMEDS::Locker lock;
1220 throw SALOMEDS::Study::StudyInvalidReference();
1222 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1223 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1224 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1230 //============================================================================
1231 /*! Function : GetDumpPath
1234 //============================================================================
1235 char* SALOMEDS_Study_i::GetDumpPath()
1237 return CORBA::string_dup(_impl->GetDumpPath().c_str());
1240 //============================================================================
1241 /*! Function : GetCommonParameters
1244 //============================================================================
1245 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1247 SALOMEDS::Locker lock;
1250 throw SALOMEDS::Study::StudyInvalidReference();
1252 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1253 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1254 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1256 return aParam._retn();
1259 //============================================================================
1260 /*! Function : GetCommonModuleParameters
1263 //============================================================================
1264 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1265 const char* theModuleName,
1266 CORBA::Long theSavePoint)
1268 SALOMEDS::Locker lock;
1271 throw SALOMEDS::Study::StudyInvalidReference();
1273 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1274 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1275 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1277 return aParam._retn();
1280 //============================================================================
1281 /*! Function : SetStudyLock
1284 //============================================================================
1285 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1287 SALOMEDS::Locker lock;
1290 throw SALOMEDS::Study::StudyInvalidReference();
1292 _impl->SetStudyLock(theLockerID);
1295 //============================================================================
1296 /*! Function : IsStudyLocked
1299 //============================================================================
1300 bool SALOMEDS_Study_i::IsStudyLocked()
1302 SALOMEDS::Locker lock;
1305 throw SALOMEDS::Study::StudyInvalidReference();
1307 return _impl->IsStudyLocked();
1310 //============================================================================
1311 /*! Function : UnLockStudy
1314 //============================================================================
1315 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1317 SALOMEDS::Locker lock;
1320 throw SALOMEDS::Study::StudyInvalidReference();
1322 _impl->UnLockStudy(theLockerID);
1325 //============================================================================
1326 /*! Function : GetLockerID
1329 //============================================================================
1330 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1332 SALOMEDS::Locker lock;
1335 throw SALOMEDS::Study::StudyInvalidReference();
1337 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1339 std::vector<std::string> aSeq = _impl->GetLockerID();
1341 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1342 aResult->length(aLength);
1343 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1344 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1347 return aResult._retn();
1349 //============================================================================
1350 /*! Function : SetReal
1353 //============================================================================
1354 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1357 throw SALOMEDS::Study::StudyInvalidReference();
1360 _impl->SetVariable(std::string(theVarName),
1362 SALOMEDSImpl_GenericVariable::REAL_VAR);
1364 _notifier->modifyNB_Notification(theVarName);
1367 //============================================================================
1368 /*! Function : SetInteger
1371 //============================================================================
1372 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1375 throw SALOMEDS::Study::StudyInvalidReference();
1377 _impl->SetVariable(std::string(theVarName),
1379 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1381 _notifier->modifyNB_Notification(theVarName);
1384 //============================================================================
1385 /*! Function : SetBoolean
1388 //============================================================================
1389 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1392 throw SALOMEDS::Study::StudyInvalidReference();
1394 _impl->SetVariable(std::string(theVarName),
1396 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1398 _notifier->modifyNB_Notification(theVarName);
1401 //============================================================================
1402 /*! Function : SetString
1405 //============================================================================
1406 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1409 throw SALOMEDS::Study::StudyInvalidReference();
1411 _impl->SetStringVariable(std::string(theVarName),
1413 SALOMEDSImpl_GenericVariable::STRING_VAR);
1415 _notifier->modifyNB_Notification(theVarName);
1418 //============================================================================
1419 /*! Function : SetStringAsDouble
1422 //============================================================================
1423 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1426 throw SALOMEDS::Study::StudyInvalidReference();
1428 _impl->SetStringVariableAsDouble(std::string(theVarName),
1430 SALOMEDSImpl_GenericVariable::STRING_VAR);
1433 //============================================================================
1434 /*! Function : GetReal
1437 //============================================================================
1438 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1441 throw SALOMEDS::Study::StudyInvalidReference();
1443 return _impl->GetVariableValue(std::string(theVarName));
1446 //============================================================================
1447 /*! Function : GetInteger
1450 //============================================================================
1451 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1454 throw SALOMEDS::Study::StudyInvalidReference();
1456 return (long)_impl->GetVariableValue(std::string(theVarName));
1459 //============================================================================
1460 /*! Function : GetBoolean
1463 //============================================================================
1464 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1467 throw SALOMEDS::Study::StudyInvalidReference();
1469 return (bool)_impl->GetVariableValue(std::string(theVarName));
1472 //============================================================================
1473 /*! Function : GetString
1476 //============================================================================
1477 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1480 throw SALOMEDS::Study::StudyInvalidReference();
1482 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1485 //============================================================================
1486 /*! Function : IsReal
1489 //============================================================================
1490 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1493 throw SALOMEDS::Study::StudyInvalidReference();
1495 return _impl->IsTypeOf(std::string(theVarName),
1496 SALOMEDSImpl_GenericVariable::REAL_VAR);
1499 //============================================================================
1500 /*! Function : IsInteger
1503 //============================================================================
1504 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1507 throw SALOMEDS::Study::StudyInvalidReference();
1509 return _impl->IsTypeOf(std::string(theVarName),
1510 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1513 //============================================================================
1514 /*! Function : IsBoolean
1517 //============================================================================
1518 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1521 throw SALOMEDS::Study::StudyInvalidReference();
1523 return _impl->IsTypeOf(std::string(theVarName),
1524 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1527 //============================================================================
1528 /*! Function : IsString
1531 //============================================================================
1532 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1535 throw SALOMEDS::Study::StudyInvalidReference();
1537 return _impl->IsTypeOf(std::string(theVarName),
1538 SALOMEDSImpl_GenericVariable::STRING_VAR);
1541 //============================================================================
1542 /*! Function : IsVariable
1545 //============================================================================
1546 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1549 throw SALOMEDS::Study::StudyInvalidReference();
1551 return _impl->IsVariable(std::string(theVarName));
1554 //============================================================================
1555 /*! Function : GetVariableNames
1558 //============================================================================
1559 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1562 throw SALOMEDS::Study::StudyInvalidReference();
1564 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1566 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1568 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1569 aResult->length(aLen);
1570 for (int anInd = 0; anInd < aLen; anInd++)
1571 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1573 return aResult._retn();
1576 //============================================================================
1577 /*! Function : RemoveVariable
1580 //============================================================================
1581 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1584 throw SALOMEDS::Study::StudyInvalidReference();
1586 bool res = _impl->RemoveVariable(std::string(theVarName));
1587 if (res && _notifier)
1588 _notifier->modifyNB_Notification(theVarName);
1593 //============================================================================
1594 /*! Function : RenameVariable
1597 //============================================================================
1598 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1601 throw SALOMEDS::Study::StudyInvalidReference();
1603 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1604 if (res && _notifier)
1605 _notifier->modifyNB_Notification(theVarName);
1610 //============================================================================
1611 /*! Function : IsVariableUsed
1614 //============================================================================
1615 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1618 throw SALOMEDS::Study::StudyInvalidReference();
1620 return _impl->IsVariableUsed(std::string(theVarName));
1624 //============================================================================
1625 /*! Function : ParseVariables
1628 //============================================================================
1629 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1632 throw SALOMEDS::Study::StudyInvalidReference();
1634 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1636 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1638 int aSectionsLen = (int)aSections.size(); //!< TODO: conversion from size_t to int
1639 aResult->length(aSectionsLen);
1641 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1642 std::vector<std::string> aVarNames = aSections[aSectionInd];
1644 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1646 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1647 aList->length(aLen);
1649 for (int anInd = 0; anInd < aLen; anInd++)
1650 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1652 aResult[aSectionInd] = aList;
1655 return aResult._retn();
1658 //============================================================================
1659 /*! Function : GetDefaultScript
1662 //============================================================================
1663 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1665 SALOMEDS::Locker lock;
1668 throw SALOMEDS::Study::StudyInvalidReference();
1670 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1671 return CORBA::string_dup(script.c_str());
1674 //============================================================================
1675 /*! Function : EnableUseCaseAutoFilling
1678 //============================================================================
1679 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1682 throw SALOMEDS::Study::StudyInvalidReference();
1684 _impl->EnableUseCaseAutoFilling(isEnabled);
1685 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1688 builder->SetOnAddSObject(_impl->GetCallback());
1689 builder->SetOnRemoveSObject(_impl->GetCallback());
1692 builder->SetOnAddSObject(NULL);
1693 builder->SetOnRemoveSObject(NULL);
1699 CORBA::Long SALOMEDS_Study_i::getPID()
1702 return (CORBA::Long)_getpid();
1704 return (CORBA::Long)getpid();
1708 void SALOMEDS_Study_i::ShutdownWithExit()
1710 exit( EXIT_SUCCESS );
1713 void SALOMEDS_Study_i::Shutdown()
1715 if(!CORBA::is_nil(_orb))
1717 _closed = true; // force 'closed' flag to avoid terminating
1720 //============================================================================
1721 /*! Function : attach
1722 * Purpose : This function attach an observer to the study
1724 //============================================================================
1725 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1728 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1732 //============================================================================
1733 /*! Function : detach
1734 * Purpose : This function detaches an observer from the study
1736 //============================================================================
1737 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1740 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1743 //===========================================================================
1744 // PRIVATE FUNCTIONS
1745 //===========================================================================
1746 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1749 long pid = (long)_getpid();
1751 long pid = (long)getpid();
1753 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1754 return reinterpret_cast<CORBA::LongLong>(_impl);
1757 void SALOMEDS_Study_i::NameChanged(SALOME::Session_ptr session)
1760 SALOMEDS::sendMessageToGUIGivenSession(session,"studyNameChanged" );