C++ implementation of Engines::Container interface. More...
#include <SALOME_Container_i.hxx>

Public Member Functions | |
| Engines_Container_i () | |
| Default constructor, not for use.  More... | |
| Engines_Container_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, char *containerName, int argc, char *argv[], bool activAndRegist=true, bool isServantAloneInProcess=true) | |
| Construtor to use.  More... | |
| virtual | ~Engines_Container_i () | 
| Destructor.  More... | |
| virtual bool | load_component_Library (const char *componentName, CORBA::String_out reason) | 
| load a component implementation  More... | |
| virtual  Engines::EngineComponent_ptr  | create_component_instance (const char *componentName, CORBA::Long studyId) | 
| Create a new component instance.  More... | |
| virtual  Engines::EngineComponent_ptr  | create_component_instance_env (const char *componentName, CORBA::Long studyId, const Engines::FieldsDict &env, CORBA::String_out reason) | 
| Create a new component instance with environment variables specified.  More... | |
| virtual char * | create_python_service_instance (const char *CompName, CORBA::String_out reason) | 
| Engines::EngineComponent_ptr | find_component_instance (const char *registeredName, CORBA::Long studyId) | 
| Find an existing (in the container) component instance.  More... | |
| Engines::EngineComponent_ptr | load_impl (const char *nameToRegister, const char *componentName) | 
| Find or create a new component instance.  More... | |
| void | remove_impl (Engines::EngineComponent_ptr component_i) | 
| Remove the component instance from container.  More... | |
| void | finalize_removal () | 
| Unload component libraries from the container.  More... | |
| virtual void | ping () | 
| Ping the servant to check it is still alive.  More... | |
| char * | name () | 
| Get container name.  More... | |
| char * | workingdir () | 
| Get container working directory.  More... | |
| char * | logfilename () | 
| Get container log file name.  More... | |
| void | logfilename (const char *name) | 
| Set container log file name.  More... | |
| virtual void | Shutdown () | 
| Shutdown the container.  More... | |
| char * | getHostName () | 
| Get container host name.  More... | |
| CORBA::Long | getPID () | 
| Get container PID.  More... | |
| bool | Kill_impl () | 
| Kill current container.  More... | |
| Engines::fileRef_ptr | createFileRef (const char *origFileName) | 
| Get or create a file reference object associated to a local file (to transfer it)  More... | |
| Engines::fileTransfer_ptr | getFileTransfer () | 
| Get a fileTransfer reference.  More... | |
| virtual Engines::Salome_file_ptr | createSalome_file (const char *origFileName) | 
| Create a Salome file.  More... | |
| void | copyFile (Engines::Container_ptr container, const char *remoteFile, const char *localFile) | 
| copy a file from a remote host (container) to the local host  More... | |
| Engines::PyNode_ptr | createPyNode (const char *nodeName, const char *code) | 
| create a PyNode object to execute remote python code  More... | |
| Engines::PyNode_ptr | getDefaultPyNode (const char *nodeName) | 
| Retrieves the last created PyNode instance with createPyNode.  More... | |
| Engines::PyScriptNode_ptr | createPyScriptNode (const char *nodeName, const char *code) | 
| create a PyScriptNode object to execute remote python code  More... | |
| Engines::PyScriptNode_ptr | getDefaultPyScriptNode (const char *nodeName) | 
| Retrieves the last created PyScriptNode instance with createPyScriptNode.  More... | |
| Engines::EngineComponent_ptr | find_or_create_instance (std::string genericRegisterName, std::string componentLibraryName) | 
| Finds an already existing component instance or create a new instance.  More... | |
| bool | load_component_CppImplementation (const char *componentName, std::string &reason) | 
| try to load a C++ component implementation  More... | |
| bool | load_component_PythonImplementation (const char *componentName, std::string &reason) | 
| try to load a Python component implementation  More... | |
| bool | load_component_ExecutableImplementation (const char *componentName, std::string &reason) | 
| try to load a Executable component implementation  More... | |
| Engines::EngineComponent_ptr | createPythonInstance (std::string CompName, int studyId, std::string &error) | 
| Create a new component instance (Python implementation)  More... | |
| Engines::EngineComponent_ptr | createExecutableInstance (std::string CompName, int studyId, const Engines::FieldsDict &env, std::string &error) | 
| Create a new component instance (Executable implementation)  More... | |
| Engines::EngineComponent_ptr | createInstance (std::string genericRegisterName, void *handle, int studyId, std::string &error) | 
| Create a new component instance (C++ implementation)  More... | |
| int | getArgc () | 
| char ** | getArgv () | 
| void | registerTemporaryFile (const std::string &fileName) | 
| void | unregisterTemporaryFile (const std::string &fileName) | 
| void | clearTemporaryFiles () | 
Static Public Member Functions | |
| static bool | isPythonContainer (const char *ContainerName) | 
| Indicate if container is a python one.  More... | |
| static void | decInstanceCnt (std::string genericRegisterName) | 
| Decrement component instance reference count.  More... | |
Protected Attributes | |
| bool | _isSupervContainer | 
| SALOME_NamingService * | _NS | 
| std::string | _library_path | 
| std::string | _containerName | 
| std::string | _logfilename | 
| CORBA::ORB_var | _orb | 
| PortableServer::POA_var | _poa | 
| PortableServer::ObjectId * | _id | 
| int | _numInstance | 
| std::map< std::string,  Engines::EngineComponent_var >  | _listInstances_map | 
| std::map< std::string,  Engines::fileRef_var >  | _fileRef_map | 
| std::map< std::string,  Engines::Salome_file_var >  | _Salome_file_map | 
| std::map< std::string,  Engines::PyScriptNode_var >  | _dftPyScriptNode | 
| std::map< std::string,  Engines::PyNode_var >  | _dftPyNode | 
| Utils_Mutex | _mutexForDftPy | 
| std::list< std::string > | _tmp_files | 
| Engines::fileTransfer_var | _fileTransfer | 
| int | _argc | 
| char ** | _argv | 
| long | _pid | 
| bool | _isServantAloneInProcess | 
Static Protected Attributes | |
| static std::map< std::string, int > | _cntInstances_map | 
| static std::map< std::string,  void * >  | _library_map | 
| static std::map< std::string,  void * >  | _toRemove_map | 
| static omni_mutex | _numInstanceMutex | 
C++ implementation of Engines::Container interface.
| Engines_Container_i::Engines_Container_i | ( | ) | 
Default constructor, not for use.
| Engines_Container_i::Engines_Container_i | ( | CORBA::ORB_ptr | orb, | 
| PortableServer::POA_ptr | poa, | ||
| char * | containerName, | ||
| int | argc, | ||
| char * | argv[], | ||
| bool | activAndRegist = true,  | 
        ||
| bool | isServantAloneInProcess = true  | 
        ||
| ) | 
Construtor to use.
References _argc, _argv, _containerName, _fileTransfer, _id, _isSupervContainer, _NS, _orb, _pid, _poa, _pyCont, ActSigIntHandler(), ASSERT, SALOME_NamingService::BuildContainerNameForNS(), Kernel_Utils::GetHostname(), INFOS, SALOME_NamingService::init_orb(), MESSAGE, SALOME_NamingService::Register(), and SCRUTE.
      
  | 
  virtual | 
