Salome HOME
Merge branch 'agy/ParallelContainerLaunch'
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 6 Oct 2014 15:28:26 +0000 (17:28 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 6 Oct 2014 15:28:26 +0000 (17:28 +0200)
31 files changed:
CMakeLists.txt
bin/appliskel/tests/concurrentSession/TestConcurrentSession.py
bin/appliskel/tests/launcher/TestLauncherSessionArgs.py
bin/appliskel/tests/launcher/getLogger.py
bin/launchConfigureParser.py
bin/parseConfigFile.py
bin/runConsole.py
bin/runSalome.py
bin/runSession.py
bin/salomeContext.py
bin/salomeContextUtils.py.in
bin/salome_session.py
doc/salome/salome_command.dox
idl/SALOMEDS.idl
salome_adm/cmake_files/FindSalomeSphinx.cmake
salome_adm/cmake_files/FindSphinx.cmake
salome_adm/cmake_files/deprecated/am2cmake.py
src/Container/SALOME_ComponentPy.py
src/KERNEL_PY/__init__.py
src/KERNEL_PY/kernel/diclookup.py
src/KERNEL_PY/kernel/parametric/study_exchange_vars.py
src/KERNEL_PY/kernel/syshelper.py
src/KERNEL_PY/salome_ComponentGUI.py
src/KERNEL_PY/salome_kernel.py
src/KERNEL_PY/salome_study.py
src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py
src/SALOMEDS/CMakeLists.txt
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/Utils/Utils_ORB_INIT.cxx
src/Utils/Utils_ORB_INIT.hxx

index 91c7aaefda62e83456624747ffd4bb927c2ac9e2..26de8514e12eee1d9dca2ed4693617f02fff94c6 100755 (executable)
@@ -31,10 +31,10 @@ STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
 
 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
 SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
-SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 # Our own set of macros:
 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/salome_adm/cmake_files")
index aab1777af46e7363f2ad8b167508f7f047904848..1bc310ccc3983411eff9dc9fc62eec89415a417b 100644 (file)
@@ -42,7 +42,9 @@ class TestConcurrentLaunch(unittest.TestCase):
   def tearDown(self):
     pass
   #
-  def appli(self, args=[]):
+  def appli(self, args=None):
+    if args is None:
+      args = []
     try:
       self.SALOME.main(self.SALOME_appli_args + args)
     except SystemExit, e:
@@ -50,7 +52,9 @@ class TestConcurrentLaunch(unittest.TestCase):
         logging.error(e)
       pass
   #
-  def session(self, args=[]):
+  def session(self, args=None):
+    if args is None:
+      args = []
     try:
       self.SALOME.main(self.SALOME_shell_args + args)
     except SystemExit, e:
index 20445e9df9a9e2b74cede9ed59863e6946e5485b..f3987f18b4ef8b28ef90c2658b6a9991e1801e4f 100644 (file)
@@ -67,7 +67,9 @@ class TestSessionArgs(unittest.TestCase):
   def tearDown(self):
     self.removeLogFile()
   #
-  def session(self, args=[]):
+  def session(self, args=None):
+    if args is None:
+      args = []
     try:
       self.SALOME.main(self.SALOME_args + args)
     except SystemExit, e:
index 8e952ebf52b42b1829ea24730fb9e6cff34467da..4d45dc3f13b01b97ca90b5a151a1759e81d6539b 100644 (file)
@@ -21,7 +21,9 @@ import os
 import sys
 import logging
 
-def getLogger(args=[]):
+def getLogger(args=None):
+  if args is None:
+    args = []
   outfileOptionPrefix = "outfile="
   outfileArgs = [ str(x) for x in args if str(x).startswith(outfileOptionPrefix) ]
   allFiles = [ x.replace(outfileOptionPrefix, '') for x in outfileArgs ]
index cfb247f619dcbfef936d53549b6061ca2a5d0519..77df1a60d64b7f23e1ca8b8c807676a90db49e6d 100755 (executable)
@@ -483,7 +483,9 @@ def store_boolean (option, opt, value, parser, *args):
         for attribute in args:
             setattr(parser.values, attribute, value)
 
-def CreateOptionParser (theAdditionalOptions=[]):
+def CreateOptionParser (theAdditionalOptions=None):
+    if theAdditionalOptions is None:
+        theAdditionalOptions = []
     # GUI/Terminal. Default: GUI
     help_str = "Launch without GUI (in the terminal mode)."
     o_t = optparse.Option("-t",
@@ -871,7 +873,7 @@ Python file arguments, if any, must be comma-separated (without blank characters
 args = {}
 #def get_env():
 #args = []
-def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgname):
+def get_env(theAdditionalOptions=None, appname=salomeappname, cfgname=salomecfgname):
     ###
     # Collect launch configuration files:
     # - The environment variable "<appname>Config" (SalomeAppConfig) which can
@@ -894,6 +896,9 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam
     #   specified in configuration file(s)
     ###
 
+    if theAdditionalOptions is None:
+        theAdditionalOptions = []
+
     global args
     config_var = appname+'Config'
 
@@ -902,15 +907,13 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam
         separator = ";"
 
     # check KERNEL_ROOT_DIR
-    try:
-        kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
-    except:
+    kernel_root_dir = os.environ.get("KERNEL_ROOT_DIR", None)
+    if kernel_root_dir is None:
         print """
         For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set.
         KERNEL_ROOT_DIR is mandatory.
         """
         sys.exit(1)
-        pass
 
     ############################
     # parse command line options
@@ -1000,15 +1003,15 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam
     # set default values for options which are NOT set in config files
     for aKey in listKeys:
         if not args.has_key( aKey ):
-            args[aKey]=[]
+            args[aKey] = []
 
     for aKey in boolKeys:
         if not args.has_key( aKey ):
-            args[aKey]=0
+            args[aKey] = 0
 
     if args[file_nam]:
         afile=args[file_nam]
-        args[file_nam]=[afile]
+        args[file_nam] = [afile]
 
     args[appname_nam] = appname
 
index 3054ed1f341eeb2154d3280befda32627afe1970..2f2bbb2ead9cf4998129338d3600b2bcb9c2d6f1 100644 (file)
@@ -163,7 +163,9 @@ class MultiOptSafeConfigParser(ConfigParser.SafeConfigParser):
 # Input: filename, and a list of reserved keywords (environment variables)
 # Output: a list of pairs (variable, value), and a dictionary associating a list of user-defined values to each reserved keywords
 # Note: Does not support duplicate keys in a same section
-def parseConfigFile(filename, reserved = []):
+def parseConfigFile(filename, reserved = None):
+  if reserved is None:
+    reserved = []
   config = MultiOptSafeConfigParser()
   config.optionxform = str # case sensitive
 
@@ -183,10 +185,12 @@ def parseConfigFile(filename, reserved = []):
     raise SalomeContextException(msg)
 #
 
-def __processConfigFile(config, reserved = [], filename="UNKNOWN FILENAME"):
+def __processConfigFile(config, reserved = None, filename="UNKNOWN FILENAME"):
   # :TODO: may detect duplicated variables in the same section (raise a warning)
   #        or even duplicate sections
 
+  if reserved is None:
+    reserved = []
   unsetVariables = []
   outputVariables = []
   # Get raw items for each section, and make some processing for environment variables management
@@ -245,12 +249,14 @@ def _trimColons(var):
 #    - virtually add a section to configuration file
 #    - process shell keywords (if, then...)
 class EnvFileConverter(object):
-  def __init__(self, fp, section_name, reserved = [], outputFile=None):
+  def __init__(self, fp, section_name, reserved = None, outputFile=None):
+    if reserved is None:
+      reserved = []
     self.fp = fp
     self.sechead = '[' + section_name + ']\n'
     self.reserved = reserved
     self.outputFile = outputFile
-    self.allParsedVariableNames=[]
+    self.allParsedVariableNames = []
     # exclude line that begin with:
     self.exclude = [ 'if', 'then', 'else', 'fi', '#', 'echo', 'exit' ]
     self.exclude.append('$gconfTool') # QUICK FIX :TODO: provide method to extend this variable
@@ -371,7 +377,9 @@ class EnvFileConverter(object):
   #
 
 # Convert .sh environment file to configuration file format
-def convertEnvFileToConfigFile(envFilename, configFilename, reserved=[]):
+def convertEnvFileToConfigFile(envFilename, configFilename, reserved=None):
+  if reserved is None:
+    reserved = []
   logConfigParser.debug('convert env file %s to %s'%(envFilename, configFilename))
   fileContents = open(envFilename, 'r').read()
 
index fdaba6ce5abbf6e4d96288d9f9d2471708004f11..57c54d0ed367c8a1c59b7c56ed04e793427fb613 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-def __prompt(environment = None, commands=[], message = "Connecting to SALOME"):
+def __prompt(environment = None, commands=None, message = "Connecting to SALOME"):
   if environment is None:
     environment = globals().copy()
     environment.update(locals())
+  if commands is None:
+    commands = []
 
   import code
   import rlcompleter
@@ -38,7 +40,9 @@ def __prompt(environment = None, commands=[], message = "Connecting to SALOME"):
   return shell.interact
 #
 
-def connect(args=[]):
+def connect(args=None):
+  if args is None:
+    args = []
   p = __prompt(commands=["import salomeConsole"])
   p()
 #
index c819b857c8513c044d2a650d8e4e63e69cbf26d6..f66b12939db0978ef6d421c82984cd02abe28040 100755 (executable)
@@ -738,11 +738,15 @@ def useSalome(args, modules_list, modules_root_dir):
 
         # run python scripts, passed as command line arguments
         toimport = []
-        if args.has_key('pyscript'):
-            if args.has_key('gui') and args.has_key('session_gui'):
-                if not args['gui'] or not args['session_gui']:
+        if args.has_key('gui') and args.has_key('session_gui'):
+            if not args['gui'] or not args['session_gui']:
+                if args.has_key('study_hdf'):
+                    toopen = args['study_hdf']
+                    if toopen:
+                        import salome
+                        salome.salome_init(toopen)
+                if args.has_key('pyscript'):
                     toimport = args['pyscript']
-
         from salomeContextUtils import formatScriptsAndArgs
         command = formatScriptsAndArgs(toimport)
         if command:
index 92c6b4705936450753b0c0c2375419ef5687f477..f698e323d252914a436b0cbc298a2c3cbb9d49b8 100644 (file)
@@ -34,7 +34,9 @@ class MyParser(OptionParser):
         return self.epilog
 #
 
-def configureSession(args=[]):
+def configureSession(args=None):
+  if args is None:
+    args = []
   usage = "Usage: %prog [options] [command]"
   epilog  = """\n
 If the command is not given a shell is opened; else execute the given command.
index f4eb21508eb2fbfed0d8be11c1ff1644b98b796b..00de96345629011071517ea9ef43a30ef26091ad 100644 (file)
@@ -69,11 +69,11 @@ class SalomeContext:
   the SalomeContext class will try to automatically convert them
   to .cfg format before setting the environment.
   """
-  def __init__(self, configFileNames=[]):
+  def __init__(self, configFileNames=0):
     #it could be None explicitely (if user use multiples setVariable...for standalone)
-    if configFileNames==None:
+    if configFileNames is None:
        return
-
+    configFileNames = configFileNames or []
     if len(configFileNames) == 0:
       raise SalomeContextException("No configuration files given")
 
@@ -231,7 +231,9 @@ class SalomeContext:
       sys.exit(1)
   #
 
-  def __setEnvironmentFromConfigFile(self, filename, reserved=[]):
+  def __setEnvironmentFromConfigFile(self, filename, reserved=None):
+    if reserved is None:
+      reserved = []
     try:
       unsetVars, configVars, reservedDict = parseConfigFile(filename, reserved)
     except SalomeContextException, e:
@@ -277,7 +279,9 @@ class SalomeContext:
     sys.path[:0] = os.getenv('PYTHONPATH','').split(':')
   #
 
-  def _runAppli(self, args=[]):
+  def _runAppli(self, args=None):
+    if args is None:
+      args = []
     # Initialize SALOME environment
     sys.argv = ['runSalome'] + args
     import setenv
@@ -287,7 +291,9 @@ class SalomeContext:
     runSalome.runSalome()
   #
 
-  def _runSession(self, args=[]):
+  def _runSession(self, args=None):
+    if args is None:
+      args = []
     sys.argv = ['runSession'] + args
     import runSession
     runSession.configureSession(args)
@@ -300,7 +306,9 @@ class SalomeContext:
     return runSession.runSession(command)
   #
 
-  def _runConsole(self, args=[]):
+  def _runConsole(self, args=None):
+    if args is None:
+      args = []
     # Initialize SALOME environment
     sys.argv = ['runConsole'] + args
     import setenv
@@ -311,7 +319,9 @@ class SalomeContext:
     return proc.communicate()
   #
 
-  def _killAll(self, args=[]):
+  def _killAll(self, args=None):
+    if args is None:
+      args = []
     try:
       import PortManager # mandatory
       from multiprocessing import Process
@@ -332,16 +342,16 @@ class SalomeContext:
 
   #
 
-  def _showInfo(self, args=[]):
+  def _showInfo(self, args=None):
     print "Running with python", platform.python_version()
     self._runAppli(["--version"])
   #
 
-  def _usage(self, unused=[]):
+  def _usage(self, unused=None):
     usage()
   #
 
-  def _makeCoffee(self, args=[]):
+  def _makeCoffee(self, args=None):
     print "                        ("
     print "                          )     ("
     print "                   ___...(-------)-....___"
@@ -388,7 +398,6 @@ class SalomeContext:
     return self._logger
   #
 
-import pickle
 if __name__ == "__main__":
   if len(sys.argv) == 3:
     context = pickle.loads(sys.argv[1])
index 3f517dcf73b3c154d03c8d0dc99170cce3e16ac0..6e6a8fe0ae3af54fbab910b535a156c137ce4933 100644 (file)
@@ -102,7 +102,9 @@ def __getScriptPath(scriptName, searchPathList):
 #
 
 # Return an array of dictionaries {script_name: [list_of_its_args]}
-def getScriptsAndArgs(args=[], searchPathList=None):
+def getScriptsAndArgs(args=None, searchPathList=None):
+  if args is None:
+    args = []
   if searchPathList is None:
     searchPathList = sys.path
 
@@ -175,7 +177,9 @@ def getScriptsAndArgs(args=[], searchPathList=None):
 
 # Formatting scripts and args as a Bash-like command-line:
 # script1.py [args] ; script2.py [args] ; ...
-def formatScriptsAndArgs(scriptArgs=[]):
+def formatScriptsAndArgs(scriptArgs=None):
+    if scriptArgs is None:
+      scriptArgs = []
     commands = []
     for sc_dict in scriptArgs:
       for script, sc_args in sc_dict.items(): # single entry
index d7d79639c2aa57d924113cff0a12812a9e24c4c1..e9f3b088b26bc37a57d05e5a215949a54ce9557f 100644 (file)
@@ -33,7 +33,9 @@ import socket
 
 _session = None
 
-def startSession(modules=[]):
+def startSession(modules=None):
+    if modules is None:
+        modules = []
     global _session
     if _session: return
     from searchFreePort import searchFreePort
index e4c924d540b6eec0e527cbca33f4171a784833ec..dd52d38fd2b5a015985d03e0bfcdd8c66d850a2a 100644 (file)
@@ -118,7 +118,7 @@ except SystemExit, e:
 \section salome_api The API
 An API named \c SalomeContext, written in Python, allows for the construction of SALOME execution context and for application start. Each launcher creates a \c SalomeContext object, and optionally gives it a list of configuration files to describe the context:
 \code
-SalomeContext.__init__(configFileNames=[])
+SalomeContext.__init__(configFileNames=None)
 \endcode
 
 A launcher can also directly call the API functions to define, suppress or extend (add information) an environment variable:
index 2fcb127bc0dbc4a06cce2b75f69d7f7ba45409d2..9bf7b9ccfea6a843b909c438eae420f4582b38c3 100644 (file)
@@ -125,6 +125,8 @@ during each working session.
   interface Study
   {
 
+//! Invalid study reference
+    exception StudyInvalidReference {};
 //! Invalid study context
     exception StudyInvalidContext {};
 //! Invalid study component
@@ -153,15 +155,15 @@ during each working session.
 //! Sequence containing %SObjects
     typedef sequence<SObject> ListOfSObject;
 //!  Get the persistent reference to the %Study.
-    PersistentReference  GetPersistentReference();
+    PersistentReference  GetPersistentReference() raises(StudyInvalidReference);
 //! Get a transient reference to the %Study.
-    SalomeReference      GetTransientReference();
+    SalomeReference      GetTransientReference() raises(StudyInvalidReference);
 
 /*! \brief indicate whether the %Study is empty
 
     \return True if the %Study is empty
 */
-    boolean IsEmpty();
+    boolean IsEmpty() raises(StudyInvalidReference);
 /*! \brief  Find a %SComponent by its name.
 
    \param aComponentName    It's a string value in the Comment Attribute of the Component,
@@ -170,11 +172,11 @@ during each working session.
 <em>See \ref example1 for an example of this method usage in batchmode of %SALOME application.</em>
 
 */
-    SComponent FindComponent  (in string aComponentName);
+    SComponent FindComponent  (in string aComponentName) raises(StudyInvalidReference);
 
 /*! \brief  Find a %SComponent by ID of the according %SObject
 */
-    SComponent FindComponentID(in ID aComponentID);
+    SComponent FindComponentID(in ID aComponentID) raises(StudyInvalidReference);
 /*! \brief  Find a %SObject by the Name Attribute of this %SObject
 
     \param anObjectName String parameter defining the name of the object
@@ -182,40 +184,40 @@ during each working session.
 
 <em>See \ref example19 for an example of this method usage in batchmode of %SALOME application.</em>
 */
-    SObject       FindObject      (in string anObjectName);
+    SObject       FindObject      (in string anObjectName) raises(StudyInvalidReference);
 /*! \brief  Find a %SObject by its ID
 
     \param aObjectID This parameter defines the ID of the required object
     \return The obtained %SObject
 */
-    SObject       FindObjectID    (in ID aObjectID);
+    SObject       FindObjectID    (in ID aObjectID) raises(StudyInvalidReference);
 /*! \brief Create a %SObject by its ID
 
     \param aObjectID This parameter defines the ID of the required object
     \return The created %SObject
 */
-    SObject       CreateObjectID    (in ID aObjectID);
+    SObject       CreateObjectID    (in ID aObjectID) raises(StudyInvalidReference);
 /*!  \brief Find a %SObject by IOR of the object belonging to this %SObject.
 
     \param anObjectName This parameter defines the IOR of the object
     \return The obtained %SObject
 */
-    SObject       FindObjectIOR   (in ID aObjectIOR);
+    SObject       FindObjectIOR   (in ID aObjectIOR) raises(StudyInvalidReference);
 /*! \brief  Find in the study all %SObjects produced by a given %Component.
 
     \param anObjectName The Name Attribute of the searched %SObjects should correspond to <VAR>anObjectName</VAR>.
     \param aComponentName The name of the component, which objects are searched for.
 */
-    ListOfSObject FindObjectByName(in string anObjectName, in string aComponentName);
+    ListOfSObject FindObjectByName(in string anObjectName, in string aComponentName) raises(StudyInvalidReference);
 /*! \brief  Find a %SObject by the path to it.
 
     \param thePath The path to the required %SObject.
     \return The obtained %SObject.
 */
-    SObject FindObjectByPath(in string thePath);
+    SObject FindObjectByPath(in string thePath) raises(StudyInvalidReference);
 /*! \brief Get the path to the %SObject.
 */
-    string  GetObjectPath(in Object theObject);
+    string GetObjectPath(in Object theObject) raises(StudyInvalidReference);
 
 /*! \brief  Set the context of the %Study.
 
@@ -223,44 +225,44 @@ during each working session.
 
 <em>See \ref example23 for an example of this method usage in batchmode of %SALOME application.</em>
 */
-    void SetContext(in string thePath);
+    void SetContext(in string thePath) raises (StudyInvalidReference, StudyInvalidContext);
 /*!  \brief Get the context of the %Study.
     
 <em>See \ref example23 for an example of this method usage in batchmode of %SALOME application.</em>
 */
-    string GetContext();
+    string GetContext() raises (StudyInvalidReference, StudyInvalidContext);
 /*!  \brief Get a list of names of objects corresponding to the context.
 
    \note  If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
 */
-    ListOfStrings GetObjectNames(in string theContext);
+    ListOfStrings GetObjectNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
 /*! \brief Get a list of names of directories and subdirectories corresponding to the context.
 
    \note  If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
 */
-    ListOfStrings GetDirectoryNames(in string theContext);
+    ListOfStrings GetDirectoryNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
 /*! \brief  Get a list of names of Files corresponding to the context.
 
     \note  If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
 */
-    ListOfStrings GetFileNames(in string theContext);
+    ListOfStrings GetFileNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
 /*! \brief Get a list of names of Components corresponding to the context.
 
    \note  If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
 */
-    ListOfStrings GetComponentNames(in string theContext);
+    ListOfStrings GetComponentNames(in string theContext) raises(StudyInvalidReference);
 /*!  \brief Create a new iterator of child levels of the given %SObject.
 
     \param aSO The given %SObject
     \return A new iterator of child levels of the given %SObject.
 */
-    ChildIterator      NewChildIterator(in SObject aSO);
+    ChildIterator NewChildIterator(in SObject aSO) raises(StudyInvalidReference);
 
 /*!  \brief Create a new iterator of the %SComponents.
 
     \return A new iterator of the %SComponents.
 */
-    SComponentIterator NewComponentIterator();
+    SComponentIterator NewComponentIterator() raises(StudyInvalidReference);
 
 /*! \brief  Create a new %StudyBuilder to add or modify an object in the study.
 
@@ -268,12 +270,12 @@ during each working session.
 
 <em>See \ref example20 for an example of this method usage in batchmode of %SALOME application.</em>
 */
-    StudyBuilder NewBuilder() ;
+    StudyBuilder NewBuilder() raises(StudyInvalidReference);
 /*! \brief Labels dependency
 
     Updates the map with IOR attribute. It's an inner method used for optimization.
 */
-    void UpdateIORLabelMap(in string anIOR, in string anEntry);
+    void UpdateIORLabelMap(in string anIOR, in string anEntry) raises(StudyInvalidReference);
 
 /*! \brief Getting properties of the study
 
@@ -282,7 +284,7 @@ during each working session.
 <em>See \ref example20 for an example of this method usage in batchmode of %SALOME application.</em>
 
 */
-    AttributeStudyProperties GetProperties();
+    AttributeStudyProperties GetProperties() raises(StudyInvalidReference);
 /*! \brief  Indicate whether the %study has been saved
 */
     attribute boolean IsSaved;
@@ -290,33 +292,33 @@ during each working session.
 
   Returns True if the %study has been modified and not saved.
 */
-    boolean IsModified();
+    boolean IsModified() raises(StudyInvalidReference);
 
 /*! \brief  Mark the %study as being modified and not saved.
 */
-    void Modified();
+    void Modified() raises(StudyInvalidReference);
 
 /*! \brief  Indicate the file where the %study has been saved
 */
-    attribute string  URL;
+    attribute string URL;
 
 /*! \brief List of %SObjects
 
     Returns the list of %SObjects which refers to %anObject.
 */
-    ListOfSObject FindDependances(in SObject anObject);
+    ListOfSObject FindDependances(in SObject anObject) raises(StudyInvalidReference);
 
 /*! \brief The date of the last saving of the study
 
     Returns the date of the last saving of study with format: "DD/MM/YYYY HH:MM"
 */
-    string GetLastModificationDate();
+    string GetLastModificationDate() raises(StudyInvalidReference);
 /*! \brief The list of modification dates of the study
 
     Returns the list of modification dates (without creation date) with format "DD/MM/YYYY HH:MM".
       Note : the first modification begins the list.
 */
-    ListOfDates GetModificationsDate();
+    ListOfDates GetModificationsDate() raises(StudyInvalidReference);
 /*! \brief Object conversion.
 
     Converts an object into IOR.
@@ -332,38 +334,38 @@ during each working session.
 
 /*!  \brief Get a new %UseCaseBuilder.
 */
-    UseCaseBuilder  GetUseCaseBuilder();
+    UseCaseBuilder  GetUseCaseBuilder() raises(StudyInvalidReference);
 
 /*! \brief  Close the components in the study, remove itself from the %StudyManager.
 */
-    void Close();
+    void Close() raises(StudyInvalidReference);
 
 /*! \brief  Enable (if isEnabled = True)/disable automatic addition of new %SObjects to the use case.
 */
-    void EnableUseCaseAutoFilling(in boolean isEnabled);
+    void EnableUseCaseAutoFilling(in boolean isEnabled) raises(StudyInvalidReference);
 
 /*!
     Functions for internal usage only
 */
-    void AddPostponed(in string theIOR);
+    void AddPostponed(in string theIOR) raises(StudyInvalidReference);
 
-    void AddCreatedPostponed(in string theIOR);
+    void AddCreatedPostponed(in string theIOR) raises(StudyInvalidReference);
 
-    void RemovePostponed(in long theUndoLimit);
+    void RemovePostponed(in long theUndoLimit) raises(StudyInvalidReference);
 
-    void UndoPostponed(in long theWay);
+    void UndoPostponed(in long theWay) raises(StudyInvalidReference);
 
     boolean DumpStudy(in string thePath,
                       in string theBaseName,
                       in boolean isPublished,
-                      in boolean isMultiFile);
+                      in boolean isMultiFile) raises(StudyInvalidReference);
 
 /*! \brief  Get an AttributeParameter used to store common parameters for given %theSavePoint.
 
     \param theID identifies a common parameters set (Example: "Interface Applicative")
     \param theSavePoint is number of a set of parameters as there can be several sets
 */
-    AttributeParameter GetCommonParameters(in string theID, in long theSavePoint);
+    AttributeParameter GetCommonParameters(in string theID, in long theSavePoint) raises(StudyInvalidReference);
 
 /*! \brief  Get an AttributeParameter used to store parameters for given %theModuleName.
 
@@ -371,7 +373,7 @@ during each working session.
     \param theModuleName is a name of the module (Example: "Geometry")
     \param theSavePoint is number of a set of parameters as there can be several sets
 */
-    AttributeParameter GetModuleParameters(in string theID, in string theModuleName, in long theSavePoint);
+    AttributeParameter GetModuleParameters(in string theID, in string theModuleName, in long theSavePoint) raises(StudyInvalidReference);
 
 
 /*! \brief Get a default Python script to restore visual parameters for given %theModuleName.
@@ -379,7 +381,7 @@ during each working session.
     \param theModuleName is a name of the module (Example: "Geometry")
     \param indent is a string to use for script indentation
 */
-    string GetDefaultScript(in string theModuleName, in string indent);
+    string GetDefaultScript(in string theModuleName, in string indent) raises(StudyInvalidReference);
 
 /*!
     Private method, returns an implementation of this Study.
@@ -395,24 +397,24 @@ during each working session.
     The lock status can be checked by method IsStudyLocked
     \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that locks the study.
 */
-    void SetStudyLock(in string theLockerID);
+    void SetStudyLock(in string theLockerID) raises(StudyInvalidReference);
 
 /*! \brief Indicate if the Study is locked
 
    Returns True if the Study was marked locked. 
 */
-    boolean IsStudyLocked();
+    boolean IsStudyLocked() raises(StudyInvalidReference);
 
 /*! \brief  Mark this Study as being unlocked by the given locker. 
 
      The lock status can be checked by method IsStudyLocked
     \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that unlocks the study.
 */
-    void UnLockStudy(in string theLockerID);
+    void UnLockStudy(in string theLockerID) raises(StudyInvalidReference);
 
 /*! \brief  Get the list of IDs of the Study's lockers. 
 */
-    ListOfStrings GetLockerID();
+    ListOfStrings GetLockerID() raises(StudyInvalidReference);
 
 /*! \brief  Create real variable with Name theVarName and value theValue 
 
@@ -420,7 +422,7 @@ during each working session.
     \param theVarName is a name of the variable
     \param theVarName is a value of the variable.
 */
-    void SetReal( in string theVarName, in double theValue );
+    void SetReal( in string theVarName, in double theValue ) raises(StudyInvalidReference);
 
 /*! \brief  Create integer variable with Name theVarName and value theValue 
 
@@ -428,14 +430,14 @@ during each working session.
     \param theVarName is a name of the variable
     \param theVarName is a value of the variable.
 */
-    void SetInteger( in string theVarName, in long theValue );
+    void SetInteger( in string theVarName, in long theValue ) raises(StudyInvalidReference);
 /*! \brief  Create boolean variable with Name theVarName and value theValue 
 
     (or set if variable value into theValue already exists)
     \param theVarName is a name of the variable
     \param theVarName is a value of the variable.
 */
-    void SetBoolean( in string theVarName, in boolean theValue );
+    void SetBoolean( in string theVarName, in boolean theValue ) raises(StudyInvalidReference);
 
 /*! \brief  Create string variable with Name theVarName and value theValue 
 
@@ -443,35 +445,35 @@ during each working session.
     \param theVarName is a name of the variable
     \param theVarName is a value of the variable.
 */
-    void SetString( in string theVarName, in string theValue );
+    void SetString( in string theVarName, in string theValue ) raises(StudyInvalidReference);
 
 /*! \brief  Set current value as double for string variable
 */
-    void SetStringAsDouble( in string theVarName, in double theValue );
+    void SetStringAsDouble( in string theVarName, in double theValue ) raises(StudyInvalidReference);
 
 /*! \brief Get value of a real variable
 
     \param theVarName is a name of the variable.
 */
-    double GetReal( in string theVarName );
+    double GetReal( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Get value of an integer variable
 
     \param theVarName is a name of the variable.
 */
-    long GetInteger( in string theVarName );
+    long GetInteger( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Get value of a boolean variable
 
     \param theVarName is a name of the variable.
 */
-    boolean GetBoolean( in string theVarName );
+    boolean GetBoolean( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Get value of a string variable
 
     \param theVarName is a name of the variable.
 */
-    string GetString( in string theVarName );
+    string GetString( in string theVarName ) raises(StudyInvalidReference);
     
 
 /*! \brief Indicate if a variable is real
@@ -479,28 +481,28 @@ during each working session.
     Return true if variable is real otherwise return false.
     \param theVarName is a name of the variable.
 */
-    boolean IsReal( in string theVarName );
+    boolean IsReal( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Indicate if a variable is integer
 
     Return true if variable is integer otherwise return false.
     \param theVarName is a name of the variable.
 */
-    boolean IsInteger( in string theVarName );
+    boolean IsInteger( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Indicate if a variable is boolean
 
     Return true if variable is boolean otherwise return false.
     \param theVarName is a name of the variable.
 */
-    boolean IsBoolean( in string theVarName );
+    boolean IsBoolean( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Indicate if a variable is string
 
     Return true if variable is string otherwise return false.
     \param theVarName is a name of the variable.
 */
-    boolean IsString( in string theVarName );
+    boolean IsString( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Indicate if a variable exists in the study
 
@@ -508,11 +510,11 @@ during each working session.
     otherwise return false.
     \param theVarName is a name of the variable.
 */
-    boolean IsVariable( in string theVarName );
+    boolean IsVariable( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Get names of all variables from the study.
 */
-    ListOfStrings GetVariableNames();
+    ListOfStrings GetVariableNames() raises(StudyInvalidReference);
 
 /*! \brief Remove a variable
 
@@ -521,7 +523,7 @@ during each working session.
    \param theVarName Name of the variable.
    \return Status of operation.
 */
-    boolean RemoveVariable( in string theVarName );
+    boolean RemoveVariable( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Rename a variable
 
@@ -531,7 +533,7 @@ during each working session.
    \param theNewVarName New name for the variable.
    \return Status of operation.
 */
-    boolean RenameVariable( in string theVarName, in string theNewVarName );
+    boolean RenameVariable( in string theVarName, in string theNewVarName ) raises(StudyInvalidReference);
 
 /*! \brief Indicate whether variable is used
 
@@ -540,14 +542,14 @@ during each working session.
    \param theVarName Name of the variable.
    \return Variable usage.
 */
-    boolean IsVariableUsed( in string theVarName );
+    boolean IsVariableUsed( in string theVarName ) raises(StudyInvalidReference);
 
 /*! \brief Parse variables used for object creation
 
    \param string with variables, separated by special symbol. 
    \return Variables list.
 */
-    ListOfListOfStrings ParseVariables( in string theVars );
+    ListOfListOfStrings ParseVariables( in string theVars ) raises(StudyInvalidReference);
 
 /*!
      Attach an observer to the Study
index 78378d6084b378ebc55925e08b9b813cee7e267e..4ef6c0f07c636895c7e90470c5dba73aed6dec96 100644 (file)
@@ -31,13 +31,16 @@ SET(DOCUTILS_ROOT_DIR "$ENV{DOCUTILS_ROOT_DIR}" CACHE PATH "Path to the Docutils
 # Ensure the command is run with the given PYTHONPATH
 IF(WIN32 AND NOT CYGWIN)
    SET(SPHINX_EXECUTABLE ${SPHINX_EXECUTABLE})
+   SET(SPHINX_APIDOC_EXECUTABLE ${SPHINX_APIDOC_EXECUTABLE})
 ELSE()
    SET(SPHINX_EXECUTABLE /usr/bin/env PYTHONPATH="${SPHINX_PYTHONPATH}:$$PYTHONPATH" ${SPHINX_EXECUTABLE})
+   SET(SPHINX_APIDOC_EXECUTABLE /usr/bin/env PYTHONPATH="${SPHINX_PYTHONPATH}:$$PYTHONPATH" ${SPHINX_APIDOC_EXECUTABLE})
 ENDIF()
 
 MARK_AS_ADVANCED(SPHINX_EXECUTABLE)
 
 IF(SPHINX_FOUND)
   SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SPHINX_EXECUTABLE})
+  SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SPHINX_APIDOC_EXECUTABLE})
   SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${SPHINX_PYTHONPATH})
 ENDIF()
index c3fd775b126999c8cbaabfb024d285ac2ec9a6ef..01c3a3d3e8099fa2f758b348bf45d59ac0dd317e 100644 (file)
@@ -28,6 +28,7 @@
 #
 
 FIND_PROGRAM(SPHINX_EXECUTABLE sphinx-build PATH_SUFFIXES Scripts)
+FIND_PROGRAM(SPHINX_APIDOC_EXECUTABLE sphinx-apidoc PATH_SUFFIXES Scripts)
 
 # Get root dir locally, going up two levels from the exec:
 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH)
@@ -39,5 +40,5 @@ ELSE()
 ENDIF()
 # Handle the standard arguments of the find_package() command:
 INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE SPHINX_APIDOC_EXECUTABLE)
 
index 6c45fd2a63e8f393c0678a3ea70536fd67545cec..b864b88792b95af81a3906bc959f61ee4c345eca 100644 (file)
@@ -816,10 +816,10 @@ class CMakeFile(object):
                 pass
             # --
             newlines.append("""
-            set(VERSION 7.4.0)
+            set(VERSION 7.4.1)
             set(SHORT_VERSION 7.4)
-            set(XVERSION 0x070400)
-            set(VERSION_DEV 0)
+            set(XVERSION 0x070401)
+            set(VERSION_DEV 1)
             """)
             pass
         # --
index 3a801a75329ab19136b48e242c3cc1c3e8d19d11..e581178d2b15e846c68960a78b2d1690e7461db3 100755 (executable)
@@ -322,11 +322,11 @@ class SALOME_ComponentPy_i (Engines__POA.EngineComponent):
     #-------------------------------------------------------------------------    
 
     def importData(self, studyId, dataContainer, options):
-       return [] # no implmenetation by default
+       return [] # no implementation by default
 
     #-------------------------------------------------------------------------    
 
     def getModifiedData(self, studyId):
-       return [] # no implmenetation by default
+       return [] # no implementation by default
 
     pass # end of SALOME_ComponentPy_i
index 6933a14f297e9170f1e0ecd6329e5a38ac2e69b0..7c779f2ff42143be0da077ec71311d6d8fe160c4 100755 (executable)
@@ -221,7 +221,7 @@ def salome_init(theStudyId=0,embedded=0):
             salome_initial=0
             sg = salome_iapp_init(embedded)
             orb, lcc, naming_service, cm = salome_kernel_init()
-            myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init(theStudyId)
+            myStudyManager, myStudyId, myStudy, myStudyName = salome_study_init(theStudyId)
             pass
         pass
     except RuntimeError, inst:
@@ -238,13 +238,18 @@ def salome_init(theStudyId=0,embedded=0):
         ============================================
         """
         raise
-
+    
 def salome_close():
-    global salome_initial
+    global salome_initial, myStudy, myStudyId, myStudyName
+    try:
+        # study can be closed either from GUI or directly with salome.myStudy.Close()
+        myStudy.Close()
+    except:
+        pass
     salome_initial=1
     salome_iapp_close()
-    salome_kernel_close()
     salome_study_close()
+    myStudyId, myStudy, myStudyName=None,None,None
     pass
 
 
index 140d13ad86e10b63d7148a6cb759ce63748b992f..7c7095a04dfe511124a1273522506e79bf69145e 100644 (file)
@@ -53,8 +53,10 @@ class Lookup(dict):
     a dictionary which can lookup value by key, or keys by value
     """
     ## items can be a list of pair_lists or a dictionary
-    def __init__(self, items=[]):
+    def __init__(self, items=None):
         """items can be a list of pair_lists or a dictionary"""
+       if items is None:
+           items = []
         dict.__init__(self, items)
 
     ## find the key(s) as a list given a value
index e30a33949d811b35fd308a1018fb2be7d30f060d..ccc1cb53be228f0f075e5341d8cca957f49d8fe6 100644 (file)
@@ -50,8 +50,10 @@ class Variable:
     its name. Other attributes are reserved for future use.
     """
     
-    def __init__(self, name, dimension = [], minValue = None, maxValue = None,
+    def __init__(self, name, dimension = None, minValue = None, maxValue = None,
                  initialValue = None):
+        if dimension is None:
+         dimension = []
         self.name = name
         
         # Reserved for future use
@@ -100,8 +102,12 @@ class ExchangeVariables:
 
     """
     
-    def __init__(self, inputVarList = [], outputVarList = [],
+    def __init__(self, inputVarList = None, outputVarList = None,
                  refEntry = None):
+        if inputVarList is None:
+         inputVarList = []
+       if outputVarList is None:
+         outputVarList = []
         self.inputVarList = inputVarList
         self.outputVarList = outputVarList
         self.refEntry = refEntry
index eb83e7966b546e81f7f8951fdb41422c2e07abde..e76502b646711fa80679ef09115ca1e54881404f 100644 (file)
@@ -25,7 +25,7 @@ __author__="gboulant"
 __date__ ="$21 mai 2010 18:00:23$"
 
 
-def findFiles(rootpath, excludes=[]):
+def findFiles(rootpath, excludes=None):
     """
     This looks after files recursively from the specified rootpath,
     but without visiting directories whose basename is in the list
@@ -34,6 +34,8 @@ def findFiles(rootpath, excludes=[]):
     if not os.path.exists(rootpath):
         raise RuntimeError("the path %s does not exists"%rootpath)
 
+    if excludes is None:
+        excludes = []
     exclude_options=""
     for excludepath in excludes:
         exclude_options+="-e %s "%excludepath
index 902e5d33fc072b005edba752bec57ed548d023a6..9c6ef033f7cc3a6cb50bad8fd9f86446cac83b13 100644 (file)
@@ -69,6 +69,11 @@ def setVectorsMode(objId, mode):
 
     #--------------------------------------------------------------------------
 
+def setVerticesMode(objId, mode):
+    return
+
+    #--------------------------------------------------------------------------
+
 # --- From SMESHGUI_SWIG
 
     #--------------------------------------------------------------------------
index 9824f788be8220efcee3240e1536d5765e8b647c..0f6f62720c4220fb7bc42c7026b15201cecc390b 100755 (executable)
@@ -32,15 +32,15 @@ from SALOME_NamingServicePy import *
 from SALOME_utilities import *
 import Engines
 
-salome_kernel_initial=1
+orb = None
+lcc = None
+naming_service = None
+cm = None
 
 def salome_kernel_init():
-    global salome_kernel_initial
     global orb, lcc, naming_service, cm
     
-    if salome_kernel_initial:
-        salome_kernel_initial = 0
-        
+    if not orb:
         # initialise the ORB
         orb = CORBA.ORB_init([''], CORBA.ORB_ID)
 
@@ -55,8 +55,3 @@ def salome_kernel_init():
         cm = obj._narrow(Engines.ContainerManager)
 
     return orb, lcc, naming_service, cm
-
-def salome_kernel_close():
-    global salome_kernel_initial
-    salome_kernel_initial=1
-    pass
index 29ba67d032871cf78eba9da6cde40be6fcc56d25..ae3853675be40ab20a8ce79812f167ccc1c49a33 100755 (executable)
@@ -31,6 +31,11 @@ import SALOMEDS
 import salome_iapp
 from launchConfigureParser import verbose
 
+myStudyManager = None
+myStudyId = None
+myStudy = None
+myStudyName = None
+
 #--------------------------------------------------------------------------
 
 def DumpComponent(Study, SO, Builder,offset):
@@ -70,8 +75,9 @@ def DumpStudies():
   """
     Dump all studies in a StudyManager
   """
+  global myStudyManager
   for name in myStudyManager.GetOpenStudies():
-    s=myStudyManager.GetStudyByName(name)
+    s = myStudyManager.GetStudyByName(name)
     print "study:",name, s._get_StudyId()
     DumpStudy(s)
 
@@ -79,6 +85,7 @@ def DumpStudies():
 #--------------------------------------------------------------------------
 
 def IDToObject(id):
+    global myStudy
     myObj = None
     mySO = myStudy.FindObjectID(id);
     if mySO is not None:
@@ -104,6 +111,7 @@ def ObjectToID(obj):
     return ""
 
 def IDToSObject(id):
+    global myStudy
     mySO = myStudy.FindObjectID(id);
     return mySO
 
@@ -178,6 +186,7 @@ def PersistentPresentation(theStudy, theSO, theWithID):
 
 def GetTree(theSO):
     # returns the document list tree (as list)
+    global myStudy
     aResult = [theSO.GetID()]
     anIter = myStudy.NewChildIterator(theSO)
     while anIter.More():
@@ -188,6 +197,8 @@ def GetTree(theSO):
     #--------------------------------------------------------------------------
 
 def CheckCopyPaste(theSO, theInfo ,theComponentPaste):
+    global myStudyManager, myStudy
+
     aRoot = theSO
     while aRoot.GetID() != "0:":
         aRoot = aRoot.GetFather()
@@ -229,6 +240,7 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste):
 
 def GetComponentVersion(theComponent, all_versions = False):
     # returns the document list tree (as list)
+    global myStudy
     props = myStudy.GetProperties()
     stored_components = props.GetStoredComponents()
     version = "no component data" # vsr: better raise an exception in this case?
@@ -269,31 +281,27 @@ def FindFileInDataDir(filename):
 
 salome_study_ID = -1
 
-def getActiveStudy(theStudyId=0):
+# *args are used here to support backward compatibility
+# previously it was possible to pass theStudyId parameter to this function
+# which is no more supported.
+def getActiveStudy(*args):
+    global myStudyManager
     global salome_study_ID
 
+    if not myStudyManager:
+        print "No active study"
+        return None
+        pass
+
     if verbose(): print "getActiveStudy"
     if salome_study_ID == -1:
-        if salome_iapp.hasDesktop():
-            if verbose(): print "---in gui"
-            salome_study_ID = salome_iapp.sg.getActiveStudyId()
+        listOpenStudies = myStudyManager.GetOpenStudies()
+        if len(listOpenStudies) == 0:
+            return None
         else:
-            if verbose(): print "---outside gui"
-            if theStudyId:
-                aStudy=myStudyManager.GetStudyByID(theStudyId)
-                if aStudy:
-                    if verbose(): print "connection to existing study ", theStudyId
-                    salome_study_ID = theStudyId
-            if salome_study_ID == -1:
-                listOpenStudies = myStudyManager.GetOpenStudies()
-                if len(listOpenStudies) == 0:
-                    salome_study_ID = createNewStudy()
-                else:
-                    s = myStudyManager.GetStudyByName(listOpenStudies[0])
-                    salome_study_ID = s._get_StudyId()
-            else:
-                pass
-            if verbose(): print"--- Study Id ", salome_study_ID
+            s = myStudyManager.GetStudyByName(listOpenStudies[0])
+            salome_study_ID = s._get_StudyId()
+    if verbose(): print"--- Study Id ", salome_study_ID
     return salome_study_ID
 
     #--------------------------------------------------------------------------
@@ -303,50 +311,51 @@ def setCurrentStudy(theStudy):
     Change current study : an existing one given by a study object.
 
     :param theStudy: the study CORBA object to set as current study
+
+    Obsolete: only one study can be opened at the moment.
+    This function works properly if specified theStudy parameter
+    corresponds to the currently opened study.
+    Kept for backward compatibility only.
     """
     global myStudyId, myStudy, myStudyName
     global salome_study_ID
-    myStudy=theStudy
-    myStudyId=theStudy._get_StudyId()
-    myStudyName=theStudy._get_Name()
+    myStudy = theStudy
+    myStudyId = theStudy._get_StudyId()
+    myStudyName = theStudy._get_Name()
     return myStudyId, myStudy, myStudyName
 
     #--------------------------------------------------------------------------
 
-def setCurrentStudyId(theStudyId=0):
+# *args are used here to support backward compatibility
+# previously it was possible to pass theStudyId parameter to this function
+# which is no more supported.
+def setCurrentStudyId(*args):
     """
     Change current study : an existing or new one.
-    optional argument : theStudyId
-        0      : create a new study (default).
-        n (>0) : try connection to study with Id = n, or create a new one
-                 if study not found.
+
+    This function connects to the single opened study if there is any; otherwise
+    new empty study is created.
+
+    Obsolete: only one study can be opened at the moment.
+    Kept for backward compatibility only.
     """
-    global myStudyId, myStudy, myStudyName
+    global myStudyManager, myStudyId, myStudy, myStudyName
     global salome_study_ID
     salome_study_ID = -1
-    myStudyId = getActiveStudy(theStudyId)
+    myStudyId = getActiveStudy()
+    if not myStudyId:
+      myStudyId = createNewStudy()
     if verbose(): print "myStudyId",myStudyId
     myStudy = myStudyManager.GetStudyByID(myStudyId)
     myStudyName = myStudy._get_Name()
-
     return myStudyId, myStudy, myStudyName
 
     #--------------------------------------------------------------------------
 
 def createNewStudy():
+    global myStudyManager
     print "createNewStudy"
-    i=1
-    aStudyName = "noName"
-    nameAlreadyInUse = 1
-    listOfOpenStudies = myStudyManager.GetOpenStudies()
-    print listOfOpenStudies
-    while nameAlreadyInUse:
-        aStudyName = "extStudy_%d"%i
-        if aStudyName not in listOfOpenStudies:
-            nameAlreadyInUse=0
-        else:
-            i = i+1
-
+    aStudyName = "extStudy"
     theStudy = myStudyManager.NewStudy(aStudyName)
     theStudyId = theStudy._get_StudyId()
     print aStudyName, theStudyId
@@ -354,26 +363,29 @@ def createNewStudy():
 
     #--------------------------------------------------------------------------
 
-salome_study_initial = 1
+def openStudy(theStudyPath):
+    global myStudyManager
+    print "openStudy"
+    theStudy = myStudyManager.Open(theStudyPath)
+    theStudyId = theStudy._get_StudyId()
+    print theStudyPath, theStudyId
+    return theStudyId
+
+    #--------------------------------------------------------------------------
 
-def salome_study_init(theStudyId=0):
+def salome_study_init(theStudyPath=None):
     """
     Performs only once study creation or connection.
-    optional argument : theStudyId
-      When in embedded interpreter inside IAPP, theStudyId is not used
-      When used without GUI (external interpreter)
-        0      : create a new study (default).
-        n (>0) : try connection to study with Id = n, or create a new one
-                 if study not found.
+    optional argument : theStudyPath
+        None        : attach to the currently active single study;
+                      create new empty study if there is active study
+        <URL> (str) : open study with the given file name
     """
-
-    global salome_study_initial
     global myStudyManager, myStudyId, myStudy, myStudyName
     global orb, lcc, naming_service, cm
 
-    if salome_study_initial:
-        salome_study_initial = 0
-
+    if verbose(): print "theStudyPath:", theStudyPath
+    if not myStudyManager:
         orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init()
 
         # get Study Manager reference
@@ -381,17 +393,28 @@ def salome_study_init(theStudyId=0):
         obj = naming_service.Resolve('myStudyManager')
         myStudyManager = obj._narrow(SALOMEDS.StudyManager)
         if verbose(): print "studyManager found"
+        pass
 
-        # get active study Id, ref and name
-        myStudyId = getActiveStudy(theStudyId)
-        if verbose(): print "myStudyId",myStudyId
+    # get active study Id, ref and name
+    myStudy = None
+    myStudyId = getActiveStudy()
+    if myStudyId == None :
+        import types
+        if theStudyPath and type(theStudyPath) == types.StringType:
+            myStudyId = openStudy(theStudyPath)
+        else:
+            myStudyId = createNewStudy()
+    if verbose(): print "myStudyId", myStudyId
+
+    if myStudy == None:
         myStudy = myStudyManager.GetStudyByID(myStudyId)
-        myStudyName = myStudy._get_Name()
+    myStudyName = myStudy._get_Name()
 
     return myStudyManager, myStudyId, myStudy, myStudyName
 
 def salome_study_close():
-    global salome_study_initial, salome_study_ID
-    salome_study_initial=1
-    salome_study_ID=-1
+    global salome_study_ID
+    global myStudyId, myStudy, myStudyName
+    salome_study_ID = -1
+    myStudyId, myStudy, myStudyName = None, None, None
     pass
index 9a4995c0dd16a0ac64a2f9125a7c08a9f09b5916..fd1fa6508ab5b4efee4a85222a322e4d3565ac1e 100644 (file)
@@ -46,28 +46,40 @@ class ContainerParameters (Engines.ContainerParameters):
     Engines.ContainerParameters.__init__(self,container_name, mode, workingdir, nb_proc, isMPI, parallelLib,resource_params)
 
 class ResourceParameters (Engines.ResourceParameters):
-  def __init__(self, name="", hostname="", OS="", componentList=[],
+  def __init__(self, name="", hostname="", OS="", componentList=None,
                      nb_proc=0, mem_mb=0, cpu_clock=0, nb_node=0, nb_proc_per_node=0,
-                     policy="", resList=[], can_launch_batch_jobs = False, can_run_containers = False):
+                     policy="", resList=None, can_launch_batch_jobs = False, can_run_containers = False):
+    if componentList is None:
+      componentList = []
+    if resList is None:
+      resList = []
     Engines.ResourceParameters.__init__(self, name, hostname, can_launch_batch_jobs, can_run_containers,
                                         OS, componentList, nb_proc, mem_mb, cpu_clock, nb_node,
                                         nb_proc_per_node, policy, resList)
 
 class JobParameters (Engines.JobParameters):
-  def __init__(self, job_name="", job_type="", job_file="", env_file="", in_files=[], out_files=[],
+  def __init__(self, job_name="", job_type="", job_file="", env_file="", in_files=None, out_files=None,
                      work_directory="", local_directory="", result_directory="", maximum_duration="",
                      resource_required=None, queue="", exclusive = False, mem_per_cpu = 0,
-                     specific_parameters=[], launcher_file = "", launcher_args = ""):
+                     specific_parameters=None, launcher_file = "", launcher_args = ""):
+    if in_files is None:
+      in_files = []
+    if out_files is None:
+      out_files = []
+    if specific_parameters is None:
+      specific_parameters = []
     Engines.JobParameters.__init__(self, job_name, job_type, job_file, env_file, in_files, out_files,
                                          work_directory, local_directory, result_directory, maximum_duration,
                                          resource_required, queue, exclusive, mem_per_cpu,
                                          specific_parameters, launcher_file, launcher_args)
 
 class ResourceDefinition(Engines.ResourceDefinition):
-  def __init__(self, name="", hostname="", protocol="rsh", username="", applipath="", componentList=[],
+  def __init__(self, name="", hostname="", protocol="rsh", username="", applipath="", componentList=None,
                mode="interactive", OS="", mem_mb=1, cpu_clock=1, nb_node=1, nb_proc_per_node=1,
                batch="", mpiImpl="", iprotocol="rsh", type = "single_machine",
                can_launch_batch_jobs = False, can_run_containers = False, working_directory = ""):
+    if componentList is None:
+      componentList = []
     Engines.ResourceDefinition.__init__(self, name, hostname, type, protocol, username, applipath,
                                         componentList, OS, mem_mb, cpu_clock, nb_node, nb_proc_per_node,
                                         batch, mpiImpl, iprotocol, can_launch_batch_jobs,
index bd54f4c287b32f325c6f9d3678daa8e7f7210bce..aef592069dca85f3705f2ab17da6230e02437171 100755 (executable)
@@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../HDFPersist
   ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace
+  ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
   ${CMAKE_CURRENT_SOURCE_DIR}/../Utils
   ${CMAKE_CURRENT_SOURCE_DIR}/../DF
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMEDSImpl
@@ -51,6 +52,7 @@ SET(COMMON_LIBS
   SALOMELocalTrace
   SALOMEBasics
   SalomeHDFPersist
+  SalomeKernelHelpers
   DF
   SalomeDSImpl
   SalomeGenericObj
index 5bbc01b31cb8a13b4c32a9fbdf347175fafc5064..b19a8fd2b6715589e2f10c496b1b2a8933df289e 100644 (file)
@@ -25,6 +25,7 @@
 //  Module : SALOME
 //
 #include "utilities.h"
+#include <sstream>
 #include "SALOMEDS_Study_i.hxx"
 #include "SALOMEDS_StudyManager_i.hxx"
 #include "SALOMEDS_UseCaseIterator_i.hxx"
@@ -48,6 +49,7 @@
 #include "DF_Attribute.hxx"
 
 #include "Basics_Utils.hxx"
+#include "SALOME_KernelServices.hxx"
 
 #ifdef WIN32
 #include <process.h>
@@ -232,9 +234,23 @@ SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDSImpl_Study* theImpl,
   _builder        = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);  
   _notifier       = new SALOMEDS::Notifier(_orb);
   _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
+  _closed         = false;
 
   theImpl->setNotifier(_notifier);
   theImpl->setGenObjRegister( _genObjRegister );
+
+  // Notify GUI that study was created
+  SALOME_NamingService *aNamingService = KERNEL::getNamingService();
+  CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
+  SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
+  if ( !CORBA::is_nil(aSession) ) {
+    std::stringstream ss;
+    ss << "studyCreated:" << theImpl->StudyId();
+    std::string str = ss.str();
+    SALOMEDS::unlock();
+    aSession->emitMessageOneWay(str.c_str());
+    SALOMEDS::lock();
+  }
 }
   
 //============================================================================
@@ -266,6 +282,8 @@ SALOMEDS_Study_i::~SALOMEDS_Study_i()
 char* SALOMEDS_Study_i::GetPersistentReference()
 {
   SALOMEDS::Locker lock; 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
   return CORBA::string_dup(_impl->GetPersistentReference().c_str());
 }
 //============================================================================
@@ -276,7 +294,9 @@ char* SALOMEDS_Study_i::GetPersistentReference()
 char* SALOMEDS_Study_i::GetTransientReference()
 {
   SALOMEDS::Locker lock; 
-  return CORBA::string_dup(_impl->GetTransientReference().c_str()); 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+  return CORBA::string_dup(_impl->GetTransientReference().c_str());
 }
 
 //============================================================================
@@ -287,6 +307,8 @@ char* SALOMEDS_Study_i::GetTransientReference()
 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
 {
   SALOMEDS::Locker lock; 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
   return _impl->IsEmpty();
 }
 
@@ -299,10 +321,15 @@ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponent
 {
   SALOMEDS::Locker lock; 
   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::SComponent_var sco;
+
   SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
-  if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
+  if (!aCompImpl.IsNull())
+    sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
 
-  SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
   return sco._retn();
 }
 
@@ -315,10 +342,15 @@ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponen
 {
   SALOMEDS::Locker lock; 
   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::SComponent_var sco;
+
   SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
-  if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
+  if (!aCompImpl.IsNull())
+    sco = SALOMEDS_SComponent_i::New(aCompImpl, _orb);
 
-  SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
   return sco._retn();
 }
 
@@ -331,18 +363,23 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
 {
   SALOMEDS::Locker lock; 
 
-  SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
-  if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::SObject_var so;
 
-  if(aSO.IsComponent()) {
-    SALOMEDSImpl_SComponent aSCO = aSO;
-    SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
-    return sco._retn();
+  SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
+  if (!aSO.IsNull()) {
+    if (aSO.IsComponent()) {
+      SALOMEDSImpl_SComponent aSCO = aSO;
+      so = SALOMEDS_SComponent_i::New(aSCO, _orb);
+    }
+    else {
+      so = SALOMEDS_SObject_i::New(aSO, _orb);
+    }
   }
-   
-  SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
- return so._retn();
+
+  return so._retn();
 }
 
 //============================================================================
@@ -354,9 +391,15 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::SObject_var so;
+
   SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
-  if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
-  SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
+  if (!aSO.IsNull())
+    so = SALOMEDS_SObject_i::New(aSO, _orb);
+
   return so._retn();
 }
 
@@ -369,12 +412,17 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
 {
   SALOMEDS::Locker lock; 
 
-  if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
 
-  SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
-  if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+  SALOMEDS::SObject_var so;
+
+  if (anObjectID && strlen(anObjectID) > 0) {
+    SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
+    if (!aSO.IsNull())
+      so = SALOMEDS_SObject_i::New(aSO, _orb);
+  }
 
-  SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
   return so._retn();
 }
 
@@ -389,16 +437,21 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char*
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
-                                                               std::string((char*)aComponentName));
+                                                                  std::string((char*)aComponentName));
+
+  SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
   int aLength = aSeq.size();
-  SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
   listSO->length(aLength);
-  for(int i = 0; i<aLength; i++) {
-    SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSeq[i], _orb);
-    listSO[i] = so ;
+  for (int i = 0; i < aLength; i++) {
+    SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New(aSeq[i], _orb);
+    listSO[i] = so;
   }
-  return listSO._retn() ;
+  
+  return listSO._retn();
 }
 
 //============================================================================
@@ -410,10 +463,15 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::SObject_var so;
+
   SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
-  if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+  if (!aSO.IsNull())
+    so = SALOMEDS_SObject_i::New(aSO, _orb);
 
-  SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
   return so._retn();
 }
 
@@ -426,10 +484,15 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::SObject_var so;
+
   SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
-  if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
+  if (!aSO.IsNull())
+    so = SALOMEDS_SObject_i::New (aSO, _orb);
 
-  SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
   return so._retn();
 }
 
@@ -442,22 +505,28 @@ char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
 {
   SALOMEDS::Locker lock; 
 
-  std::string aPath("");
-  if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.c_str());
-  SALOMEDSImpl_SObject aSO;
-  SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
 
-  if(!CORBA::is_nil(aSObj)) {
-    aSO = _impl->FindObjectID(aSObj->GetID());
-  }
-  else {
-    aSO  = _impl->FindObjectIOR(_orb->object_to_string(theObject));
+  std::string aPath = "";
+
+  if (!CORBA::is_nil(theObject)) {
+    SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
+    SALOMEDSImpl_SObject aSO;
+
+    if (!CORBA::is_nil(aSObj)) {
+      aSO = _impl->FindObjectID(aSObj->GetID());
+    }
+    else {
+      aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
+    }
+    
+    if (!aSO.IsNull()) {    
+      aPath = _impl->GetObjectPath(aSO);
+    }
   }
-   
-  if(aSO.IsNull()) return CORBA::string_dup(aPath.c_str());
-  
-  aPath = _impl->GetObjectPath(aSO);
-  return  CORBA::string_dup(aPath.c_str());
+
+  return CORBA::string_dup(aPath.c_str());
 }
 
 
@@ -470,8 +539,11 @@ void SALOMEDS_Study_i::SetContext(const char* thePath)
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->SetContext(std::string((char*)thePath));
-  if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext") 
+  if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext") 
     throw SALOMEDS::Study::StudyInvalidContext();  
 }
 
@@ -484,7 +556,11 @@ char* SALOMEDS_Study_i::GetContext()
 {
   SALOMEDS::Locker lock; 
   
-  if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
+
   return CORBA::string_dup(_impl->GetContext().c_str());
 }
 
@@ -497,11 +573,14 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
 
   if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
     throw SALOMEDS::Study::StudyInvalidContext();
-
+  
   std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
   if (_impl->GetErrorCode() == "InvalidContext")
     throw SALOMEDS::Study::StudyInvalidContext();
@@ -524,11 +603,14 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theCont
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
 
   if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
     throw SALOMEDS::Study::StudyInvalidContext();
-
+  
   std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
   if (_impl->GetErrorCode() == "InvalidContext")
     throw SALOMEDS::Study::StudyInvalidContext();
@@ -538,7 +620,7 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theCont
   for (int anIndex = 0; anIndex < aLength; anIndex++) {
     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
   }
-
+  
   return aResult._retn();
 }
 
@@ -551,11 +633,14 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
 
   if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
     throw SALOMEDS::Study::StudyInvalidContext();
-
+  
   std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
   if (_impl->GetErrorCode() == "InvalidContext")
     throw SALOMEDS::Study::StudyInvalidContext();
@@ -579,6 +664,9 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theCont
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
 
   std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
@@ -601,14 +689,16 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject
 {
   SALOMEDS::Locker lock; 
 
-  CORBA::String_var anID=theSO->GetID();
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  CORBA::String_var anID = theSO->GetID();
   SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
   SALOMEDSImpl_ChildIterator anItr(aSO);
-
-  //Create iterator
   SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
+  SALOMEDS::ChildIterator_var it = it_servant->_this();
 
-  return it_servant->_this();
+  return it._retn();
 }
 
 
@@ -620,9 +710,15 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject
 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
 {
   SALOMEDS::Locker lock; 
-  SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
-  _it->Init();
-  return _it->_this();
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
+  it_servant->Init();
+  SALOMEDS::SComponentIterator_var it = it_servant->_this();
+
+  return it._retn();
 }
 
 
@@ -634,7 +730,13 @@ SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
 {
   SALOMEDS::Locker lock; 
-  return _builder->_this();
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::StudyBuilder_var sb = SALOMEDS::StudyBuilder::_duplicate(_builder->_this());
+
+  return sb._retn();
 }
  
 //============================================================================
@@ -645,6 +747,7 @@ SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
 char* SALOMEDS_Study_i::Name()
 {
   SALOMEDS::Locker lock; 
+  // Name is specified as IDL attribute: user exception cannot be raised
   return CORBA::string_dup(_impl->Name().c_str());
 }
 
@@ -656,6 +759,7 @@ char* SALOMEDS_Study_i::Name()
 void SALOMEDS_Study_i::Name(const char* name)
 {
   SALOMEDS::Locker lock;  
+  // Name is specified as IDL attribute: user exception cannot be raised
   _impl->Name(std::string(name));
 }
 
@@ -664,10 +768,11 @@ void SALOMEDS_Study_i::Name(const char* name)
  *  Purpose  : get if study has been saved
  */
 //============================================================================
-CORBA::Boolean  SALOMEDS_Study_i::IsSaved()
+CORBA::Boolean SALOMEDS_Study_i::IsSaved()
 {
   SALOMEDS::Locker lock; 
-  return _impl->IsSaved();
+  // IsSaved is specified as IDL attribute: user exception cannot be raised
+  return (!_closed) ? _impl->IsSaved() : false;
 }
 
 //============================================================================
@@ -678,7 +783,9 @@ CORBA::Boolean  SALOMEDS_Study_i::IsSaved()
 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
 {
   SALOMEDS::Locker lock; 
-  _impl->IsSaved(save);
+  // IsSaved is specified as IDL attribute: user exception cannot be raised
+  if (!_closed)
+    _impl->IsSaved(save);
 }
 
 //============================================================================
@@ -686,9 +793,13 @@ void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
  *  Purpose  : Detect if a Study has been modified since it has been saved
  */
 //============================================================================
-CORBA::Boolean  SALOMEDS_Study_i::IsModified()
+CORBA::Boolean SALOMEDS_Study_i::IsModified()
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsModified();
 }
 
@@ -697,12 +808,15 @@ CORBA::Boolean  SALOMEDS_Study_i::IsModified()
  *  Purpose  : Sets a Modified flag of a Study to True
  */
 //============================================================================
-void  SALOMEDS_Study_i::Modified()
+void SALOMEDS_Study_i::Modified()
 {
   SALOMEDS::Locker lock; 
-  return _impl->Modify();
-}
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  _impl->Modify();
+}
 
 //============================================================================
 /*! Function : URL
@@ -712,6 +826,7 @@ void  SALOMEDS_Study_i::Modified()
 char* SALOMEDS_Study_i::URL()
 {
   SALOMEDS::Locker lock; 
+  // URL is specified as IDL attribute: user exception cannot be raised
   return CORBA::string_dup(_impl->URL().c_str());
 }
 
@@ -723,25 +838,31 @@ char* SALOMEDS_Study_i::URL()
 void SALOMEDS_Study_i::URL(const char* url)
 {
   SALOMEDS::Locker lock; 
+  // URL is specified as IDL attribute: user exception cannot be raised
   _impl->URL(std::string((char*)url));
 }
 
-
 CORBA::Short SALOMEDS_Study_i::StudyId()
 {
   SALOMEDS::Locker lock; 
+  // StudyId is specified as IDL attribute: user exception cannot be raised
   return _impl->StudyId();
 }
 
 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
 { 
   SALOMEDS::Locker lock; 
+  // StudyId is specified as IDL attribute: user exception cannot be raised
   _impl->StudyId(id);
 }
 
-void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) 
+void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry) 
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
 }
 
@@ -767,11 +888,11 @@ SALOMEDS_Study_i* SALOMEDS_Study_i::GetStudyServant(SALOMEDSImpl_Study* aStudyIm
   if (_mapOfStudies.find(aStudyImpl) != _mapOfStudies.end()) 
     return _mapOfStudies[aStudyImpl];
   else
-    {
-      SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, orb);
-      _mapOfStudies[aStudyImpl]=Study_servant;
-      return Study_servant;
-    }
+  {
+    SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, orb);
+    _mapOfStudies[aStudyImpl]=Study_servant;
+    return Study_servant;
+  }
 }
 
 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute) 
@@ -784,6 +905,9 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObj
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::GenericAttribute_ptr aTarget;
   if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
     return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
@@ -798,14 +922,22 @@ SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
 {
   SALOMEDS::Locker lock; 
   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
   SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
-  return SP->AttributeStudyProperties::_this();
+  SALOMEDS::AttributeStudyProperties_var aProp = SP->_this();
+  return aProp._retn();
 }
 
 char* SALOMEDS_Study_i::GetLastModificationDate() 
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
 }
 
@@ -813,19 +945,22 @@ SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
 {
   SALOMEDS::Locker lock; 
   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
+
   std::vector<std::string> aSeq = _impl->GetModificationsDate();
+
   int aLength = aSeq.size();
-  SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
   aDates->length(aLength);
-
-  for(int anIndex = 0; anIndex < aLength; anIndex++) {
+  for (int anIndex = 0; anIndex < aLength; anIndex++) {
     aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
   }
+
   return aDates._retn();
 }
 
-
-
 //============================================================================
 /*! Function : GetUseCaseBuilder
  *  Purpose  : Returns a UseCase builder
@@ -834,8 +969,13 @@ SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() 
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
-  return UCBuilder->_this();
+  SALOMEDS::UseCaseBuilder_var uc = UCBuilder->_this();
+  return uc._retn();
 }
 
 
@@ -848,8 +988,11 @@ void SALOMEDS_Study_i::Close()
 {
   SALOMEDS::Locker lock; 
 
-  RemovePostponed(-1);
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
 
+  RemovePostponed(-1);
+  
   SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
   for (; itcomponent->More(); itcomponent->Next()) {
     SALOMEDS::SComponent_var sco = itcomponent->Value();
@@ -861,31 +1004,41 @@ void SALOMEDS_Study_i::Close()
       // we have found the associated engine to write the data 
       MESSAGE ( "We have found an engine for data type :"<< compodatatype);
       //_narrow can throw a corba exception
-      try
-        {
-          CORBA::Object_var obj = _orb->string_to_object(IOREngine);
-          if (!CORBA::is_nil(obj)) 
-            {
-              SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
-              if (!anEngine->_is_nil()) 
-                { 
-                  SALOMEDS::unlock();
-                  anEngine->Close(sco);
-                  SALOMEDS::lock();
-                }
-            }
-        } 
-      catch (CORBA::Exception&) 
-        {/*pass*/ }
+      try {
+       CORBA::Object_var obj = _orb->string_to_object(IOREngine);
+       if (!CORBA::is_nil(obj)) {
+         SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
+         if (!anEngine->_is_nil())  { 
+           SALOMEDS::unlock();
+           anEngine->Close(sco);
+           SALOMEDS::lock();
+         }
+       }
+      } 
+      catch (CORBA::Exception&) {
+      }
     }
     sco->UnRegister();
   }
-
+  
   //Does not need any more this iterator
   itcomponent->UnRegister();
-
-
+  
+  // Notify GUI that study is closed
+  SALOME_NamingService *aNamingService = KERNEL::getNamingService();
+  CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
+  SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
+  if ( !CORBA::is_nil(aSession) ) {
+    std::stringstream ss;
+    ss << "studyClosed:" << _impl->StudyId();
+    std::string str = ss.str();
+    SALOMEDS::unlock();
+    aSession->emitMessageOneWay(str.c_str());
+    SALOMEDS::lock();
+  }
+  
   _impl->Close();
+  _closed = true;
 }
 
 //============================================================================
@@ -910,24 +1063,23 @@ void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
  *  Purpose  : 
  */
 //============================================================================
-#ifndef WIN32
-void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/) 
-#else
 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/) 
-#endif
 {  
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   std::vector<std::string> anIORs = _impl->GetIORs();
   int i, aSize = (int)anIORs.size();
-
-  for(i = 0; i < aSize; i++) {
+  
+  for (i = 0; i < aSize; i++) {
     try {
       CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
       SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
-          //rnv: To avoid double deletion of the Salome Generic Objects:
-          //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
-          //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
+      //rnv: To avoid double deletion of the Salome Generic Objects:
+      //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
+      //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
       //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
     } catch (...) {}
   }
@@ -940,11 +1092,7 @@ void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/)
  *  Purpose  : 
  */
 //============================================================================
-#ifndef WIN32
-void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay) 
-#else
 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay) 
-#endif
 {
   SALOMEDS::Locker lock; 
   //Not implemented
@@ -963,10 +1111,14 @@ CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
   SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
-  CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
+  bool ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
   delete factory;
+
   return ret;
 }
 
@@ -979,9 +1131,14 @@ SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const cha
 {
   SALOMEDS::Locker lock; 
   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
   SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
-  return SP->AttributeParameter::_this();
+  SALOMEDS::AttributeParameter_var aParam = SP->_this();
+
+  return aParam._retn();
 }
  
 //============================================================================
@@ -995,9 +1152,14 @@ SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const cha
 {
   SALOMEDS::Locker lock; 
   
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
   SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
-  return SP->AttributeParameter::_this();
+  SALOMEDS::AttributeParameter_var aParam = SP->_this();
+
+  return aParam._retn();
 }
 
 //============================================================================
@@ -1008,6 +1170,10 @@ SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const cha
 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->SetStudyLock(theLockerID);
 }
 
@@ -1019,6 +1185,10 @@ void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
 bool SALOMEDS_Study_i::IsStudyLocked()
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsStudyLocked();
 }
 
