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());
293 //============================================================================
295 * Purpose : Clear study components
297 //============================================================================
298 void SALOMEDS_Study_i::Clear()
300 SALOMEDS::Locker lock;
302 throw SALOMEDS::Study::StudyInvalidReference();
303 //delete the builder servant
304 PortableServer::POA_var poa=_builder->_default_POA();
305 PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
306 poa->deactivate_object(anObjectId.in());
307 _builder->_remove_ref();
311 if (_impl->GetDocument()) {
312 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
313 for (; itcomponent->More(); itcomponent->Next()) {
314 SALOMEDS::SComponent_var sco = itcomponent->Value();
315 CORBA::String_var compodatatype=sco->ComponentDataType();
316 MESSAGE ( "Look for an engine for data type :"<< compodatatype);
317 // if there is an associated Engine call its method for closing
318 CORBA::String_var IOREngine;
319 if (sco->ComponentIOR(IOREngine)) {
320 // we have found the associated engine to write the data
321 MESSAGE ( "We have found an engine for data type :"<< compodatatype);
322 //_narrow can throw a corba exception
324 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
325 if (!CORBA::is_nil(obj)) {
326 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
327 if (!anEngine->_is_nil()) {
329 anEngine->Close(sco);
334 catch (CORBA::Exception&) {
340 //Does not need any more this iterator
341 itcomponent->UnRegister();
344 // Notify GUI that study is cleared
345 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
346 CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
347 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
348 if ( !CORBA::is_nil(aSession) ) {
349 std::stringstream ss;
350 ss << "studyCleared";
351 std::string str = ss.str();
353 aSession->emitMessageOneWay(str.c_str());
358 _impl->setNotifier(0);
360 delete _genObjRegister;
365 //============================================================================
367 * Purpose : Open a Study from it's persistent reference
369 //============================================================================
370 bool SALOMEDS_Study_i::Open(const char* aUrl)
371 throw(SALOME::SALOME_Exception)
373 SALOMEDS::Locker lock;
375 Unexpect aCatch(SalomeException);
376 MESSAGE("Begin of SALOMEDS_Study_i::Open");
378 bool res = _impl->Open(std::string(aUrl));
380 // update desktop title with new study name
384 THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
388 //============================================================================
390 * Purpose : Save a Study to it's persistent reference
392 //============================================================================
393 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
395 SALOMEDS::Locker lock;
397 throw SALOMEDS::Study::StudyInvalidReference();
398 return _impl->Save(_factory, theMultiFile);
401 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
403 SALOMEDS::Locker lock;
405 throw SALOMEDS::Study::StudyInvalidReference();
406 return _impl->SaveASCII(_factory, theMultiFile);
409 //=============================================================================
410 /*! Function : SaveAs
411 * Purpose : Save a study to the persistent reference aUrl
413 //============================================================================
414 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
416 SALOMEDS::Locker lock;
418 throw SALOMEDS::Study::StudyInvalidReference();
419 return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
422 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
424 SALOMEDS::Locker lock;
426 throw SALOMEDS::Study::StudyInvalidReference();
427 return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
430 //============================================================================
431 /*! Function : CanCopy
434 //============================================================================
435 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
437 SALOMEDS::Locker lock;
439 throw SALOMEDS::Study::StudyInvalidReference();
441 CORBA::String_var anID = theObject->GetID();
442 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
444 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
445 bool ret = _impl->CanCopy(anObject, aDriver);
450 //============================================================================
454 //============================================================================
455 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
457 SALOMEDS::Locker lock;
459 throw SALOMEDS::Study::StudyInvalidReference();
461 CORBA::String_var anID = theObject->GetID();
462 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
464 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
465 bool ret = _impl->Copy(anObject, aDriver);
470 //============================================================================
471 /*! Function : CanPaste
474 //============================================================================
475 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
477 SALOMEDS::Locker lock;
479 throw SALOMEDS::Study::StudyInvalidReference();
481 CORBA::String_var anID = theObject->GetID();
482 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
484 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
485 bool ret = _impl->CanPaste(anObject, aDriver);
490 //============================================================================
494 //============================================================================
495 SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
496 throw(SALOMEDS::StudyBuilder::LockProtection)
498 SALOMEDS::Locker lock;
500 Unexpect aCatch(LockProtection);
502 CORBA::String_var anID = theObject->GetID();
503 SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
504 SALOMEDSImpl_SObject aNewSO;
507 SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
508 aNewSO = _impl->Paste(anObject, aDriver);
512 throw SALOMEDS::StudyBuilder::LockProtection();
515 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
519 SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
521 SALOMEDS_Driver_i* driver = NULL;
523 SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
525 std::string IOREngine = aSCO.GetIOR();
526 if(!IOREngine.empty()) {
527 CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
528 Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
529 driver = new SALOMEDS_Driver_i(Engine, orb);
536 //============================================================================
537 /*! Function : GetPersistentReference
538 * Purpose : Get persistent reference of study (idem URL())
540 //============================================================================
541 char* SALOMEDS_Study_i::GetPersistentReference()
543 SALOMEDS::Locker lock;
545 throw SALOMEDS::Study::StudyInvalidReference();
546 return CORBA::string_dup(_impl->GetPersistentReference().c_str());
548 //============================================================================
549 /*! Function : GetTransientReference
550 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
552 //============================================================================
553 char* SALOMEDS_Study_i::GetTransientReference()
555 SALOMEDS::Locker lock;
557 throw SALOMEDS::Study::StudyInvalidReference();
558 return CORBA::string_dup(_impl->GetTransientReference().c_str());
561 //============================================================================
562 /*! Function : IsEmpty
563 * Purpose : Detect if study is empty
565 //============================================================================
566 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
568 SALOMEDS::Locker lock;
570 throw SALOMEDS::Study::StudyInvalidReference();
571 return _impl->IsEmpty();
574 //============================================================================
575 /*! Function : FindComponent
576 * Purpose : Find a Component with ComponentDataType = aComponentName
578 //============================================================================
579 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
581 SALOMEDS::Locker lock;
584 throw SALOMEDS::Study::StudyInvalidReference();
586 SALOMEDS::SComponent_var sco;
588 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
589 if (!aCompImpl.IsNull())
590 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
595 //============================================================================
596 /*! Function : FindComponentID
597 * Purpose : Find a Component from it's ID
599 //============================================================================
600 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
602 SALOMEDS::Locker lock;
605 throw SALOMEDS::Study::StudyInvalidReference();
607 SALOMEDS::SComponent_var sco;
609 SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
610 if (!aCompImpl.IsNull())
611 sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
616 //============================================================================
617 /*! Function : FindObject
618 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
620 //============================================================================
621 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
623 SALOMEDS::Locker lock;
626 throw SALOMEDS::Study::StudyInvalidReference();
628 SALOMEDS::SObject_var so;
630 SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
632 if (aSO.IsComponent()) {
633 SALOMEDSImpl_SComponent aSCO = aSO;
634 so = SALOMEDS_SComponent_i::New(aSCO, _orb);
637 so = SALOMEDS_SObject_i::New(aSO, _orb);
644 //============================================================================
645 /*! Function : FindObjectID
646 * Purpose : Find an Object with ID = anObjectID
648 //============================================================================
649 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
651 SALOMEDS::Locker lock;
654 throw SALOMEDS::Study::StudyInvalidReference();
656 SALOMEDS::SObject_var so;
658 SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
660 so = SALOMEDS_SObject_i::New(aSO, _orb);
665 //============================================================================
666 /*! Function : CreateObjectID
667 * Purpose : Creates an Object with ID = anObjectID
669 //============================================================================
670 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
672 SALOMEDS::Locker lock;
675 throw SALOMEDS::Study::StudyInvalidReference();
677 SALOMEDS::SObject_var so;
679 if (anObjectID && strlen(anObjectID) > 0) {
680 SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
682 so = SALOMEDS_SObject_i::New(aSO, _orb);
688 //============================================================================
689 /*! Function : FindObjectByName
690 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
691 * : with ComponentDataType = aComponentName
693 //============================================================================
694 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
695 const char* aComponentName )
697 SALOMEDS::Locker lock;
700 throw SALOMEDS::Study::StudyInvalidReference();
702 std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
703 std::string((char*)aComponentName));
705 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
706 int aLength = aSeq.size();
707 listSO->length(aLength);
708 for (int i = 0; i < aLength; i++) {
709 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
713 return listSO._retn();
716 //============================================================================
717 /*! Function : FindObjectIOR
718 * Purpose : Find an Object with IOR = anObjectIOR
720 //============================================================================
721 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
723 SALOMEDS::Locker lock;
726 throw SALOMEDS::Study::StudyInvalidReference();
728 SALOMEDS::SObject_var so;
730 SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
732 so = SALOMEDS_SObject_i::New(aSO, _orb);
737 //============================================================================
738 /*! Function : FindObjectByPath
739 * Purpose : Find an Object by its path = thePath
741 //============================================================================
742 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
744 SALOMEDS::Locker lock;
747 throw SALOMEDS::Study::StudyInvalidReference();
749 SALOMEDS::SObject_var so;
751 SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
753 so = SALOMEDS_SObject_i::New (aSO, _orb);
758 //============================================================================
759 /*! Function : GetObjectPath
762 //============================================================================
763 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
765 SALOMEDS::Locker lock;
768 throw SALOMEDS::Study::StudyInvalidReference();
770 std::string aPath = "";
772 if (!CORBA::is_nil(theObject)) {
773 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
774 SALOMEDSImpl_SObject aSO;
776 if (!CORBA::is_nil(aSObj)) {
777 aSO = _impl->FindObjectID(aSObj->GetID());
780 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
784 aPath = _impl->GetObjectPath(aSO);
788 return CORBA::string_dup(aPath.c_str());
792 //============================================================================
793 /*! Function : SetContext
794 * Purpose : Sets the current context
796 //============================================================================
797 void SALOMEDS_Study_i::SetContext(const char* thePath)
799 SALOMEDS::Locker lock;
802 throw SALOMEDS::Study::StudyInvalidReference();
804 _impl->SetContext(std::string((char*)thePath));
805 if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
806 throw SALOMEDS::Study::StudyInvalidContext();
809 //============================================================================
810 /*! Function : GetContext
811 * Purpose : Gets the current context
813 //============================================================================
814 char* SALOMEDS_Study_i::GetContext()
816 SALOMEDS::Locker lock;
819 throw SALOMEDS::Study::StudyInvalidReference();
821 if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
823 return CORBA::string_dup(_impl->GetContext().c_str());
826 //============================================================================
827 /*! Function : GetObjectNames
828 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
830 //============================================================================
831 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
833 SALOMEDS::Locker lock;
836 throw SALOMEDS::Study::StudyInvalidReference();
838 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
840 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
841 throw SALOMEDS::Study::StudyInvalidContext();
843 std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
844 if (_impl->GetErrorCode() == "InvalidContext")
845 throw SALOMEDS::Study::StudyInvalidContext();
847 int aLength = aSeq.size();
848 aResult->length(aLength);
849 for (int anIndex = 0; anIndex < aLength; anIndex++) {
850 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
853 return aResult._retn();
856 //============================================================================
857 /*! Function : GetDirectoryNames
858 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
860 //============================================================================
861 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
863 SALOMEDS::Locker lock;
866 throw SALOMEDS::Study::StudyInvalidReference();
868 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
870 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
871 throw SALOMEDS::Study::StudyInvalidContext();
873 std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
874 if (_impl->GetErrorCode() == "InvalidContext")
875 throw SALOMEDS::Study::StudyInvalidContext();
877 int aLength = aSeq.size();
878 aResult->length(aLength);
879 for (int anIndex = 0; anIndex < aLength; anIndex++) {
880 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
883 return aResult._retn();
886 //============================================================================
887 /*! Function : GetFileNames
888 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
890 //============================================================================
891 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
893 SALOMEDS::Locker lock;
896 throw SALOMEDS::Study::StudyInvalidReference();
898 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
900 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
901 throw SALOMEDS::Study::StudyInvalidContext();
903 std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
904 if (_impl->GetErrorCode() == "InvalidContext")
905 throw SALOMEDS::Study::StudyInvalidContext();
907 int aLength = aSeq.size();
908 aResult->length(aLength);
909 for (int anIndex = 0; anIndex < aLength; anIndex++) {
910 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
913 return aResult._retn();
916 //============================================================================
917 /*! Function : GetComponentNames
918 * Purpose : method to get all components names
919 * SRN: Note, theContext can be any, it doesn't matter
921 //============================================================================
922 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
924 SALOMEDS::Locker lock;
927 throw SALOMEDS::Study::StudyInvalidReference();
929 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
931 std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
933 int aLength = aSeq.size();
934 aResult->length(aLength);
935 for(int anIndex = 0; anIndex < aLength; anIndex++) {
936 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
939 return aResult._retn();
942 //============================================================================
943 /*! Function : NewChildIterator
944 * Purpose : Create a ChildIterator from an SObject
946 //============================================================================
947 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
949 SALOMEDS::Locker lock;
952 throw SALOMEDS::Study::StudyInvalidReference();
954 CORBA::String_var anID = theSO->GetID();
955 SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
956 SALOMEDSImpl_ChildIterator anItr(aSO);
957 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
958 SALOMEDS::ChildIterator_var it = it_servant->_this();
964 //============================================================================
965 /*! Function : NewComponentIterator
966 * Purpose : Create a SComponentIterator
968 //============================================================================
969 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
971 SALOMEDS::Locker lock;
974 throw SALOMEDS::Study::StudyInvalidReference();
976 SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
978 SALOMEDS::SComponentIterator_var it = it_servant->_this();
984 //============================================================================
985 /*! Function : NewBuilder
986 * Purpose : Create a StudyBuilder
988 //============================================================================
989 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
991 SALOMEDS::Locker lock;
994 throw SALOMEDS::Study::StudyInvalidReference();
996 SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
1001 //============================================================================
1003 * Purpose : get study name
1005 //============================================================================
1006 char* SALOMEDS_Study_i::Name()
1008 SALOMEDS::Locker lock;
1009 // Name is specified as IDL attribute: user exception cannot be raised
1010 return CORBA::string_dup(_impl->Name().c_str());
1013 //============================================================================
1014 /*! Function : IsSaved
1015 * Purpose : get if study has been saved
1017 //============================================================================
1018 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
1020 SALOMEDS::Locker lock;
1021 // IsSaved is specified as IDL attribute: user exception cannot be raised
1022 return (!_closed) ? _impl->IsSaved() : false;
1025 //============================================================================
1026 /*! Function : IsSaved
1027 * Purpose : set if study has been saved
1029 //============================================================================
1030 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
1032 SALOMEDS::Locker lock;
1033 // IsSaved is specified as IDL attribute: user exception cannot be raised
1035 _impl->IsSaved(save);
1038 //============================================================================
1039 /*! Function : IsModified
1040 * Purpose : Detect if a Study has been modified since it has been saved
1042 //============================================================================
1043 CORBA::Boolean SALOMEDS_Study_i::IsModified()
1045 SALOMEDS::Locker lock;
1048 throw SALOMEDS::Study::StudyInvalidReference();
1050 return _impl->IsModified();
1053 //============================================================================
1054 /*! Function : Modified
1055 * Purpose : Sets a Modified flag of a Study to True
1057 //============================================================================
1058 void SALOMEDS_Study_i::Modified()
1060 SALOMEDS::Locker lock;
1063 throw SALOMEDS::Study::StudyInvalidReference();
1068 //============================================================================
1070 * Purpose : get URL of the study (persistent reference of the study)
1072 //============================================================================
1073 char* SALOMEDS_Study_i::URL()
1075 SALOMEDS::Locker lock;
1076 // URL is specified as IDL attribute: user exception cannot be raised
1077 return CORBA::string_dup(_impl->URL().c_str());
1080 //============================================================================
1082 * Purpose : set URL of the study (persistent reference of the study)
1084 //============================================================================
1085 void SALOMEDS_Study_i::URL(const char* url)
1087 SALOMEDS::Locker lock;
1088 // URL is specified as IDL attribute: user exception cannot be raised
1089 _impl->URL(std::string((char*)url));
1091 // update desktop title with new study name
1095 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry)
1097 SALOMEDS::Locker lock;
1100 throw SALOMEDS::Study::StudyInvalidReference();
1102 _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
1105 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb)
1107 SALOMEDS::Locker lock;
1109 SALOMEDSImpl_AttributeIOR* Att = NULL;
1110 if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
1111 char* IOR = CORBA::string_dup(Att->Value().c_str());
1112 CORBA::Object_var obj = orb->string_to_object(IOR);
1113 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
1114 ASSERT(!CORBA::is_nil(aStudy));
1115 return SALOMEDS::Study::_duplicate(aStudy);
1117 MESSAGE("GetStudy: Problem to get study");
1119 return SALOMEDS::Study::_nil();
1122 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
1124 SALOMEDS::Locker lock;
1125 SALOMEDSImpl_Study::IORUpdated(theAttribute);
1128 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
1130 SALOMEDS::Locker lock;
1133 throw SALOMEDS::Study::StudyInvalidReference();
1135 SALOMEDS::GenericAttribute_ptr aTarget;
1136 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
1137 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
1139 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
1145 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
1147 SALOMEDS::Locker lock;
1150 throw SALOMEDS::Study::StudyInvalidReference();
1152 SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
1153 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
1154 SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
1155 return aProp._retn();
1158 char* SALOMEDS_Study_i::GetLastModificationDate()
1160 SALOMEDS::Locker lock;
1163 throw SALOMEDS::Study::StudyInvalidReference();
1165 return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
1168 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
1170 SALOMEDS::Locker lock;
1173 throw SALOMEDS::Study::StudyInvalidReference();
1175 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
1177 std::vector<std::string> aSeq = _impl->GetModificationsDate();
1179 int aLength = aSeq.size();
1180 aDates->length(aLength);
1181 for (int anIndex = 0; anIndex < aLength; anIndex++) {
1182 aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1185 return aDates._retn();
1188 //============================================================================
1189 /*! Function : GetUseCaseBuilder
1190 * Purpose : Returns a UseCase builder
1192 //============================================================================
1193 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
1195 SALOMEDS::Locker lock;
1198 throw SALOMEDS::Study::StudyInvalidReference();
1200 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
1201 SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
1205 //============================================================================
1206 /*! Function : AddPostponed
1209 //============================================================================
1210 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
1212 SALOMEDS::Locker lock;
1216 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
1218 SALOMEDS::Locker lock;
1222 //============================================================================
1223 /*! Function : RemovePostponed
1226 //============================================================================
1227 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
1229 SALOMEDS::Locker lock;
1232 throw SALOMEDS::Study::StudyInvalidReference();
1234 std::vector<std::string> anIORs = _impl->GetIORs();
1235 int i, aSize = (int)anIORs.size();
1237 for (i = 0; i < aSize; i++) {
1239 CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
1240 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
1241 //rnv: To avoid double deletion of the Salome Generic Objects:
1242 //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
1243 //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
1244 //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
1251 //============================================================================
1252 /*! Function : UndoPostponed
1255 //============================================================================
1256 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
1258 SALOMEDS::Locker lock;
1263 //============================================================================
1264 /*! Function : DumpStudy
1267 //============================================================================
1268 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
1269 const char* theBaseName,
1270 CORBA::Boolean isPublished,
1271 CORBA::Boolean isMultiFile)
1273 SALOMEDS::Locker lock;
1276 throw SALOMEDS::Study::StudyInvalidReference();
1278 std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
1279 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
1280 bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
1286 //============================================================================
1287 /*! Function : GetCommonParameters
1290 //============================================================================
1291 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
1293 SALOMEDS::Locker lock;
1296 throw SALOMEDS::Study::StudyInvalidReference();
1298 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
1299 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1300 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1302 return aParam._retn();
1305 //============================================================================
1306 /*! Function : GetCommonModuleParameters
1309 //============================================================================
1310 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
1311 const char* theModuleName,
1312 CORBA::Long theSavePoint)
1314 SALOMEDS::Locker lock;
1317 throw SALOMEDS::Study::StudyInvalidReference();
1319 SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
1320 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
1321 SALOMEDS::AttributeParameter_var aParam = SP->_this();
1323 return aParam._retn();
1326 //============================================================================
1327 /*! Function : SetStudyLock
1330 //============================================================================
1331 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
1333 SALOMEDS::Locker lock;
1336 throw SALOMEDS::Study::StudyInvalidReference();
1338 _impl->SetStudyLock(theLockerID);
1341 //============================================================================
1342 /*! Function : IsStudyLocked
1345 //============================================================================
1346 bool SALOMEDS_Study_i::IsStudyLocked()
1348 SALOMEDS::Locker lock;
1351 throw SALOMEDS::Study::StudyInvalidReference();
1353 return _impl->IsStudyLocked();
1356 //============================================================================
1357 /*! Function : UnLockStudy
1360 //============================================================================
1361 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1363 SALOMEDS::Locker lock;
1366 throw SALOMEDS::Study::StudyInvalidReference();
1368 _impl->UnLockStudy(theLockerID);
1371 //============================================================================
1372 /*! Function : GetLockerID
1375 //============================================================================
1376 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1378 SALOMEDS::Locker lock;
1381 throw SALOMEDS::Study::StudyInvalidReference();
1383 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1385 std::vector<std::string> aSeq = _impl->GetLockerID();
1387 int aLength = aSeq.size();
1388 aResult->length(aLength);
1389 for(int anIndex = 0; anIndex < aLength; anIndex++) {
1390 aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1393 return aResult._retn();
1395 //============================================================================
1396 /*! Function : SetReal
1399 //============================================================================
1400 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1403 throw SALOMEDS::Study::StudyInvalidReference();
1406 _impl->SetVariable(std::string(theVarName),
1408 SALOMEDSImpl_GenericVariable::REAL_VAR);
1410 _notifier->modifyNB_Notification(theVarName);
1413 //============================================================================
1414 /*! Function : SetInteger
1417 //============================================================================
1418 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1421 throw SALOMEDS::Study::StudyInvalidReference();
1423 _impl->SetVariable(std::string(theVarName),
1425 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1427 _notifier->modifyNB_Notification(theVarName);
1430 //============================================================================
1431 /*! Function : SetBoolean
1434 //============================================================================
1435 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1438 throw SALOMEDS::Study::StudyInvalidReference();
1440 _impl->SetVariable(std::string(theVarName),
1442 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1444 _notifier->modifyNB_Notification(theVarName);
1447 //============================================================================
1448 /*! Function : SetString
1451 //============================================================================
1452 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1455 throw SALOMEDS::Study::StudyInvalidReference();
1457 _impl->SetStringVariable(std::string(theVarName),
1459 SALOMEDSImpl_GenericVariable::STRING_VAR);
1461 _notifier->modifyNB_Notification(theVarName);
1464 //============================================================================
1465 /*! Function : SetStringAsDouble
1468 //============================================================================
1469 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1472 throw SALOMEDS::Study::StudyInvalidReference();
1474 _impl->SetStringVariableAsDouble(std::string(theVarName),
1476 SALOMEDSImpl_GenericVariable::STRING_VAR);
1479 //============================================================================
1480 /*! Function : GetReal
1483 //============================================================================
1484 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1487 throw SALOMEDS::Study::StudyInvalidReference();
1489 return _impl->GetVariableValue(std::string(theVarName));
1492 //============================================================================
1493 /*! Function : GetInteger
1496 //============================================================================
1497 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1500 throw SALOMEDS::Study::StudyInvalidReference();
1502 return (long)_impl->GetVariableValue(std::string(theVarName));
1505 //============================================================================
1506 /*! Function : GetBoolean
1509 //============================================================================
1510 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1513 throw SALOMEDS::Study::StudyInvalidReference();
1515 return (bool)_impl->GetVariableValue(std::string(theVarName));
1518 //============================================================================
1519 /*! Function : GetString
1522 //============================================================================
1523 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1526 throw SALOMEDS::Study::StudyInvalidReference();
1528 return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1531 //============================================================================
1532 /*! Function : IsReal
1535 //============================================================================
1536 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1539 throw SALOMEDS::Study::StudyInvalidReference();
1541 return _impl->IsTypeOf(std::string(theVarName),
1542 SALOMEDSImpl_GenericVariable::REAL_VAR);
1545 //============================================================================
1546 /*! Function : IsInteger
1549 //============================================================================
1550 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1553 throw SALOMEDS::Study::StudyInvalidReference();
1555 return _impl->IsTypeOf(std::string(theVarName),
1556 SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1559 //============================================================================
1560 /*! Function : IsBoolean
1563 //============================================================================
1564 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1567 throw SALOMEDS::Study::StudyInvalidReference();
1569 return _impl->IsTypeOf(std::string(theVarName),
1570 SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1573 //============================================================================
1574 /*! Function : IsString
1577 //============================================================================
1578 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1581 throw SALOMEDS::Study::StudyInvalidReference();
1583 return _impl->IsTypeOf(std::string(theVarName),
1584 SALOMEDSImpl_GenericVariable::STRING_VAR);
1587 //============================================================================
1588 /*! Function : IsVariable
1591 //============================================================================
1592 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1595 throw SALOMEDS::Study::StudyInvalidReference();
1597 return _impl->IsVariable(std::string(theVarName));
1600 //============================================================================
1601 /*! Function : GetVariableNames
1604 //============================================================================
1605 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1608 throw SALOMEDS::Study::StudyInvalidReference();
1610 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1612 std::vector<std::string> aVarNames = _impl->GetVariableNames();
1614 int aLen = aVarNames.size();
1615 aResult->length(aLen);
1616 for (int anInd = 0; anInd < aLen; anInd++)
1617 aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1619 return aResult._retn();
1622 //============================================================================
1623 /*! Function : RemoveVariable
1626 //============================================================================
1627 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1630 throw SALOMEDS::Study::StudyInvalidReference();
1632 bool res = _impl->RemoveVariable(std::string(theVarName));
1633 if (res && _notifier)
1634 _notifier->modifyNB_Notification(theVarName);
1639 //============================================================================
1640 /*! Function : RenameVariable
1643 //============================================================================
1644 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1647 throw SALOMEDS::Study::StudyInvalidReference();
1649 bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1650 if (res && _notifier)
1651 _notifier->modifyNB_Notification(theVarName);
1656 //============================================================================
1657 /*! Function : IsVariableUsed
1660 //============================================================================
1661 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1664 throw SALOMEDS::Study::StudyInvalidReference();
1666 return _impl->IsVariableUsed(std::string(theVarName));
1670 //============================================================================
1671 /*! Function : ParseVariables
1674 //============================================================================
1675 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1678 throw SALOMEDS::Study::StudyInvalidReference();
1680 SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1682 std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1684 int aSectionsLen = aSections.size();
1685 aResult->length(aSectionsLen);
1687 for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1688 std::vector<std::string> aVarNames = aSections[aSectionInd];
1690 SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1692 int aLen = aVarNames.size();
1693 aList->length(aLen);
1695 for (int anInd = 0; anInd < aLen; anInd++)
1696 aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1698 aResult[aSectionInd] = aList;
1701 return aResult._retn();
1704 //============================================================================
1705 /*! Function : GetDefaultScript
1708 //============================================================================
1709 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1711 SALOMEDS::Locker lock;
1714 throw SALOMEDS::Study::StudyInvalidReference();
1716 std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1717 return CORBA::string_dup(script.c_str());
1720 //============================================================================
1721 /*! Function : EnableUseCaseAutoFilling
1724 //============================================================================
1725 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
1728 throw SALOMEDS::Study::StudyInvalidReference();
1730 _impl->EnableUseCaseAutoFilling(isEnabled);
1731 SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1734 builder->SetOnAddSObject(_impl->GetCallback());
1735 builder->SetOnRemoveSObject(_impl->GetCallback());
1738 builder->SetOnAddSObject(NULL);
1739 builder->SetOnRemoveSObject(NULL);
1745 CORBA::Long SALOMEDS_Study_i::getPID()
1748 return (CORBA::Long)_getpid();
1750 return (CORBA::Long)getpid();
1754 void SALOMEDS_Study_i::ShutdownWithExit()
1756 exit( EXIT_SUCCESS );
1759 void SALOMEDS_Study_i::Shutdown()
1761 if(!CORBA::is_nil(_orb))
1765 //============================================================================
1766 /*! Function : attach
1767 * Purpose : This function attach an observer to the study
1769 //============================================================================
1770 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
1773 static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
1777 //============================================================================
1778 /*! Function : detach
1779 * Purpose : This function detaches an observer from the study
1781 //============================================================================
1782 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
1785 static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
1788 //===========================================================================
1789 // PRIVATE FUNCTIONS
1790 //===========================================================================
1791 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1794 long pid = (long)_getpid();
1796 long pid = (long)getpid();
1798 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1799 return reinterpret_cast<CORBA::LongLong>(_impl);
1802 void SALOMEDS_Study_i::NameChanged()
1804 // Notify GUI that the name of study was changed
1805 SALOME_NamingService *aNamingService = KERNEL::getNamingService();
1806 CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
1807 SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
1808 if ( !CORBA::is_nil(aSession) ) {
1809 std::stringstream ss;
1810 ss << "studyNameChanged";
1811 std::string str = ss.str();
1813 aSession->emitMessageOneWay(str.c_str());