Engines::EngineComponent create_component_instance(in string componentName,
in long studyId);
+ //! Create a new Python servant instance of a generic service.
+ /*!
+ This simply loads the service in the current container by importing the
+ corresponding Python module.
+ Warning: no internal registration is done, so it is up to the caller to
+ manage the various instanciation.
+ \param serviceName Name of the service
+
+ >0 otherwise (== study id)
+ \param reason in case of error (return void string) a string explaining the error
+ \return the IOR of the loaded service.
+ */
+ string create_python_service_instance(in string serviceName,
+ out string reason);
+
//! Create a new servant instance of a component with environment variables specified.
/*!
Component library must be loaded.
return iobject._retn();
}
+char *
+Engines_Container_i::create_python_service_instance(const char * CompName,
+ CORBA::String_out reason)
+{
+ CORBA::Object_var object = CORBA::Object::_nil();
+
+ _numInstanceMutex.lock() ; // lock on the instance number
+ _numInstance++ ;
+ int numInstance = _numInstance ;
+ _numInstanceMutex.unlock() ;
+
+ char aNumI[12];
+ sprintf( aNumI , "%d" , numInstance ) ;
+ std::string instanceName = std::string(CompName) + "_inst_" + aNumI ;
+ std::string component_registerName = _containerName + "/" + instanceName;
+
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ PyObject *result = PyObject_CallMethod(_pyCont,
+ (char*)"create_component_instance",
+ (char*)"ssl",
+ CompName,
+ instanceName.c_str(),
+ 0);
+ const char *ior;
+ const char *error;
+ PyArg_ParseTuple(result,"ss", &ior, &error);
+ reason = CORBA::string_dup(error);
+ Py_DECREF(result);
+ PyGILState_Release(gstate);
+
+ return CORBA::string_dup(ior);
+}
+
+
//=============================================================================
//! Create a new component instance (C++ implementation)
/*!
create_component_instance_env( const char* componentName,
CORBA::Long studyId, // 0 for multiStudy
const Engines::FieldsDict& env,
- CORBA::String_out reason);
+ CORBA::String_out reason);
+
+ 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); // 0 for multiStudy