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")
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:
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:
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:
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 ]
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",
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
# specified in configuration file(s)
###
+ if theAdditionalOptions is None:
+ theAdditionalOptions = []
+
global args
config_var = appname+'Config'
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
# 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
# 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
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
# - 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
#
# 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()
# 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
return shell.interact
#
-def connect(args=[]):
+def connect(args=None):
+ if args is None:
+ args = []
p = __prompt(commands=["import salomeConsole"])
p()
#
# 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:
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.
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")
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:
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
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)
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
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
#
- 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 " ___...(-------)-....___"
return self._logger
#
-import pickle
if __name__ == "__main__":
if len(sys.argv) == 3:
context = pickle.loads(sys.argv[1])
#
# 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
# 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
_session = None
-def startSession(modules=[]):
+def startSession(modules=None):
+ if modules is None:
+ modules = []
global _session
if _session: return
from searchFreePort import searchFreePort
\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:
interface Study
{
+//! Invalid study reference
+ exception StudyInvalidReference {};
//! Invalid study context
exception StudyInvalidContext {};
//! Invalid study component
//! 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,
<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
<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.
<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.
<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
<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;
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.
/*! \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.
\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.
\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.
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
\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
\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
\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
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
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
\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
\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
\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
# 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()
#
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)
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)
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
# --
#-------------------------------------------------------------------------
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
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:
============================================
"""
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
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
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
"""
- 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
__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
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
#--------------------------------------------------------------------------
+def setVerticesMode(objId, mode):
+ return
+
+ #--------------------------------------------------------------------------
+
# --- From SMESHGUI_SWIG
#--------------------------------------------------------------------------
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)
cm = obj._narrow(Engines.ContainerManager)
return orb, lcc, naming_service, cm
-
-def salome_kernel_close():
- global salome_kernel_initial
- salome_kernel_initial=1
- pass
import salome_iapp
from launchConfigureParser import verbose
+myStudyManager = None
+myStudyId = None
+myStudy = None
+myStudyName = None
+
#--------------------------------------------------------------------------
def DumpComponent(Study, SO, Builder,offset):
"""
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)
#--------------------------------------------------------------------------
def IDToObject(id):
+ global myStudy
myObj = None
mySO = myStudy.FindObjectID(id);
if mySO is not None:
return ""
def IDToSObject(id):
+ global myStudy
mySO = myStudy.FindObjectID(id);
return mySO
def GetTree(theSO):
# returns the document list tree (as list)
+ global myStudy
aResult = [theSO.GetID()]
anIter = myStudy.NewChildIterator(theSO)
while anIter.More():
#--------------------------------------------------------------------------
def CheckCopyPaste(theSO, theInfo ,theComponentPaste):
+ global myStudyManager, myStudy
+
aRoot = theSO
while aRoot.GetID() != "0:":
aRoot = aRoot.GetFather()
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?
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
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
-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
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
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,
${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
SALOMELocalTrace
SALOMEBasics
SalomeHDFPersist
+ SalomeKernelHelpers
DF
SalomeDSImpl
SalomeGenericObj
// Module : SALOME
//
#include "utilities.h"
+#include <sstream>
#include "SALOMEDS_Study_i.hxx"
#include "SALOMEDS_StudyManager_i.hxx"
#include "SALOMEDS_UseCaseIterator_i.hxx"
#include "DF_Attribute.hxx"
#include "Basics_Utils.hxx"
+#include "SALOME_KernelServices.hxx"
#ifdef WIN32
#include <process.h>
_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();
+ }
}
//============================================================================
char* SALOMEDS_Study_i::GetPersistentReference()
{
SALOMEDS::Locker lock;
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
return CORBA::string_dup(_impl->GetPersistentReference().c_str());
}
//============================================================================
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());
}
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
{
SALOMEDS::Locker lock;
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
return _impl->IsEmpty();
}
{
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();
}
{
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();
}
{
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();
}
//============================================================================
{
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();
}
{
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();
}
{
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();
}
//============================================================================
{
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();
}
{
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();
}
{
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());
}
{
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();
}
{
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());
}
{
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();
{
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();
for (int anIndex = 0; anIndex < aLength; anIndex++) {
aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
}
-
+
return aResult._retn();
}
{
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();
{
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));
{
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();
}
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();
}
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();
}
//============================================================================
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());
}
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));
}
* 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;
}
//============================================================================
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);
}
//============================================================================
* 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();
}
* 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
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());
}
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));
}
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)
{
SALOMEDS::Locker lock;
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
SALOMEDS::GenericAttribute_ptr aTarget;
if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
{
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());
}
{
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
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();
}
{
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();
// 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;
}
//============================================================================
* 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 (...) {}
}
* 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
{
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;
}
{
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();
}
//============================================================================
{
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();
}
//============================================================================
void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
{
SALOMEDS::Locker lock;
+
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
_impl->SetStudyLock(theLockerID);
}
bool SALOMEDS_Study_i::IsStudyLocked()
{
SALOMEDS::Locker lock;
+
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
return _impl->IsStudyLocked();
}
void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
{
SALOMEDS::Locker lock;
+
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
_impl->UnLockStudy(theLockerID);
}
{
SALOMEDS::Locker lock;
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
std::vector<std::string> aSeq = _impl->GetLockerID();
for(int anIndex = 0; anIndex < aLength; anIndex++) {
aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
}
+
return aResult._retn();
}
//============================================================================
//============================================================================
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);
}
//============================================================================
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);
}
//============================================================================
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);
}
//============================================================================
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);
}
//============================================================================
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);
}
//============================================================================
//============================================================================
CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
{
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
return _impl->GetVariableValue(std::string(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));
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
{
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
return (bool)_impl->GetVariableValue(std::string(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());
}
//============================================================================
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);
}
//============================================================================
//============================================================================
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);
}
//============================================================================
//============================================================================
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);
}
//============================================================================
//============================================================================
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);
}
//============================================================================
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
{
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
return _impl->IsVariable(std::string(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());
//============================================================================
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;
}
//============================================================================
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;
}
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
{
+ if (_closed)
+ throw SALOMEDS::Study::StudyInvalidReference();
+
return _impl->IsVariableUsed(std::string(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);
{
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());
}
//============================================================================
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());
}
* 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);
}
//============================================================================
void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
{
- if(_notifier)
+ if (_notifier)
static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
}
static std::map<SALOMEDSImpl_Study*, SALOMEDS_Study_i*> _mapOfStudies;
SALOMEDSImpl_AbstractCallback* _notifier;
SALOMEDSImpl_AbstractCallback* _genObjRegister;
+ bool _closed;
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,
}
}
+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 )
{
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 );