@@ -1030,6 +1200,10 @@ bool SALOMEDS_Study_i::IsStudyLocked()
 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
 {
   SALOMEDS::Locker lock; 
+
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->UnLockStudy(theLockerID);
 }
 
@@ -1042,6 +1216,9 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
 
   std::vector<std::string> aSeq = _impl->GetLockerID();
@@ -1051,6 +1228,7 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
   for(int anIndex = 0; anIndex < aLength; anIndex++) {
     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
   }
+
   return aResult._retn();
 }
 //============================================================================
@@ -1060,10 +1238,14 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
 //============================================================================
 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+
   _impl->SetVariable(std::string(theVarName), 
-                     theValue,
-                     SALOMEDSImpl_GenericVariable::REAL_VAR);
-  if(_notifier)
+                    theValue,
+                    SALOMEDSImpl_GenericVariable::REAL_VAR);
+  if (_notifier)
     _notifier->modifyNB_Notification(theVarName);
 }
 
@@ -1074,10 +1256,13 @@ void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
 //============================================================================
 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->SetVariable(std::string(theVarName), 
-                     theValue,
-                     SALOMEDSImpl_GenericVariable::INTEGER_VAR);
-  if(_notifier)
+                    theValue,
+                    SALOMEDSImpl_GenericVariable::INTEGER_VAR);
+  if (_notifier)
     _notifier->modifyNB_Notification(theVarName);
 }
 
