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 class GenObjRegister: public SALOMEDSImpl_AbstractCallback
185 GenObjRegister(CORBA::ORB_ptr orb)
187 _orb = CORBA::ORB::_duplicate(orb);
189 virtual void RegisterGenObj (const std::string& theIOR)
193 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
194 if ( obj->_non_existent() ) return;
195 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
196 if(! CORBA::is_nil(gobj) )
201 catch(const CORBA::Exception& e)
205 virtual void UnRegisterGenObj(const std::string& theIOR)
209 CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
210 if ( obj->_non_existent() ) return;
211 SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
212 if(! CORBA::is_nil(gobj) )
217 catch(const CORBA::Exception& e)
226 } // namespace SALOMEDS
228 //============================================================================
229 /*! Function : SALOMEDS_Study_i
230 * Purpose : SALOMEDS_Study_i constructor
232 //============================================================================
233 SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb)
235 _orb = CORBA::ORB::_duplicate(orb);
236 _impl = new SALOMEDSImpl_Study();
237 _factory = new SALOMEDS_DriverFactory_i(_orb);
242 //============================================================================
243 /*! Function : ~SALOMEDS_Study_i
244 * Purpose : SALOMEDS_Study_i destructor
246 //============================================================================
247 SALOMEDS_Study_i::~SALOMEDS_Study_i()
254 //============================================================================
256 * Purpose : Initialize study components
258 //============================================================================
259 void SALOMEDS_Study_i::Init()
261 if ( !_impl->GetDocument() )
264 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
265 _notifier = new SALOMEDS::Notifier(_orb);
266 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
269 _impl->setNotifier(_notifier);
270 _impl->setGenObjRegister( _genObjRegister );
272 // Notify GUI that study was created
273 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
274 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
275 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
276 if ( !CORBA::is_nil(aSession) ) {
277 std::stringstream ss;
278 ss << "studyCreated";
279 std::string str = ss.str();
281 aSession->emitMessageOneWay(str.c_str());
286 //============================================================================
288 * Purpose : Clear study components
290 //============================================================================
291 void SALOMEDS_Study_i::Clear()
293 //delete the builder servant
294 PortableServer::POA_var poa=_builder->_default_POA();
295 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
296 poa->deactivate_object(anObjectId.in());
297 _builder->_remove_ref();
299 SALOMEDS::Locker lock;
302 throw SALOMEDS::Study::StudyInvalidReference();
305 if (_impl->GetDocument()) {
306 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
307 for (; itcomponent->More(); itcomponent->Next()) {
308 SALOMEDS::SComponent_var sco = itcomponent->Value();
309 CORBA::String_var compodatatype=sco->ComponentDataType();
310 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
311 // if there is an associated Engine call its method for closing
312 CORBA::String_var IOREngine;
313 if (sco->ComponentIOR(IOREngine)) {
314 // we have found the associated engine to write the data
315 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
316 //_narrow can throw a corba exception
318 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
319 if (!CORBA::is_nil(obj)) {
320 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
321 if (!anEngine->_is_nil()) {
323 anEngine->Close(sco);
328 catch (CORBA::Exception&) {
334 //Does not need any more this iterator
335 itcomponent->UnRegister();
338 // Notify GUI that study is cleared
339 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
340 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
341 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
342 if ( !CORBA::is_nil(aSession) ) {
343 std::stringstream ss;
344 ss << "studyCleared";
345 std::string str = ss.str();
347 aSession->emitMessageOneWay(str.c_str());
352 _impl->setNotifier(0);
354 delete _genObjRegister;
359 //============================================================================
361 * Purpose : Open a Study from it's persistent reference
363 //============================================================================
364 bool SALOMEDS_Study_i::Open(const char* aUrl)
365 throw(SALOME::SALOME_Exception)
367 SALOMEDS::Locker lock;
369 Unexpect aCatch(SalomeException);
370 MESSAGE("Begin of SALOMEDS_Study_i::Open");
372 bool res = _impl->Open(std::string(aUrl));
375 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
379 //============================================================================
381 * Purpose : Save a Study to it's persistent reference
383 //============================================================================
384 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
386 SALOMEDS::Locker lock;
387 return _impl->Save(_factory, theMultiFile);
390 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
392 SALOMEDS::Locker lock;
393 return _impl->SaveASCII(_factory, theMultiFile);
396 //=============================================================================
397 /*! Function : SaveAs
398 * Purpose : Save a study to the persistent reference aUrl
400 //============================================================================
401 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
403 SALOMEDS::Locker lock;
404 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
407 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
409 SALOMEDS::Locker lock;
410 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
413 //============================================================================
414 /*! Function : CanCopy
417 //============================================================================
418 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
420 SALOMEDS::Locker lock;
422 CORBA::String_var anID = theObject->GetID();
423 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
425 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
426 bool ret = _impl->CanCopy(anObject, aDriver);
431 //============================================================================
435 //============================================================================
436 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
438 SALOMEDS::Locker lock;
440 CORBA::String_var anID = theObject->GetID();
441 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
443 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
444 bool ret = _impl->Copy(anObject, aDriver);
449 //============================================================================
450 /*! Function : CanPaste
453 //============================================================================
454 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
456 SALOMEDS::Locker lock;
458 CORBA::String_var anID = theObject->GetID();
459 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
461 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
462 bool ret = _impl->CanPaste(anObject, aDriver);
467 //============================================================================
471 //============================================================================
472 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
473 throw(SALOMEDS::StudyBuilder::LockProtection)
475 SALOMEDS::Locker lock;
477 Unexpect aCatch(LockProtection);
479 CORBA::String_var anID = theObject->GetID();
480 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
481 SALOMEDSImpl_SObject aNewSO;
484 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
485 aNewSO = _impl->Paste(anObject, aDriver);
489 throw SALOMEDS::StudyBuilder::LockProtection();
492 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
496 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
498 SALOMEDS_Driver_i* driver = NULL;
500 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
502 std::string IOREngine = aSCO.GetIOR();
503 if(!IOREngine.empty()) {
504 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
505 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
506 driver = new SALOMEDS_Driver_i(Engine, orb);
513 //============================================================================
514 /*! Function : GetPersistentReference
515 * Purpose : Get persistent reference of study (idem URL())
517 //============================================================================
518 char* SALOMEDS_Study_i::GetPersistentReference()
520 SALOMEDS::Locker lock;
522 throw SALOMEDS::Study::StudyInvalidReference();
523 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
525 //============================================================================
526 /*! Function : GetTransientReference
527 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
529 //============================================================================
530 char* SALOMEDS_Study_i::GetTransientReference()
532 SALOMEDS::Locker lock;
534 throw SALOMEDS::Study::StudyInvalidReference();
535 return CORBA::string_dup(_impl->GetTransientReference().c_str());
538 //============================================================================
539 /*! Function : IsEmpty
540 * Purpose : Detect if study is empty
542 //============================================================================
543 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
545 SALOMEDS::Locker lock;
547 throw SALOMEDS::Study::StudyInvalidReference();
548 return _impl->IsEmpty();
551 //============================================================================
552 /*! Function : FindComponent
553 * Purpose : Find a Component with ComponentDataType = aComponentName
555 //============================================================================
556 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
558 SALOMEDS::Locker lock;
561 throw SALOMEDS::Study::StudyInvalidReference();
563 SALOMEDS::SComponent_var sco;
565 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
566 if (!aCompImpl.IsNull())
567 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
572 //============================================================================
573 /*! Function : FindComponentID
574 * Purpose : Find a Component from it's ID
576 //============================================================================
577 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
579 SALOMEDS::Locker lock;
582 throw SALOMEDS::Study::StudyInvalidReference();
584 SALOMEDS::SComponent_var sco;
586 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
587 if (!aCompImpl.IsNull())
588 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
593 //============================================================================
594 /*! Function : FindObject
595 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
597 //============================================================================
598 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
600 SALOMEDS::Locker lock;
603 throw SALOMEDS::Study::StudyInvalidReference();
605 SALOMEDS::SObject_var so;
607 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
609 if (aSO.IsComponent()) {
610 SALOMEDSImpl_SComponent aSCO = aSO;
611 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
614 so = SALOMEDS_SObject_i::New(aSO, _orb);
621 //============================================================================
622 /*! Function : FindObjectID
623 * Purpose : Find an Object with ID = anObjectID
625 //============================================================================
626 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
628 SALOMEDS::Locker lock;
631 throw SALOMEDS::Study::StudyInvalidReference();
633 SALOMEDS::SObject_var so;
635 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
637 so = SALOMEDS_SObject_i::New(aSO, _orb);
642 //============================================================================
643 /*! Function : CreateObjectID
644 * Purpose : Creates an Object with ID = anObjectID
646 //============================================================================
647 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
649 SALOMEDS::Locker lock;
652 throw SALOMEDS::Study::StudyInvalidReference();
654 SALOMEDS::SObject_var so;
656 if (anObjectID && strlen(anObjectID) > 0) {
657 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
659 so = SALOMEDS_SObject_i::New(aSO, _orb);
665 //============================================================================
666 /*! Function : FindObjectByName
667 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
668 * : with ComponentDataType = aComponentName
670 //============================================================================
671 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
672 const char* aComponentName )
674 SALOMEDS::Locker lock;
677 throw SALOMEDS::Study::StudyInvalidReference();
679 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
680 std::string((char*)aComponentName));
682 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
683 int aLength = aSeq.size();
684 listSO->length(aLength);
685 for (int i = 0; i < aLength; i++) {
686 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
690 return listSO._retn();
693 //============================================================================
694 /*! Function : FindObjectIOR
695 * Purpose : Find an Object with IOR = anObjectIOR
697 //============================================================================
698 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
700 SALOMEDS::Locker lock;
703 throw SALOMEDS::Study::StudyInvalidReference();
705 SALOMEDS::SObject_var so;
707 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
709 so = SALOMEDS_SObject_i::New(aSO, _orb);
714 //============================================================================
715 /*! Function : FindObjectByPath
716 * Purpose : Find an Object by its path = thePath
718 //============================================================================
719 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
721 SALOMEDS::Locker lock;
724 throw SALOMEDS::Study::StudyInvalidReference();
726 SALOMEDS::SObject_var so;
728 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
730 so = SALOMEDS_SObject_i::New (aSO, _orb);
735 //============================================================================
736 /*! Function : GetObjectPath
739 //============================================================================
740 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
742 SALOMEDS::Locker lock;
745 throw SALOMEDS::Study::StudyInvalidReference();
747 std::string aPath = "";
749 if (!CORBA::is_nil(theObject)) {
750 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
751 SALOMEDSImpl_SObject aSO;
753 if (!CORBA::is_nil(aSObj)) {
754 aSO = _impl->FindObjectID(aSObj->GetID());
757 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
761 aPath = _impl->GetObjectPath(aSO);
765 return CORBA::string_dup(aPath.c_str());
769 //============================================================================
770 /*! Function : SetContext
771 * Purpose : Sets the current context
773 //============================================================================
774 void SALOMEDS_Study_i::SetContext(const char* thePath)
776 SALOMEDS::Locker lock;
779 throw SALOMEDS::Study::StudyInvalidReference();
781 _impl->SetContext(std::string((char*)thePath));
782 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
783 throw SALOMEDS::Study::StudyInvalidContext();
786 //============================================================================
787 /*! Function : GetContext
788 * Purpose : Gets the current context
790 //============================================================================
791 char* SALOMEDS_Study_i::GetContext()
793 SALOMEDS::Locker lock;
796 throw SALOMEDS::Study::StudyInvalidReference();
798 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
800 return CORBA::string_dup(_impl->GetContext().c_str());
803 //============================================================================
804 /*! Function : GetObjectNames
805 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
807 //============================================================================
808 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
810 SALOMEDS::Locker lock;
813 throw SALOMEDS::Study::StudyInvalidReference();
815 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
817 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
818 throw SALOMEDS::Study::StudyInvalidContext();
820 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
821 if (_impl->GetErrorCode() == "InvalidContext")
822 throw SALOMEDS::Study::StudyInvalidContext();
824 int aLength = aSeq.size();
825 aResult->length(aLength);
826 for (int anIndex = 0; anIndex < aLength; anIndex++) {
827 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
830 return aResult._retn();
833 //============================================================================
834 /*! Function : GetDirectoryNames
835 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
837 //============================================================================
838 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
840 SALOMEDS::Locker lock;
843 throw SALOMEDS::Study::StudyInvalidReference();
845 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
847 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
848 throw SALOMEDS::Study::StudyInvalidContext();
850 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
851 if (_impl->GetErrorCode() == "InvalidContext")
852 throw SALOMEDS::Study::StudyInvalidContext();
854 int aLength = aSeq.size();
855 aResult->length(aLength);
856 for (int anIndex = 0; anIndex < aLength; anIndex++) {
857 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
860 return aResult._retn();
863 //============================================================================
864 /*! Function : GetFileNames
865 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
867 //============================================================================
868 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
870 SALOMEDS::Locker lock;
873 throw SALOMEDS::Study::StudyInvalidReference();
875 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
877 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
878 throw SALOMEDS::Study::StudyInvalidContext();
880 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
881 if (_impl->GetErrorCode() == "InvalidContext")
882 throw SALOMEDS::Study::StudyInvalidContext();
884 int aLength = aSeq.size();
885 aResult->length(aLength);
886 for (int anIndex = 0; anIndex < aLength; anIndex++) {
887 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
890 return aResult._retn();
893 //============================================================================
894 /*! Function : GetComponentNames
895 * Purpose : method to get all components names
896 * SRN: Note, theContext can be any, it doesn't matter
898 //============================================================================
899 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
901 SALOMEDS::Locker lock;
904 throw SALOMEDS::Study::StudyInvalidReference();
906 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
908 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
910 int aLength = aSeq.size();
911 aResult->length(aLength);
912 for(int anIndex = 0; anIndex < aLength; anIndex++) {
913 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
916 return aResult._retn();
919 //============================================================================
920 /*! Function : NewChildIterator
921 * Purpose : Create a ChildIterator from an SObject
923 //============================================================================
924 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
926 SALOMEDS::Locker lock;
929 throw SALOMEDS::Study::StudyInvalidReference();
931 CORBA::String_var anID = theSO->GetID();
932 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
933 SALOMEDSImpl_ChildIterator anItr(aSO);
934 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
935 SALOMEDS::ChildIterator_var it = it_servant->_this();
941 //============================================================================
942 /*! Function : NewComponentIterator
943 * Purpose : Create a SComponentIterator
945 //============================================================================
946 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
948 SALOMEDS::Locker lock;
951 throw SALOMEDS::Study::StudyInvalidReference();
953 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
955 SALOMEDS::SComponentIterator_var it = it_servant->_this();
961 //============================================================================
962 /*! Function : NewBuilder
963 * Purpose : Create a StudyBuilder
965 //============================================================================
966 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
968 SALOMEDS::Locker lock;
971 throw SALOMEDS::Study::StudyInvalidReference();
973 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
978 //============================================================================
980 * Purpose : get study name
982 //============================================================================
983 char* SALOMEDS_Study_i::Name()
985 SALOMEDS::Locker lock;
986 // Name is specified as IDL attribute: user exception cannot be raised
987 return CORBA::string_dup(_impl->Name().c_str());
990 //============================================================================
991 /*! Function : IsSaved
992 * Purpose : get if study has been saved
994 //============================================================================
995 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
997 SALOMEDS::Locker lock;
998 // IsSaved is specified as IDL attribute: user exception cannot be raised
999 return (!_closed) ? _impl->IsSaved() : false;
1002 //============================================================================
1003 /*! Function : IsSaved
1004 * Purpose : set if study has been saved
1006 //============================================================================
1007 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1009 SALOMEDS::Locker lock;
1010 // IsSaved is specified as IDL attribute: user exception cannot be raised
1012 _impl->IsSaved(save);
1015 //============================================================================
1016 /*! Function : IsModified
1017 * Purpose : Detect if a Study has been modified since it has been saved
1019 //============================================================================
1020 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1022 SALOMEDS::Locker lock;
1025 throw SALOMEDS::Study::StudyInvalidReference();
1027 return _impl->IsModified();
1030 //============================================================================
1031 /*! Function : Modified
1032 * Purpose : Sets a Modified flag of a Study to True
1034 //============================================================================
1035 void SALOMEDS_Study_i::Modified()
1037 SALOMEDS::Locker lock;
1040 throw SALOMEDS::Study::StudyInvalidReference();
1045 //============================================================================
1047 * Purpose : get URL of the study (persistent reference of the study)
1049 //============================================================================
1050 char* SALOMEDS_Study_i::URL()
1052 SALOMEDS::Locker lock;
1053 // URL is specified as IDL attribute: user exception cannot be raised
1054 return CORBA::string_dup(_impl->URL().c_str());
1057 //============================================================================
1059 * Purpose : set URL of the study (persistent reference of the study)
1061 //============================================================================
1062 void SALOMEDS_Study_i::URL(const char* url)
1064 SALOMEDS::Locker lock;
1065 // URL is specified as IDL attribute: user exception cannot be raised
1066 _impl->URL(std::string((char*)url));
1069 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1071 SALOMEDS::Locker lock;
1074 throw SALOMEDS::Study::StudyInvalidReference();
1076 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1079 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1081 SALOMEDS::Locker lock;
1083 SALOMEDSImpl_AttributeIOR* Att = NULL;
1084 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1085 char* IOR = CORBA::string_dup(Att->Value().c_str());
1086 CORBA::Object_var obj = orb->string_to_object(IOR);
1087 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1088 ASSERT(!CORBA::is_nil(aStudy));
1089 return SALOMEDS::Study::_duplicate(aStudy);
1091 MESSAGE("GetStudy: Problem to get study");
1093 return SALOMEDS::Study::_nil();
1096 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1098 SALOMEDS::Locker lock;
1099 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1102 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1104 SALOMEDS::Locker lock;
1107 throw SALOMEDS::Study::StudyInvalidReference();
1109 SALOMEDS::GenericAttribute_ptr aTarget;
1110 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1111 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1113 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1119 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1121 SALOMEDS::Locker lock;
1124 throw SALOMEDS::Study::StudyInvalidReference();
1126 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1127 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1128 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1129 return aProp._retn();
1132 char* SALOMEDS_Study_i::GetLastModificationDate()
1134 SALOMEDS::Locker lock;
1137 throw SALOMEDS::Study::StudyInvalidReference();
1139 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1142 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1144 SALOMEDS::Locker lock;
1147 throw SALOMEDS::Study::StudyInvalidReference();
1149 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1151 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1153 int aLength = aSeq.size();
1154 aDates->length(aLength);
1155 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1156 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1159 return aDates._retn();
1162 //============================================================================
1163 /*! Function : GetUseCaseBuilder
1164 * Purpose : Returns a UseCase builder
1166 //============================================================================
1167 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1169 SALOMEDS::Locker lock;
1172 throw SALOMEDS::Study::StudyInvalidReference();
1174 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1175 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1179 //============================================================================
1180 /*! Function : AddPostponed
1183 //============================================================================
1184 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1186 SALOMEDS::Locker lock;
1190 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1192 SALOMEDS::Locker lock;
1196 //============================================================================
1197 /*! Function : RemovePostponed
1200 //============================================================================
1201 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1203 SALOMEDS::Locker lock;
1206 throw SALOMEDS::Study::StudyInvalidReference();
1208 std::vector<std::string> anIORs = _impl->GetIORs();
1209 int i, aSize = (int)anIORs.size();
1211 for (i = 0; i < aSize; i++) {
1213 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1214 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1215 //rnv: To avoid double deletion of the Salome Generic Objects:
1216 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1217 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1218 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1225 //============================================================================
1226 /*! Function : UndoPostponed
1229 //============================================================================
1230 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1232 SALOMEDS::Locker lock;
1237 //============================================================================
1238 /*! Function : DumpStudy
1241 //============================================================================
1242 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1243 const char* theBaseName,
1244 CORBA::Boolean isPublished,
1245 CORBA::Boolean isMultiFile)
1247 SALOMEDS::Locker lock;
1250 throw SALOMEDS::Study::StudyInvalidReference();
1252 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1253 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1254 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1260 //============================================================================
1261 /*! Function : GetCommonParameters
1264 //============================================================================
1265 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1267 SALOMEDS::Locker lock;
1270 throw SALOMEDS::Study::StudyInvalidReference();
1272 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1273 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1274 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1276 return aParam._retn();
1279 //============================================================================
1280 /*! Function : GetCommonModuleParameters
1283 //============================================================================
1284 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1285 const char* theModuleName,
1286 CORBA::Long theSavePoint)
1288 SALOMEDS::Locker lock;
1291 throw SALOMEDS::Study::StudyInvalidReference();
1293 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1294 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1295 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1297 return aParam._retn();
1300 //============================================================================
1301 /*! Function : SetStudyLock
1304 //============================================================================
1305 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1307 SALOMEDS::Locker lock;
1310 throw SALOMEDS::Study::StudyInvalidReference();
1312 _impl->SetStudyLock(theLockerID);
1315 //============================================================================
1316 /*! Function : IsStudyLocked
1319 //============================================================================
1320 bool SALOMEDS_Study_i::IsStudyLocked()
1322 SALOMEDS::Locker lock;
1325 throw SALOMEDS::Study::StudyInvalidReference();
1327 return _impl->IsStudyLocked();
1330 //============================================================================
1331 /*! Function : UnLockStudy
1334 //============================================================================
1335 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1337 SALOMEDS::Locker lock;
1340 throw SALOMEDS::Study::StudyInvalidReference();
1342 _impl->UnLockStudy(theLockerID);
1345 //============================================================================
1346 /*! Function : GetLockerID
1349 //============================================================================
1350 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1352 SALOMEDS::Locker lock;
1355 throw SALOMEDS::Study::StudyInvalidReference();
1357 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1359 std::vector<std::string> aSeq = _impl->GetLockerID();
1361 int aLength = aSeq.size();
1362 aResult->length(aLength);
1363 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1364 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1367 return aResult._retn();
1369 //============================================================================
1370 /*! Function : SetReal
1373 //============================================================================
1374 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1377 throw SALOMEDS::Study::StudyInvalidReference();
1380 _impl->SetVariable(std::string(theVarName),
1382 SALOMEDSImpl_GenericVariable::REAL_VAR);
1384 _notifier->modifyNB_Notification(theVarName);
1387 //============================================================================
1388 /*! Function : SetInteger
1391 //============================================================================
1392 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1395 throw SALOMEDS::Study::StudyInvalidReference();
1397 _impl->SetVariable(std::string(theVarName),
1399 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1401 _notifier->modifyNB_Notification(theVarName);
1404 //============================================================================
1405 /*! Function : SetBoolean
1408 //============================================================================
1409 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1412 throw SALOMEDS::Study::StudyInvalidReference();
1414 _impl->SetVariable(std::string(theVarName),
1416 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1418 _notifier->modifyNB_Notification(theVarName);
1421 //============================================================================
1422 /*! Function : SetString
1425 //============================================================================
1426 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1429 throw SALOMEDS::Study::StudyInvalidReference();
1431 _impl->SetStringVariable(std::string(theVarName),
1433 SALOMEDSImpl_GenericVariable::STRING_VAR);
1435 _notifier->modifyNB_Notification(theVarName);
1438 //============================================================================
1439 /*! Function : SetStringAsDouble
1442 //============================================================================
1443 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1446 throw SALOMEDS::Study::StudyInvalidReference();
1448 _impl->SetStringVariableAsDouble(std::string(theVarName),
1450 SALOMEDSImpl_GenericVariable::STRING_VAR);
1453 //============================================================================
1454 /*! Function : GetReal
1457 //============================================================================
1458 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1461 throw SALOMEDS::Study::StudyInvalidReference();
1463 return _impl->GetVariableValue(std::string(theVarName));
1466 //============================================================================
1467 /*! Function : GetInteger
1470 //============================================================================
1471 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1474 throw SALOMEDS::Study::StudyInvalidReference();
1476 return (long)_impl->GetVariableValue(std::string(theVarName));
1479 //============================================================================
1480 /*! Function : GetBoolean
1483 //============================================================================
1484 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1487 throw SALOMEDS::Study::StudyInvalidReference();
1489 return (bool)_impl->GetVariableValue(std::string(theVarName));
1492 //============================================================================
1493 /*! Function : GetString
1496 //============================================================================
1497 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1500 throw SALOMEDS::Study::StudyInvalidReference();
1502 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1505 //============================================================================
1506 /*! Function : IsReal
1509 //============================================================================
1510 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1513 throw SALOMEDS::Study::StudyInvalidReference();
1515 return _impl->IsTypeOf(std::string(theVarName),
1516 SALOMEDSImpl_GenericVariable::REAL_VAR);
1519 //============================================================================
1520 /*! Function : IsInteger
1523 //============================================================================
1524 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1527 throw SALOMEDS::Study::StudyInvalidReference();
1529 return _impl->IsTypeOf(std::string(theVarName),
1530 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1533 //============================================================================
1534 /*! Function : IsBoolean
1537 //============================================================================
1538 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1541 throw SALOMEDS::Study::StudyInvalidReference();
1543 return _impl->IsTypeOf(std::string(theVarName),
1544 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1547 //============================================================================
1548 /*! Function : IsString
1551 //============================================================================
1552 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1555 throw SALOMEDS::Study::StudyInvalidReference();
1557 return _impl->IsTypeOf(std::string(theVarName),
1558 SALOMEDSImpl_GenericVariable::STRING_VAR);
1561 //============================================================================
1562 /*! Function : IsVariable
1565 //============================================================================
1566 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1569 throw SALOMEDS::Study::StudyInvalidReference();
1571 return _impl->IsVariable(std::string(theVarName));
1574 //============================================================================
1575 /*! Function : GetVariableNames
1578 //============================================================================
1579 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1582 throw SALOMEDS::Study::StudyInvalidReference();
1584 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1586 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1588 int aLen = aVarNames.size();
1589 aResult->length(aLen);
1590 for (int anInd = 0; anInd < aLen; anInd++)
1591 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1593 return aResult._retn();
1596 //============================================================================
1597 /*! Function : RemoveVariable
1600 //============================================================================
1601 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1604 throw SALOMEDS::Study::StudyInvalidReference();
1606 bool res = _impl->RemoveVariable(std::string(theVarName));
1607 if (res && _notifier)
1608 _notifier->modifyNB_Notification(theVarName);
1613 //============================================================================
1614 /*! Function : RenameVariable
1617 //============================================================================
1618 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1621 throw SALOMEDS::Study::StudyInvalidReference();
1623 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1624 if (res && _notifier)
1625 _notifier->modifyNB_Notification(theVarName);
1630 //============================================================================
1631 /*! Function : IsVariableUsed
1634 //============================================================================
1635 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1638 throw SALOMEDS::Study::StudyInvalidReference();
1640 return _impl->IsVariableUsed(std::string(theVarName));
1644 //============================================================================
1645 /*! Function : ParseVariables
1648 //============================================================================
1649 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1652 throw SALOMEDS::Study::StudyInvalidReference();
1654 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1656 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1658 int aSectionsLen = aSections.size();
1659 aResult->length(aSectionsLen);
1661 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1662 std::vector<std::string> aVarNames = aSections[aSectionInd];
1664 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1666 int aLen = aVarNames.size();
1667 aList->length(aLen);
1669 for (int anInd = 0; anInd < aLen; anInd++)
1670 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1672 aResult[aSectionInd] = aList;
1675 return aResult._retn();
1678 //============================================================================
1679 /*! Function : GetDefaultScript
1682 //============================================================================
1683 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1685 SALOMEDS::Locker lock;
1688 throw SALOMEDS::Study::StudyInvalidReference();
1690 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1691 return CORBA::string_dup(script.c_str());
1694 //============================================================================
1695 /*! Function : EnableUseCaseAutoFilling
1698 //============================================================================
1699 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1702 throw SALOMEDS::Study::StudyInvalidReference();
1704 _impl->EnableUseCaseAutoFilling(isEnabled);
1705 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1708 builder->SetOnAddSObject(_impl->GetCallback());
1709 builder->SetOnRemoveSObject(_impl->GetCallback());
1712 builder->SetOnAddSObject(NULL);
1713 builder->SetOnRemoveSObject(NULL);
1719 CORBA::Long SALOMEDS_Study_i::getPID()
1722 return (CORBA::Long)_getpid();
1724 return (CORBA::Long)getpid();
1728 void SALOMEDS_Study_i::ShutdownWithExit()
1730 exit( EXIT_SUCCESS );
1733 void SALOMEDS_Study_i::Shutdown()
1735 if(!CORBA::is_nil(_orb))
1739 //============================================================================
1740 /*! Function : attach
1741 * Purpose : This function attach an observer to the study
1743 //============================================================================
1744 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1747 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1751 //============================================================================
1752 /*! Function : detach
1753 * Purpose : This function detaches an observer from the study
1755 //============================================================================
1756 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1759 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1762 //===========================================================================
1763 // PRIVATE FUNCTIONS
1764 //===========================================================================
1765 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1768 long pid = (long)_getpid();
1770 long pid = (long)getpid();
1772 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1773 return reinterpret_cast<CORBA::LongLong>(_impl);