/* For each component contained in this container
* tell it to self-destroy
*/
- std::map<std::string, Engines::Component_var>::iterator itm;
+ std::map<std::string, Engines::EngineComponent_var>::iterator itm;
for (itm = _listInstances_map.begin(); itm != _listInstances_map.end(); itm++)
{
try
* \return a loaded component
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::create_component_instance(const char*genericRegisterName,
CORBA::Long studyId)
{
Engines::FieldsDict_var env = new Engines::FieldsDict;
char* reason;
- Engines::Component_ptr compo = create_component_instance_env(genericRegisterName, studyId, env, reason);
+ Engines::EngineComponent_ptr compo =
+ create_component_instance_env(genericRegisterName, studyId, env, reason);
CORBA::string_free(reason);
return compo;
}
* \return a loaded component
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::create_component_instance_env(const char*genericRegisterName,
CORBA::Long studyId,
const Engines::FieldsDict& env,
{
INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy");
reason=CORBA::string_dup("studyId must be > 0 for mono study instance, =0 for multiStudy");
- return Engines::Component::_nil() ;
+ return Engines::EngineComponent::_nil() ;
}
std::string error;
if (_library_map.count(genericRegisterName) != 0)
{
// It's a Python component
- Engines::Component_ptr compo = createPythonInstance(genericRegisterName, studyId, error);
+ Engines::EngineComponent_ptr compo = createPythonInstance(genericRegisterName, studyId, error);
reason=CORBA::string_dup(error.c_str());
return compo;
}
{
// It's a C++ component
void* handle = _library_map[impl_name];
- Engines::Component_ptr compo = createInstance(genericRegisterName, handle, studyId, error);
+ Engines::EngineComponent_ptr compo = createInstance(genericRegisterName, handle, studyId, error);
reason=CORBA::string_dup(error.c_str());
return compo;
}
if (_library_map.count(impl_name) != 0)
{
//It's an executable component
- Engines::Component_ptr compo = createExecutableInstance(genericRegisterName, studyId, env, error);
+ Engines::EngineComponent_ptr compo = createExecutableInstance(genericRegisterName, studyId, env, error);
reason=CORBA::string_dup(error.c_str());
return compo;
}
error += genericRegisterName;
INFOS(error);
reason=CORBA::string_dup(error.c_str());
- return Engines::Component::_nil() ;
+ return Engines::EngineComponent::_nil() ;
}
//=============================================================================
* it's registration.
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::createExecutableInstance(std::string CompName, int studyId,
const Engines::FieldsDict& env,
std::string& reason)
{
- Engines::Component_var iobject = Engines::Component::_nil() ;
+ Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
_numInstanceMutex.lock() ; // lock on the instance number
_numInstance++ ;
{
reason="SALOME_Container::create_component_instance system failed (system command status -1)";
MESSAGE(reason);
- return Engines::Component::_nil();
+ return Engines::EngineComponent::_nil();
}
#ifndef WIN32
else if (WEXITSTATUS(status) == 217)
{
reason="SALOME_Container::create_component_instance system failed (system command status 217)";
MESSAGE(reason);
- return Engines::Component::_nil();
+ return Engines::EngineComponent::_nil();
}
#endif
else
{
reason="SALOME_Container::create_component_instance failed";
MESSAGE(reason);
- return Engines::Component::_nil();
+ return Engines::EngineComponent::_nil();
}
else
{
MESSAGE("SALOME_Container::create_component_instance successful");
- iobject=Engines::Component::_narrow(obj);
+ iobject = Engines::EngineComponent::_narrow(obj);
_listInstances_map[instanceName] = iobject;
return iobject._retn();
}
* \return a loaded component
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::createPythonInstance(std::string CompName, int studyId,
std::string& reason)
{
- Engines::Component_var iobject = Engines::Component::_nil() ;
+ Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
_numInstanceMutex.lock() ; // lock on the instance number
_numInstance++ ;
if( iors!="" )
{
CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
- iobject = Engines::Component::_narrow( obj ) ;
+ iobject = Engines::EngineComponent::_narrow( obj ) ;
_listInstances_map[instanceName] = iobject;
}
return iobject._retn();
* - component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::createInstance(std::string genericRegisterName,
void *handle,
int studyId,
reason=dlerror();
INFOS(reason);
#endif
- return Engines::Component::_nil() ;
+ return Engines::EngineComponent::_nil() ;
}
// --- create instance
- Engines::Component_var iobject = Engines::Component::_nil() ;
+ Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
try
{
// --- get reference & servant from id
CORBA::Object_var obj = _poa->id_to_reference(*id);
- iobject = Engines::Component::_narrow( obj ) ;
+ iobject = Engines::EngineComponent::_narrow( obj ) ;
Engines_Component_i *servant =
dynamic_cast<Engines_Component_i*>(_poa->reference_to_servant(iobject));
* \return the first instance found with same studyId
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::find_component_instance( const char* registeredName,
CORBA::Long studyId)
{
- Engines::Component_var anEngine = Engines::Component::_nil();
- std::map<std::string,Engines::Component_var>::iterator itm =_listInstances_map.begin();
+ Engines::EngineComponent_var anEngine = Engines::EngineComponent::_nil();
+ std::map<std::string,Engines::EngineComponent_var>::iterator itm =_listInstances_map.begin();
while (itm != _listInstances_map.end())
{
std::string instance = (*itm).first;
*/
//=============================================================================
-void Engines_Container_i::remove_impl(Engines::Component_ptr component_i)
+void Engines_Container_i::remove_impl(Engines::EngineComponent_ptr component_i)
{
ASSERT(! CORBA::is_nil(component_i));
std::string instanceName = component_i->instanceName() ;
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::load_impl( const char* genericRegisterName,
const char* componentName )
{
char* reason;
std::string impl_name = std::string(LIB) + genericRegisterName + ENGINESO;
- Engines::Component_var iobject = Engines::Component::_nil() ;
+ Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
if (load_component_Library(genericRegisterName,reason))
iobject = find_or_create_instance(genericRegisterName, impl_name);
CORBA::string_free(reason);
*/
//=============================================================================
-Engines::Component_ptr
+Engines::EngineComponent_ptr
Engines_Container_i::find_or_create_instance(std::string genericRegisterName,
std::string componentLibraryName)
{
if (_library_map.count(impl_name) == 0)
{
INFOS("shared library " << impl_name <<" must be loaded before creating instance");
- return Engines::Component::_nil() ;
+ return Engines::EngineComponent::_nil() ;
}
else
{
void* handle = _library_map[impl_name];
std::string component_registerBase =
_containerName + "/" + aGenRegisterName;
- Engines::Component_var iobject = Engines::Component::_nil() ;
+ Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
std::string reason;
try
{
}
else
{
- iobject = Engines::Component::_narrow( obj ) ;
+ iobject = Engines::EngineComponent::_narrow( obj ) ;
Engines_Component_i *servant =
dynamic_cast<Engines_Component_i*>
(_poa->reference_to_servant(iobject));
}
else // monoStudy instance: NOK
{
- iobject = Engines::Component::_nil();
+ iobject = Engines::EngineComponent::_nil();
INFOS("load_impl & find_component_instance methods "
<< "NOT SUITABLE for mono study components");
}
}
+//=============================================================================
+/*! \brief create a PyScriptNode object to execute remote python code
+ * \param nodeName the name of the node
+ * \param code the python code to load
+ * \return the PyScriptNode
+ */
+//=============================================================================
+Engines::PyScriptNode_ptr Engines_Container_i::createPyScriptNode(const char* nodeName, const char* code)
+{
+ Engines::PyScriptNode_var node= Engines::PyScriptNode::_nil();
+
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ PyObject *res = PyObject_CallMethod(_pyCont,
+ (char*)"create_pyscriptnode",
+ (char*)"ss",
+ nodeName,
+ code);
+ if(res==NULL)
+ {
+ //internal error
+ PyErr_Print();
+ PyGILState_Release(gstate);
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "can not create a python node";
+ throw SALOME::SALOME_Exception(es);
+ }
+ long ierr=PyInt_AsLong(PyTuple_GetItem(res,0));
+ PyObject* result=PyTuple_GetItem(res,1);
+ std::string astr=PyString_AsString(result);
+ Py_DECREF(res);
+ PyGILState_Release(gstate);
+
+ if(ierr==0)
+ {
+ CORBA::Object_var obj = _orb->string_to_object(astr.c_str());
+ node = Engines::PyScriptNode::_narrow(obj);
+ return node._retn();
+ }
+ else
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = astr.c_str();
+ throw SALOME::SALOME_Exception(es);
+ }
+}
+
//=============================================================================
/* int checkifexecutable(const char *filename)
*
}
return found;
}
-