@@ -1088,10 +1273,13 @@ void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
 //============================================================================
 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->SetVariable(std::string(theVarName), 
-                     theValue,
-                     SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
-  if(_notifier)
+                    theValue,
+                    SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
+  if (_notifier)
     _notifier->modifyNB_Notification(theVarName);
 }
 
@@ -1102,10 +1290,13 @@ void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValu
 //============================================================================
 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->SetStringVariable(std::string(theVarName), 
-                           theValue,
-                           SALOMEDSImpl_GenericVariable::STRING_VAR);
-  if(_notifier)
+                          theValue,
+                          SALOMEDSImpl_GenericVariable::STRING_VAR);
+  if (_notifier)
     _notifier->modifyNB_Notification(theVarName);
 }
 
@@ -1116,9 +1307,12 @@ void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
 //============================================================================
 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->SetStringVariableAsDouble(std::string(theVarName), 
-                                   theValue,
-                                   SALOMEDSImpl_GenericVariable::STRING_VAR);
+                                  theValue,
+                                  SALOMEDSImpl_GenericVariable::STRING_VAR);
 }
 
 //============================================================================
@@ -1128,6 +1322,9 @@ void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double t
 //============================================================================
 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->GetVariableValue(std::string(theVarName));
 }
 
@@ -1138,7 +1335,10 @@ CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
 //============================================================================
 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
 {
-  return (int)_impl->GetVariableValue(std::string(theVarName));
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  return (long)_impl->GetVariableValue(std::string(theVarName));
 }
 
 //============================================================================
