1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_Study_i.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
29 #include "SALOMEDS_Study_i.hxx"
30 #include "SALOMEDS_UseCaseIterator_i.hxx"
31 #include "SALOMEDS_GenericAttribute_i.hxx"
32 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
33 #include "SALOMEDS_AttributeParameter_i.hxx"
34 #include "SALOMEDS_ChildIterator_i.hxx"
35 #include "SALOMEDS_Driver_i.hxx"
36 #include "SALOMEDS.hxx"
38 #include "SALOMEDSImpl_SObject.hxx"
39 #include "SALOMEDSImpl_SComponent.hxx"
40 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
42 #include "SALOMEDSImpl_AttributeParameter.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_IParameters.hxx"
45 #include "SALOMEDSImpl_Callback.hxx"
47 #include "DF_Label.hxx"
48 #include "DF_Attribute.hxx"
50 #include "Utils_ExceptHandlers.hxx"
52 #include "Basics_Utils.hxx"
53 #include "SALOME_KernelServices.hxx"
58 #include <sys/types.h>
62 UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
63 UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
65 static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
69 class Notifier: public SALOMEDSImpl_AbstractCallback
72 Notifier(CORBA::ORB_ptr orb)
74 _orb = CORBA::ORB::_duplicate(orb);
77 //============================================================================
78 /*! Function : addSO_Notification
79 * Purpose : This function tells all the observers that a SO has been added
81 //============================================================================
83 virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject)
85 std::string anID=theSObject.GetID();
86 const char* cID=anID.c_str();
87 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
89 it->first->notifyObserverID(cID,1);
91 return true; // NGE return always true but can be modified if needed
94 //============================================================================
95 /*! Function : removeSO_Notification
96 * Purpose : This function tells all the observers that a SO has been removed
98 //============================================================================
100 virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject)
102 std::string anID=theSObject.GetID();
103 const char* cID=anID.c_str();
104 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
106 it->first->notifyObserverID(cID,2);
108 return true; // NGE return always true but can be modified if needed
111 //============================================================================
112 /*! Function : modifySO_Notification
113 * Purpose : This function tells all the observers that a SO has been modified
115 //============================================================================
117 virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason)
119 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
123 std::string anID=theSObject.GetID();
124 const char* cID=anID.c_str();
125 it->first->notifyObserverID(cID,reason);
128 return true; // NGE return always true but can be modified if needed
131 //============================================================================
132 /*! Function : modifyNB_Notification
133 * Purpose : This function tells all the observers that
134 * a NoteBook variable has been added/modified/removed.
136 //============================================================================
138 virtual bool modifyNB_Notification(const char* theVarName)
140 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
142 it->first->notifyObserverID(theVarName,6);
144 return true; // NGE return always true but can be modified if needed
147 //============================================================================
148 /*! Function : attach
149 * Purpose : register an Observer
151 //============================================================================
153 virtual void attach(SALOMEDS::Observer_ptr theObs, bool modify)
155 myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
158 //============================================================================
159 /*! Function : detach
160 * Purpose : unregister an Observer
162 //============================================================================
164 virtual void detach(SALOMEDS::Observer_ptr theObs)
166 for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
168 if ( it->first->_is_equivalent(theObs) ) {
169 myObservers.erase( it );
176 typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
177 typedef ObsList::iterator ObsListIter;
182 } // namespace SALOMEDS
184 //============================================================================
185 /*! Function : SALOMEDS_Study_i
186 * Purpose : SALOMEDS_Study_i constructor
188 //============================================================================
189 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb)
191 _orb = CORBA::ORB::_duplicate(orb);
192 _impl = new SALOMEDSImpl_Study();
193 _factory = new SALOMEDS_DriverFactory_i(_orb);
198 //============================================================================
199 /*! Function : ~SALOMEDS_Study_i
200 * Purpose : SALOMEDS_Study_i destructor
202 //============================================================================
203 SALOMEDS_Study_i::~SALOMEDS_Study_i()
210 //============================================================================
212 * Purpose : Initialize study components
214 //============================================================================
215 void SALOMEDS_Study_i::Init()
217 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
218 _notifier = new SALOMEDS::Notifier(_orb);
221 _impl->setNotifier(_notifier);
223 // Notify GUI that study was created
224 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
225 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
226 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
227 if ( !CORBA::is_nil(aSession) ) {
228 std::stringstream ss;
229 ss << "studyCreated";
230 std::string str = ss.str();
232 aSession->emitMessageOneWay(str.c_str());
237 //============================================================================
239 * Purpose : Clear study components
241 //============================================================================
242 void SALOMEDS_Study_i::Clear()
244 //delete the builder servant
245 PortableServer::POA_var poa=_builder->_default_POA();
246 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
247 poa->deactivate_object(anObjectId.in());
248 _builder->_remove_ref();
251 _impl->setNotifier(0);
254 SALOMEDS::Locker lock;
257 throw SALOMEDS::Study::StudyInvalidReference();
261 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
262 for (; itcomponent->More(); itcomponent->Next()) {
263 SALOMEDS::SComponent_var sco = itcomponent->Value();
264 CORBA::String_var compodatatype=sco->ComponentDataType();
265 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
266 // if there is an associated Engine call its method for closing
267 CORBA::String_var IOREngine;
268 if (sco->ComponentIOR(IOREngine)) {
269 // we have found the associated engine to write the data
270 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
271 //_narrow can throw a corba exception
273 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
274 if (!CORBA::is_nil(obj)) {
275 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
276 if (!anEngine->_is_nil()) {
278 anEngine->Close(sco);
283 catch (CORBA::Exception&) {
289 //Does not need any more this iterator
290 itcomponent->UnRegister();
292 // Notify GUI that study is cleared
293 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
294 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
295 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
296 if ( !CORBA::is_nil(aSession) ) {
297 std::stringstream ss;
298 ss << "studyCleared";
299 std::string str = ss.str();
301 aSession->emitMessageOneWay(str.c_str());
308 //============================================================================
310 * Purpose : Open a Study from it's persistent reference
312 //============================================================================
313 bool SALOMEDS_Study_i::Open(const char* aUrl)
314 throw(SALOME::SALOME_Exception)
316 SALOMEDS::Locker lock;
318 Unexpect aCatch(SalomeException);
319 MESSAGE("Begin of SALOMEDS_Study_i::Open");
321 bool res = _impl->Open(std::string(aUrl));
324 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
328 //============================================================================
330 * Purpose : Save a Study to it's persistent reference
332 //============================================================================
333 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
335 SALOMEDS::Locker lock;
336 return _impl->Save(_factory, theMultiFile);
339 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
341 SALOMEDS::Locker lock;
342 return _impl->SaveASCII(_factory, theMultiFile);
345 //=============================================================================
346 /*! Function : SaveAs
347 * Purpose : Save a study to the persistent reference aUrl
349 //============================================================================
350 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
352 SALOMEDS::Locker lock;
353 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
356 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
358 SALOMEDS::Locker lock;
359 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
362 //============================================================================
363 /*! Function : CanCopy
366 //============================================================================
367 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
369 SALOMEDS::Locker lock;
371 CORBA::String_var anID = theObject->GetID();
372 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
374 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
375 bool ret = _impl->CanCopy(anObject, aDriver);
380 //============================================================================
384 //============================================================================
385 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
387 SALOMEDS::Locker lock;
389 CORBA::String_var anID = theObject->GetID();
390 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
392 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
393 bool ret = _impl->Copy(anObject, aDriver);
398 //============================================================================
399 /*! Function : CanPaste
402 //============================================================================
403 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
405 SALOMEDS::Locker lock;
407 CORBA::String_var anID = theObject->GetID();
408 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
410 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
411 bool ret = _impl->CanPaste(anObject, aDriver);
416 //============================================================================
420 //============================================================================
421 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
422 throw(SALOMEDS::StudyBuilder::LockProtection)
424 SALOMEDS::Locker lock;
426 Unexpect aCatch(LockProtection);
428 CORBA::String_var anID = theObject->GetID();
429 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
430 SALOMEDSImpl_SObject aNewSO;
433 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
434 aNewSO = _impl->Paste(anObject, aDriver);
438 throw SALOMEDS::StudyBuilder::LockProtection();
441 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
445 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
447 SALOMEDS_Driver_i* driver = NULL;
449 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
451 std::string IOREngine = aSCO.GetIOR();
452 if(!IOREngine.empty()) {
453 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
454 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
455 driver = new SALOMEDS_Driver_i(Engine, orb);
462 //============================================================================
463 /*! Function : GetPersistentReference
464 * Purpose : Get persistent reference of study (idem URL())
466 //============================================================================
467 char* SALOMEDS_Study_i::GetPersistentReference()
469 SALOMEDS::Locker lock;
471 throw SALOMEDS::Study::StudyInvalidReference();
472 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
474 //============================================================================
475 /*! Function : GetTransientReference
476 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
478 //============================================================================
479 char* SALOMEDS_Study_i::GetTransientReference()
481 SALOMEDS::Locker lock;
483 throw SALOMEDS::Study::StudyInvalidReference();
484 return CORBA::string_dup(_impl->GetTransientReference().c_str());
487 //============================================================================
488 /*! Function : IsEmpty
489 * Purpose : Detect if study is empty
491 //============================================================================
492 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
494 SALOMEDS::Locker lock;
496 throw SALOMEDS::Study::StudyInvalidReference();
497 return _impl->IsEmpty();
500 //============================================================================
501 /*! Function : FindComponent
502 * Purpose : Find a Component with ComponentDataType = aComponentName
504 //============================================================================
505 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
507 SALOMEDS::Locker lock;
510 throw SALOMEDS::Study::StudyInvalidReference();
512 SALOMEDS::SComponent_var sco;
514 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
515 if (!aCompImpl.IsNull())
516 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
521 //============================================================================
522 /*! Function : FindComponentID
523 * Purpose : Find a Component from it's ID
525 //============================================================================
526 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
528 SALOMEDS::Locker lock;
531 throw SALOMEDS::Study::StudyInvalidReference();
533 SALOMEDS::SComponent_var sco;
535 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
536 if (!aCompImpl.IsNull())
537 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
542 //============================================================================
543 /*! Function : FindObject
544 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
546 //============================================================================
547 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
549 SALOMEDS::Locker lock;
552 throw SALOMEDS::Study::StudyInvalidReference();
554 SALOMEDS::SObject_var so;
556 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
558 if (aSO.IsComponent()) {
559 SALOMEDSImpl_SComponent aSCO = aSO;
560 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
563 so = SALOMEDS_SObject_i::New(aSO, _orb);
570 //============================================================================
571 /*! Function : FindObjectID
572 * Purpose : Find an Object with ID = anObjectID
574 //============================================================================
575 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
577 SALOMEDS::Locker lock;
580 throw SALOMEDS::Study::StudyInvalidReference();
582 SALOMEDS::SObject_var so;
584 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
586 so = SALOMEDS_SObject_i::New(aSO, _orb);
591 //============================================================================
592 /*! Function : CreateObjectID
593 * Purpose : Creates an Object with ID = anObjectID
595 //============================================================================
596 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
598 SALOMEDS::Locker lock;
601 throw SALOMEDS::Study::StudyInvalidReference();
603 SALOMEDS::SObject_var so;
605 if (anObjectID && strlen(anObjectID) > 0) {
606 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
608 so = SALOMEDS_SObject_i::New(aSO, _orb);
614 //============================================================================
615 /*! Function : FindObjectByName
616 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
617 * : with ComponentDataType = aComponentName
619 //============================================================================
620 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
621 const char* aComponentName )
623 SALOMEDS::Locker lock;
626 throw SALOMEDS::Study::StudyInvalidReference();
628 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
629 std::string((char*)aComponentName));
631 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
632 int aLength = aSeq.size();
633 listSO->length(aLength);
634 for (int i = 0; i < aLength; i++) {
635 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
639 return listSO._retn();
642 //============================================================================
643 /*! Function : FindObjectIOR
644 * Purpose : Find an Object with IOR = anObjectIOR
646 //============================================================================
647 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
649 SALOMEDS::Locker lock;
652 throw SALOMEDS::Study::StudyInvalidReference();
654 SALOMEDS::SObject_var so;
656 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
658 so = SALOMEDS_SObject_i::New(aSO, _orb);
663 //============================================================================
664 /*! Function : FindObjectByPath
665 * Purpose : Find an Object by its path = thePath
667 //============================================================================
668 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
670 SALOMEDS::Locker lock;
673 throw SALOMEDS::Study::StudyInvalidReference();
675 SALOMEDS::SObject_var so;
677 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
679 so = SALOMEDS_SObject_i::New (aSO, _orb);
684 //============================================================================
685 /*! Function : GetObjectPath
688 //============================================================================
689 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
691 SALOMEDS::Locker lock;
694 throw SALOMEDS::Study::StudyInvalidReference();
696 std::string aPath = "";
698 if (!CORBA::is_nil(theObject)) {
699 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
700 SALOMEDSImpl_SObject aSO;
702 if (!CORBA::is_nil(aSObj)) {
703 aSO = _impl->FindObjectID(aSObj->GetID());
706 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
710 aPath = _impl->GetObjectPath(aSO);
714 return CORBA::string_dup(aPath.c_str());
718 //============================================================================
719 /*! Function : SetContext
720 * Purpose : Sets the current context
722 //============================================================================
723 void SALOMEDS_Study_i::SetContext(const char* thePath)
725 SALOMEDS::Locker lock;
728 throw SALOMEDS::Study::StudyInvalidReference();
730 _impl->SetContext(std::string((char*)thePath));
731 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
732 throw SALOMEDS::Study::StudyInvalidContext();
735 //============================================================================
736 /*! Function : GetContext
737 * Purpose : Gets the current context
739 //============================================================================
740 char* SALOMEDS_Study_i::GetContext()
742 SALOMEDS::Locker lock;
745 throw SALOMEDS::Study::StudyInvalidReference();
747 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
749 return CORBA::string_dup(_impl->GetContext().c_str());
752 //============================================================================
753 /*! Function : GetObjectNames
754 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
756 //============================================================================
757 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
759 SALOMEDS::Locker lock;
762 throw SALOMEDS::Study::StudyInvalidReference();
764 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
766 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
767 throw SALOMEDS::Study::StudyInvalidContext();
769 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
770 if (_impl->GetErrorCode() == "InvalidContext")
771 throw SALOMEDS::Study::StudyInvalidContext();
773 int aLength = aSeq.size();
774 aResult->length(aLength);
775 for (int anIndex = 0; anIndex < aLength; anIndex++) {
776 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
779 return aResult._retn();
782 //============================================================================
783 /*! Function : GetDirectoryNames
784 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
786 //============================================================================
787 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
789 SALOMEDS::Locker lock;
792 throw SALOMEDS::Study::StudyInvalidReference();
794 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
796 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
797 throw SALOMEDS::Study::StudyInvalidContext();
799 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
800 if (_impl->GetErrorCode() == "InvalidContext")
801 throw SALOMEDS::Study::StudyInvalidContext();
803 int aLength = aSeq.size();
804 aResult->length(aLength);
805 for (int anIndex = 0; anIndex < aLength; anIndex++) {
806 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
809 return aResult._retn();
812 //============================================================================
813 /*! Function : GetFileNames
814 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
816 //============================================================================
817 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
819 SALOMEDS::Locker lock;
822 throw SALOMEDS::Study::StudyInvalidReference();
824 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
826 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
827 throw SALOMEDS::Study::StudyInvalidContext();
829 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
830 if (_impl->GetErrorCode() == "InvalidContext")
831 throw SALOMEDS::Study::StudyInvalidContext();
833 int aLength = aSeq.size();
834 aResult->length(aLength);
835 for (int anIndex = 0; anIndex < aLength; anIndex++) {
836 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
839 return aResult._retn();
842 //============================================================================
843 /*! Function : GetComponentNames
844 * Purpose : method to get all components names
845 * SRN: Note, theContext can be any, it doesn't matter
847 //============================================================================
848 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
850 SALOMEDS::Locker lock;
853 throw SALOMEDS::Study::StudyInvalidReference();
855 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
857 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
859 int aLength = aSeq.size();
860 aResult->length(aLength);
861 for(int anIndex = 0; anIndex < aLength; anIndex++) {
862 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
865 return aResult._retn();
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 char* SALOMEDS_Study_i::Name()
934 SALOMEDS::Locker lock;
935 // Name is specified as IDL attribute: user exception cannot be raised
936 return CORBA::string_dup(_impl->Name().c_str());
939 //============================================================================
940 /*! Function : IsSaved
941 * Purpose : get if study has been saved
943 //============================================================================
944 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
946 SALOMEDS::Locker lock;
947 // IsSaved is specified as IDL attribute: user exception cannot be raised
948 return (!_closed) ? _impl->IsSaved() : false;
951 //============================================================================
952 /*! Function : IsSaved
953 * Purpose : set if study has been saved
955 //============================================================================
956 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
958 SALOMEDS::Locker lock;
959 // IsSaved is specified as IDL attribute: user exception cannot be raised
961 _impl->IsSaved(save);
964 //============================================================================
965 /*! Function : IsModified
966 * Purpose : Detect if a Study has been modified since it has been saved
968 //============================================================================
969 CORBA::Boolean SALOMEDS_Study_i::IsModified()
971 SALOMEDS::Locker lock;
974 throw SALOMEDS::Study::StudyInvalidReference();
976 return _impl->IsModified();
979 //============================================================================
980 /*! Function : Modified
981 * Purpose : Sets a Modified flag of a Study to True
983 //============================================================================
984 void SALOMEDS_Study_i::Modified()
986 SALOMEDS::Locker lock;
989 throw SALOMEDS::Study::StudyInvalidReference();
994 //============================================================================
996 * Purpose : get URL of the study (persistent reference of the study)
998 //============================================================================
999 char* SALOMEDS_Study_i::URL()
1001 SALOMEDS::Locker lock;
1002 // URL is specified as IDL attribute: user exception cannot be raised
1003 return CORBA::string_dup(_impl->URL().c_str());
1006 //============================================================================
1008 * Purpose : set URL of the study (persistent reference of the study)
1010 //============================================================================
1011 void SALOMEDS_Study_i::URL(const char* url)
1013 SALOMEDS::Locker lock;
1014 // URL is specified as IDL attribute: user exception cannot be raised
1015 _impl->URL(std::string((char*)url));
1018 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1020 SALOMEDS::Locker lock;
1023 throw SALOMEDS::Study::StudyInvalidReference();
1025 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1028 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1030 SALOMEDS::Locker lock;
1031 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1034 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1036 SALOMEDS::Locker lock;
1039 throw SALOMEDS::Study::StudyInvalidReference();
1041 SALOMEDS::GenericAttribute_ptr aTarget;
1042 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1043 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1045 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1051 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1053 SALOMEDS::Locker lock;
1056 throw SALOMEDS::Study::StudyInvalidReference();
1058 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1059 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1060 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1061 return aProp._retn();
1064 char* SALOMEDS_Study_i::GetLastModificationDate()
1066 SALOMEDS::Locker lock;
1069 throw SALOMEDS::Study::StudyInvalidReference();
1071 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1074 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1076 SALOMEDS::Locker lock;
1079 throw SALOMEDS::Study::StudyInvalidReference();
1081 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1083 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1085 int aLength = aSeq.size();
1086 aDates->length(aLength);
1087 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1088 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1091 return aDates._retn();
1094 //============================================================================
1095 /*! Function : GetUseCaseBuilder
1096 * Purpose : Returns a UseCase builder
1098 //============================================================================
1099 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1101 SALOMEDS::Locker lock;
1104 throw SALOMEDS::Study::StudyInvalidReference();
1106 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1107 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1111 //============================================================================
1112 /*! Function : AddPostponed
1115 //============================================================================
1116 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1118 SALOMEDS::Locker lock;
1122 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1124 SALOMEDS::Locker lock;
1128 //============================================================================
1129 /*! Function : RemovePostponed
1132 //============================================================================
1133 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1135 SALOMEDS::Locker lock;
1138 throw SALOMEDS::Study::StudyInvalidReference();
1140 std::vector<std::string> anIORs = _impl->GetIORs();
1141 int i, aSize = (int)anIORs.size();
1143 for (i = 0; i < aSize; i++) {
1145 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1146 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1147 //rnv: To avoid double deletion of the Salome Generic Objects:
1148 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1149 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1150 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1157 //============================================================================
1158 /*! Function : UndoPostponed
1161 //============================================================================
1162 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1164 SALOMEDS::Locker lock;
1169 //============================================================================
1170 /*! Function : DumpStudy
1173 //============================================================================
1174 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1175 const char* theBaseName,
1176 CORBA::Boolean isPublished,
1177 CORBA::Boolean isMultiFile)
1179 SALOMEDS::Locker lock;
1182 throw SALOMEDS::Study::StudyInvalidReference();
1184 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1185 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1186 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1192 //============================================================================
1193 /*! Function : GetCommonParameters
1196 //============================================================================
1197 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1199 SALOMEDS::Locker lock;
1202 throw SALOMEDS::Study::StudyInvalidReference();
1204 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1205 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1206 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1208 return aParam._retn();
1211 //============================================================================
1212 /*! Function : GetCommonModuleParameters
1215 //============================================================================
1216 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1217 const char* theModuleName,
1218 CORBA::Long theSavePoint)
1220 SALOMEDS::Locker lock;
1223 throw SALOMEDS::Study::StudyInvalidReference();
1225 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1226 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1227 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1229 return aParam._retn();
1232 //============================================================================
1233 /*! Function : SetStudyLock
1236 //============================================================================
1237 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1239 SALOMEDS::Locker lock;
1242 throw SALOMEDS::Study::StudyInvalidReference();
1244 _impl->SetStudyLock(theLockerID);
1247 //============================================================================
1248 /*! Function : IsStudyLocked
1251 //============================================================================
1252 bool SALOMEDS_Study_i::IsStudyLocked()
1254 SALOMEDS::Locker lock;
1257 throw SALOMEDS::Study::StudyInvalidReference();
1259 return _impl->IsStudyLocked();
1262 //============================================================================
1263 /*! Function : UnLockStudy
1266 //============================================================================
1267 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1269 SALOMEDS::Locker lock;
1272 throw SALOMEDS::Study::StudyInvalidReference();
1274 _impl->UnLockStudy(theLockerID);
1277 //============================================================================
1278 /*! Function : GetLockerID
1281 //============================================================================
1282 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1284 SALOMEDS::Locker lock;
1287 throw SALOMEDS::Study::StudyInvalidReference();
1289 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1291 std::vector<std::string> aSeq = _impl->GetLockerID();
1293 int aLength = aSeq.size();
1294 aResult->length(aLength);
1295 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1296 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1299 return aResult._retn();
1301 //============================================================================
1302 /*! Function : SetReal
1305 //============================================================================
1306 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1309 throw SALOMEDS::Study::StudyInvalidReference();
1312 _impl->SetVariable(std::string(theVarName),
1314 SALOMEDSImpl_GenericVariable::REAL_VAR);
1316 _notifier->modifyNB_Notification(theVarName);
1319 //============================================================================
1320 /*! Function : SetInteger
1323 //============================================================================
1324 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1327 throw SALOMEDS::Study::StudyInvalidReference();
1329 _impl->SetVariable(std::string(theVarName),
1331 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1333 _notifier->modifyNB_Notification(theVarName);
1336 //============================================================================
1337 /*! Function : SetBoolean
1340 //============================================================================
1341 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1344 throw SALOMEDS::Study::StudyInvalidReference();
1346 _impl->SetVariable(std::string(theVarName),
1348 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1350 _notifier->modifyNB_Notification(theVarName);
1353 //============================================================================
1354 /*! Function : SetString
1357 //============================================================================
1358 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1361 throw SALOMEDS::Study::StudyInvalidReference();
1363 _impl->SetStringVariable(std::string(theVarName),
1365 SALOMEDSImpl_GenericVariable::STRING_VAR);
1367 _notifier->modifyNB_Notification(theVarName);
1370 //============================================================================
1371 /*! Function : SetStringAsDouble
1374 //============================================================================
1375 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1378 throw SALOMEDS::Study::StudyInvalidReference();
1380 _impl->SetStringVariableAsDouble(std::string(theVarName),
1382 SALOMEDSImpl_GenericVariable::STRING_VAR);
1385 //============================================================================
1386 /*! Function : GetReal
1389 //============================================================================
1390 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1393 throw SALOMEDS::Study::StudyInvalidReference();
1395 return _impl->GetVariableValue(std::string(theVarName));
1398 //============================================================================
1399 /*! Function : GetInteger
1402 //============================================================================
1403 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1406 throw SALOMEDS::Study::StudyInvalidReference();
1408 return (long)_impl->GetVariableValue(std::string(theVarName));
1411 //============================================================================
1412 /*! Function : GetBoolean
1415 //============================================================================
1416 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1419 throw SALOMEDS::Study::StudyInvalidReference();
1421 return (bool)_impl->GetVariableValue(std::string(theVarName));
1424 //============================================================================
1425 /*! Function : GetString
1428 //============================================================================
1429 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1432 throw SALOMEDS::Study::StudyInvalidReference();
1434 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1437 //============================================================================
1438 /*! Function : IsReal
1441 //============================================================================
1442 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1445 throw SALOMEDS::Study::StudyInvalidReference();
1447 return _impl->IsTypeOf(std::string(theVarName),
1448 SALOMEDSImpl_GenericVariable::REAL_VAR);
1451 //============================================================================
1452 /*! Function : IsInteger
1455 //============================================================================
1456 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1459 throw SALOMEDS::Study::StudyInvalidReference();
1461 return _impl->IsTypeOf(std::string(theVarName),
1462 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1465 //============================================================================
1466 /*! Function : IsBoolean
1469 //============================================================================
1470 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1473 throw SALOMEDS::Study::StudyInvalidReference();
1475 return _impl->IsTypeOf(std::string(theVarName),
1476 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1479 //============================================================================
1480 /*! Function : IsString
1483 //============================================================================
1484 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1487 throw SALOMEDS::Study::StudyInvalidReference();
1489 return _impl->IsTypeOf(std::string(theVarName),
1490 SALOMEDSImpl_GenericVariable::STRING_VAR);
1493 //============================================================================
1494 /*! Function : IsVariable
1497 //============================================================================
1498 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1501 throw SALOMEDS::Study::StudyInvalidReference();
1503 return _impl->IsVariable(std::string(theVarName));
1506 //============================================================================
1507 /*! Function : GetVariableNames
1510 //============================================================================
1511 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1514 throw SALOMEDS::Study::StudyInvalidReference();
1516 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1518 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1520 int aLen = aVarNames.size();
1521 aResult->length(aLen);
1522 for (int anInd = 0; anInd < aLen; anInd++)
1523 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1525 return aResult._retn();
1528 //============================================================================
1529 /*! Function : RemoveVariable
1532 //============================================================================
1533 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1536 throw SALOMEDS::Study::StudyInvalidReference();
1538 bool res = _impl->RemoveVariable(std::string(theVarName));
1539 if (res && _notifier)
1540 _notifier->modifyNB_Notification(theVarName);
1545 //============================================================================
1546 /*! Function : RenameVariable
1549 //============================================================================
1550 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1553 throw SALOMEDS::Study::StudyInvalidReference();
1555 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1556 if (res && _notifier)
1557 _notifier->modifyNB_Notification(theVarName);
1562 //============================================================================
1563 /*! Function : IsVariableUsed
1566 //============================================================================
1567 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1570 throw SALOMEDS::Study::StudyInvalidReference();
1572 return _impl->IsVariableUsed(std::string(theVarName));
1576 //============================================================================
1577 /*! Function : ParseVariables
1580 //============================================================================
1581 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1584 throw SALOMEDS::Study::StudyInvalidReference();
1586 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1588 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1590 int aSectionsLen = aSections.size();
1591 aResult->length(aSectionsLen);
1593 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1594 std::vector<std::string> aVarNames = aSections[aSectionInd];
1596 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1598 int aLen = aVarNames.size();
1599 aList->length(aLen);
1601 for (int anInd = 0; anInd < aLen; anInd++)
1602 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1604 aResult[aSectionInd] = aList;
1607 return aResult._retn();
1610 //============================================================================
1611 /*! Function : GetDefaultScript
1614 //============================================================================
1615 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1617 SALOMEDS::Locker lock;
1620 throw SALOMEDS::Study::StudyInvalidReference();
1622 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1623 return CORBA::string_dup(script.c_str());
1626 //============================================================================
1627 /*! Function : EnableUseCaseAutoFilling
1630 //============================================================================
1631 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1634 throw SALOMEDS::Study::StudyInvalidReference();
1636 _impl->EnableUseCaseAutoFilling(isEnabled);
1637 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1640 builder->SetOnAddSObject(_impl->GetCallback());
1641 builder->SetOnRemoveSObject(_impl->GetCallback());
1644 builder->SetOnAddSObject(NULL);
1645 builder->SetOnRemoveSObject(NULL);
1651 CORBA::Long SALOMEDS_Study_i::getPID()
1654 return (CORBA::Long)_getpid();
1656 return (CORBA::Long)getpid();
1660 void SALOMEDS_Study_i::ShutdownWithExit()
1662 exit( EXIT_SUCCESS );
1665 void SALOMEDS_Study_i::Shutdown()
1667 if(!CORBA::is_nil(_orb))
1671 //============================================================================
1672 /*! Function : attach
1673 * Purpose : This function attach an observer to the study
1675 //============================================================================
1676 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1679 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1683 //============================================================================
1684 /*! Function : detach
1685 * Purpose : This function detaches an observer from the study
1687 //============================================================================
1688 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1691 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1694 //===========================================================================
1695 // PRIVATE FUNCTIONS
1696 //===========================================================================
1697 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1700 long pid = (long)_getpid();
1702 long pid = (long)getpid();
1704 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1705 return reinterpret_cast<CORBA::LongLong>(_impl);