//=============================================================================
/*!
- * Construtor
+ * Constructor
*/
//=============================================================================
* \param componentName like COMPONENT
* try to make a Python import of COMPONENT,
* then a lib open of libCOMPONENTEngine.so
- * \return true if dlopen successfull or already done, false otherwise
+ * \return true if dlopen successful or already done, false otherwise
*/
//=============================================================================
bool ret = false;
std::string aCompName = componentName;
#ifndef WIN32
+#ifdef __APPLE__
+ std::string impl_name = string ("lib") + aCompName + string("Engine.dylib");
+#else
std::string impl_name = string ("lib") + aCompName + string("Engine.so");
+#endif
#else
std::string impl_name = aCompName + string("Engine.dll");
#endif
MESSAGE("Try to load C++ component");
void* handle;
#ifndef WIN32
- handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
+ handle = dlopen( impl_name.c_str() , RTLD_LAZY | RTLD_GLOBAL ) ;
#else
handle = dlopen( impl_name.c_str() , 0 ) ;
#endif
PyObject *result = PyObject_CallMethod(pyCont,
(char*)"import_component",
(char*)"s",componentName);
- std::string ret_p= PyString_AsString(result);
+ std::string ret_p= PyUnicode_AsUTF8(result);
Py_XDECREF(result);
Py_RELEASE_NEW_THREAD;
* The servant registers itself to naming service and Registry.
* \param genericRegisterName Name of the component instance to register
* in Registry & Name Service (without _inst_n suffix)
- * \param studyId 0 for multiStudy instance,
- * study Id (>0) otherwise
* \return a loaded component
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Parallel_Container_i::create_component_instance(const char*genericRegisterName,
- CORBA::Long studyId)
+Engines_Parallel_Container_i::create_component_instance(const char*genericRegisterName)
{
Engines::FieldsDict_var env = new Engines::FieldsDict;
char* reason;
- Engines::EngineComponent_ptr compo = create_component_instance_env(genericRegisterName,studyId,env, reason);
+ Engines::EngineComponent_ptr compo = create_component_instance_env(genericRegisterName,env, reason);
CORBA::string_free(reason);
return compo;
}
* The servant registers itself to naming service and Registry.
* \param genericRegisterName Name of the component instance to register
* in Registry & Name Service (without _inst_n suffix)
- * \param studyId 0 for multiStudy instance,
- * study Id (>0) otherwise
* \param env dict of environment variables
* \return a loaded component
*/
Engines::EngineComponent_ptr
Engines_Parallel_Container_i::create_component_instance_env(const char*genericRegisterName,
- CORBA::Long studyId,
const Engines::FieldsDict& env,
CORBA::String_out reason)
{
MESSAGE("Begin of create_component_instance in node : " << getMyRank());
reason=CORBA::string_dup("");
- if (studyId < 0)
- {
- INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy");
- return Engines::EngineComponent::_nil() ;
- }
-
std::string aCompName = genericRegisterName;
#ifndef WIN32
+#ifdef __APPLE__
+ std::string impl_name = string ("lib") + aCompName + string("Engine.dylib");
+#else
std::string impl_name = string ("lib") + aCompName +string("Engine.so");
+#endif
#else
std::string impl_name = aCompName +string("Engine.dll");
#endif
void* handle = _library_map[impl_name];
if (handle)
type_of_lib = "cpp";
- if (_library_map.count(aCompName) != 0 and !handle)
+ if (_library_map.count(aCompName) != 0 && !handle)
type_of_lib = "python";
if (type_of_lib == "Not Loaded")
Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil();
if (type_of_lib == "cpp")
- iobject = createCPPInstance(aCompName, handle, studyId);
+ iobject = createCPPInstance(aCompName, handle);
else
- iobject = createPythonInstance(aCompName, studyId);
+ iobject = createPythonInstance(aCompName);
_numInstanceMutex.unlock();
return iobject._retn();
* CORBA method: Finds a servant instance of a component
* \param registeredName Name of the component in Registry or Name Service,
* without instance suffix number
- * \param studyId 0 if instance is not associated to a study,
- * >0 otherwise (== study id)
- * \return the first instance found with same studyId
+ * \return the first found instance
*/
//=============================================================================
-Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_component_instance( const char* registeredName,
- CORBA::Long studyId)
+Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_component_instance(const char* registeredName)
{
Engines::EngineComponent_var anEngine = Engines::EngineComponent::_nil();
std::map<std::string,Engines::EngineComponent_var>::iterator itm =_listInstances_map.begin();
if (instance.find(registeredName) == 0)
{
anEngine = (*itm).second;
- if (studyId == anEngine->getStudyId())
- {
- return anEngine._retn();
- }
+ return anEngine._retn();
}
itm++;
}
if (origName[0] != '/')
{
- INFOS("path of file to copy must be an absolute path begining with '/'");
+ INFOS("path of file to copy must be an absolute path beginning with '/'");
return Engines::fileRef::_nil();
}
CORBA::Object_var obj = _NS->ResolveFirst(component_registerBase.c_str());
if (CORBA::is_nil( obj ))
{
- iobject = create_component_instance(genericRegisterName.c_str(),
- 0); // force multiStudy instance here !
+ iobject = create_component_instance(genericRegisterName.c_str());
}
else
{
iobject = Engines::EngineComponent::_narrow(obj) ;
- Engines_Component_i *servant = dynamic_cast<Engines_Component_i*>(_poa->reference_to_servant(iobject));
- ASSERT(servant)
- int studyId = servant->getStudyId();
- ASSERT (studyId >= 0);
- if (studyId != 0) // monoStudy instance: NOK
- {
- iobject = Engines::EngineComponent::_nil();
- INFOS("load_impl & find_component_instance methods "
- << "NOT SUITABLE for mono study components");
- }
}
}
catch (...)
{
- INFOS( "Container_i::load_impl catched" ) ;
+ INFOS( "Container_i::load_impl caught" ) ;
}
return iobject._retn();
}
* in Registry & Name Service,
* (without _inst_n suffix, like "COMPONENT")
* \param handle loaded library handle
- * \param studyId 0 for multiStudy instance,
- * study Id (>0) otherwise
* \return a loaded component
*
* example with names:
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterName, int studyId)
+Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterName)
{
Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil();
PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
PyObject *result = PyObject_CallMethod(pyCont,
(char*)"create_component_instance",
- (char*)"ssl",
+ (char*)"ss",
genericRegisterName.c_str(),
- instanceName.c_str(),
- studyId);
+ instanceName.c_str());
const char *ior;
const char *error;
PyArg_ParseTuple(result,"ss", &ior, &error);
* in Registry & Name Service,
* (without _inst_n suffix, like "COMPONENT")
* \param handle loaded library handle
- * \param studyId 0 for multiStudy instance,
- * study Id (>0) otherwise
* \return a loaded component
*
* example with names:
//=============================================================================
Engines::EngineComponent_ptr
Engines_Parallel_Container_i::createCPPInstance(std::string genericRegisterName,
- void *handle,
- int studyId)
+ void *handle)
{
MESSAGE("Entering Engines_Parallel_Container_i::createCPPInstance");
std::string component_registerName =
_containerName + "/" + instanceName;
- // --- Instanciate required CORBA object
+ // --- Instantiate required CORBA object
PortableServer::ObjectId *id; //not owner, do not delete (nore use var)
id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(),
return iobject._retn();
}
- // --- get reference & servant from id
+ // --- get reference from id
CORBA::Object_var obj = _poa->id_to_reference(*id);
iobject = Engines::EngineComponent::_narrow(obj);
- Engines_Component_i *servant =
- dynamic_cast<Engines_Component_i*>(_poa->reference_to_servant(iobject));
- ASSERT(servant);
- servant->_remove_ref(); // compensate previous id_to_reference
_listInstances_map[instanceName] = iobject;
_cntInstances_map[aGenRegisterName] += 1;
-#if defined(_DEBUG_) || defined(_DEBUG)
- bool ret_studyId = servant->setStudyId(studyId);
- ASSERT(ret_studyId);
-#else
- servant->setStudyId(studyId);
-#endif
// --- register the engine under the name
// containerName(.dir)/instanceName(.object)
}
catch (...)
{
- INFOS( "Container_i::createInstance exception catched" );
+ INFOS( "Container_i::createInstance exception caught" );
}
return iobject._retn();
}
void
Engines_Parallel_Container_i::create_paco_component_node_instance(const char* componentName,
- const char* proxy_containerName,
- CORBA::Long studyId)
+ const char* proxy_containerName)
{
// Init de la méthode
char * proxy_ior;
std::string _proxy_containerName = proxy_containerName;
#ifndef WIN32
+#ifdef __APPLE__
+ string impl_name = string ("lib") + aCompName + string("Engine.dylib");
+#else
string impl_name = string ("lib") + aCompName +string("Engine.so");
+#endif
#else
string impl_name = aCompName +string("Engine.dll");
#endif
std::string instanceName = aCompName + "_inst_" + aNumI + "_work_node_" + aNumI2;
std::string component_registerName = _containerName + "/" + instanceName;
- // --- Instanciate work node
+ // --- Instantiate work node
PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
id = (Component_factory) (_orb, proxy_ior, getMyRank(), _poa, _id, instanceName.c_str(), componentName);
CORBA::string_free(proxy_ior);
- // --- get reference & servant from id
+ // --- get reference from id
CORBA::Object_var obj = _poa->id_to_reference(*id);
work_node = Engines::EngineComponent_PaCO::_narrow(obj) ;
if (CORBA::is_nil(work_node))
}
catch (...)
{
- INFOS("Container_i::create_paco_component_node_instance exception catched");
+ INFOS("Container_i::create_paco_component_node_instance exception caught");
SALOME::ExceptionStruct es;
es.type = SALOME::INTERNAL_ERROR;
- es.text = "Container_i::create_paco_component_node_instance exception catched";
+ es.text = "Container_i::create_paco_component_node_instance exception caught";
throw SALOME::SALOME_Exception(es);
}
}