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_ptr _poa;
70 * Return a unique study obj but servant is embeded here.
73 SALOMEDS::Study_ptr KERNEL::getStudyServantSA()
75 static SALOMEDS::Study_ptr aStudy;
76 if(CORBA::is_nil(aStudy))
78 CORBA::ORB_ptr orb = KERNEL::getORB();
79 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
80 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
81 _poa = PortableServer::POA::_duplicate(poa);
82 SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb,SALOME::Session::_nil());
83 aStudy = servant->_this();
85 return SALOMEDS::Study::_duplicate(aStudy);
90 class Notifier: public SALOMEDSImpl_AbstractCallback
93 Notifier(CORBA::ORB_ptr orb)
95 _orb = CORBA::ORB::_duplicate(orb);
98 //============================================================================
99 /*! Function : addSO_Notification
100 * Purpose : This function tells all the observers that a SO has been added
102 //============================================================================
104 virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject)
106 std::string anID=theSObject.GetID();
107 const char* cID=anID.c_str();
108 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
110 it->first->notifyObserverID(cID,1);
112 return true; // NGE return always true but can be modified if needed
115 //============================================================================
116 /*! Function : removeSO_Notification
117 * Purpose : This function tells all the observers that a SO has been removed
119 //============================================================================
121 virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject)
123 std::string anID=theSObject.GetID();
124 const char* cID=anID.c_str();
125 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
127 it->first->notifyObserverID(cID,2);
129 return true; // NGE return always true but can be modified if needed
132 //============================================================================
133 /*! Function : modifySO_Notification
134 * Purpose : This function tells all the observers that a SO has been modified
136 //============================================================================
138 virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason)
140 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
144 std::string anID=theSObject.GetID();
145 const char* cID=anID.c_str();
146 it->first->notifyObserverID(cID,reason);
149 return true; // NGE return always true but can be modified if needed
152 //============================================================================
153 /*! Function : modifyNB_Notification
154 * Purpose : This function tells all the observers that
155 * a NoteBook variable has been added/modified/removed.
157 //============================================================================
159 virtual bool modifyNB_Notification(const char* theVarName)
161 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
163 it->first->notifyObserverID(theVarName,6);
165 return true; // NGE return always true but can be modified if needed
168 //============================================================================
169 /*! Function : attach
170 * Purpose : register an Observer
172 //============================================================================
174 virtual void attach(SALOMEDS::Observer_ptr theObs, bool modify)
176 myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
179 //============================================================================
180 /*! Function : detach
181 * Purpose : unregister an Observer
183 //============================================================================
185 virtual void detach(SALOMEDS::Observer_ptr theObs)
187 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
189 if ( it->first->_is_equivalent(theObs) ) {
190 myObservers.erase( it );
197 typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
198 typedef ObsList::iterator ObsListIter;
203 class GenObjRegister: public SALOMEDSImpl_AbstractCallback
206 GenObjRegister(CORBA::ORB_ptr orb)
208 _orb = CORBA::ORB::_duplicate(orb);
210 virtual void RegisterGenObj (const std::string& theIOR)
214 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
215 if ( obj->_non_existent() ) return;
216 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
217 if(! CORBA::is_nil(gobj) )
222 catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
226 virtual void UnRegisterGenObj(const std::string& theIOR)
230 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
231 if ( obj->_non_existent() ) return;
232 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
233 if(! CORBA::is_nil(gobj) )
238 catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
248 //================================================================================
250 * \brief emitMessageOneWay to SALOME::Session
252 //================================================================================
254 void sendMessageToGUIGivenSession(SALOME::Session_ptr session, const char* msg )
256 if ( !CORBA::is_nil(session) ) {
258 session->emitMessageOneWay( msg );
263 //================================================================================
265 * \brief emitMessageOneWay to SALOME::Session
267 //================================================================================
269 void sendMessageToGUI(const char* msg )
271 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
272 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
273 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
274 sendMessageToGUIGivenSession(aSession,msg);
277 } // namespace SALOMEDS
279 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb)
281 _orb = CORBA::ORB::_duplicate(orb);
282 _impl = new SALOMEDSImpl_Study();
283 _factory = new SALOMEDS_DriverFactory_i(_orb);
285 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
286 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
287 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
291 //============================================================================
292 /*! Function : SALOMEDS_Study_i
293 * Purpose : SALOMEDS_Study_i constructor
295 //============================================================================
296 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME::Session_ptr session)
298 _orb = CORBA::ORB::_duplicate(orb);
299 _impl = new SALOMEDSImpl_Study();
300 _factory = new SALOMEDS_DriverFactory_i(_orb,!CORBA::is_nil(session));
306 //============================================================================
307 /*! Function : ~SALOMEDS_Study_i
308 * Purpose : SALOMEDS_Study_i destructor
310 //============================================================================
311 SALOMEDS_Study_i::~SALOMEDS_Study_i()
318 void SALOMEDS_Study_i::Init()
320 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
321 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
322 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
326 //============================================================================
328 * Purpose : Initialize study components
330 //============================================================================
331 void SALOMEDS_Study_i::Init(SALOME::Session_ptr session)
334 //throw SALOMEDS::Study::StudyInvalidReference();
337 SALOMEDS::Locker lock;
339 if ( !_impl->GetDocument() )
342 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
343 _notifier = new SALOMEDS::Notifier(_orb);
344 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
347 _impl->setNotifier(_notifier);
348 _impl->setGenObjRegister( _genObjRegister );
350 // Notify GUI that study was created
351 SALOMEDS::sendMessageToGUIGivenSession( session, "studyCreated" );
353 // update desktop title with new study name
354 NameChanged(session);
357 //============================================================================
359 * Purpose : Clear study components
361 //============================================================================
362 void SALOMEDS_Study_i::Clear()
367 SALOMEDS::Locker lock;
369 //delete the builder servant
370 PortableServer::POA_var poa=_default_POA();
371 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
372 poa->deactivate_object(anObjectId.in());
373 _builder->_remove_ref();
377 if (_impl->GetDocument()) {
378 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
379 for (; itcomponent->More(); itcomponent->Next()) {
380 SALOMEDS::SComponent_var sco = itcomponent->Value();
381 CORBA::String_var compodatatype=sco->ComponentDataType();
382 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
383 // if there is an associated Engine call its method for closing
384 CORBA::String_var IOREngine;
385 if (sco->ComponentIOR(IOREngine)) {
386 // we have found the associated engine to write the data
387 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
388 //_narrow can throw a corba exception
390 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
391 if (!CORBA::is_nil(obj)) {
392 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
393 if (!anEngine->_is_nil()) {
395 anEngine->Close(sco);
400 catch (CORBA::Exception&) {
406 //Does not need any more this iterator
407 itcomponent->UnRegister();
410 // Notify GUI that study is cleared
411 SALOMEDS::sendMessageToGUI( "studyCleared" );
414 _impl->setNotifier(0);
416 delete _genObjRegister;
422 //============================================================================
424 \brief Get default POA for the servant object.
426 This function is implicitly called from "_this()" function.
427 Default POA can be set via the constructor.
429 \return reference to the default POA for the servant
431 //============================================================================
432 PortableServer::POA_ptr SALOMEDS_Study_i::_default_POA()
434 PortableServer::POA_ptr poa = GetThePOA();
435 MESSAGE("SALOMEDS_Study_i::_default_POA: " << poa);
436 return PortableServer::POA::_duplicate(poa);
439 //============================================================================
441 * Purpose : Open a Study from it's persistent reference
443 //============================================================================
444 bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
450 SALOMEDS::Locker lock;
452 Unexpect aCatch(SalomeException);
453 MESSAGE("Begin of SALOMEDS_Study_i::Open");
454 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
455 bool res = _impl->Open( aUrl );
457 // update desktop title with new study name
459 SALOMEDS::sendMessageToGUI( "connect_to_study" );
462 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
466 //============================================================================
467 /*! Function : CanOpen
468 * Purpose : Check that a Study can be opened
470 //============================================================================
471 bool SALOMEDS_Study_i::CanOpen(const wchar_t* aWUrl)
473 SALOMEDS::Locker lock;
475 Unexpect aCatch(SalomeException);
476 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
478 return SALOMEDSImpl_Study().Open( aUrl );
481 PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA()
486 void SALOMEDS_Study_i::SetThePOA(PortableServer::POA_ptr thePOA)
488 _poa = PortableServer::POA::_duplicate(thePOA);
491 //============================================================================
493 * Purpose : Save a Study to it's persistent reference
495 //============================================================================
496 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
498 SALOMEDS::Locker lock;
500 throw SALOMEDS::Study::StudyInvalidReference();
501 return _impl->Save(_factory, theMultiFile, theASCII);
504 //=============================================================================
505 /*! Function : SaveAs
506 * Purpose : Save a study to the persistent reference aUrl
508 //============================================================================
509 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const wchar_t* aWUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
511 SALOMEDS::Locker lock;
513 throw SALOMEDS::Study::StudyInvalidReference();
515 std::string aUrl = Kernel_Utils::encode_s(aWUrl);
516 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
519 //============================================================================
520 /*! Function : CanCopy
523 //============================================================================
524 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
526 SALOMEDS::Locker lock;
528 throw SALOMEDS::Study::StudyInvalidReference();
530 CORBA::String_var anID = theObject->GetID();
531 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
533 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
534 bool ret = _impl->CanCopy(anObject, aDriver);
539 //============================================================================
543 //============================================================================
544 CORBA::Boolean SALOMEDS_Study_i::Copy(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->Copy(anObject, aDriver);
559 //============================================================================
560 /*! Function : CanPaste
563 //============================================================================
564 CORBA::Boolean SALOMEDS_Study_i::CanPaste(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->CanPaste(anObject, aDriver);
579 //============================================================================
583 //============================================================================
584 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
587 SALOMEDS::Locker lock;
589 Unexpect aCatch(LockProtection);
591 CORBA::String_var anID = theObject->GetID();
592 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
593 SALOMEDSImpl_SObject aNewSO;
596 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
597 aNewSO = _impl->Paste(anObject, aDriver);
601 throw SALOMEDS::StudyBuilder::LockProtection();
604 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
608 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
610 SALOMEDS_Driver_i* driver = NULL;
612 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
614 std::string IOREngine = aSCO.GetIOR();
615 if(!IOREngine.empty()) {
616 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
617 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
618 driver = new SALOMEDS_Driver_i(Engine, orb);
625 //============================================================================
626 /*! Function : GetPersistentReference
627 * Purpose : Get persistent reference of study (idem URL())
629 //============================================================================
630 char* SALOMEDS_Study_i::GetPersistentReference()
632 SALOMEDS::Locker lock;
634 throw SALOMEDS::Study::StudyInvalidReference();
635 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
638 //============================================================================
639 /*! Function : IsEmpty
640 * Purpose : Detect if study is empty
642 //============================================================================
643 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
645 SALOMEDS::Locker lock;
647 throw SALOMEDS::Study::StudyInvalidReference();
648 return _impl->IsEmpty();
651 //============================================================================
652 /*! Function : FindComponent
653 * Purpose : Find a Component with ComponentDataType = aComponentName
655 //============================================================================
656 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
658 SALOMEDS::Locker lock;
661 throw SALOMEDS::Study::StudyInvalidReference();
663 SALOMEDS::SComponent_var sco;
665 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
666 if (!aCompImpl.IsNull())
667 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
672 //============================================================================
673 /*! Function : FindComponentID
674 * Purpose : Find a Component from it's ID
676 //============================================================================
677 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
679 SALOMEDS::Locker lock;
682 throw SALOMEDS::Study::StudyInvalidReference();
684 SALOMEDS::SComponent_var sco;
686 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
687 if (!aCompImpl.IsNull())
688 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
693 //============================================================================
694 /*! Function : FindObject
695 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
697 //============================================================================
698 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
700 SALOMEDS::Locker lock;
703 throw SALOMEDS::Study::StudyInvalidReference();
705 SALOMEDS::SObject_var so;
707 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
709 if (aSO.IsComponent()) {
710 SALOMEDSImpl_SComponent aSCO = aSO;
711 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
714 so = SALOMEDS_SObject_i::New(aSO, _orb);
721 //============================================================================
722 /*! Function : FindObjectID
723 * Purpose : Find an Object with ID = anObjectID
725 //============================================================================
726 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
728 SALOMEDS::Locker lock;
731 throw SALOMEDS::Study::StudyInvalidReference();
733 SALOMEDS::SObject_var so;
735 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
737 so = SALOMEDS_SObject_i::New(aSO, _orb);
742 //============================================================================
743 /*! Function : CreateObjectID
744 * Purpose : Creates an Object with ID = anObjectID
746 //============================================================================
747 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
749 SALOMEDS::Locker lock;
752 throw SALOMEDS::Study::StudyInvalidReference();
754 SALOMEDS::SObject_var so;
756 if (anObjectID && strlen(anObjectID) > 0) {
757 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
759 so = SALOMEDS_SObject_i::New(aSO, _orb);
765 //============================================================================
766 /*! Function : FindObjectByName
767 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
768 * : with ComponentDataType = aComponentName
770 //============================================================================
771 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
772 const char* aComponentName )
774 SALOMEDS::Locker lock;
777 throw SALOMEDS::Study::StudyInvalidReference();
779 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
780 std::string((char*)aComponentName));
782 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
783 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
784 listSO->length(aLength);
785 for (int i = 0; i < aLength; i++) {
786 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
790 return listSO._retn();
793 //============================================================================
794 /*! Function : FindObjectIOR
795 * Purpose : Find an Object with IOR = anObjectIOR
797 //============================================================================
798 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
800 SALOMEDS::Locker lock;
803 throw SALOMEDS::Study::StudyInvalidReference();
805 SALOMEDS::SObject_var so;
807 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
809 so = SALOMEDS_SObject_i::New(aSO, _orb);
814 //============================================================================
815 /*! Function : FindObjectByPath
816 * Purpose : Find an Object by its path = thePath
818 //============================================================================
819 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
821 SALOMEDS::Locker lock;
824 throw SALOMEDS::Study::StudyInvalidReference();
826 SALOMEDS::SObject_var so;
828 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
830 so = SALOMEDS_SObject_i::New (aSO, _orb);
835 //============================================================================
836 /*! Function : GetObjectPath
839 //============================================================================
840 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
842 SALOMEDS::Locker lock;
845 throw SALOMEDS::Study::StudyInvalidReference();
847 std::string aPath = "";
849 if (!CORBA::is_nil(theObject)) {
850 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
851 SALOMEDSImpl_SObject aSO;
853 if (!CORBA::is_nil(aSObj)) {
854 aSO = _impl->FindObjectID(aSObj->GetID());
857 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
861 aPath = _impl->GetObjectPath(aSO);
865 return CORBA::string_dup(aPath.c_str());
868 //============================================================================
869 /*! Function : NewChildIterator
870 * Purpose : Create a ChildIterator from an SObject
872 //============================================================================
873 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
875 SALOMEDS::Locker lock;
878 throw SALOMEDS::Study::StudyInvalidReference();
880 CORBA::String_var anID = theSO->GetID();
881 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
882 SALOMEDSImpl_ChildIterator anItr(aSO);
883 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
884 SALOMEDS::ChildIterator_var it = it_servant->_this();
890 //============================================================================
891 /*! Function : NewComponentIterator
892 * Purpose : Create a SComponentIterator
894 //============================================================================
895 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
897 SALOMEDS::Locker lock;
900 throw SALOMEDS::Study::StudyInvalidReference();
902 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
904 SALOMEDS::SComponentIterator_var it = it_servant->_this();
910 //============================================================================
911 /*! Function : NewBuilder
912 * Purpose : Create a StudyBuilder
914 //============================================================================
915 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
917 SALOMEDS::Locker lock;
920 throw SALOMEDS::Study::StudyInvalidReference();
922 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
927 //============================================================================
929 * Purpose : get study name
931 //============================================================================
932 wchar_t* SALOMEDS_Study_i::Name()
934 SALOMEDS::Locker lock;
935 // Name is specified as IDL attribute: user exception cannot be raised
936 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->Name()));
939 //============================================================================
941 * Purpose : set study name
943 //============================================================================
944 void SALOMEDS_Study_i::Name(const wchar_t* wname)
946 SALOMEDS::Locker lock;
947 // Name is specified as IDL attribute: user exception cannot be raised
948 _impl->Name(Kernel_Utils::encode_s(wname));
951 //============================================================================
952 /*! Function : IsSaved
953 * Purpose : get if study has been saved
955 //============================================================================
956 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
958 SALOMEDS::Locker lock;
959 // IsSaved is specified as IDL attribute: user exception cannot be raised
960 return (!_closed) ? _impl->IsSaved() : false;
963 //============================================================================
964 /*! Function : IsSaved
965 * Purpose : set if study has been saved
967 //============================================================================
968 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
970 SALOMEDS::Locker lock;
971 // IsSaved is specified as IDL attribute: user exception cannot be raised
973 _impl->IsSaved(save);
976 //============================================================================
977 /*! Function : IsModified
978 * Purpose : Detect if a Study has been modified since it has been saved
980 //============================================================================
981 CORBA::Boolean SALOMEDS_Study_i::IsModified()
983 SALOMEDS::Locker lock;
986 throw SALOMEDS::Study::StudyInvalidReference();
988 return _impl->IsModified();
991 //============================================================================
992 /*! Function : Modified
993 * Purpose : Sets a Modified flag of a Study to True
995 //============================================================================
996 void SALOMEDS_Study_i::Modified()
998 SALOMEDS::Locker lock;
1001 throw SALOMEDS::Study::StudyInvalidReference();
1006 //============================================================================
1008 * Purpose : get URL of the study (persistent reference of the study)
1010 //============================================================================
1011 wchar_t* SALOMEDS_Study_i::URL()
1013 SALOMEDS::Locker lock;
1014 // URL is specified as IDL attribute: user exception cannot be raised
1015 return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->URL()));
1018 //============================================================================
1020 * Purpose : set URL of the study (persistent reference of the study)
1022 //============================================================================
1023 void SALOMEDS_Study_i::URL(const wchar_t* wurl)
1025 SALOMEDS::Locker lock;
1026 // URL is specified as IDL attribute: user exception cannot be raised
1027 _impl->URL(Kernel_Utils::encode_s(wurl));
1029 // update desktop title with new study name
1030 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1031 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1032 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1033 NameChanged(aSession);
1036 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1038 SALOMEDS::Locker lock;
1041 throw SALOMEDS::Study::StudyInvalidReference();
1043 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1046 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1048 SALOMEDS::Locker lock;
1049 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1052 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1054 SALOMEDS::Locker lock;
1057 throw SALOMEDS::Study::StudyInvalidReference();
1059 SALOMEDS::GenericAttribute_ptr aTarget;
1060 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1061 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1063 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1069 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1071 SALOMEDS::Locker lock;
1074 throw SALOMEDS::Study::StudyInvalidReference();
1076 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1077 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1078 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1079 return aProp._retn();
1082 char* SALOMEDS_Study_i::GetLastModificationDate()
1084 SALOMEDS::Locker lock;
1087 throw SALOMEDS::Study::StudyInvalidReference();
1089 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1092 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1094 SALOMEDS::Locker lock;
1097 throw SALOMEDS::Study::StudyInvalidReference();
1099 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1101 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1103 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1104 aDates->length(aLength);
1105 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1106 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1109 return aDates._retn();
1112 //============================================================================
1113 /*! Function : GetUseCaseBuilder
1114 * Purpose : Returns a UseCase builder
1116 //============================================================================
1117 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1119 SALOMEDS::Locker lock;
1122 throw SALOMEDS::Study::StudyInvalidReference();
1124 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1125 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1129 //============================================================================
1130 /*! Function : AddPostponed
1133 //============================================================================
1134 void SALOMEDS_Study_i::AddPostponed(const char* /*theIOR*/)
1136 SALOMEDS::Locker lock;
1140 void SALOMEDS_Study_i::AddCreatedPostponed(const char* /*theIOR*/)
1142 SALOMEDS::Locker lock;
1146 //============================================================================
1147 /*! Function : RemovePostponed
1150 //============================================================================
1151 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1153 SALOMEDS::Locker lock;
1156 throw SALOMEDS::Study::StudyInvalidReference();
1158 std::vector<std::string> anIORs = _impl->GetIORs();
1159 int i, aSize = (int)anIORs.size();
1161 for (i = 0; i < aSize; i++) {
1163 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1164 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1165 //rnv: To avoid double deletion of the Salome Generic Objects:
1166 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1167 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1168 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1175 //============================================================================
1176 /*! Function : UndoPostponed
1179 //============================================================================
1180 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long /*theWay*/)
1182 SALOMEDS::Locker lock;
1187 //============================================================================
1188 /*! Function : DumpStudy
1191 //============================================================================
1192 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1193 const char* theBaseName,
1194 CORBA::Boolean isPublished,
1195 CORBA::Boolean isMultiFile)
1197 SALOMEDS::Locker lock;
1200 throw SALOMEDS::Study::StudyInvalidReference();
1202 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1203 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1204 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1210 //============================================================================
1211 /*! Function : GetDumpPath
1214 //============================================================================
1215 char* SALOMEDS_Study_i::GetDumpPath()
1217 return CORBA::string_dup(_impl->GetDumpPath().c_str());
1220 //============================================================================
1221 /*! Function : GetCommonParameters
1224 //============================================================================
1225 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1227 SALOMEDS::Locker lock;
1230 throw SALOMEDS::Study::StudyInvalidReference();
1232 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1233 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1234 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1236 return aParam._retn();
1239 //============================================================================
1240 /*! Function : GetCommonModuleParameters
1243 //============================================================================
1244 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1245 const char* theModuleName,
1246 CORBA::Long theSavePoint)
1248 SALOMEDS::Locker lock;
1251 throw SALOMEDS::Study::StudyInvalidReference();
1253 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1254 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1255 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1257 return aParam._retn();
1260 //============================================================================
1261 /*! Function : SetStudyLock
1264 //============================================================================
1265 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1267 SALOMEDS::Locker lock;
1270 throw SALOMEDS::Study::StudyInvalidReference();
1272 _impl->SetStudyLock(theLockerID);
1275 //============================================================================
1276 /*! Function : IsStudyLocked
1279 //============================================================================
1280 bool SALOMEDS_Study_i::IsStudyLocked()
1282 SALOMEDS::Locker lock;
1285 throw SALOMEDS::Study::StudyInvalidReference();
1287 return _impl->IsStudyLocked();
1290 //============================================================================
1291 /*! Function : UnLockStudy
1294 //============================================================================
1295 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1297 SALOMEDS::Locker lock;
1300 throw SALOMEDS::Study::StudyInvalidReference();
1302 _impl->UnLockStudy(theLockerID);
1305 //============================================================================
1306 /*! Function : GetLockerID
1309 //============================================================================
1310 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1312 SALOMEDS::Locker lock;
1315 throw SALOMEDS::Study::StudyInvalidReference();
1317 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1319 std::vector<std::string> aSeq = _impl->GetLockerID();
1321 int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
1322 aResult->length(aLength);
1323 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1324 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1327 return aResult._retn();
1329 //============================================================================
1330 /*! Function : SetReal
1333 //============================================================================
1334 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1337 throw SALOMEDS::Study::StudyInvalidReference();
1340 _impl->SetVariable(std::string(theVarName),
1342 SALOMEDSImpl_GenericVariable::REAL_VAR);
1344 _notifier->modifyNB_Notification(theVarName);
1347 //============================================================================
1348 /*! Function : SetInteger
1351 //============================================================================
1352 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1355 throw SALOMEDS::Study::StudyInvalidReference();
1357 _impl->SetVariable(std::string(theVarName),
1359 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1361 _notifier->modifyNB_Notification(theVarName);
1364 //============================================================================
1365 /*! Function : SetBoolean
1368 //============================================================================
1369 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1372 throw SALOMEDS::Study::StudyInvalidReference();
1374 _impl->SetVariable(std::string(theVarName),
1376 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1378 _notifier->modifyNB_Notification(theVarName);
1381 //============================================================================
1382 /*! Function : SetString
1385 //============================================================================
1386 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1389 throw SALOMEDS::Study::StudyInvalidReference();
1391 _impl->SetStringVariable(std::string(theVarName),
1393 SALOMEDSImpl_GenericVariable::STRING_VAR);
1395 _notifier->modifyNB_Notification(theVarName);
1398 //============================================================================
1399 /*! Function : SetStringAsDouble
1402 //============================================================================
1403 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1406 throw SALOMEDS::Study::StudyInvalidReference();
1408 _impl->SetStringVariableAsDouble(std::string(theVarName),
1410 SALOMEDSImpl_GenericVariable::STRING_VAR);
1413 //============================================================================
1414 /*! Function : GetReal
1417 //============================================================================
1418 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1421 throw SALOMEDS::Study::StudyInvalidReference();
1423 return _impl->GetVariableValue(std::string(theVarName));
1426 //============================================================================
1427 /*! Function : GetInteger
1430 //============================================================================
1431 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1434 throw SALOMEDS::Study::StudyInvalidReference();
1436 return (long)_impl->GetVariableValue(std::string(theVarName));
1439 //============================================================================
1440 /*! Function : GetBoolean
1443 //============================================================================
1444 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1447 throw SALOMEDS::Study::StudyInvalidReference();
1449 return (bool)_impl->GetVariableValue(std::string(theVarName));
1452 //============================================================================
1453 /*! Function : GetString
1456 //============================================================================
1457 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1460 throw SALOMEDS::Study::StudyInvalidReference();
1462 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1465 //============================================================================
1466 /*! Function : IsReal
1469 //============================================================================
1470 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1473 throw SALOMEDS::Study::StudyInvalidReference();
1475 return _impl->IsTypeOf(std::string(theVarName),
1476 SALOMEDSImpl_GenericVariable::REAL_VAR);
1479 //============================================================================
1480 /*! Function : IsInteger
1483 //============================================================================
1484 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1487 throw SALOMEDS::Study::StudyInvalidReference();
1489 return _impl->IsTypeOf(std::string(theVarName),
1490 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1493 //============================================================================
1494 /*! Function : IsBoolean
1497 //============================================================================
1498 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1501 throw SALOMEDS::Study::StudyInvalidReference();
1503 return _impl->IsTypeOf(std::string(theVarName),
1504 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1507 //============================================================================
1508 /*! Function : IsString
1511 //============================================================================
1512 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1515 throw SALOMEDS::Study::StudyInvalidReference();
1517 return _impl->IsTypeOf(std::string(theVarName),
1518 SALOMEDSImpl_GenericVariable::STRING_VAR);
1521 //============================================================================
1522 /*! Function : IsVariable
1525 //============================================================================
1526 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1529 throw SALOMEDS::Study::StudyInvalidReference();
1531 return _impl->IsVariable(std::string(theVarName));
1534 //============================================================================
1535 /*! Function : GetVariableNames
1538 //============================================================================
1539 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1542 throw SALOMEDS::Study::StudyInvalidReference();
1544 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1546 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1548 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1549 aResult->length(aLen);
1550 for (int anInd = 0; anInd < aLen; anInd++)
1551 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1553 return aResult._retn();
1556 //============================================================================
1557 /*! Function : RemoveVariable
1560 //============================================================================
1561 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1564 throw SALOMEDS::Study::StudyInvalidReference();
1566 bool res = _impl->RemoveVariable(std::string(theVarName));
1567 if (res && _notifier)
1568 _notifier->modifyNB_Notification(theVarName);
1573 //============================================================================
1574 /*! Function : RenameVariable
1577 //============================================================================
1578 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1581 throw SALOMEDS::Study::StudyInvalidReference();
1583 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1584 if (res && _notifier)
1585 _notifier->modifyNB_Notification(theVarName);
1590 //============================================================================
1591 /*! Function : IsVariableUsed
1594 //============================================================================
1595 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1598 throw SALOMEDS::Study::StudyInvalidReference();
1600 return _impl->IsVariableUsed(std::string(theVarName));
1604 //============================================================================
1605 /*! Function : ParseVariables
1608 //============================================================================
1609 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1612 throw SALOMEDS::Study::StudyInvalidReference();
1614 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1616 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1618 int aSectionsLen = (int)aSections.size(); //!< TODO: conversion from size_t to int
1619 aResult->length(aSectionsLen);
1621 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1622 std::vector<std::string> aVarNames = aSections[aSectionInd];
1624 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1626 int aLen = (int)aVarNames.size(); //!< TODO: conversion from size_t to int
1627 aList->length(aLen);
1629 for (int anInd = 0; anInd < aLen; anInd++)
1630 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1632 aResult[aSectionInd] = aList;
1635 return aResult._retn();
1638 //============================================================================
1639 /*! Function : GetDefaultScript
1642 //============================================================================
1643 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1645 SALOMEDS::Locker lock;
1648 throw SALOMEDS::Study::StudyInvalidReference();
1650 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1651 return CORBA::string_dup(script.c_str());
1654 //============================================================================
1655 /*! Function : EnableUseCaseAutoFilling
1658 //============================================================================
1659 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1662 throw SALOMEDS::Study::StudyInvalidReference();
1664 _impl->EnableUseCaseAutoFilling(isEnabled);
1665 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1668 builder->SetOnAddSObject(_impl->GetCallback());
1669 builder->SetOnRemoveSObject(_impl->GetCallback());
1672 builder->SetOnAddSObject(NULL);
1673 builder->SetOnRemoveSObject(NULL);
1679 CORBA::Long SALOMEDS_Study_i::getPID()
1682 return (CORBA::Long)_getpid();
1684 return (CORBA::Long)getpid();
1688 void SALOMEDS_Study_i::ShutdownWithExit()
1690 exit( EXIT_SUCCESS );
1693 void SALOMEDS_Study_i::Shutdown()
1695 if(!CORBA::is_nil(_orb))
1697 _closed = true; // force 'closed' flag to avoid terminating
1700 //============================================================================
1701 /*! Function : attach
1702 * Purpose : This function attach an observer to the study
1704 //============================================================================
1705 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1708 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1712 //============================================================================
1713 /*! Function : detach
1714 * Purpose : This function detaches an observer from the study
1716 //============================================================================
1717 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1720 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1723 //===========================================================================
1724 // PRIVATE FUNCTIONS
1725 //===========================================================================
1726 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1729 long pid = (long)_getpid();
1731 long pid = (long)getpid();
1733 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1734 return reinterpret_cast<CORBA::LongLong>(_impl);
1737 void SALOMEDS_Study_i::NameChanged(SALOME::Session_ptr session)
1740 SALOMEDS::sendMessageToGUIGivenSession(session,"studyNameChanged" );