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)
385 SALOMEDS::Locker lock;
387 Unexpect aCatch(SalomeException);
388 MESSAGE("Begin of SALOMEDS_Study_i::Open");
390 bool res = _impl->Open(std::string(aUrl));
392 // update desktop title with new study name
396 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
400 //============================================================================
402 * Purpose : Save a Study to it's persistent reference
404 //============================================================================
405 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
407 SALOMEDS::Locker lock;
409 throw SALOMEDS::Study::StudyInvalidReference();
410 return _impl->Save(_factory, theMultiFile);
413 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
415 SALOMEDS::Locker lock;
417 throw SALOMEDS::Study::StudyInvalidReference();
418 return _impl->SaveASCII(_factory, theMultiFile);
421 //=============================================================================
422 /*! Function : SaveAs
423 * Purpose : Save a study to the persistent reference aUrl
425 //============================================================================
426 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
428 SALOMEDS::Locker lock;
430 throw SALOMEDS::Study::StudyInvalidReference();
431 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
434 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
436 SALOMEDS::Locker lock;
438 throw SALOMEDS::Study::StudyInvalidReference();
439 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
442 //============================================================================
443 /*! Function : CanCopy
446 //============================================================================
447 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
449 SALOMEDS::Locker lock;
451 throw SALOMEDS::Study::StudyInvalidReference();
453 CORBA::String_var anID = theObject->GetID();
454 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
456 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
457 bool ret = _impl->CanCopy(anObject, aDriver);
462 //============================================================================
466 //============================================================================
467 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
469 SALOMEDS::Locker lock;
471 throw SALOMEDS::Study::StudyInvalidReference();
473 CORBA::String_var anID = theObject->GetID();
474 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
476 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
477 bool ret = _impl->Copy(anObject, aDriver);
482 //============================================================================
483 /*! Function : CanPaste
486 //============================================================================
487 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
489 SALOMEDS::Locker lock;
491 throw SALOMEDS::Study::StudyInvalidReference();
493 CORBA::String_var anID = theObject->GetID();
494 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
496 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
497 bool ret = _impl->CanPaste(anObject, aDriver);
502 //============================================================================
506 //============================================================================
507 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
508 throw(SALOMEDS::StudyBuilder::LockProtection)
510 SALOMEDS::Locker lock;
512 Unexpect aCatch(LockProtection);
514 CORBA::String_var anID = theObject->GetID();
515 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
516 SALOMEDSImpl_SObject aNewSO;
519 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
520 aNewSO = _impl->Paste(anObject, aDriver);
524 throw SALOMEDS::StudyBuilder::LockProtection();
527 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
531 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
533 SALOMEDS_Driver_i* driver = NULL;
535 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
537 std::string IOREngine = aSCO.GetIOR();
538 if(!IOREngine.empty()) {
539 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
540 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
541 driver = new SALOMEDS_Driver_i(Engine, orb);
548 //============================================================================
549 /*! Function : GetPersistentReference
550 * Purpose : Get persistent reference of study (idem URL())
552 //============================================================================
553 char* SALOMEDS_Study_i::GetPersistentReference()
555 SALOMEDS::Locker lock;
557 throw SALOMEDS::Study::StudyInvalidReference();
558 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
560 //============================================================================
561 /*! Function : GetTransientReference
562 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
564 //============================================================================
565 char* SALOMEDS_Study_i::GetTransientReference()
567 SALOMEDS::Locker lock;
569 throw SALOMEDS::Study::StudyInvalidReference();
570 return CORBA::string_dup(_impl->GetTransientReference().c_str());
573 //============================================================================
574 /*! Function : IsEmpty
575 * Purpose : Detect if study is empty
577 //============================================================================
578 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
580 SALOMEDS::Locker lock;
582 throw SALOMEDS::Study::StudyInvalidReference();
583 return _impl->IsEmpty();
586 //============================================================================
587 /*! Function : FindComponent
588 * Purpose : Find a Component with ComponentDataType = aComponentName
590 //============================================================================
591 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
593 SALOMEDS::Locker lock;
596 throw SALOMEDS::Study::StudyInvalidReference();
598 SALOMEDS::SComponent_var sco;
600 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
601 if (!aCompImpl.IsNull())
602 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
607 //============================================================================
608 /*! Function : FindComponentID
609 * Purpose : Find a Component from it's ID
611 //============================================================================
612 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
614 SALOMEDS::Locker lock;
617 throw SALOMEDS::Study::StudyInvalidReference();
619 SALOMEDS::SComponent_var sco;
621 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
622 if (!aCompImpl.IsNull())
623 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
628 //============================================================================
629 /*! Function : FindObject
630 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
632 //============================================================================
633 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
635 SALOMEDS::Locker lock;
638 throw SALOMEDS::Study::StudyInvalidReference();
640 SALOMEDS::SObject_var so;
642 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
644 if (aSO.IsComponent()) {
645 SALOMEDSImpl_SComponent aSCO = aSO;
646 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
649 so = SALOMEDS_SObject_i::New(aSO, _orb);
656 //============================================================================
657 /*! Function : FindObjectID
658 * Purpose : Find an Object with ID = anObjectID
660 //============================================================================
661 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
663 SALOMEDS::Locker lock;
666 throw SALOMEDS::Study::StudyInvalidReference();
668 SALOMEDS::SObject_var so;
670 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
672 so = SALOMEDS_SObject_i::New(aSO, _orb);
677 //============================================================================
678 /*! Function : CreateObjectID
679 * Purpose : Creates an Object with ID = anObjectID
681 //============================================================================
682 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
684 SALOMEDS::Locker lock;
687 throw SALOMEDS::Study::StudyInvalidReference();
689 SALOMEDS::SObject_var so;
691 if (anObjectID && strlen(anObjectID) > 0) {
692 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
694 so = SALOMEDS_SObject_i::New(aSO, _orb);
700 //============================================================================
701 /*! Function : FindObjectByName
702 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
703 * : with ComponentDataType = aComponentName
705 //============================================================================
706 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
707 const char* aComponentName )
709 SALOMEDS::Locker lock;
712 throw SALOMEDS::Study::StudyInvalidReference();
714 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
715 std::string((char*)aComponentName));
717 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
718 int aLength = aSeq.size();
719 listSO->length(aLength);
720 for (int i = 0; i < aLength; i++) {
721 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
725 return listSO._retn();
728 //============================================================================
729 /*! Function : FindObjectIOR
730 * Purpose : Find an Object with IOR = anObjectIOR
732 //============================================================================
733 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
735 SALOMEDS::Locker lock;
738 throw SALOMEDS::Study::StudyInvalidReference();
740 SALOMEDS::SObject_var so;
742 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
744 so = SALOMEDS_SObject_i::New(aSO, _orb);
749 //============================================================================
750 /*! Function : FindObjectByPath
751 * Purpose : Find an Object by its path = thePath
753 //============================================================================
754 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
756 SALOMEDS::Locker lock;
759 throw SALOMEDS::Study::StudyInvalidReference();
761 SALOMEDS::SObject_var so;
763 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
765 so = SALOMEDS_SObject_i::New (aSO, _orb);
770 //============================================================================
771 /*! Function : GetObjectPath
774 //============================================================================
775 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
777 SALOMEDS::Locker lock;
780 throw SALOMEDS::Study::StudyInvalidReference();
782 std::string aPath = "";
784 if (!CORBA::is_nil(theObject)) {
785 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
786 SALOMEDSImpl_SObject aSO;
788 if (!CORBA::is_nil(aSObj)) {
789 aSO = _impl->FindObjectID(aSObj->GetID());
792 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
796 aPath = _impl->GetObjectPath(aSO);
800 return CORBA::string_dup(aPath.c_str());
804 //============================================================================
805 /*! Function : SetContext
806 * Purpose : Sets the current context
808 //============================================================================
809 void SALOMEDS_Study_i::SetContext(const char* thePath)
811 SALOMEDS::Locker lock;
814 throw SALOMEDS::Study::StudyInvalidReference();
816 _impl->SetContext(std::string((char*)thePath));
817 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
818 throw SALOMEDS::Study::StudyInvalidContext();
821 //============================================================================
822 /*! Function : GetContext
823 * Purpose : Gets the current context
825 //============================================================================
826 char* SALOMEDS_Study_i::GetContext()
828 SALOMEDS::Locker lock;
831 throw SALOMEDS::Study::StudyInvalidReference();
833 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
835 return CORBA::string_dup(_impl->GetContext().c_str());
838 //============================================================================
839 /*! Function : GetObjectNames
840 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
842 //============================================================================
843 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
845 SALOMEDS::Locker lock;
848 throw SALOMEDS::Study::StudyInvalidReference();
850 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
852 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
853 throw SALOMEDS::Study::StudyInvalidContext();
855 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
856 if (_impl->GetErrorCode() == "InvalidContext")
857 throw SALOMEDS::Study::StudyInvalidContext();
859 int aLength = aSeq.size();
860 aResult->length(aLength);
861 for (int anIndex = 0; anIndex < aLength; anIndex++) {
862 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
865 return aResult._retn();
868 //============================================================================
869 /*! Function : GetDirectoryNames
870 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
872 //============================================================================
873 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
875 SALOMEDS::Locker lock;
878 throw SALOMEDS::Study::StudyInvalidReference();
880 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
882 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
883 throw SALOMEDS::Study::StudyInvalidContext();
885 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
886 if (_impl->GetErrorCode() == "InvalidContext")
887 throw SALOMEDS::Study::StudyInvalidContext();
889 int aLength = aSeq.size();
890 aResult->length(aLength);
891 for (int anIndex = 0; anIndex < aLength; anIndex++) {
892 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
895 return aResult._retn();
898 //============================================================================
899 /*! Function : GetFileNames
900 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
902 //============================================================================
903 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
905 SALOMEDS::Locker lock;
908 throw SALOMEDS::Study::StudyInvalidReference();
910 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
912 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
913 throw SALOMEDS::Study::StudyInvalidContext();
915 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
916 if (_impl->GetErrorCode() == "InvalidContext")
917 throw SALOMEDS::Study::StudyInvalidContext();
919 int aLength = aSeq.size();
920 aResult->length(aLength);
921 for (int anIndex = 0; anIndex < aLength; anIndex++) {
922 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
925 return aResult._retn();
928 //============================================================================
929 /*! Function : GetComponentNames
930 * Purpose : method to get all components names
931 * SRN: Note, theContext can be any, it doesn't matter
933 //============================================================================
934 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
936 SALOMEDS::Locker lock;
939 throw SALOMEDS::Study::StudyInvalidReference();
941 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
943 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
945 int aLength = aSeq.size();
946 aResult->length(aLength);
947 for(int anIndex = 0; anIndex < aLength; anIndex++) {
948 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
951 return aResult._retn();
954 //============================================================================
955 /*! Function : NewChildIterator
956 * Purpose : Create a ChildIterator from an SObject
958 //============================================================================
959 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
961 SALOMEDS::Locker lock;
964 throw SALOMEDS::Study::StudyInvalidReference();
966 CORBA::String_var anID = theSO->GetID();
967 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
968 SALOMEDSImpl_ChildIterator anItr(aSO);
969 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
970 SALOMEDS::ChildIterator_var it = it_servant->_this();
976 //============================================================================
977 /*! Function : NewComponentIterator
978 * Purpose : Create a SComponentIterator
980 //============================================================================
981 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
983 SALOMEDS::Locker lock;
986 throw SALOMEDS::Study::StudyInvalidReference();
988 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
990 SALOMEDS::SComponentIterator_var it = it_servant->_this();
996 //============================================================================
997 /*! Function : NewBuilder
998 * Purpose : Create a StudyBuilder
1000 //============================================================================
1001 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
1003 SALOMEDS::Locker lock;
1006 throw SALOMEDS::Study::StudyInvalidReference();
1008 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
1013 //============================================================================
1015 * Purpose : get study name
1017 //============================================================================
1018 char* SALOMEDS_Study_i::Name()
1020 SALOMEDS::Locker lock;
1021 // Name is specified as IDL attribute: user exception cannot be raised
1022 return CORBA::string_dup(_impl->Name().c_str());
1025 //============================================================================
1026 /*! Function : IsSaved
1027 * Purpose : get if study has been saved
1029 //============================================================================
1030 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1032 SALOMEDS::Locker lock;
1033 // IsSaved is specified as IDL attribute: user exception cannot be raised
1034 return (!_closed) ? _impl->IsSaved() : false;
1037 //============================================================================
1038 /*! Function : IsSaved
1039 * Purpose : set if study has been saved
1041 //============================================================================
1042 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1044 SALOMEDS::Locker lock;
1045 // IsSaved is specified as IDL attribute: user exception cannot be raised
1047 _impl->IsSaved(save);
1050 //============================================================================
1051 /*! Function : IsModified
1052 * Purpose : Detect if a Study has been modified since it has been saved
1054 //============================================================================
1055 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1057 SALOMEDS::Locker lock;
1060 throw SALOMEDS::Study::StudyInvalidReference();
1062 return _impl->IsModified();
1065 //============================================================================
1066 /*! Function : Modified
1067 * Purpose : Sets a Modified flag of a Study to True
1069 //============================================================================
1070 void SALOMEDS_Study_i::Modified()
1072 SALOMEDS::Locker lock;
1075 throw SALOMEDS::Study::StudyInvalidReference();
1080 //============================================================================
1082 * Purpose : get URL of the study (persistent reference of the study)
1084 //============================================================================
1085 char* SALOMEDS_Study_i::URL()
1087 SALOMEDS::Locker lock;
1088 // URL is specified as IDL attribute: user exception cannot be raised
1089 return CORBA::string_dup(_impl->URL().c_str());
1092 //============================================================================
1094 * Purpose : set URL of the study (persistent reference of the study)
1096 //============================================================================
1097 void SALOMEDS_Study_i::URL(const char* url)
1099 SALOMEDS::Locker lock;
1100 // URL is specified as IDL attribute: user exception cannot be raised
1101 _impl->URL(std::string((char*)url));
1103 // update desktop title with new study name
1107 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1109 SALOMEDS::Locker lock;
1112 throw SALOMEDS::Study::StudyInvalidReference();
1114 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1117 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1119 SALOMEDS::Locker lock;
1121 SALOMEDSImpl_AttributeIOR* Att = NULL;
1122 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1123 char* IOR = CORBA::string_dup(Att->Value().c_str());
1124 CORBA::Object_var obj = orb->string_to_object(IOR);
1125 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1126 ASSERT(!CORBA::is_nil(aStudy));
1127 return SALOMEDS::Study::_duplicate(aStudy);
1129 MESSAGE("GetStudy: Problem to get study");
1131 return SALOMEDS::Study::_nil();
1134 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1136 SALOMEDS::Locker lock;
1137 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1140 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1142 SALOMEDS::Locker lock;
1145 throw SALOMEDS::Study::StudyInvalidReference();
1147 SALOMEDS::GenericAttribute_ptr aTarget;
1148 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1149 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1151 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1157 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1159 SALOMEDS::Locker lock;
1162 throw SALOMEDS::Study::StudyInvalidReference();
1164 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1165 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1166 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1167 return aProp._retn();
1170 char* SALOMEDS_Study_i::GetLastModificationDate()
1172 SALOMEDS::Locker lock;
1175 throw SALOMEDS::Study::StudyInvalidReference();
1177 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1180 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1182 SALOMEDS::Locker lock;
1185 throw SALOMEDS::Study::StudyInvalidReference();
1187 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1189 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1191 int aLength = aSeq.size();
1192 aDates->length(aLength);
1193 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1194 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1197 return aDates._retn();
1200 //============================================================================
1201 /*! Function : GetUseCaseBuilder
1202 * Purpose : Returns a UseCase builder
1204 //============================================================================
1205 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1207 SALOMEDS::Locker lock;
1210 throw SALOMEDS::Study::StudyInvalidReference();
1212 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1213 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1217 //============================================================================
1218 /*! Function : AddPostponed
1221 //============================================================================
1222 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1224 SALOMEDS::Locker lock;
1228 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1230 SALOMEDS::Locker lock;
1234 //============================================================================
1235 /*! Function : RemovePostponed
1238 //============================================================================
1239 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1241 SALOMEDS::Locker lock;
1244 throw SALOMEDS::Study::StudyInvalidReference();
1246 std::vector<std::string> anIORs = _impl->GetIORs();
1247 int i, aSize = (int)anIORs.size();
1249 for (i = 0; i < aSize; i++) {
1251 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1252 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1253 //rnv: To avoid double deletion of the Salome Generic Objects:
1254 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1255 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1256 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1263 //============================================================================
1264 /*! Function : UndoPostponed
1267 //============================================================================
1268 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1270 SALOMEDS::Locker lock;
1275 //============================================================================
1276 /*! Function : DumpStudy
1279 //============================================================================
1280 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1281 const char* theBaseName,
1282 CORBA::Boolean isPublished,
1283 CORBA::Boolean isMultiFile)
1285 SALOMEDS::Locker lock;
1288 throw SALOMEDS::Study::StudyInvalidReference();
1290 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1291 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1292 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1298 //============================================================================
1299 /*! Function : GetCommonParameters
1302 //============================================================================
1303 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1305 SALOMEDS::Locker lock;
1308 throw SALOMEDS::Study::StudyInvalidReference();
1310 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1311 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1312 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1314 return aParam._retn();
1317 //============================================================================
1318 /*! Function : GetCommonModuleParameters
1321 //============================================================================
1322 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1323 const char* theModuleName,
1324 CORBA::Long theSavePoint)
1326 SALOMEDS::Locker lock;
1329 throw SALOMEDS::Study::StudyInvalidReference();
1331 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1332 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1333 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1335 return aParam._retn();
1338 //============================================================================
1339 /*! Function : SetStudyLock
1342 //============================================================================
1343 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1345 SALOMEDS::Locker lock;
1348 throw SALOMEDS::Study::StudyInvalidReference();
1350 _impl->SetStudyLock(theLockerID);
1353 //============================================================================
1354 /*! Function : IsStudyLocked
1357 //============================================================================
1358 bool SALOMEDS_Study_i::IsStudyLocked()
1360 SALOMEDS::Locker lock;
1363 throw SALOMEDS::Study::StudyInvalidReference();
1365 return _impl->IsStudyLocked();
1368 //============================================================================
1369 /*! Function : UnLockStudy
1372 //============================================================================
1373 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1375 SALOMEDS::Locker lock;
1378 throw SALOMEDS::Study::StudyInvalidReference();
1380 _impl->UnLockStudy(theLockerID);
1383 //============================================================================
1384 /*! Function : GetLockerID
1387 //============================================================================
1388 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1390 SALOMEDS::Locker lock;
1393 throw SALOMEDS::Study::StudyInvalidReference();
1395 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1397 std::vector<std::string> aSeq = _impl->GetLockerID();
1399 int aLength = aSeq.size();
1400 aResult->length(aLength);
1401 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1402 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1405 return aResult._retn();
1407 //============================================================================
1408 /*! Function : SetReal
1411 //============================================================================
1412 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1415 throw SALOMEDS::Study::StudyInvalidReference();
1418 _impl->SetVariable(std::string(theVarName),
1420 SALOMEDSImpl_GenericVariable::REAL_VAR);
1422 _notifier->modifyNB_Notification(theVarName);
1425 //============================================================================
1426 /*! Function : SetInteger
1429 //============================================================================
1430 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1433 throw SALOMEDS::Study::StudyInvalidReference();
1435 _impl->SetVariable(std::string(theVarName),
1437 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1439 _notifier->modifyNB_Notification(theVarName);
1442 //============================================================================
1443 /*! Function : SetBoolean
1446 //============================================================================
1447 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1450 throw SALOMEDS::Study::StudyInvalidReference();
1452 _impl->SetVariable(std::string(theVarName),
1454 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1456 _notifier->modifyNB_Notification(theVarName);
1459 //============================================================================
1460 /*! Function : SetString
1463 //============================================================================
1464 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1467 throw SALOMEDS::Study::StudyInvalidReference();
1469 _impl->SetStringVariable(std::string(theVarName),
1471 SALOMEDSImpl_GenericVariable::STRING_VAR);
1473 _notifier->modifyNB_Notification(theVarName);
1476 //============================================================================
1477 /*! Function : SetStringAsDouble
1480 //============================================================================
1481 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1484 throw SALOMEDS::Study::StudyInvalidReference();
1486 _impl->SetStringVariableAsDouble(std::string(theVarName),
1488 SALOMEDSImpl_GenericVariable::STRING_VAR);
1491 //============================================================================
1492 /*! Function : GetReal
1495 //============================================================================
1496 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1499 throw SALOMEDS::Study::StudyInvalidReference();
1501 return _impl->GetVariableValue(std::string(theVarName));
1504 //============================================================================
1505 /*! Function : GetInteger
1508 //============================================================================
1509 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1512 throw SALOMEDS::Study::StudyInvalidReference();
1514 return (long)_impl->GetVariableValue(std::string(theVarName));
1517 //============================================================================
1518 /*! Function : GetBoolean
1521 //============================================================================
1522 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1525 throw SALOMEDS::Study::StudyInvalidReference();
1527 return (bool)_impl->GetVariableValue(std::string(theVarName));
1530 //============================================================================
1531 /*! Function : GetString
1534 //============================================================================
1535 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1538 throw SALOMEDS::Study::StudyInvalidReference();
1540 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1543 //============================================================================
1544 /*! Function : IsReal
1547 //============================================================================
1548 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1551 throw SALOMEDS::Study::StudyInvalidReference();
1553 return _impl->IsTypeOf(std::string(theVarName),
1554 SALOMEDSImpl_GenericVariable::REAL_VAR);
1557 //============================================================================
1558 /*! Function : IsInteger
1561 //============================================================================
1562 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1565 throw SALOMEDS::Study::StudyInvalidReference();
1567 return _impl->IsTypeOf(std::string(theVarName),
1568 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1571 //============================================================================
1572 /*! Function : IsBoolean
1575 //============================================================================
1576 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1579 throw SALOMEDS::Study::StudyInvalidReference();
1581 return _impl->IsTypeOf(std::string(theVarName),
1582 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1585 //============================================================================
1586 /*! Function : IsString
1589 //============================================================================
1590 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1593 throw SALOMEDS::Study::StudyInvalidReference();
1595 return _impl->IsTypeOf(std::string(theVarName),
1596 SALOMEDSImpl_GenericVariable::STRING_VAR);
1599 //============================================================================
1600 /*! Function : IsVariable
1603 //============================================================================
1604 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1607 throw SALOMEDS::Study::StudyInvalidReference();
1609 return _impl->IsVariable(std::string(theVarName));
1612 //============================================================================
1613 /*! Function : GetVariableNames
1616 //============================================================================
1617 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1620 throw SALOMEDS::Study::StudyInvalidReference();
1622 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1624 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1626 int aLen = aVarNames.size();
1627 aResult->length(aLen);
1628 for (int anInd = 0; anInd < aLen; anInd++)
1629 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1631 return aResult._retn();
1634 //============================================================================
1635 /*! Function : RemoveVariable
1638 //============================================================================
1639 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1642 throw SALOMEDS::Study::StudyInvalidReference();
1644 bool res = _impl->RemoveVariable(std::string(theVarName));
1645 if (res && _notifier)
1646 _notifier->modifyNB_Notification(theVarName);
1651 //============================================================================
1652 /*! Function : RenameVariable
1655 //============================================================================
1656 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1659 throw SALOMEDS::Study::StudyInvalidReference();
1661 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1662 if (res && _notifier)
1663 _notifier->modifyNB_Notification(theVarName);
1668 //============================================================================
1669 /*! Function : IsVariableUsed
1672 //============================================================================
1673 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1676 throw SALOMEDS::Study::StudyInvalidReference();
1678 return _impl->IsVariableUsed(std::string(theVarName));
1682 //============================================================================
1683 /*! Function : ParseVariables
1686 //============================================================================
1687 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1690 throw SALOMEDS::Study::StudyInvalidReference();
1692 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1694 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1696 int aSectionsLen = aSections.size();
1697 aResult->length(aSectionsLen);
1699 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1700 std::vector<std::string> aVarNames = aSections[aSectionInd];
1702 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1704 int aLen = aVarNames.size();
1705 aList->length(aLen);
1707 for (int anInd = 0; anInd < aLen; anInd++)
1708 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1710 aResult[aSectionInd] = aList;
1713 return aResult._retn();
1716 //============================================================================
1717 /*! Function : GetDefaultScript
1720 //============================================================================
1721 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1723 SALOMEDS::Locker lock;
1726 throw SALOMEDS::Study::StudyInvalidReference();
1728 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1729 return CORBA::string_dup(script.c_str());
1732 //============================================================================
1733 /*! Function : EnableUseCaseAutoFilling
1736 //============================================================================
1737 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1740 throw SALOMEDS::Study::StudyInvalidReference();
1742 _impl->EnableUseCaseAutoFilling(isEnabled);
1743 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1746 builder->SetOnAddSObject(_impl->GetCallback());
1747 builder->SetOnRemoveSObject(_impl->GetCallback());
1750 builder->SetOnAddSObject(NULL);
1751 builder->SetOnRemoveSObject(NULL);
1757 CORBA::Long SALOMEDS_Study_i::getPID()
1760 return (CORBA::Long)_getpid();
1762 return (CORBA::Long)getpid();
1766 void SALOMEDS_Study_i::ShutdownWithExit()
1768 exit( EXIT_SUCCESS );
1771 void SALOMEDS_Study_i::Shutdown()
1773 if(!CORBA::is_nil(_orb))
1777 //============================================================================
1778 /*! Function : attach
1779 * Purpose : This function attach an observer to the study
1781 //============================================================================
1782 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1785 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1789 //============================================================================
1790 /*! Function : detach
1791 * Purpose : This function detaches an observer from the study
1793 //============================================================================
1794 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1797 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1800 //===========================================================================
1801 // PRIVATE FUNCTIONS
1802 //===========================================================================
1803 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1806 long pid = (long)_getpid();
1808 long pid = (long)getpid();
1810 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1811 return reinterpret_cast<CORBA::LongLong>(_impl);
1814 void SALOMEDS_Study_i::NameChanged()
1816 // Notify GUI that the name of study was changed
1817 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1818 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1819 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1820 if ( !CORBA::is_nil(aSession) ) {
1821 std::stringstream ss;
1822 ss << "studyNameChanged";
1823 std::string str = ss.str();
1825 aSession->emitMessageOneWay(str.c_str());