Destructor.
References _dftPyNode, _dftPyScriptNode, _id, _NS, and MESSAGE.
| void Engines_Container_i::clearTemporaryFiles | ( | ) | 
References _tmp_files.
Referenced by Shutdown().
      
  | 
  virtual | 
Create a new component instance.
CORBA method: Creates a new servant instance of a component. The servant registers itself to naming service and Registry.
| genericRegisterName | Name of the component instance to register in Registry & Name Service (without _inst_n suffix) | 
| studyId | 0 for multiStudy instance, study Id (>0) otherwise | 
References create_component_instance_env().
      
  | 
  virtual | 
Create a new component instance with environment variables specified.
CORBA method: Creates a new servant instance of a component. The servant registers itself to naming service and Registry.
| genericRegisterName | Name of the component instance to register in Registry & Name Service (without _inst_n suffix) | 
| studyId | 0 for multiStudy instance, study Id (>0) otherwise | 
| env | dict of env variables | 
| reason | explains error when create_component_instance_env fails | 
Reimplemented in Engines_MPIContainer_i.
References _library_map, createExecutableInstance(), createInstance(), createPythonInstance(), ENGINESO, INFOS, and LIB.
Referenced by create_component_instance().
      
  | 
  virtual | 
References _containerName, _numInstance, _numInstanceMutex, and _pyCont.
| Engines::EngineComponent_ptr Engines_Container_i::createExecutableInstance | ( | std::string | CompName, | 
| int | studyId, | ||
| const Engines::FieldsDict & | env, | ||
| std::string & | reason | ||
| ) | 
Create a new component instance (Executable implementation)
| CompName | Name of the component instance | 
| studyId | 0 for multiStudy instance, study Id (>0) otherwise | 
| env | dict of env variables | 
| reason | explains error when creation fails | 
This component is implemented in an executable with name genericRegisterName.exe It must register itself in Naming Service. The container waits some time (10 s max) it's registration.
References _containerName, _listInstances_map, _NS, _numInstance, _numInstanceMutex, _orb, SALOME_NamingService::Destroy_Name(), INFOS, MESSAGE, and SALOME_NamingService::Resolve().
Referenced by create_component_instance_env().
| Engines::fileRef_ptr Engines_Container_i::createFileRef | ( | const char * | origFileName | ) | 
Get or create a file reference object associated to a local file (to transfer it)
CORBA method: get or create a fileRef object associated to a local file (a file on the computer on which runs the container server), which stores a list of (machine, localFileName) corresponding to copies already done.
| origFileName | absolute path for a local file to copy on other computers | 
References _fileRef_map, _id, _numInstanceMutex, _poa, ASSERT, and INFOS.
| Engines::EngineComponent_ptr Engines_Container_i::createInstance | ( | std::string | genericRegisterName, | 
| void * | handle, | ||
| int | studyId, | ||
| std::string & | reason | ||
| ) | 
Create a new component instance (C++ implementation)
C++ method: create a servant instance of a component.
| genericRegisterName | Name of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT") | 
| handle | loaded library handle | 
| studyId | 0 for multiStudy instance, study Id (>0) otherwise | 
| reason | explains error when creation fails | 
example with names:
References _cntInstances_map, _containerName, _id, _listInstances_map, _NS, _numInstance, _numInstanceMutex, _orb, _poa, ASSERT, INFOS, MESSAGE, SALOME_NamingService::Register(), SCRUTE, and Engines_Component_i::setStudyId().
Referenced by create_component_instance_env(), and find_or_create_instance().
create a PyNode object to execute remote python code
| nodeName | the name of the node | 
| code | the python code to load | 
References _dftPyNode, _mutexForDftPy, _orb, _pyCont, SALOME::INTERNAL_ERROR, SALOME::ExceptionStruct::text, and SALOME::ExceptionStruct::type.
| Engines::PyScriptNode_ptr Engines_Container_i::createPyScriptNode | ( | const char * | nodeName, | 
| const char * | code | ||
| ) | 
create a PyScriptNode object to execute remote python code
| nodeName | the name of the node | 
| code | the python code to load | 
References _dftPyScriptNode, _mutexForDftPy, _orb, _pyCont, SALOME::INTERNAL_ERROR, SALOME::ExceptionStruct::text, and SALOME::ExceptionStruct::type.
| Engines::EngineComponent_ptr Engines_Container_i::createPythonInstance | ( | std::string | CompName, | 
| int | studyId, | ||
| std::string & | reason | ||
| ) | 
Create a new component instance (Python implementation)
| CompName | Name of the component instance | 
| studyId | 0 for multiStudy instance, study Id (>0) otherwise | 
| reason | explains error when creation fails | 
References _containerName, _listInstances_map, _numInstance, _numInstanceMutex, _orb, and _pyCont.
Referenced by create_component_instance_env().
      
  | 
  virtual | 
