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());
299 _impl->GetDocument()->SetModified(false);
303 //============================================================================
305 * Purpose : Clear study components
307 //============================================================================
308 void SALOMEDS_Study_i::Clear()
310 SALOMEDS::Locker lock;
313 //delete the builder servant
314 PortableServer::POA_var poa=_builder->_default_POA();
315 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
316 poa->deactivate_object(anObjectId.in());
317 _builder->_remove_ref();
321 if (_impl->GetDocument()) {
322 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
323 for (; itcomponent->More(); itcomponent->Next()) {
324 SALOMEDS::SComponent_var sco = itcomponent->Value();
325 CORBA::String_var compodatatype=sco->ComponentDataType();
326 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
327 // if there is an associated Engine call its method for closing
328 CORBA::String_var IOREngine;
329 if (sco->ComponentIOR(IOREngine)) {
330 // we have found the associated engine to write the data
331 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
332 //_narrow can throw a corba exception
334 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
335 if (!CORBA::is_nil(obj)) {
336 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
337 if (!anEngine->_is_nil()) {
339 anEngine->Close(sco);
344 catch (CORBA::Exception&) {
350 //Does not need any more this iterator
351 itcomponent->UnRegister();
354 // Notify GUI that study is cleared
355 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
356 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
357 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
358 if ( !CORBA::is_nil(aSession) ) {
359 std::stringstream ss;
360 ss << "studyCleared";
361 std::string str = ss.str();
363 aSession->emitMessageOneWay(str.c_str());
368 _impl->setNotifier(0);
370 delete _genObjRegister;
376 //============================================================================
378 * Purpose : Open a Study from it's persistent reference
380 //============================================================================
381 bool SALOMEDS_Study_i::Open(const char* aUrl)
382 throw(SALOME::SALOME_Exception)
387 SALOMEDS::Locker lock;
389 Unexpect aCatch(SalomeException);
390 MESSAGE("Begin of SALOMEDS_Study_i::Open");
392 bool res = _impl->Open(std::string(aUrl));
394 // update desktop title with new study name
398 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
402 //============================================================================
404 * Purpose : Save a Study to it's persistent reference
406 //============================================================================
407 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
409 SALOMEDS::Locker lock;
411 throw SALOMEDS::Study::StudyInvalidReference();
412 return _impl->Save(_factory, theMultiFile);
415 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
417 SALOMEDS::Locker lock;
419 throw SALOMEDS::Study::StudyInvalidReference();
420 return _impl->SaveASCII(_factory, theMultiFile);
423 //=============================================================================
424 /*! Function : SaveAs
425 * Purpose : Save a study to the persistent reference aUrl
427 //============================================================================
428 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
430 SALOMEDS::Locker lock;
432 throw SALOMEDS::Study::StudyInvalidReference();
433 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
436 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
438 SALOMEDS::Locker lock;
440 throw SALOMEDS::Study::StudyInvalidReference();
441 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
444 //============================================================================
445 /*! Function : CanCopy
448 //============================================================================
449 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
451 SALOMEDS::Locker lock;
453 throw SALOMEDS::Study::StudyInvalidReference();
455 CORBA::String_var anID = theObject->GetID();
456 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
458 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
459 bool ret = _impl->CanCopy(anObject, aDriver);
464 //============================================================================
468 //============================================================================
469 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
471 SALOMEDS::Locker lock;
473 throw SALOMEDS::Study::StudyInvalidReference();
475 CORBA::String_var anID = theObject->GetID();
476 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
478 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
479 bool ret = _impl->Copy(anObject, aDriver);
484 //============================================================================
485 /*! Function : CanPaste
488 //============================================================================
489 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
491 SALOMEDS::Locker lock;
493 throw SALOMEDS::Study::StudyInvalidReference();
495 CORBA::String_var anID = theObject->GetID();
496 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
498 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
499 bool ret = _impl->CanPaste(anObject, aDriver);
504 //============================================================================
508 //============================================================================
509 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
510 throw(SALOMEDS::StudyBuilder::LockProtection)
512 SALOMEDS::Locker lock;
514 Unexpect aCatch(LockProtection);
516 CORBA::String_var anID = theObject->GetID();
517 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
518 SALOMEDSImpl_SObject aNewSO;
521 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
522 aNewSO = _impl->Paste(anObject, aDriver);
526 throw SALOMEDS::StudyBuilder::LockProtection();
529 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
533 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
535 SALOMEDS_Driver_i* driver = NULL;
537 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
539 std::string IOREngine = aSCO.GetIOR();
540 if(!IOREngine.empty()) {
541 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
542 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
543 driver = new SALOMEDS_Driver_i(Engine, orb);
550 //============================================================================
551 /*! Function : GetPersistentReference
552 * Purpose : Get persistent reference of study (idem URL())
554 //============================================================================
555 char* SALOMEDS_Study_i::GetPersistentReference()
557 SALOMEDS::Locker lock;
559 throw SALOMEDS::Study::StudyInvalidReference();
560 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
562 //============================================================================
563 /*! Function : GetTransientReference
564 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
566 //============================================================================
567 char* SALOMEDS_Study_i::GetTransientReference()
569 SALOMEDS::Locker lock;
571 throw SALOMEDS::Study::StudyInvalidReference();
572 return CORBA::string_dup(_impl->GetTransientReference().c_str());
575 //============================================================================
576 /*! Function : IsEmpty
577 * Purpose : Detect if study is empty
579 //============================================================================
580 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
582 SALOMEDS::Locker lock;
584 throw SALOMEDS::Study::StudyInvalidReference();
585 return _impl->IsEmpty();
588 //============================================================================
589 /*! Function : FindComponent
590 * Purpose : Find a Component with ComponentDataType = aComponentName
592 //============================================================================
593 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
595 SALOMEDS::Locker lock;
598 throw SALOMEDS::Study::StudyInvalidReference();
600 SALOMEDS::SComponent_var sco;
602 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
603 if (!aCompImpl.IsNull())
604 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
609 //============================================================================
610 /*! Function : FindComponentID
611 * Purpose : Find a Component from it's ID
613 //============================================================================
614 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
616 SALOMEDS::Locker lock;
619 throw SALOMEDS::Study::StudyInvalidReference();
621 SALOMEDS::SComponent_var sco;
623 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
624 if (!aCompImpl.IsNull())
625 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
630 //============================================================================
631 /*! Function : FindObject
632 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
634 //============================================================================
635 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
637 SALOMEDS::Locker lock;
640 throw SALOMEDS::Study::StudyInvalidReference();
642 SALOMEDS::SObject_var so;
644 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
646 if (aSO.IsComponent()) {
647 SALOMEDSImpl_SComponent aSCO = aSO;
648 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
651 so = SALOMEDS_SObject_i::New(aSO, _orb);
658 //============================================================================
659 /*! Function : FindObjectID
660 * Purpose : Find an Object with ID = anObjectID
662 //============================================================================
663 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
665 SALOMEDS::Locker lock;
668 throw SALOMEDS::Study::StudyInvalidReference();
670 SALOMEDS::SObject_var so;
672 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
674 so = SALOMEDS_SObject_i::New(aSO, _orb);
679 //============================================================================
680 /*! Function : CreateObjectID
681 * Purpose : Creates an Object with ID = anObjectID
683 //============================================================================
684 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
686 SALOMEDS::Locker lock;
689 throw SALOMEDS::Study::StudyInvalidReference();
691 SALOMEDS::SObject_var so;
693 if (anObjectID && strlen(anObjectID) > 0) {
694 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
696 so = SALOMEDS_SObject_i::New(aSO, _orb);
702 //============================================================================
703 /*! Function : FindObjectByName
704 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
705 * : with ComponentDataType = aComponentName
707 //============================================================================
708 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
709 const char* aComponentName )
711 SALOMEDS::Locker lock;
714 throw SALOMEDS::Study::StudyInvalidReference();
716 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
717 std::string((char*)aComponentName));
719 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
720 int aLength = aSeq.size();
721 listSO->length(aLength);
722 for (int i = 0; i < aLength; i++) {
723 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
727 return listSO._retn();
730 //============================================================================
731 /*! Function : FindObjectIOR
732 * Purpose : Find an Object with IOR = anObjectIOR
734 //============================================================================
735 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
737 SALOMEDS::Locker lock;
740 throw SALOMEDS::Study::StudyInvalidReference();
742 SALOMEDS::SObject_var so;
744 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
746 so = SALOMEDS_SObject_i::New(aSO, _orb);
751 //============================================================================
752 /*! Function : FindObjectByPath
753 * Purpose : Find an Object by its path = thePath
755 //============================================================================
756 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
758 SALOMEDS::Locker lock;
761 throw SALOMEDS::Study::StudyInvalidReference();
763 SALOMEDS::SObject_var so;
765 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
767 so = SALOMEDS_SObject_i::New (aSO, _orb);
772 //============================================================================
773 /*! Function : GetObjectPath
776 //============================================================================
777 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
779 SALOMEDS::Locker lock;
782 throw SALOMEDS::Study::StudyInvalidReference();
784 std::string aPath = "";
786 if (!CORBA::is_nil(theObject)) {
787 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
788 SALOMEDSImpl_SObject aSO;
790 if (!CORBA::is_nil(aSObj)) {
791 aSO = _impl->FindObjectID(aSObj->GetID());
794 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
798 aPath = _impl->GetObjectPath(aSO);
802 return CORBA::string_dup(aPath.c_str());
806 //============================================================================
807 /*! Function : SetContext
808 * Purpose : Sets the current context
810 //============================================================================
811 void SALOMEDS_Study_i::SetContext(const char* thePath)
813 SALOMEDS::Locker lock;
816 throw SALOMEDS::Study::StudyInvalidReference();
818 _impl->SetContext(std::string((char*)thePath));
819 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
820 throw SALOMEDS::Study::StudyInvalidContext();
823 //============================================================================
824 /*! Function : GetContext
825 * Purpose : Gets the current context
827 //============================================================================
828 char* SALOMEDS_Study_i::GetContext()
830 SALOMEDS::Locker lock;
833 throw SALOMEDS::Study::StudyInvalidReference();
835 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
837 return CORBA::string_dup(_impl->GetContext().c_str());
840 //============================================================================
841 /*! Function : GetObjectNames
842 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
844 //============================================================================
845 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
847 SALOMEDS::Locker lock;
850 throw SALOMEDS::Study::StudyInvalidReference();
852 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
854 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
855 throw SALOMEDS::Study::StudyInvalidContext();
857 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
858 if (_impl->GetErrorCode() == "InvalidContext")
859 throw SALOMEDS::Study::StudyInvalidContext();
861 int aLength = aSeq.size();
862 aResult->length(aLength);
863 for (int anIndex = 0; anIndex < aLength; anIndex++) {
864 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
867 return aResult._retn();
870 //============================================================================
871 /*! Function : GetDirectoryNames
872 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
874 //============================================================================
875 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
877 SALOMEDS::Locker lock;
880 throw SALOMEDS::Study::StudyInvalidReference();
882 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
884 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
885 throw SALOMEDS::Study::StudyInvalidContext();
887 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
888 if (_impl->GetErrorCode() == "InvalidContext")
889 throw SALOMEDS::Study::StudyInvalidContext();
891 int aLength = aSeq.size();
892 aResult->length(aLength);
893 for (int anIndex = 0; anIndex < aLength; anIndex++) {
894 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
897 return aResult._retn();
900 //============================================================================
901 /*! Function : GetFileNames
902 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
904 //============================================================================
905 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
907 SALOMEDS::Locker lock;
910 throw SALOMEDS::Study::StudyInvalidReference();
912 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
914 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
915 throw SALOMEDS::Study::StudyInvalidContext();
917 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
918 if (_impl->GetErrorCode() == "InvalidContext")
919 throw SALOMEDS::Study::StudyInvalidContext();
921 int aLength = aSeq.size();
922 aResult->length(aLength);
923 for (int anIndex = 0; anIndex < aLength; anIndex++) {
924 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
927 return aResult._retn();
930 //============================================================================
931 /*! Function : GetComponentNames
932 * Purpose : method to get all components names
933 * SRN: Note, theContext can be any, it doesn't matter
935 //============================================================================
936 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
938 SALOMEDS::Locker lock;
941 throw SALOMEDS::Study::StudyInvalidReference();
943 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
945 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
947 int aLength = aSeq.size();
948 aResult->length(aLength);
949 for(int anIndex = 0; anIndex < aLength; anIndex++) {
950 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
953 return aResult._retn();
956 //============================================================================
957 /*! Function : NewChildIterator
958 * Purpose : Create a ChildIterator from an SObject
960 //============================================================================
961 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
963 SALOMEDS::Locker lock;
966 throw SALOMEDS::Study::StudyInvalidReference();
968 CORBA::String_var anID = theSO->GetID();
969 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
970 SALOMEDSImpl_ChildIterator anItr(aSO);
971 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
972 SALOMEDS::ChildIterator_var it = it_servant->_this();
978 //============================================================================
979 /*! Function : NewComponentIterator
980 * Purpose : Create a SComponentIterator
982 //============================================================================
983 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
985 SALOMEDS::Locker lock;
988 throw SALOMEDS::Study::StudyInvalidReference();
990 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
992 SALOMEDS::SComponentIterator_var it = it_servant->_this();
998 //============================================================================
999 /*! Function : NewBuilder
1000 * Purpose : Create a StudyBuilder
1002 //============================================================================
1003 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
1005 SALOMEDS::Locker lock;
1008 throw SALOMEDS::Study::StudyInvalidReference();
1010 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
1015 //============================================================================
1017 * Purpose : get study name
1019 //============================================================================
1020 char* SALOMEDS_Study_i::Name()
1022 SALOMEDS::Locker lock;
1023 // Name is specified as IDL attribute: user exception cannot be raised
1024 return CORBA::string_dup(_impl->Name().c_str());
1027 //============================================================================
1028 /*! Function : IsSaved
1029 * Purpose : get if study has been saved
1031 //============================================================================
1032 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1034 SALOMEDS::Locker lock;
1035 // IsSaved is specified as IDL attribute: user exception cannot be raised
1036 return (!_closed) ? _impl->IsSaved() : false;
1039 //============================================================================
1040 /*! Function : IsSaved
1041 * Purpose : set if study has been saved
1043 //============================================================================
1044 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1046 SALOMEDS::Locker lock;
1047 // IsSaved is specified as IDL attribute: user exception cannot be raised
1049 _impl->IsSaved(save);
1052 //============================================================================
1053 /*! Function : IsModified
1054 * Purpose : Detect if a Study has been modified since it has been saved
1056 //============================================================================
1057 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1059 SALOMEDS::Locker lock;
1062 throw SALOMEDS::Study::StudyInvalidReference();
1064 return _impl->IsModified();
1067 //============================================================================
1068 /*! Function : Modified
1069 * Purpose : Sets a Modified flag of a Study to True
1071 //============================================================================
1072 void SALOMEDS_Study_i::Modified()
1074 SALOMEDS::Locker lock;
1077 throw SALOMEDS::Study::StudyInvalidReference();
1082 //============================================================================
1084 * Purpose : get URL of the study (persistent reference of the study)
1086 //============================================================================
1087 char* SALOMEDS_Study_i::URL()
1089 SALOMEDS::Locker lock;
1090 // URL is specified as IDL attribute: user exception cannot be raised
1091 return CORBA::string_dup(_impl->URL().c_str());
1094 //============================================================================
1096 * Purpose : set URL of the study (persistent reference of the study)
1098 //============================================================================
1099 void SALOMEDS_Study_i::URL(const char* url)
1101 SALOMEDS::Locker lock;
1102 // URL is specified as IDL attribute: user exception cannot be raised
1103 _impl->URL(std::string((char*)url));
1105 // update desktop title with new study name
1109 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1111 SALOMEDS::Locker lock;
1114 throw SALOMEDS::Study::StudyInvalidReference();
1116 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1119 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1121 SALOMEDS::Locker lock;
1123 SALOMEDSImpl_AttributeIOR* Att = NULL;
1124 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1125 char* IOR = CORBA::string_dup(Att->Value().c_str());
1126 CORBA::Object_var obj = orb->string_to_object(IOR);
1127 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1128 ASSERT(!CORBA::is_nil(aStudy));
1129 return SALOMEDS::Study::_duplicate(aStudy);
1131 MESSAGE("GetStudy: Problem to get study");
1133 return SALOMEDS::Study::_nil();
1136 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1138 SALOMEDS::Locker lock;
1139 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1142 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1144 SALOMEDS::Locker lock;
1147 throw SALOMEDS::Study::StudyInvalidReference();
1149 SALOMEDS::GenericAttribute_ptr aTarget;
1150 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1151 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1153 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1159 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1161 SALOMEDS::Locker lock;
1164 throw SALOMEDS::Study::StudyInvalidReference();
1166 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1167 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1168 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1169 return aProp._retn();
1172 char* SALOMEDS_Study_i::GetLastModificationDate()
1174 SALOMEDS::Locker lock;
1177 throw SALOMEDS::Study::StudyInvalidReference();
1179 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1182 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1184 SALOMEDS::Locker lock;
1187 throw SALOMEDS::Study::StudyInvalidReference();
1189 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1191 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1193 int aLength = aSeq.size();
1194 aDates->length(aLength);
1195 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1196 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1199 return aDates._retn();
1202 //============================================================================
1203 /*! Function : GetUseCaseBuilder
1204 * Purpose : Returns a UseCase builder
1206 //============================================================================
1207 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1209 SALOMEDS::Locker lock;
1212 throw SALOMEDS::Study::StudyInvalidReference();
1214 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1215 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1219 //============================================================================
1220 /*! Function : AddPostponed
1223 //============================================================================
1224 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1226 SALOMEDS::Locker lock;
1230 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1232 SALOMEDS::Locker lock;
1236 //============================================================================
1237 /*! Function : RemovePostponed
1240 //============================================================================
1241 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1243 SALOMEDS::Locker lock;
1246 throw SALOMEDS::Study::StudyInvalidReference();
1248 std::vector<std::string> anIORs = _impl->GetIORs();
1249 int i, aSize = (int)anIORs.size();
1251 for (i = 0; i < aSize; i++) {
1253 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1254 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1255 //rnv: To avoid double deletion of the Salome Generic Objects:
1256 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1257 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1258 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1265 //============================================================================
1266 /*! Function : UndoPostponed
1269 //============================================================================
1270 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1272 SALOMEDS::Locker lock;
1277 //============================================================================
1278 /*! Function : DumpStudy
1281 //============================================================================
1282 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1283 const char* theBaseName,
1284 CORBA::Boolean isPublished,
1285 CORBA::Boolean isMultiFile)
1287 SALOMEDS::Locker lock;
1290 throw SALOMEDS::Study::StudyInvalidReference();
1292 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1293 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1294 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1300 //============================================================================
1301 /*! Function : GetCommonParameters
1304 //============================================================================
1305 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1307 SALOMEDS::Locker lock;
1310 throw SALOMEDS::Study::StudyInvalidReference();
1312 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1313 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1314 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1316 return aParam._retn();
1319 //============================================================================
1320 /*! Function : GetCommonModuleParameters
1323 //============================================================================
1324 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1325 const char* theModuleName,
1326 CORBA::Long theSavePoint)
1328 SALOMEDS::Locker lock;
1331 throw SALOMEDS::Study::StudyInvalidReference();
1333 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1334 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1335 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1337 return aParam._retn();
1340 //============================================================================
1341 /*! Function : SetStudyLock
1344 //============================================================================
1345 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1347 SALOMEDS::Locker lock;
1350 throw SALOMEDS::Study::StudyInvalidReference();
1352 _impl->SetStudyLock(theLockerID);
1355 //============================================================================
1356 /*! Function : IsStudyLocked
1359 //============================================================================
1360 bool SALOMEDS_Study_i::IsStudyLocked()
1362 SALOMEDS::Locker lock;
1365 throw SALOMEDS::Study::StudyInvalidReference();
1367 return _impl->IsStudyLocked();
1370 //============================================================================
1371 /*! Function : UnLockStudy
1374 //============================================================================
1375 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1377 SALOMEDS::Locker lock;
1380 throw SALOMEDS::Study::StudyInvalidReference();
1382 _impl->UnLockStudy(theLockerID);
1385 //============================================================================
1386 /*! Function : GetLockerID
1389 //============================================================================
1390 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1392 SALOMEDS::Locker lock;
1395 throw SALOMEDS::Study::StudyInvalidReference();
1397 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1399 std::vector<std::string> aSeq = _impl->GetLockerID();
1401 int aLength = aSeq.size();
1402 aResult->length(aLength);
1403 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1404 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1407 return aResult._retn();
1409 //============================================================================
1410 /*! Function : SetReal
1413 //============================================================================
1414 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1417 throw SALOMEDS::Study::StudyInvalidReference();
1420 _impl->SetVariable(std::string(theVarName),
1422 SALOMEDSImpl_GenericVariable::REAL_VAR);
1424 _notifier->modifyNB_Notification(theVarName);
1427 //============================================================================
1428 /*! Function : SetInteger
1431 //============================================================================
1432 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1435 throw SALOMEDS::Study::StudyInvalidReference();
1437 _impl->SetVariable(std::string(theVarName),
1439 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1441 _notifier->modifyNB_Notification(theVarName);
1444 //============================================================================
1445 /*! Function : SetBoolean
1448 //============================================================================
1449 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1452 throw SALOMEDS::Study::StudyInvalidReference();
1454 _impl->SetVariable(std::string(theVarName),
1456 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1458 _notifier->modifyNB_Notification(theVarName);
1461 //============================================================================
1462 /*! Function : SetString
1465 //============================================================================
1466 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1469 throw SALOMEDS::Study::StudyInvalidReference();
1471 _impl->SetStringVariable(std::string(theVarName),
1473 SALOMEDSImpl_GenericVariable::STRING_VAR);
1475 _notifier->modifyNB_Notification(theVarName);
1478 //============================================================================
1479 /*! Function : SetStringAsDouble
1482 //============================================================================
1483 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1486 throw SALOMEDS::Study::StudyInvalidReference();
1488 _impl->SetStringVariableAsDouble(std::string(theVarName),
1490 SALOMEDSImpl_GenericVariable::STRING_VAR);
1493 //============================================================================
1494 /*! Function : GetReal
1497 //============================================================================
1498 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1501 throw SALOMEDS::Study::StudyInvalidReference();
1503 return _impl->GetVariableValue(std::string(theVarName));
1506 //============================================================================
1507 /*! Function : GetInteger
1510 //============================================================================
1511 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1514 throw SALOMEDS::Study::StudyInvalidReference();
1516 return (long)_impl->GetVariableValue(std::string(theVarName));
1519 //============================================================================
1520 /*! Function : GetBoolean
1523 //============================================================================
1524 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1527 throw SALOMEDS::Study::StudyInvalidReference();
1529 return (bool)_impl->GetVariableValue(std::string(theVarName));
1532 //============================================================================
1533 /*! Function : GetString
1536 //============================================================================
1537 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1540 throw SALOMEDS::Study::StudyInvalidReference();
1542 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1545 //============================================================================
1546 /*! Function : IsReal
1549 //============================================================================
1550 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1553 throw SALOMEDS::Study::StudyInvalidReference();
1555 return _impl->IsTypeOf(std::string(theVarName),
1556 SALOMEDSImpl_GenericVariable::REAL_VAR);
1559 //============================================================================
1560 /*! Function : IsInteger
1563 //============================================================================
1564 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1567 throw SALOMEDS::Study::StudyInvalidReference();
1569 return _impl->IsTypeOf(std::string(theVarName),
1570 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1573 //============================================================================
1574 /*! Function : IsBoolean
1577 //============================================================================
1578 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1581 throw SALOMEDS::Study::StudyInvalidReference();
1583 return _impl->IsTypeOf(std::string(theVarName),
1584 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1587 //============================================================================
1588 /*! Function : IsString
1591 //============================================================================
1592 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1595 throw SALOMEDS::Study::StudyInvalidReference();
1597 return _impl->IsTypeOf(std::string(theVarName),
1598 SALOMEDSImpl_GenericVariable::STRING_VAR);
1601 //============================================================================
1602 /*! Function : IsVariable
1605 //============================================================================
1606 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1609 throw SALOMEDS::Study::StudyInvalidReference();
1611 return _impl->IsVariable(std::string(theVarName));
1614 //============================================================================
1615 /*! Function : GetVariableNames
1618 //============================================================================
1619 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1622 throw SALOMEDS::Study::StudyInvalidReference();
1624 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1626 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1628 int aLen = aVarNames.size();
1629 aResult->length(aLen);
1630 for (int anInd = 0; anInd < aLen; anInd++)
1631 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1633 return aResult._retn();
1636 //============================================================================
1637 /*! Function : RemoveVariable
1640 //============================================================================
1641 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1644 throw SALOMEDS::Study::StudyInvalidReference();
1646 bool res = _impl->RemoveVariable(std::string(theVarName));
1647 if (res && _notifier)
1648 _notifier->modifyNB_Notification(theVarName);
1653 //============================================================================
1654 /*! Function : RenameVariable
1657 //============================================================================
1658 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1661 throw SALOMEDS::Study::StudyInvalidReference();
1663 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1664 if (res && _notifier)
1665 _notifier->modifyNB_Notification(theVarName);
1670 //============================================================================
1671 /*! Function : IsVariableUsed
1674 //============================================================================
1675 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1678 throw SALOMEDS::Study::StudyInvalidReference();
1680 return _impl->IsVariableUsed(std::string(theVarName));
1684 //============================================================================
1685 /*! Function : ParseVariables
1688 //============================================================================
1689 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1692 throw SALOMEDS::Study::StudyInvalidReference();
1694 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1696 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1698 int aSectionsLen = aSections.size();
1699 aResult->length(aSectionsLen);
1701 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1702 std::vector<std::string> aVarNames = aSections[aSectionInd];
1704 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1706 int aLen = aVarNames.size();
1707 aList->length(aLen);
1709 for (int anInd = 0; anInd < aLen; anInd++)
1710 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1712 aResult[aSectionInd] = aList;
1715 return aResult._retn();
1718 //============================================================================
1719 /*! Function : GetDefaultScript
1722 //============================================================================
1723 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1725 SALOMEDS::Locker lock;
1728 throw SALOMEDS::Study::StudyInvalidReference();
1730 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1731 return CORBA::string_dup(script.c_str());
1734 //============================================================================
1735 /*! Function : EnableUseCaseAutoFilling
1738 //============================================================================
1739 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1742 throw SALOMEDS::Study::StudyInvalidReference();
1744 _impl->EnableUseCaseAutoFilling(isEnabled);
1745 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1748 builder->SetOnAddSObject(_impl->GetCallback());
1749 builder->SetOnRemoveSObject(_impl->GetCallback());
1752 builder->SetOnAddSObject(NULL);
1753 builder->SetOnRemoveSObject(NULL);
1759 CORBA::Long SALOMEDS_Study_i::getPID()
1762 return (CORBA::Long)_getpid();
1764 return (CORBA::Long)getpid();
1768 void SALOMEDS_Study_i::ShutdownWithExit()
1770 exit( EXIT_SUCCESS );
1773 void SALOMEDS_Study_i::Shutdown()
1775 if(!CORBA::is_nil(_orb))
1779 //============================================================================
1780 /*! Function : attach
1781 * Purpose : This function attach an observer to the study
1783 //============================================================================
1784 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1787 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1791 //============================================================================
1792 /*! Function : detach
1793 * Purpose : This function detaches an observer from the study
1795 //============================================================================
1796 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1799 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1802 //===========================================================================
1803 // PRIVATE FUNCTIONS
1804 //===========================================================================
1805 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1808 long pid = (long)_getpid();
1810 long pid = (long)getpid();
1812 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1813 return reinterpret_cast<CORBA::LongLong>(_impl);
1816 void SALOMEDS_Study_i::NameChanged()
1818 // Notify GUI that the name of study was changed
1819 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1820 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1821 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1822 if ( !CORBA::is_nil(aSession) ) {
1823 std::stringstream ss;
1824 ss << "studyNameChanged";
1825 std::string str = ss.str();
1827 aSession->emitMessageOneWay(str.c_str());