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;
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;
375 //============================================================================
377 * Purpose : Open a Study from it's persistent reference
379 //============================================================================
380 bool SALOMEDS_Study_i::Open(const char* aUrl)
381 throw(SALOME::SALOME_Exception)
386 SALOMEDS::Locker lock;
388 Unexpect aCatch(SalomeException);
389 MESSAGE("Begin of SALOMEDS_Study_i::Open");
391 bool res = _impl->Open(std::string(aUrl));
393 // update desktop title with new study name
397 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
401 //============================================================================
403 * Purpose : Save a Study to it's persistent reference
405 //============================================================================
406 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
408 SALOMEDS::Locker lock;
410 throw SALOMEDS::Study::StudyInvalidReference();
411 return _impl->Save(_factory, theMultiFile);
414 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
416 SALOMEDS::Locker lock;
418 throw SALOMEDS::Study::StudyInvalidReference();
419 return _impl->SaveASCII(_factory, theMultiFile);
422 //=============================================================================
423 /*! Function : SaveAs
424 * Purpose : Save a study to the persistent reference aUrl
426 //============================================================================
427 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
429 SALOMEDS::Locker lock;
431 throw SALOMEDS::Study::StudyInvalidReference();
432 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
435 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
437 SALOMEDS::Locker lock;
439 throw SALOMEDS::Study::StudyInvalidReference();
440 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
443 //============================================================================
444 /*! Function : CanCopy
447 //============================================================================
448 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
450 SALOMEDS::Locker lock;
452 throw SALOMEDS::Study::StudyInvalidReference();
454 CORBA::String_var anID = theObject->GetID();
455 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
457 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
458 bool ret = _impl->CanCopy(anObject, aDriver);
463 //============================================================================
467 //============================================================================
468 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
470 SALOMEDS::Locker lock;
472 throw SALOMEDS::Study::StudyInvalidReference();
474 CORBA::String_var anID = theObject->GetID();
475 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
477 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
478 bool ret = _impl->Copy(anObject, aDriver);
483 //============================================================================
484 /*! Function : CanPaste
487 //============================================================================
488 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
490 SALOMEDS::Locker lock;
492 throw SALOMEDS::Study::StudyInvalidReference();
494 CORBA::String_var anID = theObject->GetID();
495 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
497 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
498 bool ret = _impl->CanPaste(anObject, aDriver);
503 //============================================================================
507 //============================================================================
508 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
509 throw(SALOMEDS::StudyBuilder::LockProtection)
511 SALOMEDS::Locker lock;
513 Unexpect aCatch(LockProtection);
515 CORBA::String_var anID = theObject->GetID();
516 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
517 SALOMEDSImpl_SObject aNewSO;
520 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
521 aNewSO = _impl->Paste(anObject, aDriver);
525 throw SALOMEDS::StudyBuilder::LockProtection();
528 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
532 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
534 SALOMEDS_Driver_i* driver = NULL;
536 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
538 std::string IOREngine = aSCO.GetIOR();
539 if(!IOREngine.empty()) {
540 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
541 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
542 driver = new SALOMEDS_Driver_i(Engine, orb);
549 //============================================================================
550 /*! Function : GetPersistentReference
551 * Purpose : Get persistent reference of study (idem URL())
553 //============================================================================
554 char* SALOMEDS_Study_i::GetPersistentReference()
556 SALOMEDS::Locker lock;
558 throw SALOMEDS::Study::StudyInvalidReference();
559 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
561 //============================================================================
562 /*! Function : GetTransientReference
563 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
565 //============================================================================
566 char* SALOMEDS_Study_i::GetTransientReference()
568 SALOMEDS::Locker lock;
570 throw SALOMEDS::Study::StudyInvalidReference();
571 return CORBA::string_dup(_impl->GetTransientReference().c_str());
574 //============================================================================
575 /*! Function : IsEmpty
576 * Purpose : Detect if study is empty
578 //============================================================================
579 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
581 SALOMEDS::Locker lock;
583 throw SALOMEDS::Study::StudyInvalidReference();
584 return _impl->IsEmpty();
587 //============================================================================
588 /*! Function : FindComponent
589 * Purpose : Find a Component with ComponentDataType = aComponentName
591 //============================================================================
592 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
594 SALOMEDS::Locker lock;
597 throw SALOMEDS::Study::StudyInvalidReference();
599 SALOMEDS::SComponent_var sco;
601 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
602 if (!aCompImpl.IsNull())
603 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
608 //============================================================================
609 /*! Function : FindComponentID
610 * Purpose : Find a Component from it's ID
612 //============================================================================
613 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
615 SALOMEDS::Locker lock;
618 throw SALOMEDS::Study::StudyInvalidReference();
620 SALOMEDS::SComponent_var sco;
622 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
623 if (!aCompImpl.IsNull())
624 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
629 //============================================================================
630 /*! Function : FindObject
631 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
633 //============================================================================
634 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
636 SALOMEDS::Locker lock;
639 throw SALOMEDS::Study::StudyInvalidReference();
641 SALOMEDS::SObject_var so;
643 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
645 if (aSO.IsComponent()) {
646 SALOMEDSImpl_SComponent aSCO = aSO;
647 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
650 so = SALOMEDS_SObject_i::New(aSO, _orb);
657 //============================================================================
658 /*! Function : FindObjectID
659 * Purpose : Find an Object with ID = anObjectID
661 //============================================================================
662 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
664 SALOMEDS::Locker lock;
667 throw SALOMEDS::Study::StudyInvalidReference();
669 SALOMEDS::SObject_var so;
671 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
673 so = SALOMEDS_SObject_i::New(aSO, _orb);
678 //============================================================================
679 /*! Function : CreateObjectID
680 * Purpose : Creates an Object with ID = anObjectID
682 //============================================================================
683 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
685 SALOMEDS::Locker lock;
688 throw SALOMEDS::Study::StudyInvalidReference();
690 SALOMEDS::SObject_var so;
692 if (anObjectID && strlen(anObjectID) > 0) {
693 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
695 so = SALOMEDS_SObject_i::New(aSO, _orb);
701 //============================================================================
702 /*! Function : FindObjectByName
703 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
704 * : with ComponentDataType = aComponentName
706 //============================================================================
707 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
708 const char* aComponentName )
710 SALOMEDS::Locker lock;
713 throw SALOMEDS::Study::StudyInvalidReference();
715 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
716 std::string((char*)aComponentName));
718 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
719 int aLength = aSeq.size();
720 listSO->length(aLength);
721 for (int i = 0; i < aLength; i++) {
722 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
726 return listSO._retn();
729 //============================================================================
730 /*! Function : FindObjectIOR
731 * Purpose : Find an Object with IOR = anObjectIOR
733 //============================================================================
734 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
736 SALOMEDS::Locker lock;
739 throw SALOMEDS::Study::StudyInvalidReference();
741 SALOMEDS::SObject_var so;
743 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
745 so = SALOMEDS_SObject_i::New(aSO, _orb);
750 //============================================================================
751 /*! Function : FindObjectByPath
752 * Purpose : Find an Object by its path = thePath
754 //============================================================================
755 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
757 SALOMEDS::Locker lock;
760 throw SALOMEDS::Study::StudyInvalidReference();
762 SALOMEDS::SObject_var so;
764 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
766 so = SALOMEDS_SObject_i::New (aSO, _orb);
771 //============================================================================
772 /*! Function : GetObjectPath
775 //============================================================================
776 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
778 SALOMEDS::Locker lock;
781 throw SALOMEDS::Study::StudyInvalidReference();
783 std::string aPath = "";
785 if (!CORBA::is_nil(theObject)) {
786 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
787 SALOMEDSImpl_SObject aSO;
789 if (!CORBA::is_nil(aSObj)) {
790 aSO = _impl->FindObjectID(aSObj->GetID());
793 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
797 aPath = _impl->GetObjectPath(aSO);
801 return CORBA::string_dup(aPath.c_str());
805 //============================================================================
806 /*! Function : SetContext
807 * Purpose : Sets the current context
809 //============================================================================
810 void SALOMEDS_Study_i::SetContext(const char* thePath)
812 SALOMEDS::Locker lock;
815 throw SALOMEDS::Study::StudyInvalidReference();
817 _impl->SetContext(std::string((char*)thePath));
818 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
819 throw SALOMEDS::Study::StudyInvalidContext();
822 //============================================================================
823 /*! Function : GetContext
824 * Purpose : Gets the current context
826 //============================================================================
827 char* SALOMEDS_Study_i::GetContext()
829 SALOMEDS::Locker lock;
832 throw SALOMEDS::Study::StudyInvalidReference();
834 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
836 return CORBA::string_dup(_impl->GetContext().c_str());
839 //============================================================================
840 /*! Function : GetObjectNames
841 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
843 //============================================================================
844 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
846 SALOMEDS::Locker lock;
849 throw SALOMEDS::Study::StudyInvalidReference();
851 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
853 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
854 throw SALOMEDS::Study::StudyInvalidContext();
856 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
857 if (_impl->GetErrorCode() == "InvalidContext")
858 throw SALOMEDS::Study::StudyInvalidContext();
860 int aLength = aSeq.size();
861 aResult->length(aLength);
862 for (int anIndex = 0; anIndex < aLength; anIndex++) {
863 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
866 return aResult._retn();
869 //============================================================================
870 /*! Function : GetDirectoryNames
871 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
873 //============================================================================
874 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
876 SALOMEDS::Locker lock;
879 throw SALOMEDS::Study::StudyInvalidReference();
881 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
883 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
884 throw SALOMEDS::Study::StudyInvalidContext();
886 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
887 if (_impl->GetErrorCode() == "InvalidContext")
888 throw SALOMEDS::Study::StudyInvalidContext();
890 int aLength = aSeq.size();
891 aResult->length(aLength);
892 for (int anIndex = 0; anIndex < aLength; anIndex++) {
893 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
896 return aResult._retn();
899 //============================================================================
900 /*! Function : GetFileNames
901 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
903 //============================================================================
904 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
906 SALOMEDS::Locker lock;
909 throw SALOMEDS::Study::StudyInvalidReference();
911 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
913 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
914 throw SALOMEDS::Study::StudyInvalidContext();
916 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
917 if (_impl->GetErrorCode() == "InvalidContext")
918 throw SALOMEDS::Study::StudyInvalidContext();
920 int aLength = aSeq.size();
921 aResult->length(aLength);
922 for (int anIndex = 0; anIndex < aLength; anIndex++) {
923 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
926 return aResult._retn();
929 //============================================================================
930 /*! Function : GetComponentNames
931 * Purpose : method to get all components names
932 * SRN: Note, theContext can be any, it doesn't matter
934 //============================================================================
935 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
937 SALOMEDS::Locker lock;
940 throw SALOMEDS::Study::StudyInvalidReference();
942 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
944 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
946 int aLength = aSeq.size();
947 aResult->length(aLength);
948 for(int anIndex = 0; anIndex < aLength; anIndex++) {
949 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
952 return aResult._retn();
955 //============================================================================
956 /*! Function : NewChildIterator
957 * Purpose : Create a ChildIterator from an SObject
959 //============================================================================
960 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
962 SALOMEDS::Locker lock;
965 throw SALOMEDS::Study::StudyInvalidReference();
967 CORBA::String_var anID = theSO->GetID();
968 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
969 SALOMEDSImpl_ChildIterator anItr(aSO);
970 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
971 SALOMEDS::ChildIterator_var it = it_servant->_this();
977 //============================================================================
978 /*! Function : NewComponentIterator
979 * Purpose : Create a SComponentIterator
981 //============================================================================
982 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
984 SALOMEDS::Locker lock;
987 throw SALOMEDS::Study::StudyInvalidReference();
989 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
991 SALOMEDS::SComponentIterator_var it = it_servant->_this();
997 //============================================================================
998 /*! Function : NewBuilder
999 * Purpose : Create a StudyBuilder
1001 //============================================================================
1002 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
1004 SALOMEDS::Locker lock;
1007 throw SALOMEDS::Study::StudyInvalidReference();
1009 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
1014 //============================================================================
1016 * Purpose : get study name
1018 //============================================================================
1019 char* SALOMEDS_Study_i::Name()
1021 SALOMEDS::Locker lock;
1022 // Name is specified as IDL attribute: user exception cannot be raised
1023 return CORBA::string_dup(_impl->Name().c_str());
1026 //============================================================================
1027 /*! Function : IsSaved
1028 * Purpose : get if study has been saved
1030 //============================================================================
1031 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1033 SALOMEDS::Locker lock;
1034 // IsSaved is specified as IDL attribute: user exception cannot be raised
1035 return (!_closed) ? _impl->IsSaved() : false;
1038 //============================================================================
1039 /*! Function : IsSaved
1040 * Purpose : set if study has been saved
1042 //============================================================================
1043 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1045 SALOMEDS::Locker lock;
1046 // IsSaved is specified as IDL attribute: user exception cannot be raised
1048 _impl->IsSaved(save);
1051 //============================================================================
1052 /*! Function : IsModified
1053 * Purpose : Detect if a Study has been modified since it has been saved
1055 //============================================================================
1056 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1058 SALOMEDS::Locker lock;
1061 throw SALOMEDS::Study::StudyInvalidReference();
1063 return _impl->IsModified();
1066 //============================================================================
1067 /*! Function : Modified
1068 * Purpose : Sets a Modified flag of a Study to True
1070 //============================================================================
1071 void SALOMEDS_Study_i::Modified()
1073 SALOMEDS::Locker lock;
1076 throw SALOMEDS::Study::StudyInvalidReference();
1081 //============================================================================
1083 * Purpose : get URL of the study (persistent reference of the study)
1085 //============================================================================
1086 char* SALOMEDS_Study_i::URL()
1088 SALOMEDS::Locker lock;
1089 // URL is specified as IDL attribute: user exception cannot be raised
1090 return CORBA::string_dup(_impl->URL().c_str());
1093 //============================================================================
1095 * Purpose : set URL of the study (persistent reference of the study)
1097 //============================================================================
1098 void SALOMEDS_Study_i::URL(const char* url)
1100 SALOMEDS::Locker lock;
1101 // URL is specified as IDL attribute: user exception cannot be raised
1102 _impl->URL(std::string((char*)url));
1104 // update desktop title with new study name
1108 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1110 SALOMEDS::Locker lock;
1113 throw SALOMEDS::Study::StudyInvalidReference();
1115 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1118 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1120 SALOMEDS::Locker lock;
1122 SALOMEDSImpl_AttributeIOR* Att = NULL;
1123 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1124 char* IOR = CORBA::string_dup(Att->Value().c_str());
1125 CORBA::Object_var obj = orb->string_to_object(IOR);
1126 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1127 ASSERT(!CORBA::is_nil(aStudy));
1128 return SALOMEDS::Study::_duplicate(aStudy);
1130 MESSAGE("GetStudy: Problem to get study");
1132 return SALOMEDS::Study::_nil();
1135 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1137 SALOMEDS::Locker lock;
1138 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1141 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1143 SALOMEDS::Locker lock;
1146 throw SALOMEDS::Study::StudyInvalidReference();
1148 SALOMEDS::GenericAttribute_ptr aTarget;
1149 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1150 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1152 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1158 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1160 SALOMEDS::Locker lock;
1163 throw SALOMEDS::Study::StudyInvalidReference();
1165 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1166 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1167 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1168 return aProp._retn();
1171 char* SALOMEDS_Study_i::GetLastModificationDate()
1173 SALOMEDS::Locker lock;
1176 throw SALOMEDS::Study::StudyInvalidReference();
1178 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1181 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1183 SALOMEDS::Locker lock;
1186 throw SALOMEDS::Study::StudyInvalidReference();
1188 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1190 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1192 int aLength = aSeq.size();
1193 aDates->length(aLength);
1194 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1195 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1198 return aDates._retn();
1201 //============================================================================
1202 /*! Function : GetUseCaseBuilder
1203 * Purpose : Returns a UseCase builder
1205 //============================================================================
1206 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1208 SALOMEDS::Locker lock;
1211 throw SALOMEDS::Study::StudyInvalidReference();
1213 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1214 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1218 //============================================================================
1219 /*! Function : AddPostponed
1222 //============================================================================
1223 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1225 SALOMEDS::Locker lock;
1229 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1231 SALOMEDS::Locker lock;
1235 //============================================================================
1236 /*! Function : RemovePostponed
1239 //============================================================================
1240 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1242 SALOMEDS::Locker lock;
1245 throw SALOMEDS::Study::StudyInvalidReference();
1247 std::vector<std::string> anIORs = _impl->GetIORs();
1248 int i, aSize = (int)anIORs.size();
1250 for (i = 0; i < aSize; i++) {
1252 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1253 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1254 //rnv: To avoid double deletion of the Salome Generic Objects:
1255 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1256 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1257 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1264 //============================================================================
1265 /*! Function : UndoPostponed
1268 //============================================================================
1269 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1271 SALOMEDS::Locker lock;
1276 //============================================================================
1277 /*! Function : DumpStudy
1280 //============================================================================
1281 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1282 const char* theBaseName,
1283 CORBA::Boolean isPublished,
1284 CORBA::Boolean isMultiFile)
1286 SALOMEDS::Locker lock;
1289 throw SALOMEDS::Study::StudyInvalidReference();
1291 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1292 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1293 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1299 //============================================================================
1300 /*! Function : GetCommonParameters
1303 //============================================================================
1304 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1306 SALOMEDS::Locker lock;
1309 throw SALOMEDS::Study::StudyInvalidReference();
1311 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1312 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1313 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1315 return aParam._retn();
1318 //============================================================================
1319 /*! Function : GetCommonModuleParameters
1322 //============================================================================
1323 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1324 const char* theModuleName,
1325 CORBA::Long theSavePoint)
1327 SALOMEDS::Locker lock;
1330 throw SALOMEDS::Study::StudyInvalidReference();
1332 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1333 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1334 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1336 return aParam._retn();
1339 //============================================================================
1340 /*! Function : SetStudyLock
1343 //============================================================================
1344 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1346 SALOMEDS::Locker lock;
1349 throw SALOMEDS::Study::StudyInvalidReference();
1351 _impl->SetStudyLock(theLockerID);
1354 //============================================================================
1355 /*! Function : IsStudyLocked
1358 //============================================================================
1359 bool SALOMEDS_Study_i::IsStudyLocked()
1361 SALOMEDS::Locker lock;
1364 throw SALOMEDS::Study::StudyInvalidReference();
1366 return _impl->IsStudyLocked();
1369 //============================================================================
1370 /*! Function : UnLockStudy
1373 //============================================================================
1374 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1376 SALOMEDS::Locker lock;
1379 throw SALOMEDS::Study::StudyInvalidReference();
1381 _impl->UnLockStudy(theLockerID);
1384 //============================================================================
1385 /*! Function : GetLockerID
1388 //============================================================================
1389 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1391 SALOMEDS::Locker lock;
1394 throw SALOMEDS::Study::StudyInvalidReference();
1396 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1398 std::vector<std::string> aSeq = _impl->GetLockerID();
1400 int aLength = aSeq.size();
1401 aResult->length(aLength);
1402 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1403 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1406 return aResult._retn();
1408 //============================================================================
1409 /*! Function : SetReal
1412 //============================================================================
1413 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1416 throw SALOMEDS::Study::StudyInvalidReference();
1419 _impl->SetVariable(std::string(theVarName),
1421 SALOMEDSImpl_GenericVariable::REAL_VAR);
1423 _notifier->modifyNB_Notification(theVarName);
1426 //============================================================================
1427 /*! Function : SetInteger
1430 //============================================================================
1431 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1434 throw SALOMEDS::Study::StudyInvalidReference();
1436 _impl->SetVariable(std::string(theVarName),
1438 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1440 _notifier->modifyNB_Notification(theVarName);
1443 //============================================================================
1444 /*! Function : SetBoolean
1447 //============================================================================
1448 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1451 throw SALOMEDS::Study::StudyInvalidReference();
1453 _impl->SetVariable(std::string(theVarName),
1455 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1457 _notifier->modifyNB_Notification(theVarName);
1460 //============================================================================
1461 /*! Function : SetString
1464 //============================================================================
1465 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1468 throw SALOMEDS::Study::StudyInvalidReference();
1470 _impl->SetStringVariable(std::string(theVarName),
1472 SALOMEDSImpl_GenericVariable::STRING_VAR);
1474 _notifier->modifyNB_Notification(theVarName);
1477 //============================================================================
1478 /*! Function : SetStringAsDouble
1481 //============================================================================
1482 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1485 throw SALOMEDS::Study::StudyInvalidReference();
1487 _impl->SetStringVariableAsDouble(std::string(theVarName),
1489 SALOMEDSImpl_GenericVariable::STRING_VAR);
1492 //============================================================================
1493 /*! Function : GetReal
1496 //============================================================================
1497 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1500 throw SALOMEDS::Study::StudyInvalidReference();
1502 return _impl->GetVariableValue(std::string(theVarName));
1505 //============================================================================
1506 /*! Function : GetInteger
1509 //============================================================================
1510 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1513 throw SALOMEDS::Study::StudyInvalidReference();
1515 return (long)_impl->GetVariableValue(std::string(theVarName));
1518 //============================================================================
1519 /*! Function : GetBoolean
1522 //============================================================================
1523 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1526 throw SALOMEDS::Study::StudyInvalidReference();
1528 return (bool)_impl->GetVariableValue(std::string(theVarName));
1531 //============================================================================
1532 /*! Function : GetString
1535 //============================================================================
1536 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1539 throw SALOMEDS::Study::StudyInvalidReference();
1541 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1544 //============================================================================
1545 /*! Function : IsReal
1548 //============================================================================
1549 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1552 throw SALOMEDS::Study::StudyInvalidReference();
1554 return _impl->IsTypeOf(std::string(theVarName),
1555 SALOMEDSImpl_GenericVariable::REAL_VAR);
1558 //============================================================================
1559 /*! Function : IsInteger
1562 //============================================================================
1563 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1566 throw SALOMEDS::Study::StudyInvalidReference();
1568 return _impl->IsTypeOf(std::string(theVarName),
1569 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1572 //============================================================================
1573 /*! Function : IsBoolean
1576 //============================================================================
1577 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1580 throw SALOMEDS::Study::StudyInvalidReference();
1582 return _impl->IsTypeOf(std::string(theVarName),
1583 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1586 //============================================================================
1587 /*! Function : IsString
1590 //============================================================================
1591 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1594 throw SALOMEDS::Study::StudyInvalidReference();
1596 return _impl->IsTypeOf(std::string(theVarName),
1597 SALOMEDSImpl_GenericVariable::STRING_VAR);
1600 //============================================================================
1601 /*! Function : IsVariable
1604 //============================================================================
1605 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1608 throw SALOMEDS::Study::StudyInvalidReference();
1610 return _impl->IsVariable(std::string(theVarName));
1613 //============================================================================
1614 /*! Function : GetVariableNames
1617 //============================================================================
1618 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1621 throw SALOMEDS::Study::StudyInvalidReference();
1623 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1625 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1627 int aLen = aVarNames.size();
1628 aResult->length(aLen);
1629 for (int anInd = 0; anInd < aLen; anInd++)
1630 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1632 return aResult._retn();
1635 //============================================================================
1636 /*! Function : RemoveVariable
1639 //============================================================================
1640 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1643 throw SALOMEDS::Study::StudyInvalidReference();
1645 bool res = _impl->RemoveVariable(std::string(theVarName));
1646 if (res && _notifier)
1647 _notifier->modifyNB_Notification(theVarName);
1652 //============================================================================
1653 /*! Function : RenameVariable
1656 //============================================================================
1657 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1660 throw SALOMEDS::Study::StudyInvalidReference();
1662 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1663 if (res && _notifier)
1664 _notifier->modifyNB_Notification(theVarName);
1669 //============================================================================
1670 /*! Function : IsVariableUsed
1673 //============================================================================
1674 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1677 throw SALOMEDS::Study::StudyInvalidReference();
1679 return _impl->IsVariableUsed(std::string(theVarName));
1683 //============================================================================
1684 /*! Function : ParseVariables
1687 //============================================================================
1688 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1691 throw SALOMEDS::Study::StudyInvalidReference();
1693 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1695 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1697 int aSectionsLen = aSections.size();
1698 aResult->length(aSectionsLen);
1700 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1701 std::vector<std::string> aVarNames = aSections[aSectionInd];
1703 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1705 int aLen = aVarNames.size();
1706 aList->length(aLen);
1708 for (int anInd = 0; anInd < aLen; anInd++)
1709 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1711 aResult[aSectionInd] = aList;
1714 return aResult._retn();
1717 //============================================================================
1718 /*! Function : GetDefaultScript
1721 //============================================================================
1722 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1724 SALOMEDS::Locker lock;
1727 throw SALOMEDS::Study::StudyInvalidReference();
1729 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1730 return CORBA::string_dup(script.c_str());
1733 //============================================================================
1734 /*! Function : EnableUseCaseAutoFilling
1737 //============================================================================
1738 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1741 throw SALOMEDS::Study::StudyInvalidReference();
1743 _impl->EnableUseCaseAutoFilling(isEnabled);
1744 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1747 builder->SetOnAddSObject(_impl->GetCallback());
1748 builder->SetOnRemoveSObject(_impl->GetCallback());
1751 builder->SetOnAddSObject(NULL);
1752 builder->SetOnRemoveSObject(NULL);
1758 CORBA::Long SALOMEDS_Study_i::getPID()
1761 return (CORBA::Long)_getpid();
1763 return (CORBA::Long)getpid();
1767 void SALOMEDS_Study_i::ShutdownWithExit()
1769 exit( EXIT_SUCCESS );
1772 void SALOMEDS_Study_i::Shutdown()
1774 if(!CORBA::is_nil(_orb))
1778 //============================================================================
1779 /*! Function : attach
1780 * Purpose : This function attach an observer to the study
1782 //============================================================================
1783 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1786 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1790 //============================================================================
1791 /*! Function : detach
1792 * Purpose : This function detaches an observer from the study
1794 //============================================================================
1795 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1798 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1801 //===========================================================================
1802 // PRIVATE FUNCTIONS
1803 //===========================================================================
1804 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1807 long pid = (long)_getpid();
1809 long pid = (long)getpid();
1811 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1812 return reinterpret_cast<CORBA::LongLong>(_impl);
1815 void SALOMEDS_Study_i::NameChanged()
1817 // Notify GUI that the name of study was changed
1818 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1819 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1820 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1821 if ( !CORBA::is_nil(aSession) ) {
1822 std::stringstream ss;
1823 ss << "studyNameChanged";
1824 std::string str = ss.str();
1826 aSession->emitMessageOneWay(str.c_str());