]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
forbid several simultaneously active studies in the same session, in study creation...
authorPaul RASCLE <paul.rascle@edf.fr>
Sat, 12 Apr 2014 15:17:09 +0000 (17:17 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Sat, 12 Apr 2014 15:17:09 +0000 (17:17 +0200)
idl/SALOMEDS.idl
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx

index d911ea1ad4516ef3c2324c738025ec2131d866d7..2fcb127bc0dbc4a06cce2b75f69d7f7ba45409d2 100644 (file)
@@ -929,7 +929,7 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
 <em>See \ref example17 for an example of this method usage in batchmode of %SALOME application.</em>
 
 */
-    Study NewStudy(in string study_name);
+    Study NewStudy(in string study_name) raises (SALOME::SALOME_Exception);
 
 /*! \brief Open a study
 
index 64af49fbd0a2090ffcc3138c2dc9e626c0ebfc47..ae55ffd06a5577b80eae058bc01782bf583ac1d9 100644 (file)
@@ -112,9 +112,21 @@ void SALOMEDS_StudyManager_i::register_name(const char * name)
  */
 //============================================================================
 SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name)
+     throw(SALOME::SALOME_Exception)
 {
   SALOMEDS::Locker lock;
 
+#ifndef ALLOW_MULTI_STUDIES
+  std::vector<SALOMEDSImpl_Study*> anOpened = _impl->GetOpenStudies();
+  int aLength = anOpened.size();
+
+  if(aLength)
+    {
+      MESSAGE("There is already an active study in this session. Launch a new session, or close the study");
+      THROW_SALOME_CORBA_EXCEPTION("Problem on New Study.\nThere is already an active study in this session.\nLaunch a new session, or close the study", SALOME::BAD_PARAM)
+    }
+#endif // !ALLOW_MULTI_STUDIES
+
   SALOMEDSImpl_Study* aStudyImpl = _impl->NewStudy(study_name);
   if(!aStudyImpl) {
     MESSAGE("NewStudy : Error : " << _impl->GetErrorCode());
@@ -157,6 +169,17 @@ SALOMEDS::Study_ptr  SALOMEDS_StudyManager_i::Open(const char* aUrl)
   Unexpect aCatch(SalomeException);
   MESSAGE("Begin of SALOMEDS_StudyManager_i::Open");
 
+  #ifndef ALLOW_MULTI_STUDIES
+  std::vector<SALOMEDSImpl_Study*> anOpened = _impl->GetOpenStudies();
+  int aLength = anOpened.size();
+
+  if(aLength)
+    {
+      MESSAGE("There is already an active study in this session. Launch a new session, or close the study.");
+      THROW_SALOME_CORBA_EXCEPTION("Problem on Open Study.\nThere is already an active study in this session.\nLaunch a new session, or close the study.", SALOME::BAD_PARAM)
+    }
+#endif // ;ALLOW_MULTI_STUDIES
+
   SALOMEDSImpl_Study* aStudyImpl = _impl->Open(std::string(aUrl));
 
   if ( !aStudyImpl )
index 0e0748c507274d92b9e19eb14de99ec734a86ee3..c323ef747188d7ad282953a34e8d7030fe81519e 100644 (file)
@@ -82,7 +82,7 @@ public:
     \param char* arguments, the new study name
     \return Study_ptr arguments
   */  
-  virtual SALOMEDS::Study_ptr NewStudy(const char* study_name);
+  virtual SALOMEDS::Study_ptr NewStudy(const char* study_name) throw (SALOME::SALOME_Exception);
 
   //! method to Open a Study from it's persistent reference
   /*!