summaryrefslogtreecommitdiff
path: root/include/module/ModuleLoader.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/module/ModuleLoader.hpp')
-rwxr-xr-xinclude/module/ModuleLoader.hpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/include/module/ModuleLoader.hpp b/include/module/ModuleLoader.hpp
index 045383f..2ae8421 100755
--- a/include/module/ModuleLoader.hpp
+++ b/include/module/ModuleLoader.hpp
@@ -30,6 +30,17 @@ struct Module {
#endif
void *user_data;
ModuleRegistry< Interface, CtorParams > *registry;
+
+ Module( ) : handle( 0 ), user_data( 0 ), registry( 0 ) {}
+
+ Module( const Module &m ) : handle( m.handle ), user_data( m.user_data ),
+ registry( m.registry ) {}
+
+ Module &operator=( Module m ) {
+ handle = m.handle;
+ user_data = m.user_data;
+ registry = m.registry;
+ }
};
template< typename Interface, typename CtorParams = NullType >
@@ -46,12 +57,12 @@ class BaseModuleLoader {
public:
BaseModuleLoader( const std::vector<std::string> files, void *user_data = 0 )
- {
- Module< Interface, CtorParams> m;
-
+ {
for( std::vector<std::string>::const_iterator it = files.begin( ); it != files.end( ); it++ ) {
+
+ Module< Interface, CtorParams> m;
#ifndef _WIN32
- m.handle = dlopen( it->c_str( ), RTLD_NOW | RTLD_GLOBAL );
+ m.handle = dlopen( it->c_str( ), RTLD_NOW | RTLD_LOCAL );
#else
m.handle = LoadLibrary( it->c_str( ) );
#endif
@@ -87,7 +98,7 @@ class BaseModuleLoader {
m.user_data = user_data;
- m_modules.insert( std::make_pair( m.registry->name, m ) );
+ m_modules.insert( std::make_pair( std::string( m.registry->name ), m ) );
}
}