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 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
262 _notifier = new SALOMEDS::Notifier(_orb);
263 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
266 _impl->setNotifier(_notifier);
267 _impl->setGenObjRegister( _genObjRegister );
269 // Notify GUI that study was created
270 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
271 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
272 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
273 if ( !CORBA::is_nil(aSession) ) {
274 std::stringstream ss;
275 ss << "studyCreated";
276 std::string str = ss.str();
278 aSession->emitMessageOneWay(str.c_str());
283 //============================================================================
285 * Purpose : Clear study components
287 //============================================================================
288 void SALOMEDS_Study_i::Clear()
290 //delete the builder servant
291 PortableServer::POA_var poa=_builder->_default_POA();
292 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
293 poa->deactivate_object(anObjectId.in());
294 _builder->_remove_ref();
296 SALOMEDS::Locker lock;
299 throw SALOMEDS::Study::StudyInvalidReference();
302 if (_impl->GetDocument()) {
303 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
304 for (; itcomponent->More(); itcomponent->Next()) {
305 SALOMEDS::SComponent_var sco = itcomponent->Value();
306 CORBA::String_var compodatatype=sco->ComponentDataType();
307 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
308 // if there is an associated Engine call its method for closing
309 CORBA::String_var IOREngine;
310 if (sco->ComponentIOR(IOREngine)) {
311 // we have found the associated engine to write the data
312 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
313 //_narrow can throw a corba exception
315 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
316 if (!CORBA::is_nil(obj)) {
317 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
318 if (!anEngine->_is_nil()) {
320 anEngine->Close(sco);
325 catch (CORBA::Exception&) {
331 //Does not need any more this iterator
332 itcomponent->UnRegister();
335 // Notify GUI that study is cleared
336 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
337 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
338 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
339 if ( !CORBA::is_nil(aSession) ) {
340 std::stringstream ss;
341 ss << "studyCleared";
342 std::string str = ss.str();
344 aSession->emitMessageOneWay(str.c_str());
349 _impl->setNotifier(0);
351 delete _genObjRegister;
356 //============================================================================
358 * Purpose : Open a Study from it's persistent reference
360 //============================================================================
361 bool SALOMEDS_Study_i::Open(const char* aUrl)
362 throw(SALOME::SALOME_Exception)
364 SALOMEDS::Locker lock;
366 Unexpect aCatch(SalomeException);
367 MESSAGE("Begin of SALOMEDS_Study_i::Open");
369 bool res = _impl->Open(std::string(aUrl));
372 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
376 //============================================================================
378 * Purpose : Save a Study to it's persistent reference
380 //============================================================================
381 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
383 SALOMEDS::Locker lock;
384 return _impl->Save(_factory, theMultiFile);
387 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
389 SALOMEDS::Locker lock;
390 return _impl->SaveASCII(_factory, theMultiFile);
393 //=============================================================================
394 /*! Function : SaveAs
395 * Purpose : Save a study to the persistent reference aUrl
397 //============================================================================
398 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
400 SALOMEDS::Locker lock;
401 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
404 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
406 SALOMEDS::Locker lock;
407 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
410 //============================================================================
411 /*! Function : CanCopy
414 //============================================================================
415 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
417 SALOMEDS::Locker lock;
419 CORBA::String_var anID = theObject->GetID();
420 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
422 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
423 bool ret = _impl->CanCopy(anObject, aDriver);
428 //============================================================================
432 //============================================================================
433 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
435 SALOMEDS::Locker lock;
437 CORBA::String_var anID = theObject->GetID();
438 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
440 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
441 bool ret = _impl->Copy(anObject, aDriver);
446 //============================================================================
447 /*! Function : CanPaste
450 //============================================================================
451 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
453 SALOMEDS::Locker lock;
455 CORBA::String_var anID = theObject->GetID();
456 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
458 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
459 bool ret = _impl->CanPaste(anObject, aDriver);
464 //============================================================================
468 //============================================================================
469 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
470 throw(SALOMEDS::StudyBuilder::LockProtection)
472 SALOMEDS::Locker lock;
474 Unexpect aCatch(LockProtection);
476 CORBA::String_var anID = theObject->GetID();
477 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
478 SALOMEDSImpl_SObject aNewSO;
481 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
482 aNewSO = _impl->Paste(anObject, aDriver);
486 throw SALOMEDS::StudyBuilder::LockProtection();
489 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
493 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
495 SALOMEDS_Driver_i* driver = NULL;
497 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
499 std::string IOREngine = aSCO.GetIOR();
500 if(!IOREngine.empty()) {
501 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
502 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
503 driver = new SALOMEDS_Driver_i(Engine, orb);
510 //============================================================================
511 /*! Function : GetPersistentReference
512 * Purpose : Get persistent reference of study (idem URL())
514 //============================================================================
515 char* SALOMEDS_Study_i::GetPersistentReference()
517 SALOMEDS::Locker lock;
519 throw SALOMEDS::Study::StudyInvalidReference();
520 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
522 //============================================================================
523 /*! Function : GetTransientReference
524 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
526 //============================================================================
527 char* SALOMEDS_Study_i::GetTransientReference()
529 SALOMEDS::Locker lock;
531 throw SALOMEDS::Study::StudyInvalidReference();
532 return CORBA::string_dup(_impl->GetTransientReference().c_str());
535 //============================================================================
536 /*! Function : IsEmpty
537 * Purpose : Detect if study is empty
539 //============================================================================
540 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
542 SALOMEDS::Locker lock;
544 throw SALOMEDS::Study::StudyInvalidReference();
545 return _impl->IsEmpty();
548 //============================================================================
549 /*! Function : FindComponent
550 * Purpose : Find a Component with ComponentDataType = aComponentName
552 //============================================================================
553 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
555 SALOMEDS::Locker lock;
558 throw SALOMEDS::Study::StudyInvalidReference();
560 SALOMEDS::SComponent_var sco;
562 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
563 if (!aCompImpl.IsNull())
564 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
569 //============================================================================
570 /*! Function : FindComponentID
571 * Purpose : Find a Component from it's ID
573 //============================================================================
574 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
576 SALOMEDS::Locker lock;
579 throw SALOMEDS::Study::StudyInvalidReference();
581 SALOMEDS::SComponent_var sco;
583 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
584 if (!aCompImpl.IsNull())
585 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
590 //============================================================================
591 /*! Function : FindObject
592 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
594 //============================================================================
595 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
597 SALOMEDS::Locker lock;
600 throw SALOMEDS::Study::StudyInvalidReference();
602 SALOMEDS::SObject_var so;
604 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
606 if (aSO.IsComponent()) {
607 SALOMEDSImpl_SComponent aSCO = aSO;
608 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
611 so = SALOMEDS_SObject_i::New(aSO, _orb);
618 //============================================================================
619 /*! Function : FindObjectID
620 * Purpose : Find an Object with ID = anObjectID
622 //============================================================================
623 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
625 SALOMEDS::Locker lock;
628 throw SALOMEDS::Study::StudyInvalidReference();
630 SALOMEDS::SObject_var so;
632 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
634 so = SALOMEDS_SObject_i::New(aSO, _orb);
639 //============================================================================
640 /*! Function : CreateObjectID
641 * Purpose : Creates an Object with ID = anObjectID
643 //============================================================================
644 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
646 SALOMEDS::Locker lock;
649 throw SALOMEDS::Study::StudyInvalidReference();
651 SALOMEDS::SObject_var so;
653 if (anObjectID && strlen(anObjectID) > 0) {
654 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
656 so = SALOMEDS_SObject_i::New(aSO, _orb);
662 //============================================================================
663 /*! Function : FindObjectByName
664 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
665 * : with ComponentDataType = aComponentName
667 //============================================================================
668 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
669 const char* aComponentName )
671 SALOMEDS::Locker lock;
674 throw SALOMEDS::Study::StudyInvalidReference();
676 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
677 std::string((char*)aComponentName));
679 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
680 int aLength = aSeq.size();
681 listSO->length(aLength);
682 for (int i = 0; i < aLength; i++) {
683 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
687 return listSO._retn();
690 //============================================================================
691 /*! Function : FindObjectIOR
692 * Purpose : Find an Object with IOR = anObjectIOR
694 //============================================================================
695 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
697 SALOMEDS::Locker lock;
700 throw SALOMEDS::Study::StudyInvalidReference();
702 SALOMEDS::SObject_var so;
704 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
706 so = SALOMEDS_SObject_i::New(aSO, _orb);
711 //============================================================================
712 /*! Function : FindObjectByPath
713 * Purpose : Find an Object by its path = thePath
715 //============================================================================
716 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
718 SALOMEDS::Locker lock;
721 throw SALOMEDS::Study::StudyInvalidReference();
723 SALOMEDS::SObject_var so;
725 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
727 so = SALOMEDS_SObject_i::New (aSO, _orb);
732 //============================================================================
733 /*! Function : GetObjectPath
736 //============================================================================
737 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
739 SALOMEDS::Locker lock;
742 throw SALOMEDS::Study::StudyInvalidReference();
744 std::string aPath = "";
746 if (!CORBA::is_nil(theObject)) {
747 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
748 SALOMEDSImpl_SObject aSO;
750 if (!CORBA::is_nil(aSObj)) {
751 aSO = _impl->FindObjectID(aSObj->GetID());
754 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
758 aPath = _impl->GetObjectPath(aSO);
762 return CORBA::string_dup(aPath.c_str());
766 //============================================================================
767 /*! Function : SetContext
768 * Purpose : Sets the current context
770 //============================================================================
771 void SALOMEDS_Study_i::SetContext(const char* thePath)
773 SALOMEDS::Locker lock;
776 throw SALOMEDS::Study::StudyInvalidReference();
778 _impl->SetContext(std::string((char*)thePath));
779 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
780 throw SALOMEDS::Study::StudyInvalidContext();
783 //============================================================================
784 /*! Function : GetContext
785 * Purpose : Gets the current context
787 //============================================================================
788 char* SALOMEDS_Study_i::GetContext()
790 SALOMEDS::Locker lock;
793 throw SALOMEDS::Study::StudyInvalidReference();
795 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
797 return CORBA::string_dup(_impl->GetContext().c_str());
800 //============================================================================
801 /*! Function : GetObjectNames
802 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
804 //============================================================================
805 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
807 SALOMEDS::Locker lock;
810 throw SALOMEDS::Study::StudyInvalidReference();
812 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
814 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
815 throw SALOMEDS::Study::StudyInvalidContext();
817 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
818 if (_impl->GetErrorCode() == "InvalidContext")
819 throw SALOMEDS::Study::StudyInvalidContext();
821 int aLength = aSeq.size();
822 aResult->length(aLength);
823 for (int anIndex = 0; anIndex < aLength; anIndex++) {
824 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
827 return aResult._retn();
830 //============================================================================
831 /*! Function : GetDirectoryNames
832 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
834 //============================================================================
835 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
837 SALOMEDS::Locker lock;
840 throw SALOMEDS::Study::StudyInvalidReference();
842 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
844 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
845 throw SALOMEDS::Study::StudyInvalidContext();
847 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
848 if (_impl->GetErrorCode() == "InvalidContext")
849 throw SALOMEDS::Study::StudyInvalidContext();
851 int aLength = aSeq.size();
852 aResult->length(aLength);
853 for (int anIndex = 0; anIndex < aLength; anIndex++) {
854 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
857 return aResult._retn();
860 //============================================================================
861 /*! Function : GetFileNames
862 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
864 //============================================================================
865 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
867 SALOMEDS::Locker lock;
870 throw SALOMEDS::Study::StudyInvalidReference();
872 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
874 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
875 throw SALOMEDS::Study::StudyInvalidContext();
877 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
878 if (_impl->GetErrorCode() == "InvalidContext")
879 throw SALOMEDS::Study::StudyInvalidContext();
881 int aLength = aSeq.size();
882 aResult->length(aLength);
883 for (int anIndex = 0; anIndex < aLength; anIndex++) {
884 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
887 return aResult._retn();
890 //============================================================================
891 /*! Function : GetComponentNames
892 * Purpose : method to get all components names
893 * SRN: Note, theContext can be any, it doesn't matter
895 //============================================================================
896 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
898 SALOMEDS::Locker lock;
901 throw SALOMEDS::Study::StudyInvalidReference();
903 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
905 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
907 int aLength = aSeq.size();
908 aResult->length(aLength);
909 for(int anIndex = 0; anIndex < aLength; anIndex++) {
910 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
913 return aResult._retn();
916 //============================================================================
917 /*! Function : NewChildIterator
918 * Purpose : Create a ChildIterator from an SObject
920 //============================================================================
921 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
923 SALOMEDS::Locker lock;
926 throw SALOMEDS::Study::StudyInvalidReference();
928 CORBA::String_var anID = theSO->GetID();
929 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
930 SALOMEDSImpl_ChildIterator anItr(aSO);
931 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
932 SALOMEDS::ChildIterator_var it = it_servant->_this();
938 //============================================================================
939 /*! Function : NewComponentIterator
940 * Purpose : Create a SComponentIterator
942 //============================================================================
943 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
945 SALOMEDS::Locker lock;
948 throw SALOMEDS::Study::StudyInvalidReference();
950 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
952 SALOMEDS::SComponentIterator_var it = it_servant->_this();
958 //============================================================================
959 /*! Function : NewBuilder
960 * Purpose : Create a StudyBuilder
962 //============================================================================
963 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
965 SALOMEDS::Locker lock;
968 throw SALOMEDS::Study::StudyInvalidReference();
970 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
975 //============================================================================
977 * Purpose : get study name
979 //============================================================================
980 char* SALOMEDS_Study_i::Name()
982 SALOMEDS::Locker lock;
983 // Name is specified as IDL attribute: user exception cannot be raised
984 return CORBA::string_dup(_impl->Name().c_str());
987 //============================================================================
988 /*! Function : IsSaved
989 * Purpose : get if study has been saved
991 //============================================================================
992 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
994 SALOMEDS::Locker lock;
995 // IsSaved is specified as IDL attribute: user exception cannot be raised
996 return (!_closed) ? _impl->IsSaved() : false;
999 //============================================================================
1000 /*! Function : IsSaved
1001 * Purpose : set if study has been saved
1003 //============================================================================
1004 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1006 SALOMEDS::Locker lock;
1007 // IsSaved is specified as IDL attribute: user exception cannot be raised
1009 _impl->IsSaved(save);
1012 //============================================================================
1013 /*! Function : IsModified
1014 * Purpose : Detect if a Study has been modified since it has been saved
1016 //============================================================================
1017 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1019 SALOMEDS::Locker lock;
1022 throw SALOMEDS::Study::StudyInvalidReference();
1024 return _impl->IsModified();
1027 //============================================================================
1028 /*! Function : Modified
1029 * Purpose : Sets a Modified flag of a Study to True
1031 //============================================================================
1032 void SALOMEDS_Study_i::Modified()
1034 SALOMEDS::Locker lock;
1037 throw SALOMEDS::Study::StudyInvalidReference();
1042 //============================================================================
1044 * Purpose : get URL of the study (persistent reference of the study)
1046 //============================================================================
1047 char* SALOMEDS_Study_i::URL()
1049 SALOMEDS::Locker lock;
1050 // URL is specified as IDL attribute: user exception cannot be raised
1051 return CORBA::string_dup(_impl->URL().c_str());
1054 //============================================================================
1056 * Purpose : set URL of the study (persistent reference of the study)
1058 //============================================================================
1059 void SALOMEDS_Study_i::URL(const char* url)
1061 SALOMEDS::Locker lock;
1062 // URL is specified as IDL attribute: user exception cannot be raised
1063 _impl->URL(std::string((char*)url));
1066 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1068 SALOMEDS::Locker lock;
1071 throw SALOMEDS::Study::StudyInvalidReference();
1073 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1076 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1078 SALOMEDS::Locker lock;
1080 SALOMEDSImpl_AttributeIOR* Att = NULL;
1081 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1082 char* IOR = CORBA::string_dup(Att->Value().c_str());
1083 CORBA::Object_var obj = orb->string_to_object(IOR);
1084 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1085 ASSERT(!CORBA::is_nil(aStudy));
1086 return SALOMEDS::Study::_duplicate(aStudy);
1088 MESSAGE("GetStudy: Problem to get study");
1090 return SALOMEDS::Study::_nil();
1093 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1095 SALOMEDS::Locker lock;
1096 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1099 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1101 SALOMEDS::Locker lock;
1104 throw SALOMEDS::Study::StudyInvalidReference();
1106 SALOMEDS::GenericAttribute_ptr aTarget;
1107 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1108 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1110 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1116 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1118 SALOMEDS::Locker lock;
1121 throw SALOMEDS::Study::StudyInvalidReference();
1123 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1124 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1125 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1126 return aProp._retn();
1129 char* SALOMEDS_Study_i::GetLastModificationDate()
1131 SALOMEDS::Locker lock;
1134 throw SALOMEDS::Study::StudyInvalidReference();
1136 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1139 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1141 SALOMEDS::Locker lock;
1144 throw SALOMEDS::Study::StudyInvalidReference();
1146 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1148 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1150 int aLength = aSeq.size();
1151 aDates->length(aLength);
1152 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1153 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1156 return aDates._retn();
1159 //============================================================================
1160 /*! Function : GetUseCaseBuilder
1161 * Purpose : Returns a UseCase builder
1163 //============================================================================
1164 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1166 SALOMEDS::Locker lock;
1169 throw SALOMEDS::Study::StudyInvalidReference();
1171 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1172 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1176 //============================================================================
1177 /*! Function : AddPostponed
1180 //============================================================================
1181 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1183 SALOMEDS::Locker lock;
1187 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1189 SALOMEDS::Locker lock;
1193 //============================================================================
1194 /*! Function : RemovePostponed
1197 //============================================================================
1198 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1200 SALOMEDS::Locker lock;
1203 throw SALOMEDS::Study::StudyInvalidReference();
1205 std::vector<std::string> anIORs = _impl->GetIORs();
1206 int i, aSize = (int)anIORs.size();
1208 for (i = 0; i < aSize; i++) {
1210 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1211 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1212 //rnv: To avoid double deletion of the Salome Generic Objects:
1213 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1214 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1215 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1222 //============================================================================
1223 /*! Function : UndoPostponed
1226 //============================================================================
1227 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1229 SALOMEDS::Locker lock;
1234 //============================================================================
1235 /*! Function : DumpStudy
1238 //============================================================================
1239 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1240 const char* theBaseName,
1241 CORBA::Boolean isPublished,
1242 CORBA::Boolean isMultiFile)
1244 SALOMEDS::Locker lock;
1247 throw SALOMEDS::Study::StudyInvalidReference();
1249 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1250 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1251 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1257 //============================================================================
1258 /*! Function : GetCommonParameters
1261 //============================================================================
1262 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1264 SALOMEDS::Locker lock;
1267 throw SALOMEDS::Study::StudyInvalidReference();
1269 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1270 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1271 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1273 return aParam._retn();
1276 //============================================================================
1277 /*! Function : GetCommonModuleParameters
1280 //============================================================================
1281 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1282 const char* theModuleName,
1283 CORBA::Long theSavePoint)
1285 SALOMEDS::Locker lock;
1288 throw SALOMEDS::Study::StudyInvalidReference();
1290 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1291 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1292 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1294 return aParam._retn();
1297 //============================================================================
1298 /*! Function : SetStudyLock
1301 //============================================================================
1302 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1304 SALOMEDS::Locker lock;
1307 throw SALOMEDS::Study::StudyInvalidReference();
1309 _impl->SetStudyLock(theLockerID);
1312 //============================================================================
1313 /*! Function : IsStudyLocked
1316 //============================================================================
1317 bool SALOMEDS_Study_i::IsStudyLocked()
1319 SALOMEDS::Locker lock;
1322 throw SALOMEDS::Study::StudyInvalidReference();
1324 return _impl->IsStudyLocked();
1327 //============================================================================
1328 /*! Function : UnLockStudy
1331 //============================================================================
1332 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1334 SALOMEDS::Locker lock;
1337 throw SALOMEDS::Study::StudyInvalidReference();
1339 _impl->UnLockStudy(theLockerID);
1342 //============================================================================
1343 /*! Function : GetLockerID
1346 //============================================================================
1347 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1349 SALOMEDS::Locker lock;
1352 throw SALOMEDS::Study::StudyInvalidReference();
1354 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1356 std::vector<std::string> aSeq = _impl->GetLockerID();
1358 int aLength = aSeq.size();
1359 aResult->length(aLength);
1360 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1361 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1364 return aResult._retn();
1366 //============================================================================
1367 /*! Function : SetReal
1370 //============================================================================
1371 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1374 throw SALOMEDS::Study::StudyInvalidReference();
1377 _impl->SetVariable(std::string(theVarName),
1379 SALOMEDSImpl_GenericVariable::REAL_VAR);
1381 _notifier->modifyNB_Notification(theVarName);
1384 //============================================================================
1385 /*! Function : SetInteger
1388 //============================================================================
1389 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1392 throw SALOMEDS::Study::StudyInvalidReference();
1394 _impl->SetVariable(std::string(theVarName),
1396 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1398 _notifier->modifyNB_Notification(theVarName);
1401 //============================================================================
1402 /*! Function : SetBoolean
1405 //============================================================================
1406 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1409 throw SALOMEDS::Study::StudyInvalidReference();
1411 _impl->SetVariable(std::string(theVarName),
1413 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1415 _notifier->modifyNB_Notification(theVarName);
1418 //============================================================================
1419 /*! Function : SetString
1422 //============================================================================
1423 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1426 throw SALOMEDS::Study::StudyInvalidReference();
1428 _impl->SetStringVariable(std::string(theVarName),
1430 SALOMEDSImpl_GenericVariable::STRING_VAR);
1432 _notifier->modifyNB_Notification(theVarName);
1435 //============================================================================
1436 /*! Function : SetStringAsDouble
1439 //============================================================================
1440 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1443 throw SALOMEDS::Study::StudyInvalidReference();
1445 _impl->SetStringVariableAsDouble(std::string(theVarName),
1447 SALOMEDSImpl_GenericVariable::STRING_VAR);
1450 //============================================================================
1451 /*! Function : GetReal
1454 //============================================================================
1455 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1458 throw SALOMEDS::Study::StudyInvalidReference();
1460 return _impl->GetVariableValue(std::string(theVarName));
1463 //============================================================================
1464 /*! Function : GetInteger
1467 //============================================================================
1468 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1471 throw SALOMEDS::Study::StudyInvalidReference();
1473 return (long)_impl->GetVariableValue(std::string(theVarName));
1476 //============================================================================
1477 /*! Function : GetBoolean
1480 //============================================================================
1481 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1484 throw SALOMEDS::Study::StudyInvalidReference();
1486 return (bool)_impl->GetVariableValue(std::string(theVarName));
1489 //============================================================================
1490 /*! Function : GetString
1493 //============================================================================
1494 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1497 throw SALOMEDS::Study::StudyInvalidReference();
1499 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1502 //============================================================================
1503 /*! Function : IsReal
1506 //============================================================================
1507 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1510 throw SALOMEDS::Study::StudyInvalidReference();
1512 return _impl->IsTypeOf(std::string(theVarName),
1513 SALOMEDSImpl_GenericVariable::REAL_VAR);
1516 //============================================================================
1517 /*! Function : IsInteger
1520 //============================================================================
1521 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1524 throw SALOMEDS::Study::StudyInvalidReference();
1526 return _impl->IsTypeOf(std::string(theVarName),
1527 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1530 //============================================================================
1531 /*! Function : IsBoolean
1534 //============================================================================
1535 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1538 throw SALOMEDS::Study::StudyInvalidReference();
1540 return _impl->IsTypeOf(std::string(theVarName),
1541 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1544 //============================================================================
1545 /*! Function : IsString
1548 //============================================================================
1549 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1552 throw SALOMEDS::Study::StudyInvalidReference();
1554 return _impl->IsTypeOf(std::string(theVarName),
1555 SALOMEDSImpl_GenericVariable::STRING_VAR);
1558 //============================================================================
1559 /*! Function : IsVariable
1562 //============================================================================
1563 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1566 throw SALOMEDS::Study::StudyInvalidReference();
1568 return _impl->IsVariable(std::string(theVarName));
1571 //============================================================================
1572 /*! Function : GetVariableNames
1575 //============================================================================
1576 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1579 throw SALOMEDS::Study::StudyInvalidReference();
1581 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1583 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1585 int aLen = aVarNames.size();
1586 aResult->length(aLen);
1587 for (int anInd = 0; anInd < aLen; anInd++)
1588 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1590 return aResult._retn();
1593 //============================================================================
1594 /*! Function : RemoveVariable
1597 //============================================================================
1598 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1601 throw SALOMEDS::Study::StudyInvalidReference();
1603 bool res = _impl->RemoveVariable(std::string(theVarName));
1604 if (res && _notifier)
1605 _notifier->modifyNB_Notification(theVarName);
1610 //============================================================================
1611 /*! Function : RenameVariable
1614 //============================================================================
1615 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1618 throw SALOMEDS::Study::StudyInvalidReference();
1620 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1621 if (res && _notifier)
1622 _notifier->modifyNB_Notification(theVarName);
1627 //============================================================================
1628 /*! Function : IsVariableUsed
1631 //============================================================================
1632 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1635 throw SALOMEDS::Study::StudyInvalidReference();
1637 return _impl->IsVariableUsed(std::string(theVarName));
1641 //============================================================================
1642 /*! Function : ParseVariables
1645 //============================================================================
1646 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1649 throw SALOMEDS::Study::StudyInvalidReference();
1651 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1653 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1655 int aSectionsLen = aSections.size();
1656 aResult->length(aSectionsLen);
1658 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1659 std::vector<std::string> aVarNames = aSections[aSectionInd];
1661 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1663 int aLen = aVarNames.size();
1664 aList->length(aLen);
1666 for (int anInd = 0; anInd < aLen; anInd++)
1667 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1669 aResult[aSectionInd] = aList;
1672 return aResult._retn();
1675 //============================================================================
1676 /*! Function : GetDefaultScript
1679 //============================================================================
1680 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1682 SALOMEDS::Locker lock;
1685 throw SALOMEDS::Study::StudyInvalidReference();
1687 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1688 return CORBA::string_dup(script.c_str());
1691 //============================================================================
1692 /*! Function : EnableUseCaseAutoFilling
1695 //============================================================================
1696 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1699 throw SALOMEDS::Study::StudyInvalidReference();
1701 _impl->EnableUseCaseAutoFilling(isEnabled);
1702 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1705 builder->SetOnAddSObject(_impl->GetCallback());
1706 builder->SetOnRemoveSObject(_impl->GetCallback());
1709 builder->SetOnAddSObject(NULL);
1710 builder->SetOnRemoveSObject(NULL);
1716 CORBA::Long SALOMEDS_Study_i::getPID()
1719 return (CORBA::Long)_getpid();
1721 return (CORBA::Long)getpid();
1725 void SALOMEDS_Study_i::ShutdownWithExit()
1727 exit( EXIT_SUCCESS );
1730 void SALOMEDS_Study_i::Shutdown()
1732 if(!CORBA::is_nil(_orb))
1736 //============================================================================
1737 /*! Function : attach
1738 * Purpose : This function attach an observer to the study
1740 //============================================================================
1741 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1744 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1748 //============================================================================
1749 /*! Function : detach
1750 * Purpose : This function detaches an observer from the study
1752 //============================================================================
1753 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1756 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1759 //===========================================================================
1760 // PRIVATE FUNCTIONS
1761 //===========================================================================
1762 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1765 long pid = (long)_getpid();
1767 long pid = (long)getpid();
1769 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1770 return reinterpret_cast<CORBA::LongLong>(_impl);