Version: 8.3.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Engines_Container_i Class Reference

C++ implementation of Engines::Container interface. More...

Inheritance diagram for Engines_Container_i:
Inheritance graph

Public Member Functions

 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)
 
virtual ~Engines_Container_i ()
 
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
 

Detailed Description

C++ implementation of Engines::Container interface.

Constructor & Destructor Documentation

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

Engines_Container_i::~Engines_Container_i ( )
virtual

Destructor

Member Function Documentation

bool Engines_Container_i::load_component_Library ( const char *  componentName,
CORBA::String_out  reason 
)
virtual

load a component implementation

CORBA method

Parameters
componentNamecomponent name
reasonexplains error when load fails
Returns
true if dlopen successfull or already done, false otherwise
Engines::EngineComponent_ptr Engines_Container_i::create_component_instance ( const char *  genericRegisterName,
CORBA::Long  studyId 
)
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.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service (without _inst_n suffix)
studyId0 for multiStudy instance, study Id (>0) otherwise
Returns
a loaded component
Engines::EngineComponent_ptr Engines_Container_i::create_component_instance_env ( const char *  genericRegisterName,
CORBA::Long  studyId,
const Engines::FieldsDict &  env,
CORBA::String_out  reason 
)
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.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service (without _inst_n suffix)
studyId0 for multiStudy instance, study Id (>0) otherwise
envdict of env variables
reasonexplains error when create_component_instance_env fails
Returns
a loaded component
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

Parameters
registeredNameName of the component in Registry or Name Service, without instance suffix number
studyId0 if instance is not associated to a study, >0 otherwise (== study id)
Returns
the first instance found with same studyId
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.

Parameters
genericRegisterNameName of the component to register in Registry & Name Service
componentNameName of the constructed library of the component
Returns
a loaded component
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

Parameters
component_iComponent to be removed
void Engines_Container_i::finalize_removal ( )

Unload component libraries from the container.

CORBA method: Discharges unused libraries from the container.

void Engines_Container_i::ping ( )
virtual

Ping the servant to check it is still alive.

CORBA method: check if servant is still alive

char * Engines_Container_i::name ( )

Get container name.

CORBA attribute: Container name (see constructor)

char * Engines_Container_i::workingdir ( )

Get container working directory.

CORBA attribute: Container working directory

char * Engines_Container_i::logfilename ( )

Get container log file name.

CORBA attribute: Container log file name

void Engines_Container_i::logfilename ( const char *  name)

Set container log file name.

void Engines_Container_i::Shutdown ( )
virtual

Shutdown the container.

CORBA method, oneway: Server shutdown.

  • Container name removed from naming service,
  • servant deactivation,
  • orb shutdown if no other servants in the process
char * Engines_Container_i::getHostName ( )

Get container host name.

CORBA method: Get the hostName of the Container (without domain extensions)

CORBA::Long Engines_Container_i::getPID ( )

Get container PID.

CORBA method: Get the PID (process identification) of the 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 !

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.

Parameters
origFileNameabsolute path for a local file to copy on other computers
Returns
a fileRef object associated to the file.
Engines::fileTransfer_ptr Engines_Container_i::getFileTransfer ( )

Get a fileTransfer reference.

CORBA method:

Returns
a reference to the fileTransfer object
Engines::Salome_file_ptr Engines_Container_i::createSalome_file ( const char *  origFileName)
virtual

Create a Salome file.

void Engines_Container_i::copyFile ( Engines::Container_ptr  container,
const char *  remoteFile,
const char *  localFile 
)

copy a file from a remote host (container) to the local host

Parameters
containerthe remote container
remoteFilethe file to copy locally from the remote host into localFile
localFilethe local file
Engines::PyNode_ptr Engines_Container_i::createPyNode ( const char *  nodeName,
const char *  code 
)

create a PyNode object to execute remote python code

Parameters
nodeNamethe name of the node
codethe python code to load
Returns
the PyNode
Engines::PyNode_ptr Engines_Container_i::getDefaultPyNode ( const char *  nodeName)

Retrieves the last created PyNode instance with createPyNode.

Engines::PyScriptNode_ptr Engines_Container_i::createPyScriptNode ( const char *  nodeName,
const char *  code 
)

create a PyScriptNode object to execute remote python code

Parameters
nodeNamethe name of the node
codethe python code to load
Returns
the PyScriptNode
Engines::PyScriptNode_ptr Engines_Container_i::getDefaultPyScriptNode ( const char *  nodeName)

Retrieves the last created PyScriptNode instance with createPyScriptNode.

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 ! -----—

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT")
componentLibraryNamelike "libCOMPONENTEngine.so"
Returns
a loaded component

example with names:

  • aGenRegisterName = COMPONENT (= first argument)
  • impl_name = libCOMPONENTEngine.so (= second argument)
  • _containerName = /Containers/cli76ce/FactoryServer
  • factoryName = COMPONENTEngine_factory
  • component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT
  • instanceName = COMPONENT_inst_1
  • component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1
bool Engines_Container_i::load_component_CppImplementation ( const char *  componentName,
std::string &  reason 
)

try to load a C++ component implementation

C++ method:

Parameters
componentNamethe name of the component (COMPONENT, for example)
reasonexplains error when load fails
Returns
true if loading is successfull or already done, false otherwise
bool Engines_Container_i::load_component_PythonImplementation ( const char *  componentName,
std::string &  reason 
)

try to load a Python component implementation

C++ method:

Parameters
componentNamename of the component
reasonexplains error when load fails
Returns
true if loading is successfull or already done, false otherwise
bool Engines_Container_i::load_component_ExecutableImplementation ( const char *  componentName,
std::string &  reason 
)

try to load a Executable component implementation

C++ method:

Parameters
componentNamename of the component
reasonexplains error when load fails
Returns
true if loading is successfull or already done, false otherwise
Engines::EngineComponent_ptr Engines_Container_i::createPythonInstance ( std::string  CompName,
int  studyId,
std::string &  reason 
)

Create a new component instance (Python implementation)

Parameters
CompNameName of the component instance
studyId0 for multiStudy instance, study Id (>0) otherwise
reasonexplains error when creation fails
Returns
a loaded component
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)

Parameters
CompNameName of the component instance
studyId0 for multiStudy instance, study Id (>0) otherwise
envdict of env variables
reasonexplains error when creation fails
Returns
a loaded component

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.

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.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT")
handleloaded library handle
studyId0 for multiStudy instance, study Id (>0) otherwise
reasonexplains error when creation fails
Returns
a loaded component

example with names:

  • aGenRegisterName = COMPONENT (= first argument)
  • _containerName = /Containers/cli76ce/FactoryServer
  • factoryName = COMPONENTEngine_factory
  • component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT
  • instanceName = COMPONENT_inst_1
  • component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1
bool Engines_Container_i::isPythonContainer ( const char *  ContainerName)
static

Indicate if container is a python one.

Retrieves only with container naming convention if it is a python container

void Engines_Container_i::decInstanceCnt ( std::string  genericRegisterName)
static

Decrement component instance reference count.