@@ -1148,6 +1348,9 @@ CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return (bool)_impl->GetVariableValue(std::string(theVarName));
 }
 
@@ -1158,6 +1361,9 @@ CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
 //============================================================================
 char* SALOMEDS_Study_i::GetString(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
 }
 
@@ -1168,8 +1374,11 @@ char* SALOMEDS_Study_i::GetString(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsTypeOf(std::string(theVarName),
-                         SALOMEDSImpl_GenericVariable::REAL_VAR);
+                        SALOMEDSImpl_GenericVariable::REAL_VAR);
 }
 
 //============================================================================
@@ -1179,8 +1388,11 @@ CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsTypeOf(std::string(theVarName),
-                         SALOMEDSImpl_GenericVariable::INTEGER_VAR);
+                        SALOMEDSImpl_GenericVariable::INTEGER_VAR);
 }
 
 //============================================================================
@@ -1190,8 +1402,11 @@ CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsTypeOf(std::string(theVarName),
-                         SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
+                        SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
 }
 
 //============================================================================
@@ -1201,8 +1416,11 @@ CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsTypeOf(std::string(theVarName),
-                         SALOMEDSImpl_GenericVariable::STRING_VAR);
+                        SALOMEDSImpl_GenericVariable::STRING_VAR);
 }
 
 //============================================================================