Create a Salome file.
References _numInstanceMutex, _Salome_file_map, ASSERT, Salome_file_i::recvFiles(), Salome_file_i::setContainer(), and Salome_file_i::setLocalFile().
      
  | 
  static | 
Decrement component instance reference count.
References _cntInstances_map, _library_map, _numInstanceMutex, _toRemove_map, ASSERT, Engines_Component_i::GetDynLibraryName(), MESSAGE, and SCRUTE.
Referenced by Engines_Component_i::~Engines_Component_i().
| void Engines_Container_i::finalize_removal | ( | ) | 
Unload component libraries from the container.
CORBA method: Discharges unused libraries from the container.
References _numInstanceMutex, _toRemove_map, MESSAGE, and SCRUTE.
| Engines::EngineComponent_ptr Engines_Container_i::find_component_instance | ( | const char * | registeredName, | 
| CORBA::Long | studyId | ||
| ) | 
Find an existing (in the container) component instance.
CORBA method: Finds a servant instance of a component
| registeredName | Name of the component in Registry or Name Service, without instance suffix number | 
| studyId | 0 if instance is not associated to a study, >0 otherwise (== study id) | 
References _listInstances_map, and SCRUTE.
| Engines::EngineComponent_ptr Engines_Container_i::find_or_create_instance | ( | std::string | genericRegisterName, | 
| std::string | componentLibraryName | ||
| ) | 
Finds an already existing component instance or create a new instance.
C++ method: Finds an already existing servant instance of a component, or create an instance. -— USE ONLY FOR MULTISTUDY INSTANCES ! -----—
| genericRegisterName | Name of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT") | 
| componentLibraryName | like "libCOMPONENTEngine.so" | 
example with names:
References _containerName, _library_map, _NS, _poa, ASSERT, createInstance(), Engines_Component_i::getStudyId(), INFOS, MESSAGE, and SALOME_NamingService::ResolveFirst().
Referenced by load_impl().
| int Engines_Container_i::getArgc | ( | ) | 
| char** Engines_Container_i::getArgv | ( | ) | 
| Engines::PyNode_ptr Engines_Container_i::getDefaultPyNode | ( | const char * | nodeName | ) | 
Retrieves the last created PyNode instance with createPyNode.
References _dftPyNode, and _mutexForDftPy.
| Engines::PyScriptNode_ptr Engines_Container_i::getDefaultPyScriptNode | ( | const char * | nodeName | ) | 
Retrieves the last created PyScriptNode instance with createPyScriptNode.
References _dftPyScriptNode, and _mutexForDftPy.
| Engines::fileTransfer_ptr Engines_Container_i::getFileTransfer | ( | ) | 
Get a fileTransfer reference.
CORBA method:
References _fileTransfer.
| char * Engines_Container_i::getHostName | ( | ) | 
Get container host name.
CORBA method: Get the hostName of the Container (without domain extensions)
References Kernel_Utils::GetHostname().
| CORBA::Long Engines_Container_i::getPID | ( | ) | 
Get container PID.
CORBA method: Get the PID (process identification) of the Container
Indicate if container is a python one.
Retrieves only with container naming convention if it is a python container
| bool Engines_Container_i::Kill_impl | ( | ) | 
Kill current container.
Kill the container.
CORBA method: Kill the container process with exit(0). To remove : never returns !
References _containerName, ASSERT, Kernel_Utils::GetHostname(), INFOS, and MESSAGE.
| bool Engines_Container_i::load_component_CppImplementation | ( | const char * | componentName, | 
| std::string & | reason | ||
| ) | 
try to load a C++ component implementation
C++ method:
| componentName | the name of the component (COMPONENT, for example) | 
| reason | explains error when load fails | 
References _library_map, _numInstanceMutex, _toRemove_map, ENGINESO, findpathof(), LIB, MESSAGE, SCRUTE, and SEP.
Referenced by load_component_Library().
| bool Engines_Container_i::load_component_ExecutableImplementation | ( | const char * | componentName, | 
| std::string & | reason | ||
| ) | 
try to load a Executable component implementation
C++ method:
| componentName | name of the component | 
| reason | explains error when load fails | 
References _library_map, _numInstanceMutex, checkifexecutable(), findpathof(), and MESSAGE.
Referenced by load_component_Library().
      
  | 
  virtual | 
load a component implementation
CORBA method
| componentName | component name | 
| reason | explains error when load fails | 
Reimplemented in Engines_MPIContainer_i.
References ENGINESO, LIB, load_component_CppImplementation(), load_component_ExecutableImplementation(), and load_component_PythonImplementation().
Referenced by load_impl().
| bool Engines_Container_i::load_component_PythonImplementation | ( | const char * | componentName, | 
| std::string & | reason | ||
| ) | 
try to load a Python component implementation
C++ method:
| componentName | name of the component | 
| reason | explains error when load fails | 
References _library_map, _numInstanceMutex, _pyCont, MESSAGE, and SCRUTE.
Referenced by load_component_Library().
| Engines::EngineComponent_ptr Engines_Container_i::load_impl | ( | const char * | genericRegisterName, | 
| const char * | componentName | ||
| ) | 
Find or create a new component instance.
CORBA method: find or create an instance of the component (servant), load a new component class (dynamic library) if required,
-— FOR COMPATIBILITY WITH 2.2 -—
-— USE ONLY FOR MULTISTUDY INSTANCES ! -----—
The servant registers itself to naming service and Registry.
| genericRegisterName | Name of the component to register in Registry & Name Service | 
| componentName | Name of the constructed library of the component | 
References ENGINESO, find_or_create_instance(), LIB, and load_component_Library().
Referenced by Engines_MPIContainer_i::Lload_impl().
| char * Engines_Container_i::logfilename | ( | ) | 
| void Engines_Container_i::logfilename | ( | const char * | name | ) | 
Set container log file name.
References _logfilename, and name().
| char * Engines_Container_i::name | ( | ) | 
Get container name.
CORBA attribute: Container name (see constructor)
References _containerName.
Referenced by logfilename().
      
  | 
  virtual | 
Ping the servant to check it is still alive.
CORBA method: check if servant is still alive
References MESSAGE.
| void Engines_Container_i::registerTemporaryFile | ( | const std::string & | fileName | ) | 
References _tmp_files.
| void Engines_Container_i::remove_impl | ( | Engines::EngineComponent_ptr | component_i | ) | 
Remove the component instance from container.
CORBA method: Stops the component servant, and deletes all related objects
| component_i | Component to be removed | 
References _listInstances_map, _NS, _numInstanceMutex, ASSERT, SALOME_NamingService::Destroy_Name(), and MESSAGE.
      
  | 
  virtual | 
Shutdown the container.
CORBA method, oneway: Server shutdown.
Reimplemented in Engines_MPIContainer_i.
References _containerName, _isServantAloneInProcess, _listInstances_map, _NS, _orb, clearTemporaryFiles(), SALOME_NamingService::Destroy_FullDirectory(), SALOME_NamingService::Destroy_Name(), and MESSAGE.
| void Engines_Container_i::unregisterTemporaryFile | ( | const std::string & | fileName | ) | 
References _tmp_files.
| char * Engines_Container_i::workingdir | ( | ) | 
Get container working directory.
CORBA attribute: Container working directory
      
  | 
  protected | 
Referenced by Engines_Container_i().
      
  | 
  protected | 
