_numInstanceMutex.lock(); // lock to be alone
// (see decInstanceCnt, finalize_removal))
- if (_toRemove_map[impl_name]) _toRemove_map.erase(impl_name);
- if (_library_map[impl_name])
+ if (_toRemove_map.count(impl_name) != 0) _toRemove_map.erase(impl_name);
+ if (_library_map.count(impl_name) != 0)
{
MESSAGE("Library " << impl_name << " already loaded");
_numInstanceMutex.unlock();
_numInstanceMutex.unlock();
return true;
}
- else
- {
- INFOS( "Can't load shared library: " << impl_name );
-#ifndef WNT
- INFOS("error dlopen: " << dlerror());
-#endif
- }
_numInstanceMutex.unlock();
// --- try import Python component
INFOS("Supervision Container does not support Python Component Engines");
return false;
}
- if (_library_map[aCompName])
+ if (_library_map.count(aCompName) != 0)
{
return true; // Python Component, already imported
}
"import_component",
"s",componentName);
int ret= PyInt_AsLong(result);
+ Py_XDECREF(result);
SCRUTE(ret);
Py_RELEASE_NEW_THREAD;
return true;
}
}
+ INFOS( "Impossible to load component: " << componentName );
+ INFOS( "Can't load shared library: " << impl_name );
+ INFOS( "Can't import Python module: " << componentName );
return false;
}
Engines::Component_var iobject = Engines::Component::_nil() ;
string aCompName = genericRegisterName;
- if (_library_map[aCompName]) // Python component
+ if (_library_map.count(aCompName) != 0) // Python component
{
if (_isSupervContainer)
{
#else
string impl_name = genericRegisterName +string("Engine.dll");
#endif
- void* handle = _library_map[impl_name];
- if ( !handle )
+ if (_library_map.count(impl_name) == 0)
{
- INFOS("shared library " << impl_name <<"must be loaded before instance");
+ INFOS("shared library " << impl_name <<" must be loaded before creating instance");
return Engines::Component::_nil() ;
}
else
{
+ void* handle = _library_map[impl_name];
iobject = createInstance(genericRegisterName,
handle,
studyId);
{
string aGenRegisterName = genericRegisterName;
string impl_name = componentLibraryName;
- void* handle = _library_map[impl_name];
- if ( !handle )
+ if (_library_map.count(impl_name) == 0)
{
- INFOS("shared library " << impl_name <<"must be loaded before instance");
+ INFOS("shared library " << impl_name <<" must be loaded before creating instance");
return Engines::Component::_nil() ;
}
else
{
// --- find a registered instance in naming service, or create
+ void* handle = _library_map[impl_name];
string component_registerBase =
_containerName + "/" + aGenRegisterName;
Engines::Component_var iobject = Engines::Component::_nil() ;
self._numInstance = self._numInstance +1
instanceName = nameToRegister + "_inst_" + `self._numInstance`
- component=__import__(componentName)
- factory=getattr(component,componentName)
- comp_i=factory(self._orb, self._poa, self._this(), self._containerName,
- instanceName, nameToRegister)
+ component=__import__(componentName)
+ factory=getattr(component,componentName)
+ comp_i=factory(self._orb, self._poa, self._this(), self._containerName,
+ instanceName, nameToRegister)
MESSAGE( "SALOME_ContainerPy_i::instance : component created")
comp_o = comp_i._this()
ret=0
try:
if verbose(): print "try import ",componentName
- __import__(componentName)
+ module=__import__(componentName)
if verbose(): print "import ",componentName," successful"
ret=1
except: