From 391f52934a576b5713b569d38998805092a2f1f9 Mon Sep 17 00:00:00 2001 From: prascle Date: Fri, 13 May 2005 14:17:44 +0000 Subject: [PATCH] PR: C++ container used as a Python container --- src/Container/Container_i.cxx | 65 ++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index dd2caf3b1..c2c346cc2 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -272,6 +272,39 @@ Engines_Container_i::load_component_Library(const char* componentName) { string aCompName = componentName; + + // --- try dlopen C++ component + + string impl_name = string ("lib") + aCompName + string("Engine.so"); + SCRUTE(impl_name); + + _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]) + { + MESSAGE("Library " << impl_name << " already loaded"); + _numInstanceMutex.unlock(); + return true; + } + + void* handle; + handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; + if ( handle ) + { + _library_map[impl_name] = handle; + _numInstanceMutex.unlock(); + return true; + } + else + { + INFOS("Can't load shared library : " << impl_name); + INFOS("error dlopen: " << dlerror()); + } + _numInstanceMutex.unlock(); + + // --- try import Python component + if (_library_map[aCompName]) { return true; // Python Component, already imported @@ -296,37 +329,7 @@ Engines_Container_i::load_component_Library(const char* componentName) return true; } } - // try dlopen C++ component - { - string impl_name = string ("lib") + componentName + string("Engine.so"); - SCRUTE(impl_name); - - _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]) - { - MESSAGE("Library " << impl_name << " already loaded"); - _numInstanceMutex.unlock(); - return true; - } - void* handle; - handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; - if ( !handle ) - { - INFOS("Can't load shared library : " << impl_name); - INFOS("error dlopen: " << dlerror()); - _numInstanceMutex.unlock(); - return false; - } - else - { - _library_map[impl_name] = handle; - _numInstanceMutex.unlock(); - return true; - } - _numInstanceMutex.unlock(); - } + return false; } //============================================================================= -- 2.39.2