Referenced by Engines_Container_i().
      
  | 
  staticprotected | 
Referenced by createInstance(), Engines_MPIContainer_i::createMPIInstance(), and decInstanceCnt().
      
  | 
  protected | 
Referenced by create_python_service_instance(), createExecutableInstance(), createInstance(), Engines_MPIContainer_i::createMPIInstance(), createPythonInstance(), Engines_Container_i(), Engines_MPIContainer_i::Engines_MPIContainer_i(), find_or_create_instance(), Kill_impl(), Engines_MPIContainer_i::Lcreate_component_instance(), Engines_MPIContainer_i::Lload_impl(), name(), Engines_MPIContainer_i::Shutdown(), and Shutdown().
      
  | 
  protected | 
Referenced by createPyNode(), getDefaultPyNode(), and ~Engines_Container_i().
      
  | 
  protected | 
Referenced by createPyScriptNode(), getDefaultPyScriptNode(), and ~Engines_Container_i().
      
  | 
  protected | 
Referenced by createFileRef().
      
  | 
  protected | 
Referenced by Engines_Container_i(), and getFileTransfer().
      
  | 
  protected | 
      
  | 
  protected | 
Referenced by Shutdown().
      
  | 
  protected | 
      
  | 
  staticprotected | 
Referenced by create_component_instance_env(), decInstanceCnt(), find_or_create_instance(), Engines_MPIContainer_i::Lcreate_component_instance(), Engines_MPIContainer_i::Lload_component_Library(), load_component_CppImplementation(), load_component_ExecutableImplementation(), and load_component_PythonImplementation().
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
Referenced by logfilename().
      
  | 
  protected | 
Referenced by createPyNode(), createPyScriptNode(), getDefaultPyNode(), and getDefaultPyScriptNode().
      
  | 
  protected | 
Referenced by createExecutableInstance(), createInstance(), Engines_MPIContainer_i::createMPIInstance(), Engines_Container_i(), Engines_MPIContainer_i::Engines_MPIContainer_i(), find_or_create_instance(), Engines_MPIContainer_i::Lcreate_component_instance(), Engines_MPIContainer_i::Lload_impl(), Engines_MPIContainer_i::remove_impl(), remove_impl(), Engines_MPIContainer_i::Shutdown(), Shutdown(), and ~Engines_Container_i().
      
  | 
  protected | 
      
  | 
  staticprotected | 
Referenced by create_python_service_instance(), createExecutableInstance(), createFileRef(), createInstance(), Engines_MPIContainer_i::createMPIInstance(), createPythonInstance(), createSalome_file(), decInstanceCnt(), Engines_MPIContainer_i::finalize_removal(), finalize_removal(), Engines_MPIContainer_i::Lcreate_component_instance(), Engines_MPIContainer_i::Lload_component_Library(), Engines_MPIContainer_i::Lload_impl(), load_component_CppImplementation(), load_component_ExecutableImplementation(), load_component_PythonImplementation(), Engines_MPIContainer_i::remove_impl(), and remove_impl().
      
  | 
  protected | 
Referenced by createExecutableInstance(), createInstance(), Engines_MPIContainer_i::createMPIInstance(), createPyNode(), createPyScriptNode(), createPythonInstance(), Engines_Container_i(), Engines_MPIContainer_i::Engines_MPIContainer_i(), Engines_MPIContainer_i::Lcreate_component_instance(), Engines_MPIContainer_i::Lload_impl(), Engines_MPIContainer_i::Shutdown(), and Shutdown().
      
  | 
  protected | 
Referenced by Engines_Container_i().
      
  | 
  protected | 
      
  | 
  protected | 
Referenced by createSalome_file().
      
  | 
  protected | 
Referenced by clearTemporaryFiles(), registerTemporaryFile(), and unregisterTemporaryFile().
      
  | 
  staticprotected |