@@ -1212,6 +1430,9 @@ CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsVariable(std::string(theVarName));
 }
 
@@ -1222,12 +1443,15 @@ CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
 //============================================================================
 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
 {
-  std::vector<std::string> aVarNames = _impl->GetVariableNames();
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
-  
+
+  std::vector<std::string> aVarNames = _impl->GetVariableNames();
+
   int aLen = aVarNames.size();
   aResult->length(aLen);
-  
   for (int anInd = 0; anInd < aLen; anInd++)
     aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
   
@@ -1241,9 +1465,13 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
 {
-  CORBA::Boolean res = _impl->RemoveVariable(std::string(theVarName));
-  if(res && _notifier)
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  bool res = _impl->RemoveVariable(std::string(theVarName));
+  if (res && _notifier)
     _notifier->modifyNB_Notification(theVarName);
+
   return res;
 }
 
@@ -1254,9 +1482,13 @@ CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
 {
-  CORBA::Boolean res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
-  if(res && _notifier)
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
+  bool res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
+  if (res && _notifier)
     _notifier->modifyNB_Notification(theVarName);
+
   return res;
 }
 
@@ -1267,6 +1499,9 @@ CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const ch
 //============================================================================
 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
 {
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   return _impl->IsVariableUsed(std::string(theVarName));
 }
 
@@ -1278,10 +1513,13 @@ CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
 //============================================================================
 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
 {
-  std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
 
   SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
 
+  std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
+
   int aSectionsLen = aSections.size();
   aResult->length(aSectionsLen);
 
@@ -1311,6 +1549,9 @@ char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char*
 {
   SALOMEDS::Locker lock; 
 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
   return CORBA::string_dup(script.c_str());
 }
@@ -1322,10 +1563,13 @@ char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char*
 //============================================================================
 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) 
 { 
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();  
+
   _impl->EnableUseCaseAutoFilling(isEnabled); 
   SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
-  if(builder) {
-    if(isEnabled) {
+  if (builder) {
+    if (isEnabled) {
       builder->SetOnAddSObject(_impl->GetCallback());
       builder->SetOnRemoveSObject(_impl->GetCallback());
     }
@@ -1341,10 +1585,10 @@ void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
  *  Purpose  : This function attach an observer to the study
  */
 //============================================================================
-void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs,CORBA::Boolean modify)
+void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify)
 {
-  if(_notifier)
-    static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs,modify);
+  if (_notifier)
+    static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs, modify);
 }
 
 
@@ -1355,7 +1599,7 @@ void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs,CORBA::Boolean modif
 //============================================================================
 void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
 {
-  if(_notifier)
+  if (_notifier)
     static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
 }
 
index d988daa48980d470f9422a733010db99cb807ab7..b334ff9094b551b95374f49cc503391527a50a68 100644 (file)
@@ -55,6 +55,7 @@ private:
   static std::map<SALOMEDSImpl_Study*, SALOMEDS_Study_i*> _mapOfStudies;
   SALOMEDSImpl_AbstractCallback* _notifier;
   SALOMEDSImpl_AbstractCallback* _genObjRegister;
+  bool                           _closed;
 
 public:
 
@@ -276,17 +277,10 @@ public:
 
   virtual void AddCreatedPostponed(const char* theIOR);
 
-#ifndef WIN32
-  virtual void RemovePostponed(const CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
-                                                        // if theUndoLimit==0, removes all
-  virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects,
-                                                // theWay = -1: get back to the list of postponed
-#else
   virtual void RemovePostponed(CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
                                                         // if theUndoLimit==0, removes all
   virtual void UndoPostponed(CORBA::Long theWay); // theWay = 1: resurrect objects,
                                                 // theWay = -1: get back to the list of postponed
-#endif
 
   virtual SALOMEDS::AttributeParameter_ptr GetCommonParameters(const char* theID, CORBA::Long theSavePoint);
   virtual SALOMEDS::AttributeParameter_ptr GetModuleParameters(const char* theID, 
index 84904ea7e4ea5174c024f5973f0f9c47219efc29..883e4a27af37991d32719a9ad2cf957301068a68 100644 (file)
@@ -54,6 +54,19 @@ ORB_INIT::~ORB_INIT()
   }
 }
 
+void ORB_INIT::explicit_destroy()
+{
+  if ( ! CORBA::is_nil( _orb ) )
+    {
+    try {
+          _orb->destroy() ;
+          _orb = CORBA::ORB::_nil();
+        }
+        catch(...) {
+          MESSAGE("Caught CORBA::Exception.");
+        }
+    }
+}
 
 CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) throw( CommException )
 {
index 3665ce881a32952285f5ffadf8c8486799a62163..b18b81e01b1316610a706c84c45b76b6be52245d 100644 (file)
@@ -56,6 +56,7 @@ private :
 public :
         ORB_INIT( void );
         virtual ~ORB_INIT();
+        void explicit_destroy();
         CORBA::ORB_var & operator() ( int argc , char **argv ) throw( CommException ) ;
 
         inline CORBA::ORB_var &orb( void );