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 // update desktop title with new study name
275 // Notify GUI that study was created
276 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
277 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
278 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
279 if ( !CORBA::is_nil(aSession) ) {
280 std::stringstream ss;
281 ss << "studyCreated";
282 std::string str = ss.str();
284 aSession->emitMessageOneWay(str.c_str());
289 //============================================================================
291 * Purpose : Clear study components
293 //============================================================================
294 void SALOMEDS_Study_i::Clear()
296 //delete the builder servant
297 PortableServer::POA_var poa=_builder->_default_POA();
298 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
299 poa->deactivate_object(anObjectId.in());
300 _builder->_remove_ref();
302 SALOMEDS::Locker lock;
305 throw SALOMEDS::Study::StudyInvalidReference();
308 if (_impl->GetDocument()) {
309 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
310 for (; itcomponent->More(); itcomponent->Next()) {
311 SALOMEDS::SComponent_var sco = itcomponent->Value();
312 CORBA::String_var compodatatype=sco->ComponentDataType();
313 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
314 // if there is an associated Engine call its method for closing
315 CORBA::String_var IOREngine;
316 if (sco->ComponentIOR(IOREngine)) {
317 // we have found the associated engine to write the data
318 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
319 //_narrow can throw a corba exception
321 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
322 if (!CORBA::is_nil(obj)) {
323 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
324 if (!anEngine->_is_nil()) {
326 anEngine->Close(sco);
331 catch (CORBA::Exception&) {
337 //Does not need any more this iterator
338 itcomponent->UnRegister();
341 // Notify GUI that study is cleared
342 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
343 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
344 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
345 if ( !CORBA::is_nil(aSession) ) {
346 std::stringstream ss;
347 ss << "studyCleared";
348 std::string str = ss.str();
350 aSession->emitMessageOneWay(str.c_str());
355 _impl->setNotifier(0);
357 delete _genObjRegister;
362 //============================================================================
364 * Purpose : Open a Study from it's persistent reference
366 //============================================================================
367 bool SALOMEDS_Study_i::Open(const char* aUrl)
368 throw(SALOME::SALOME_Exception)
370 SALOMEDS::Locker lock;
372 Unexpect aCatch(SalomeException);
373 MESSAGE("Begin of SALOMEDS_Study_i::Open");
375 bool res = _impl->Open(std::string(aUrl));
377 // update desktop title with new study name
381 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
385 //============================================================================
387 * Purpose : Save a Study to it's persistent reference
389 //============================================================================
390 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
392 SALOMEDS::Locker lock;
393 return _impl->Save(_factory, theMultiFile);
396 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
398 SALOMEDS::Locker lock;
399 return _impl->SaveASCII(_factory, theMultiFile);
402 //=============================================================================
403 /*! Function : SaveAs
404 * Purpose : Save a study to the persistent reference aUrl
406 //============================================================================
407 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
409 SALOMEDS::Locker lock;
410 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
413 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
415 SALOMEDS::Locker lock;
416 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
419 //============================================================================
420 /*! Function : CanCopy
423 //============================================================================
424 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
426 SALOMEDS::Locker lock;
428 CORBA::String_var anID = theObject->GetID();
429 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
431 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
432 bool ret = _impl->CanCopy(anObject, aDriver);
437 //============================================================================
441 //============================================================================
442 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
444 SALOMEDS::Locker lock;
446 CORBA::String_var anID = theObject->GetID();
447 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
449 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
450 bool ret = _impl->Copy(anObject, aDriver);
455 //============================================================================
456 /*! Function : CanPaste
459 //============================================================================
460 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
462 SALOMEDS::Locker lock;
464 CORBA::String_var anID = theObject->GetID();
465 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
467 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
468 bool ret = _impl->CanPaste(anObject, aDriver);
473 //============================================================================
477 //============================================================================
478 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
479 throw(SALOMEDS::StudyBuilder::LockProtection)
481 SALOMEDS::Locker lock;
483 Unexpect aCatch(LockProtection);
485 CORBA::String_var anID = theObject->GetID();
486 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
487 SALOMEDSImpl_SObject aNewSO;
490 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
491 aNewSO = _impl->Paste(anObject, aDriver);
495 throw SALOMEDS::StudyBuilder::LockProtection();
498 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
502 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
504 SALOMEDS_Driver_i* driver = NULL;
506 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
508 std::string IOREngine = aSCO.GetIOR();
509 if(!IOREngine.empty()) {
510 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
511 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
512 driver = new SALOMEDS_Driver_i(Engine, orb);
519 //============================================================================
520 /*! Function : GetPersistentReference
521 * Purpose : Get persistent reference of study (idem URL())
523 //============================================================================
524 char* SALOMEDS_Study_i::GetPersistentReference()
526 SALOMEDS::Locker lock;
528 throw SALOMEDS::Study::StudyInvalidReference();
529 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
531 //============================================================================
532 /*! Function : GetTransientReference
533 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
535 //============================================================================
536 char* SALOMEDS_Study_i::GetTransientReference()
538 SALOMEDS::Locker lock;
540 throw SALOMEDS::Study::StudyInvalidReference();
541 return CORBA::string_dup(_impl->GetTransientReference().c_str());
544 //============================================================================
545 /*! Function : IsEmpty
546 * Purpose : Detect if study is empty
548 //============================================================================
549 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
551 SALOMEDS::Locker lock;
553 throw SALOMEDS::Study::StudyInvalidReference();
554 return _impl->IsEmpty();
557 //============================================================================
558 /*! Function : FindComponent
559 * Purpose : Find a Component with ComponentDataType = aComponentName
561 //============================================================================
562 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
564 SALOMEDS::Locker lock;
567 throw SALOMEDS::Study::StudyInvalidReference();
569 SALOMEDS::SComponent_var sco;
571 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
572 if (!aCompImpl.IsNull())
573 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
578 //============================================================================
579 /*! Function : FindComponentID
580 * Purpose : Find a Component from it's ID
582 //============================================================================
583 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
585 SALOMEDS::Locker lock;
588 throw SALOMEDS::Study::StudyInvalidReference();
590 SALOMEDS::SComponent_var sco;
592 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
593 if (!aCompImpl.IsNull())
594 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
599 //============================================================================
600 /*! Function : FindObject
601 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
603 //============================================================================
604 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
606 SALOMEDS::Locker lock;
609 throw SALOMEDS::Study::StudyInvalidReference();
611 SALOMEDS::SObject_var so;
613 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
615 if (aSO.IsComponent()) {
616 SALOMEDSImpl_SComponent aSCO = aSO;
617 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
620 so = SALOMEDS_SObject_i::New(aSO, _orb);
627 //============================================================================
628 /*! Function : FindObjectID
629 * Purpose : Find an Object with ID = anObjectID
631 //============================================================================
632 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
634 SALOMEDS::Locker lock;
637 throw SALOMEDS::Study::StudyInvalidReference();
639 SALOMEDS::SObject_var so;
641 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
643 so = SALOMEDS_SObject_i::New(aSO, _orb);
648 //============================================================================
649 /*! Function : CreateObjectID
650 * Purpose : Creates an Object with ID = anObjectID
652 //============================================================================
653 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
655 SALOMEDS::Locker lock;
658 throw SALOMEDS::Study::StudyInvalidReference();
660 SALOMEDS::SObject_var so;
662 if (anObjectID && strlen(anObjectID) > 0) {
663 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
665 so = SALOMEDS_SObject_i::New(aSO, _orb);
671 //============================================================================
672 /*! Function : FindObjectByName
673 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
674 * : with ComponentDataType = aComponentName
676 //============================================================================
677 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
678 const char* aComponentName )
680 SALOMEDS::Locker lock;
683 throw SALOMEDS::Study::StudyInvalidReference();
685 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
686 std::string((char*)aComponentName));
688 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
689 int aLength = aSeq.size();
690 listSO->length(aLength);
691 for (int i = 0; i < aLength; i++) {
692 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
696 return listSO._retn();
699 //============================================================================
700 /*! Function : FindObjectIOR
701 * Purpose : Find an Object with IOR = anObjectIOR
703 //============================================================================
704 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
706 SALOMEDS::Locker lock;
709 throw SALOMEDS::Study::StudyInvalidReference();
711 SALOMEDS::SObject_var so;
713 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
715 so = SALOMEDS_SObject_i::New(aSO, _orb);
720 //============================================================================
721 /*! Function : FindObjectByPath
722 * Purpose : Find an Object by its path = thePath
724 //============================================================================
725 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
727 SALOMEDS::Locker lock;
730 throw SALOMEDS::Study::StudyInvalidReference();
732 SALOMEDS::SObject_var so;
734 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
736 so = SALOMEDS_SObject_i::New (aSO, _orb);
741 //============================================================================
742 /*! Function : GetObjectPath
745 //============================================================================
746 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
748 SALOMEDS::Locker lock;
751 throw SALOMEDS::Study::StudyInvalidReference();
753 std::string aPath = "";
755 if (!CORBA::is_nil(theObject)) {
756 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
757 SALOMEDSImpl_SObject aSO;
759 if (!CORBA::is_nil(aSObj)) {
760 aSO = _impl->FindObjectID(aSObj->GetID());
763 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
767 aPath = _impl->GetObjectPath(aSO);
771 return CORBA::string_dup(aPath.c_str());
775 //============================================================================
776 /*! Function : SetContext
777 * Purpose : Sets the current context
779 //============================================================================
780 void SALOMEDS_Study_i::SetContext(const char* thePath)
782 SALOMEDS::Locker lock;
785 throw SALOMEDS::Study::StudyInvalidReference();
787 _impl->SetContext(std::string((char*)thePath));
788 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
789 throw SALOMEDS::Study::StudyInvalidContext();
792 //============================================================================
793 /*! Function : GetContext
794 * Purpose : Gets the current context
796 //============================================================================
797 char* SALOMEDS_Study_i::GetContext()
799 SALOMEDS::Locker lock;
802 throw SALOMEDS::Study::StudyInvalidReference();
804 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
806 return CORBA::string_dup(_impl->GetContext().c_str());
809 //============================================================================
810 /*! Function : GetObjectNames
811 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
813 //============================================================================
814 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
816 SALOMEDS::Locker lock;
819 throw SALOMEDS::Study::StudyInvalidReference();
821 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
823 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
824 throw SALOMEDS::Study::StudyInvalidContext();
826 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
827 if (_impl->GetErrorCode() == "InvalidContext")
828 throw SALOMEDS::Study::StudyInvalidContext();
830 int aLength = aSeq.size();
831 aResult->length(aLength);
832 for (int anIndex = 0; anIndex < aLength; anIndex++) {
833 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
836 return aResult._retn();
839 //============================================================================
840 /*! Function : GetDirectoryNames
841 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
843 //============================================================================
844 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
846 SALOMEDS::Locker lock;
849 throw SALOMEDS::Study::StudyInvalidReference();
851 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
853 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
854 throw SALOMEDS::Study::StudyInvalidContext();
856 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
857 if (_impl->GetErrorCode() == "InvalidContext")
858 throw SALOMEDS::Study::StudyInvalidContext();
860 int aLength = aSeq.size();
861 aResult->length(aLength);
862 for (int anIndex = 0; anIndex < aLength; anIndex++) {
863 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
866 return aResult._retn();
869 //============================================================================
870 /*! Function : GetFileNames
871 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
873 //============================================================================
874 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
876 SALOMEDS::Locker lock;
879 throw SALOMEDS::Study::StudyInvalidReference();
881 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
883 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
884 throw SALOMEDS::Study::StudyInvalidContext();
886 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
887 if (_impl->GetErrorCode() == "InvalidContext")
888 throw SALOMEDS::Study::StudyInvalidContext();
890 int aLength = aSeq.size();
891 aResult->length(aLength);
892 for (int anIndex = 0; anIndex < aLength; anIndex++) {
893 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
896 return aResult._retn();
899 //============================================================================
900 /*! Function : GetComponentNames
901 * Purpose : method to get all components names
902 * SRN: Note, theContext can be any, it doesn't matter
904 //============================================================================
905 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
907 SALOMEDS::Locker lock;
910 throw SALOMEDS::Study::StudyInvalidReference();
912 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
914 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
916 int aLength = aSeq.size();
917 aResult->length(aLength);
918 for(int anIndex = 0; anIndex < aLength; anIndex++) {
919 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
922 return aResult._retn();
925 //============================================================================
926 /*! Function : NewChildIterator
927 * Purpose : Create a ChildIterator from an SObject
929 //============================================================================
930 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
932 SALOMEDS::Locker lock;
935 throw SALOMEDS::Study::StudyInvalidReference();
937 CORBA::String_var anID = theSO->GetID();
938 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
939 SALOMEDSImpl_ChildIterator anItr(aSO);
940 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
941 SALOMEDS::ChildIterator_var it = it_servant->_this();
947 //============================================================================
948 /*! Function : NewComponentIterator
949 * Purpose : Create a SComponentIterator
951 //============================================================================
952 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
954 SALOMEDS::Locker lock;
957 throw SALOMEDS::Study::StudyInvalidReference();
959 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
961 SALOMEDS::SComponentIterator_var it = it_servant->_this();
967 //============================================================================
968 /*! Function : NewBuilder
969 * Purpose : Create a StudyBuilder
971 //============================================================================
972 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
974 SALOMEDS::Locker lock;
977 throw SALOMEDS::Study::StudyInvalidReference();
979 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
984 //============================================================================
986 * Purpose : get study name
988 //============================================================================
989 char* SALOMEDS_Study_i::Name()
991 SALOMEDS::Locker lock;
992 // Name is specified as IDL attribute: user exception cannot be raised
993 return CORBA::string_dup(_impl->Name().c_str());
996 //============================================================================
997 /*! Function : IsSaved
998 * Purpose : get if study has been saved
1000 //============================================================================
1001 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1003 SALOMEDS::Locker lock;
1004 // IsSaved is specified as IDL attribute: user exception cannot be raised
1005 return (!_closed) ? _impl->IsSaved() : false;
1008 //============================================================================
1009 /*! Function : IsSaved
1010 * Purpose : set if study has been saved
1012 //============================================================================
1013 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1015 SALOMEDS::Locker lock;
1016 // IsSaved is specified as IDL attribute: user exception cannot be raised
1018 _impl->IsSaved(save);
1021 //============================================================================
1022 /*! Function : IsModified
1023 * Purpose : Detect if a Study has been modified since it has been saved
1025 //============================================================================
1026 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1028 SALOMEDS::Locker lock;
1031 throw SALOMEDS::Study::StudyInvalidReference();
1033 return _impl->IsModified();
1036 //============================================================================
1037 /*! Function : Modified
1038 * Purpose : Sets a Modified flag of a Study to True
1040 //============================================================================
1041 void SALOMEDS_Study_i::Modified()
1043 SALOMEDS::Locker lock;
1046 throw SALOMEDS::Study::StudyInvalidReference();
1051 //============================================================================
1053 * Purpose : get URL of the study (persistent reference of the study)
1055 //============================================================================
1056 char* SALOMEDS_Study_i::URL()
1058 SALOMEDS::Locker lock;
1059 // URL is specified as IDL attribute: user exception cannot be raised
1060 return CORBA::string_dup(_impl->URL().c_str());
1063 //============================================================================
1065 * Purpose : set URL of the study (persistent reference of the study)
1067 //============================================================================
1068 void SALOMEDS_Study_i::URL(const char* url)
1070 SALOMEDS::Locker lock;
1071 // URL is specified as IDL attribute: user exception cannot be raised
1072 _impl->URL(std::string((char*)url));
1074 // update desktop title with new study name
1078 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1080 SALOMEDS::Locker lock;
1083 throw SALOMEDS::Study::StudyInvalidReference();
1085 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1088 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1090 SALOMEDS::Locker lock;
1092 SALOMEDSImpl_AttributeIOR* Att = NULL;
1093 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1094 char* IOR = CORBA::string_dup(Att->Value().c_str());
1095 CORBA::Object_var obj = orb->string_to_object(IOR);
1096 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1097 ASSERT(!CORBA::is_nil(aStudy));
1098 return SALOMEDS::Study::_duplicate(aStudy);
1100 MESSAGE("GetStudy: Problem to get study");
1102 return SALOMEDS::Study::_nil();
1105 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1107 SALOMEDS::Locker lock;
1108 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1111 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1113 SALOMEDS::Locker lock;
1116 throw SALOMEDS::Study::StudyInvalidReference();
1118 SALOMEDS::GenericAttribute_ptr aTarget;
1119 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1120 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1122 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1128 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1130 SALOMEDS::Locker lock;
1133 throw SALOMEDS::Study::StudyInvalidReference();
1135 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1136 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1137 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1138 return aProp._retn();
1141 char* SALOMEDS_Study_i::GetLastModificationDate()
1143 SALOMEDS::Locker lock;
1146 throw SALOMEDS::Study::StudyInvalidReference();
1148 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1151 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1153 SALOMEDS::Locker lock;
1156 throw SALOMEDS::Study::StudyInvalidReference();
1158 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1160 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1162 int aLength = aSeq.size();
1163 aDates->length(aLength);
1164 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1165 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1168 return aDates._retn();
1171 //============================================================================
1172 /*! Function : GetUseCaseBuilder
1173 * Purpose : Returns a UseCase builder
1175 //============================================================================
1176 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1178 SALOMEDS::Locker lock;
1181 throw SALOMEDS::Study::StudyInvalidReference();
1183 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1184 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1188 //============================================================================
1189 /*! Function : AddPostponed
1192 //============================================================================
1193 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1195 SALOMEDS::Locker lock;
1199 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1201 SALOMEDS::Locker lock;
1205 //============================================================================
1206 /*! Function : RemovePostponed
1209 //============================================================================
1210 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1212 SALOMEDS::Locker lock;
1215 throw SALOMEDS::Study::StudyInvalidReference();
1217 std::vector<std::string> anIORs = _impl->GetIORs();
1218 int i, aSize = (int)anIORs.size();
1220 for (i = 0; i < aSize; i++) {
1222 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1223 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1224 //rnv: To avoid double deletion of the Salome Generic Objects:
1225 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1226 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1227 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1234 //============================================================================
1235 /*! Function : UndoPostponed
1238 //============================================================================
1239 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1241 SALOMEDS::Locker lock;
1246 //============================================================================
1247 /*! Function : DumpStudy
1250 //============================================================================
1251 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1252 const char* theBaseName,
1253 CORBA::Boolean isPublished,
1254 CORBA::Boolean isMultiFile)
1256 SALOMEDS::Locker lock;
1259 throw SALOMEDS::Study::StudyInvalidReference();
1261 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1262 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1263 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1269 //============================================================================
1270 /*! Function : GetCommonParameters
1273 //============================================================================
1274 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1276 SALOMEDS::Locker lock;
1279 throw SALOMEDS::Study::StudyInvalidReference();
1281 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1282 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1283 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1285 return aParam._retn();
1288 //============================================================================
1289 /*! Function : GetCommonModuleParameters
1292 //============================================================================
1293 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1294 const char* theModuleName,
1295 CORBA::Long theSavePoint)
1297 SALOMEDS::Locker lock;
1300 throw SALOMEDS::Study::StudyInvalidReference();
1302 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1303 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1304 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1306 return aParam._retn();
1309 //============================================================================
1310 /*! Function : SetStudyLock
1313 //============================================================================
1314 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1316 SALOMEDS::Locker lock;
1319 throw SALOMEDS::Study::StudyInvalidReference();
1321 _impl->SetStudyLock(theLockerID);
1324 //============================================================================
1325 /*! Function : IsStudyLocked
1328 //============================================================================
1329 bool SALOMEDS_Study_i::IsStudyLocked()
1331 SALOMEDS::Locker lock;
1334 throw SALOMEDS::Study::StudyInvalidReference();
1336 return _impl->IsStudyLocked();
1339 //============================================================================
1340 /*! Function : UnLockStudy
1343 //============================================================================
1344 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1346 SALOMEDS::Locker lock;
1349 throw SALOMEDS::Study::StudyInvalidReference();
1351 _impl->UnLockStudy(theLockerID);
1354 //============================================================================
1355 /*! Function : GetLockerID
1358 //============================================================================
1359 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1361 SALOMEDS::Locker lock;
1364 throw SALOMEDS::Study::StudyInvalidReference();
1366 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1368 std::vector<std::string> aSeq = _impl->GetLockerID();
1370 int aLength = aSeq.size();
1371 aResult->length(aLength);
1372 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1373 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1376 return aResult._retn();
1378 //============================================================================
1379 /*! Function : SetReal
1382 //============================================================================
1383 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1386 throw SALOMEDS::Study::StudyInvalidReference();
1389 _impl->SetVariable(std::string(theVarName),
1391 SALOMEDSImpl_GenericVariable::REAL_VAR);
1393 _notifier->modifyNB_Notification(theVarName);
1396 //============================================================================
1397 /*! Function : SetInteger
1400 //============================================================================
1401 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1404 throw SALOMEDS::Study::StudyInvalidReference();
1406 _impl->SetVariable(std::string(theVarName),
1408 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1410 _notifier->modifyNB_Notification(theVarName);
1413 //============================================================================
1414 /*! Function : SetBoolean
1417 //============================================================================
1418 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1421 throw SALOMEDS::Study::StudyInvalidReference();
1423 _impl->SetVariable(std::string(theVarName),
1425 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1427 _notifier->modifyNB_Notification(theVarName);
1430 //============================================================================
1431 /*! Function : SetString
1434 //============================================================================
1435 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1438 throw SALOMEDS::Study::StudyInvalidReference();
1440 _impl->SetStringVariable(std::string(theVarName),
1442 SALOMEDSImpl_GenericVariable::STRING_VAR);
1444 _notifier->modifyNB_Notification(theVarName);
1447 //============================================================================
1448 /*! Function : SetStringAsDouble
1451 //============================================================================
1452 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1455 throw SALOMEDS::Study::StudyInvalidReference();
1457 _impl->SetStringVariableAsDouble(std::string(theVarName),
1459 SALOMEDSImpl_GenericVariable::STRING_VAR);
1462 //============================================================================
1463 /*! Function : GetReal
1466 //============================================================================
1467 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1470 throw SALOMEDS::Study::StudyInvalidReference();
1472 return _impl->GetVariableValue(std::string(theVarName));
1475 //============================================================================
1476 /*! Function : GetInteger
1479 //============================================================================
1480 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1483 throw SALOMEDS::Study::StudyInvalidReference();
1485 return (long)_impl->GetVariableValue(std::string(theVarName));
1488 //============================================================================
1489 /*! Function : GetBoolean
1492 //============================================================================
1493 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1496 throw SALOMEDS::Study::StudyInvalidReference();
1498 return (bool)_impl->GetVariableValue(std::string(theVarName));
1501 //============================================================================
1502 /*! Function : GetString
1505 //============================================================================
1506 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1509 throw SALOMEDS::Study::StudyInvalidReference();
1511 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1514 //============================================================================
1515 /*! Function : IsReal
1518 //============================================================================
1519 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1522 throw SALOMEDS::Study::StudyInvalidReference();
1524 return _impl->IsTypeOf(std::string(theVarName),
1525 SALOMEDSImpl_GenericVariable::REAL_VAR);
1528 //============================================================================
1529 /*! Function : IsInteger
1532 //============================================================================
1533 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1536 throw SALOMEDS::Study::StudyInvalidReference();
1538 return _impl->IsTypeOf(std::string(theVarName),
1539 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1542 //============================================================================
1543 /*! Function : IsBoolean
1546 //============================================================================
1547 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1550 throw SALOMEDS::Study::StudyInvalidReference();
1552 return _impl->IsTypeOf(std::string(theVarName),
1553 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1556 //============================================================================
1557 /*! Function : IsString
1560 //============================================================================
1561 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1564 throw SALOMEDS::Study::StudyInvalidReference();
1566 return _impl->IsTypeOf(std::string(theVarName),
1567 SALOMEDSImpl_GenericVariable::STRING_VAR);
1570 //============================================================================
1571 /*! Function : IsVariable
1574 //============================================================================
1575 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1578 throw SALOMEDS::Study::StudyInvalidReference();
1580 return _impl->IsVariable(std::string(theVarName));
1583 //============================================================================
1584 /*! Function : GetVariableNames
1587 //============================================================================
1588 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1591 throw SALOMEDS::Study::StudyInvalidReference();
1593 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1595 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1597 int aLen = aVarNames.size();
1598 aResult->length(aLen);
1599 for (int anInd = 0; anInd < aLen; anInd++)
1600 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1602 return aResult._retn();
1605 //============================================================================
1606 /*! Function : RemoveVariable
1609 //============================================================================
1610 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1613 throw SALOMEDS::Study::StudyInvalidReference();
1615 bool res = _impl->RemoveVariable(std::string(theVarName));
1616 if (res && _notifier)
1617 _notifier->modifyNB_Notification(theVarName);
1622 //============================================================================
1623 /*! Function : RenameVariable
1626 //============================================================================
1627 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1630 throw SALOMEDS::Study::StudyInvalidReference();
1632 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1633 if (res && _notifier)
1634 _notifier->modifyNB_Notification(theVarName);
1639 //============================================================================
1640 /*! Function : IsVariableUsed
1643 //============================================================================
1644 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1647 throw SALOMEDS::Study::StudyInvalidReference();
1649 return _impl->IsVariableUsed(std::string(theVarName));
1653 //============================================================================
1654 /*! Function : ParseVariables
1657 //============================================================================
1658 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1661 throw SALOMEDS::Study::StudyInvalidReference();
1663 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1665 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1667 int aSectionsLen = aSections.size();
1668 aResult->length(aSectionsLen);
1670 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1671 std::vector<std::string> aVarNames = aSections[aSectionInd];
1673 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1675 int aLen = aVarNames.size();
1676 aList->length(aLen);
1678 for (int anInd = 0; anInd < aLen; anInd++)
1679 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1681 aResult[aSectionInd] = aList;
1684 return aResult._retn();
1687 //============================================================================
1688 /*! Function : GetDefaultScript
1691 //============================================================================
1692 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1694 SALOMEDS::Locker lock;
1697 throw SALOMEDS::Study::StudyInvalidReference();
1699 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1700 return CORBA::string_dup(script.c_str());
1703 //============================================================================
1704 /*! Function : EnableUseCaseAutoFilling
1707 //============================================================================
1708 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1711 throw SALOMEDS::Study::StudyInvalidReference();
1713 _impl->EnableUseCaseAutoFilling(isEnabled);
1714 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1717 builder->SetOnAddSObject(_impl->GetCallback());
1718 builder->SetOnRemoveSObject(_impl->GetCallback());
1721 builder->SetOnAddSObject(NULL);
1722 builder->SetOnRemoveSObject(NULL);
1728 CORBA::Long SALOMEDS_Study_i::getPID()
1731 return (CORBA::Long)_getpid();
1733 return (CORBA::Long)getpid();
1737 void SALOMEDS_Study_i::ShutdownWithExit()
1739 exit( EXIT_SUCCESS );
1742 void SALOMEDS_Study_i::Shutdown()
1744 if(!CORBA::is_nil(_orb))
1748 //============================================================================
1749 /*! Function : attach
1750 * Purpose : This function attach an observer to the study
1752 //============================================================================
1753 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1756 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1760 //============================================================================
1761 /*! Function : detach
1762 * Purpose : This function detaches an observer from the study
1764 //============================================================================
1765 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1768 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1771 //===========================================================================
1772 // PRIVATE FUNCTIONS
1773 //===========================================================================
1774 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1777 long pid = (long)_getpid();
1779 long pid = (long)getpid();
1781 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1782 return reinterpret_cast<CORBA::LongLong>(_impl);
1785 void SALOMEDS_Study_i::NameChanged()
1787 // Notify GUI that the name of study was changed
1788 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1789 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1790 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1791 if ( !CORBA::is_nil(aSession) ) {
1792 std::stringstream ss;
1793 ss << "studyNameChanged";
1794 std::string str = ss.str();
1796 aSession->emitMessageOneWay(str.c_str());