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);
243 //============================================================================
244 /*! Function : ~SALOMEDS_Study_i
245 * Purpose : SALOMEDS_Study_i destructor
247 //============================================================================
248 SALOMEDS_Study_i::~SALOMEDS_Study_i()
255 //============================================================================
257 * Purpose : Initialize study components
259 //============================================================================
260 void SALOMEDS_Study_i::Init()
262 if ( !_impl->GetDocument() )
266 throw SALOMEDS::Study::StudyInvalidReference();
268 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
269 _notifier = new SALOMEDS::Notifier(_orb);
270 _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
273 _impl->setNotifier(_notifier);
274 _impl->setGenObjRegister( _genObjRegister );
276 // update desktop title with new study name
279 // Notify GUI that study was created
280 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
281 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
282 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
283 if ( !CORBA::is_nil(aSession) ) {
284 std::stringstream ss;
285 ss << "studyCreated";
286 std::string str = ss.str();
288 aSession->emitMessageOneWay(str.c_str());
292 std::string anIOR = _impl->GetTransientReference();
293 if ( anIOR.empty() ) {
294 CORBA::Object_var obj = aNamingService->Resolve("/Study");
295 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( obj );
296 CORBA::String_var IORStudy = _orb->object_to_string(aStudy);
297 _impl->SetTransientReference((char*)IORStudy.in());
302 //============================================================================
304 * Purpose : Clear study components
306 //============================================================================
307 void SALOMEDS_Study_i::Clear()
309 SALOMEDS::Locker lock;
311 throw SALOMEDS::Study::StudyInvalidReference();
312 //delete the builder servant
313 PortableServer::POA_var poa=_builder->_default_POA();
314 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
315 poa->deactivate_object(anObjectId.in());
316 _builder->_remove_ref();
320 if (_impl->GetDocument()) {
321 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
322 for (; itcomponent->More(); itcomponent->Next()) {
323 SALOMEDS::SComponent_var sco = itcomponent->Value();
324 CORBA::String_var compodatatype=sco->ComponentDataType();
325 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
326 // if there is an associated Engine call its method for closing
327 CORBA::String_var IOREngine;
328 if (sco->ComponentIOR(IOREngine)) {
329 // we have found the associated engine to write the data
330 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
331 //_narrow can throw a corba exception
333 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
334 if (!CORBA::is_nil(obj)) {
335 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
336 if (!anEngine->_is_nil()) {
338 anEngine->Close(sco);
343 catch (CORBA::Exception&) {
349 //Does not need any more this iterator
350 itcomponent->UnRegister();
353 // Notify GUI that study is cleared
354 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
355 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
356 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
357 if ( !CORBA::is_nil(aSession) ) {
358 std::stringstream ss;
359 ss << "studyCleared";
360 std::string str = ss.str();
362 aSession->emitMessageOneWay(str.c_str());
367 _impl->setNotifier(0);
369 delete _genObjRegister;
374 //============================================================================
376 * Purpose : Open a Study from it's persistent reference
378 //============================================================================
379 bool SALOMEDS_Study_i::Open(const char* aUrl)
380 throw(SALOME::SALOME_Exception)
382 SALOMEDS::Locker lock;
384 Unexpect aCatch(SalomeException);
385 MESSAGE("Begin of SALOMEDS_Study_i::Open");
387 bool res = _impl->Open(std::string(aUrl));
389 // update desktop title with new study name
393 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
397 //============================================================================
399 * Purpose : Save a Study to it's persistent reference
401 //============================================================================
402 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
404 SALOMEDS::Locker lock;
406 throw SALOMEDS::Study::StudyInvalidReference();
407 return _impl->Save(_factory, theMultiFile);
410 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
412 SALOMEDS::Locker lock;
414 throw SALOMEDS::Study::StudyInvalidReference();
415 return _impl->SaveASCII(_factory, theMultiFile);
418 //=============================================================================
419 /*! Function : SaveAs
420 * Purpose : Save a study to the persistent reference aUrl
422 //============================================================================
423 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
425 SALOMEDS::Locker lock;
427 throw SALOMEDS::Study::StudyInvalidReference();
428 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
431 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
433 SALOMEDS::Locker lock;
435 throw SALOMEDS::Study::StudyInvalidReference();
436 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
439 //============================================================================
440 /*! Function : CanCopy
443 //============================================================================
444 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
446 SALOMEDS::Locker lock;
448 throw SALOMEDS::Study::StudyInvalidReference();
450 CORBA::String_var anID = theObject->GetID();
451 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
453 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
454 bool ret = _impl->CanCopy(anObject, aDriver);
459 //============================================================================
463 //============================================================================
464 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
466 SALOMEDS::Locker lock;
468 throw SALOMEDS::Study::StudyInvalidReference();
470 CORBA::String_var anID = theObject->GetID();
471 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
473 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
474 bool ret = _impl->Copy(anObject, aDriver);
479 //============================================================================
480 /*! Function : CanPaste
483 //============================================================================
484 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
486 SALOMEDS::Locker lock;
488 throw SALOMEDS::Study::StudyInvalidReference();
490 CORBA::String_var anID = theObject->GetID();
491 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
493 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
494 bool ret = _impl->CanPaste(anObject, aDriver);
499 //============================================================================
503 //============================================================================
504 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
505 throw(SALOMEDS::StudyBuilder::LockProtection)
507 SALOMEDS::Locker lock;
509 Unexpect aCatch(LockProtection);
511 CORBA::String_var anID = theObject->GetID();
512 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
513 SALOMEDSImpl_SObject aNewSO;
516 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
517 aNewSO = _impl->Paste(anObject, aDriver);
521 throw SALOMEDS::StudyBuilder::LockProtection();
524 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
528 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
530 SALOMEDS_Driver_i* driver = NULL;
532 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
534 std::string IOREngine = aSCO.GetIOR();
535 if(!IOREngine.empty()) {
536 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
537 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
538 driver = new SALOMEDS_Driver_i(Engine, orb);
545 //============================================================================
546 /*! Function : GetPersistentReference
547 * Purpose : Get persistent reference of study (idem URL())
549 //============================================================================
550 char* SALOMEDS_Study_i::GetPersistentReference()
552 SALOMEDS::Locker lock;
554 throw SALOMEDS::Study::StudyInvalidReference();
555 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
557 //============================================================================
558 /*! Function : GetTransientReference
559 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
561 //============================================================================
562 char* SALOMEDS_Study_i::GetTransientReference()
564 SALOMEDS::Locker lock;
566 throw SALOMEDS::Study::StudyInvalidReference();
567 return CORBA::string_dup(_impl->GetTransientReference().c_str());
570 //============================================================================
571 /*! Function : IsEmpty
572 * Purpose : Detect if study is empty
574 //============================================================================
575 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
577 SALOMEDS::Locker lock;
579 throw SALOMEDS::Study::StudyInvalidReference();
580 return _impl->IsEmpty();
583 //============================================================================
584 /*! Function : FindComponent
585 * Purpose : Find a Component with ComponentDataType = aComponentName
587 //============================================================================
588 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
590 SALOMEDS::Locker lock;
593 throw SALOMEDS::Study::StudyInvalidReference();
595 SALOMEDS::SComponent_var sco;
597 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
598 if (!aCompImpl.IsNull())
599 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
604 //============================================================================
605 /*! Function : FindComponentID
606 * Purpose : Find a Component from it's ID
608 //============================================================================
609 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
611 SALOMEDS::Locker lock;
614 throw SALOMEDS::Study::StudyInvalidReference();
616 SALOMEDS::SComponent_var sco;
618 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
619 if (!aCompImpl.IsNull())
620 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
625 //============================================================================
626 /*! Function : FindObject
627 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
629 //============================================================================
630 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
632 SALOMEDS::Locker lock;
635 throw SALOMEDS::Study::StudyInvalidReference();
637 SALOMEDS::SObject_var so;
639 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
641 if (aSO.IsComponent()) {
642 SALOMEDSImpl_SComponent aSCO = aSO;
643 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
646 so = SALOMEDS_SObject_i::New(aSO, _orb);
653 //============================================================================
654 /*! Function : FindObjectID
655 * Purpose : Find an Object with ID = anObjectID
657 //============================================================================
658 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
660 SALOMEDS::Locker lock;
663 throw SALOMEDS::Study::StudyInvalidReference();
665 SALOMEDS::SObject_var so;
667 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
669 so = SALOMEDS_SObject_i::New(aSO, _orb);
674 //============================================================================
675 /*! Function : CreateObjectID
676 * Purpose : Creates an Object with ID = anObjectID
678 //============================================================================
679 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
681 SALOMEDS::Locker lock;
684 throw SALOMEDS::Study::StudyInvalidReference();
686 SALOMEDS::SObject_var so;
688 if (anObjectID && strlen(anObjectID) > 0) {
689 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
691 so = SALOMEDS_SObject_i::New(aSO, _orb);
697 //============================================================================
698 /*! Function : FindObjectByName
699 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
700 * : with ComponentDataType = aComponentName
702 //============================================================================
703 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
704 const char* aComponentName )
706 SALOMEDS::Locker lock;
709 throw SALOMEDS::Study::StudyInvalidReference();
711 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
712 std::string((char*)aComponentName));
714 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
715 int aLength = aSeq.size();
716 listSO->length(aLength);
717 for (int i = 0; i < aLength; i++) {
718 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
722 return listSO._retn();
725 //============================================================================
726 /*! Function : FindObjectIOR
727 * Purpose : Find an Object with IOR = anObjectIOR
729 //============================================================================
730 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
732 SALOMEDS::Locker lock;
735 throw SALOMEDS::Study::StudyInvalidReference();
737 SALOMEDS::SObject_var so;
739 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
741 so = SALOMEDS_SObject_i::New(aSO, _orb);
746 //============================================================================
747 /*! Function : FindObjectByPath
748 * Purpose : Find an Object by its path = thePath
750 //============================================================================
751 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
753 SALOMEDS::Locker lock;
756 throw SALOMEDS::Study::StudyInvalidReference();
758 SALOMEDS::SObject_var so;
760 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
762 so = SALOMEDS_SObject_i::New (aSO, _orb);
767 //============================================================================
768 /*! Function : GetObjectPath
771 //============================================================================
772 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
774 SALOMEDS::Locker lock;
777 throw SALOMEDS::Study::StudyInvalidReference();
779 std::string aPath = "";
781 if (!CORBA::is_nil(theObject)) {
782 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
783 SALOMEDSImpl_SObject aSO;
785 if (!CORBA::is_nil(aSObj)) {
786 aSO = _impl->FindObjectID(aSObj->GetID());
789 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
793 aPath = _impl->GetObjectPath(aSO);
797 return CORBA::string_dup(aPath.c_str());
801 //============================================================================
802 /*! Function : SetContext
803 * Purpose : Sets the current context
805 //============================================================================
806 void SALOMEDS_Study_i::SetContext(const char* thePath)
808 SALOMEDS::Locker lock;
811 throw SALOMEDS::Study::StudyInvalidReference();
813 _impl->SetContext(std::string((char*)thePath));
814 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
815 throw SALOMEDS::Study::StudyInvalidContext();
818 //============================================================================
819 /*! Function : GetContext
820 * Purpose : Gets the current context
822 //============================================================================
823 char* SALOMEDS_Study_i::GetContext()
825 SALOMEDS::Locker lock;
828 throw SALOMEDS::Study::StudyInvalidReference();
830 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
832 return CORBA::string_dup(_impl->GetContext().c_str());
835 //============================================================================
836 /*! Function : GetObjectNames
837 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
839 //============================================================================
840 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
842 SALOMEDS::Locker lock;
845 throw SALOMEDS::Study::StudyInvalidReference();
847 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
849 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
850 throw SALOMEDS::Study::StudyInvalidContext();
852 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
853 if (_impl->GetErrorCode() == "InvalidContext")
854 throw SALOMEDS::Study::StudyInvalidContext();
856 int aLength = aSeq.size();
857 aResult->length(aLength);
858 for (int anIndex = 0; anIndex < aLength; anIndex++) {
859 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
862 return aResult._retn();
865 //============================================================================
866 /*! Function : GetDirectoryNames
867 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
869 //============================================================================
870 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
872 SALOMEDS::Locker lock;
875 throw SALOMEDS::Study::StudyInvalidReference();
877 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
879 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
880 throw SALOMEDS::Study::StudyInvalidContext();
882 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
883 if (_impl->GetErrorCode() == "InvalidContext")
884 throw SALOMEDS::Study::StudyInvalidContext();
886 int aLength = aSeq.size();
887 aResult->length(aLength);
888 for (int anIndex = 0; anIndex < aLength; anIndex++) {
889 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
892 return aResult._retn();
895 //============================================================================
896 /*! Function : GetFileNames
897 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
899 //============================================================================
900 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
902 SALOMEDS::Locker lock;
905 throw SALOMEDS::Study::StudyInvalidReference();
907 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
909 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
910 throw SALOMEDS::Study::StudyInvalidContext();
912 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
913 if (_impl->GetErrorCode() == "InvalidContext")
914 throw SALOMEDS::Study::StudyInvalidContext();
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 : GetComponentNames
927 * Purpose : method to get all components names
928 * SRN: Note, theContext can be any, it doesn't matter
930 //============================================================================
931 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
933 SALOMEDS::Locker lock;
936 throw SALOMEDS::Study::StudyInvalidReference();
938 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
940 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
942 int aLength = aSeq.size();
943 aResult->length(aLength);
944 for(int anIndex = 0; anIndex < aLength; anIndex++) {
945 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
948 return aResult._retn();
951 //============================================================================
952 /*! Function : NewChildIterator
953 * Purpose : Create a ChildIterator from an SObject
955 //============================================================================
956 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
958 SALOMEDS::Locker lock;
961 throw SALOMEDS::Study::StudyInvalidReference();
963 CORBA::String_var anID = theSO->GetID();
964 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
965 SALOMEDSImpl_ChildIterator anItr(aSO);
966 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
967 SALOMEDS::ChildIterator_var it = it_servant->_this();
973 //============================================================================
974 /*! Function : NewComponentIterator
975 * Purpose : Create a SComponentIterator
977 //============================================================================
978 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
980 SALOMEDS::Locker lock;
983 throw SALOMEDS::Study::StudyInvalidReference();
985 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
987 SALOMEDS::SComponentIterator_var it = it_servant->_this();
993 //============================================================================
994 /*! Function : NewBuilder
995 * Purpose : Create a StudyBuilder
997 //============================================================================
998 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
1000 SALOMEDS::Locker lock;
1003 throw SALOMEDS::Study::StudyInvalidReference();
1005 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
1010 //============================================================================
1012 * Purpose : get study name
1014 //============================================================================
1015 char* SALOMEDS_Study_i::Name()
1017 SALOMEDS::Locker lock;
1018 // Name is specified as IDL attribute: user exception cannot be raised
1019 return CORBA::string_dup(_impl->Name().c_str());
1022 //============================================================================
1023 /*! Function : IsSaved
1024 * Purpose : get if study has been saved
1026 //============================================================================
1027 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1029 SALOMEDS::Locker lock;
1030 // IsSaved is specified as IDL attribute: user exception cannot be raised
1031 return (!_closed) ? _impl->IsSaved() : false;
1034 //============================================================================
1035 /*! Function : IsSaved
1036 * Purpose : set if study has been saved
1038 //============================================================================
1039 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1041 SALOMEDS::Locker lock;
1042 // IsSaved is specified as IDL attribute: user exception cannot be raised
1044 _impl->IsSaved(save);
1047 //============================================================================
1048 /*! Function : IsModified
1049 * Purpose : Detect if a Study has been modified since it has been saved
1051 //============================================================================
1052 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1054 SALOMEDS::Locker lock;
1057 throw SALOMEDS::Study::StudyInvalidReference();
1059 return _impl->IsModified();
1062 //============================================================================
1063 /*! Function : Modified
1064 * Purpose : Sets a Modified flag of a Study to True
1066 //============================================================================
1067 void SALOMEDS_Study_i::Modified()
1069 SALOMEDS::Locker lock;
1072 throw SALOMEDS::Study::StudyInvalidReference();
1077 //============================================================================
1079 * Purpose : get URL of the study (persistent reference of the study)
1081 //============================================================================
1082 char* SALOMEDS_Study_i::URL()
1084 SALOMEDS::Locker lock;
1085 // URL is specified as IDL attribute: user exception cannot be raised
1086 return CORBA::string_dup(_impl->URL().c_str());
1089 //============================================================================
1091 * Purpose : set URL of the study (persistent reference of the study)
1093 //============================================================================
1094 void SALOMEDS_Study_i::URL(const char* url)
1096 SALOMEDS::Locker lock;
1097 // URL is specified as IDL attribute: user exception cannot be raised
1098 _impl->URL(std::string((char*)url));
1100 // update desktop title with new study name
1104 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1106 SALOMEDS::Locker lock;
1109 throw SALOMEDS::Study::StudyInvalidReference();
1111 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1114 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1116 SALOMEDS::Locker lock;
1118 SALOMEDSImpl_AttributeIOR* Att = NULL;
1119 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1120 char* IOR = CORBA::string_dup(Att->Value().c_str());
1121 CORBA::Object_var obj = orb->string_to_object(IOR);
1122 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1123 ASSERT(!CORBA::is_nil(aStudy));
1124 return SALOMEDS::Study::_duplicate(aStudy);
1126 MESSAGE("GetStudy: Problem to get study");
1128 return SALOMEDS::Study::_nil();
1131 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1133 SALOMEDS::Locker lock;
1134 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1137 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1139 SALOMEDS::Locker lock;
1142 throw SALOMEDS::Study::StudyInvalidReference();
1144 SALOMEDS::GenericAttribute_ptr aTarget;
1145 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1146 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1148 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1154 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1156 SALOMEDS::Locker lock;
1159 throw SALOMEDS::Study::StudyInvalidReference();
1161 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1162 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1163 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1164 return aProp._retn();
1167 char* SALOMEDS_Study_i::GetLastModificationDate()
1169 SALOMEDS::Locker lock;
1172 throw SALOMEDS::Study::StudyInvalidReference();
1174 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1177 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1179 SALOMEDS::Locker lock;
1182 throw SALOMEDS::Study::StudyInvalidReference();
1184 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1186 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1188 int aLength = aSeq.size();
1189 aDates->length(aLength);
1190 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1191 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1194 return aDates._retn();
1197 //============================================================================
1198 /*! Function : GetUseCaseBuilder
1199 * Purpose : Returns a UseCase builder
1201 //============================================================================
1202 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1204 SALOMEDS::Locker lock;
1207 throw SALOMEDS::Study::StudyInvalidReference();
1209 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1210 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1214 //============================================================================
1215 /*! Function : AddPostponed
1218 //============================================================================
1219 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1221 SALOMEDS::Locker lock;
1225 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1227 SALOMEDS::Locker lock;
1231 //============================================================================
1232 /*! Function : RemovePostponed
1235 //============================================================================
1236 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1238 SALOMEDS::Locker lock;
1241 throw SALOMEDS::Study::StudyInvalidReference();
1243 std::vector<std::string> anIORs = _impl->GetIORs();
1244 int i, aSize = (int)anIORs.size();
1246 for (i = 0; i < aSize; i++) {
1248 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1249 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1250 //rnv: To avoid double deletion of the Salome Generic Objects:
1251 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1252 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1253 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1260 //============================================================================
1261 /*! Function : UndoPostponed
1264 //============================================================================
1265 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1267 SALOMEDS::Locker lock;
1272 //============================================================================
1273 /*! Function : DumpStudy
1276 //============================================================================
1277 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1278 const char* theBaseName,
1279 CORBA::Boolean isPublished,
1280 CORBA::Boolean isMultiFile)
1282 SALOMEDS::Locker lock;
1285 throw SALOMEDS::Study::StudyInvalidReference();
1287 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1288 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1289 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1295 //============================================================================
1296 /*! Function : GetCommonParameters
1299 //============================================================================
1300 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1302 SALOMEDS::Locker lock;
1305 throw SALOMEDS::Study::StudyInvalidReference();
1307 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1308 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1309 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1311 return aParam._retn();
1314 //============================================================================
1315 /*! Function : GetCommonModuleParameters
1318 //============================================================================
1319 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1320 const char* theModuleName,
1321 CORBA::Long theSavePoint)
1323 SALOMEDS::Locker lock;
1326 throw SALOMEDS::Study::StudyInvalidReference();
1328 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1329 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1330 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1332 return aParam._retn();
1335 //============================================================================
1336 /*! Function : SetStudyLock
1339 //============================================================================
1340 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1342 SALOMEDS::Locker lock;
1345 throw SALOMEDS::Study::StudyInvalidReference();
1347 _impl->SetStudyLock(theLockerID);
1350 //============================================================================
1351 /*! Function : IsStudyLocked
1354 //============================================================================
1355 bool SALOMEDS_Study_i::IsStudyLocked()
1357 SALOMEDS::Locker lock;
1360 throw SALOMEDS::Study::StudyInvalidReference();
1362 return _impl->IsStudyLocked();
1365 //============================================================================
1366 /*! Function : UnLockStudy
1369 //============================================================================
1370 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1372 SALOMEDS::Locker lock;
1375 throw SALOMEDS::Study::StudyInvalidReference();
1377 _impl->UnLockStudy(theLockerID);
1380 //============================================================================
1381 /*! Function : GetLockerID
1384 //============================================================================
1385 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1387 SALOMEDS::Locker lock;
1390 throw SALOMEDS::Study::StudyInvalidReference();
1392 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1394 std::vector<std::string> aSeq = _impl->GetLockerID();
1396 int aLength = aSeq.size();
1397 aResult->length(aLength);
1398 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1399 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1402 return aResult._retn();
1404 //============================================================================
1405 /*! Function : SetReal
1408 //============================================================================
1409 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1412 throw SALOMEDS::Study::StudyInvalidReference();
1415 _impl->SetVariable(std::string(theVarName),
1417 SALOMEDSImpl_GenericVariable::REAL_VAR);
1419 _notifier->modifyNB_Notification(theVarName);
1422 //============================================================================
1423 /*! Function : SetInteger
1426 //============================================================================
1427 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1430 throw SALOMEDS::Study::StudyInvalidReference();
1432 _impl->SetVariable(std::string(theVarName),
1434 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1436 _notifier->modifyNB_Notification(theVarName);
1439 //============================================================================
1440 /*! Function : SetBoolean
1443 //============================================================================
1444 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1447 throw SALOMEDS::Study::StudyInvalidReference();
1449 _impl->SetVariable(std::string(theVarName),
1451 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1453 _notifier->modifyNB_Notification(theVarName);
1456 //============================================================================
1457 /*! Function : SetString
1460 //============================================================================
1461 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1464 throw SALOMEDS::Study::StudyInvalidReference();
1466 _impl->SetStringVariable(std::string(theVarName),
1468 SALOMEDSImpl_GenericVariable::STRING_VAR);
1470 _notifier->modifyNB_Notification(theVarName);
1473 //============================================================================
1474 /*! Function : SetStringAsDouble
1477 //============================================================================
1478 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1481 throw SALOMEDS::Study::StudyInvalidReference();
1483 _impl->SetStringVariableAsDouble(std::string(theVarName),
1485 SALOMEDSImpl_GenericVariable::STRING_VAR);
1488 //============================================================================
1489 /*! Function : GetReal
1492 //============================================================================
1493 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1496 throw SALOMEDS::Study::StudyInvalidReference();
1498 return _impl->GetVariableValue(std::string(theVarName));
1501 //============================================================================
1502 /*! Function : GetInteger
1505 //============================================================================
1506 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1509 throw SALOMEDS::Study::StudyInvalidReference();
1511 return (long)_impl->GetVariableValue(std::string(theVarName));
1514 //============================================================================
1515 /*! Function : GetBoolean
1518 //============================================================================
1519 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1522 throw SALOMEDS::Study::StudyInvalidReference();
1524 return (bool)_impl->GetVariableValue(std::string(theVarName));
1527 //============================================================================
1528 /*! Function : GetString
1531 //============================================================================
1532 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1535 throw SALOMEDS::Study::StudyInvalidReference();
1537 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1540 //============================================================================
1541 /*! Function : IsReal
1544 //============================================================================
1545 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1548 throw SALOMEDS::Study::StudyInvalidReference();
1550 return _impl->IsTypeOf(std::string(theVarName),
1551 SALOMEDSImpl_GenericVariable::REAL_VAR);
1554 //============================================================================
1555 /*! Function : IsInteger
1558 //============================================================================
1559 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1562 throw SALOMEDS::Study::StudyInvalidReference();
1564 return _impl->IsTypeOf(std::string(theVarName),
1565 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1568 //============================================================================
1569 /*! Function : IsBoolean
1572 //============================================================================
1573 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1576 throw SALOMEDS::Study::StudyInvalidReference();
1578 return _impl->IsTypeOf(std::string(theVarName),
1579 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1582 //============================================================================
1583 /*! Function : IsString
1586 //============================================================================
1587 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1590 throw SALOMEDS::Study::StudyInvalidReference();
1592 return _impl->IsTypeOf(std::string(theVarName),
1593 SALOMEDSImpl_GenericVariable::STRING_VAR);
1596 //============================================================================
1597 /*! Function : IsVariable
1600 //============================================================================
1601 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1604 throw SALOMEDS::Study::StudyInvalidReference();
1606 return _impl->IsVariable(std::string(theVarName));
1609 //============================================================================
1610 /*! Function : GetVariableNames
1613 //============================================================================
1614 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1617 throw SALOMEDS::Study::StudyInvalidReference();
1619 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1621 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1623 int aLen = aVarNames.size();
1624 aResult->length(aLen);
1625 for (int anInd = 0; anInd < aLen; anInd++)
1626 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1628 return aResult._retn();
1631 //============================================================================
1632 /*! Function : RemoveVariable
1635 //============================================================================
1636 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1639 throw SALOMEDS::Study::StudyInvalidReference();
1641 bool res = _impl->RemoveVariable(std::string(theVarName));
1642 if (res && _notifier)
1643 _notifier->modifyNB_Notification(theVarName);
1648 //============================================================================
1649 /*! Function : RenameVariable
1652 //============================================================================
1653 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1656 throw SALOMEDS::Study::StudyInvalidReference();
1658 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1659 if (res && _notifier)
1660 _notifier->modifyNB_Notification(theVarName);
1665 //============================================================================
1666 /*! Function : IsVariableUsed
1669 //============================================================================
1670 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1673 throw SALOMEDS::Study::StudyInvalidReference();
1675 return _impl->IsVariableUsed(std::string(theVarName));
1679 //============================================================================
1680 /*! Function : ParseVariables
1683 //============================================================================
1684 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1687 throw SALOMEDS::Study::StudyInvalidReference();
1689 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1691 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1693 int aSectionsLen = aSections.size();
1694 aResult->length(aSectionsLen);
1696 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1697 std::vector<std::string> aVarNames = aSections[aSectionInd];
1699 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1701 int aLen = aVarNames.size();
1702 aList->length(aLen);
1704 for (int anInd = 0; anInd < aLen; anInd++)
1705 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1707 aResult[aSectionInd] = aList;
1710 return aResult._retn();
1713 //============================================================================
1714 /*! Function : GetDefaultScript
1717 //============================================================================
1718 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1720 SALOMEDS::Locker lock;
1723 throw SALOMEDS::Study::StudyInvalidReference();
1725 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1726 return CORBA::string_dup(script.c_str());
1729 //============================================================================
1730 /*! Function : EnableUseCaseAutoFilling
1733 //============================================================================
1734 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1737 throw SALOMEDS::Study::StudyInvalidReference();
1739 _impl->EnableUseCaseAutoFilling(isEnabled);
1740 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1743 builder->SetOnAddSObject(_impl->GetCallback());
1744 builder->SetOnRemoveSObject(_impl->GetCallback());
1747 builder->SetOnAddSObject(NULL);
1748 builder->SetOnRemoveSObject(NULL);
1754 CORBA::Long SALOMEDS_Study_i::getPID()
1757 return (CORBA::Long)_getpid();
1759 return (CORBA::Long)getpid();
1763 void SALOMEDS_Study_i::ShutdownWithExit()
1765 exit( EXIT_SUCCESS );
1768 void SALOMEDS_Study_i::Shutdown()
1770 if(!CORBA::is_nil(_orb))
1774 //============================================================================
1775 /*! Function : attach
1776 * Purpose : This function attach an observer to the study
1778 //============================================================================
1779 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1782 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1786 //============================================================================
1787 /*! Function : detach
1788 * Purpose : This function detaches an observer from the study
1790 //============================================================================
1791 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1794 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1797 //===========================================================================
1798 // PRIVATE FUNCTIONS
1799 //===========================================================================
1800 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1803 long pid = (long)_getpid();
1805 long pid = (long)getpid();
1807 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1808 return reinterpret_cast<CORBA::LongLong>(_impl);
1811 void SALOMEDS_Study_i::NameChanged()
1813 // Notify GUI that the name of study was changed
1814 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1815 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1816 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1817 if ( !CORBA::is_nil(aSession) ) {
1818 std::stringstream ss;
1819 ss << "studyNameChanged";
1820 std::string str = ss.str();
1822 aSession->emitMessageOneWay(str.c_str());