From c7489cfe3f319805c069968e143e13585dcdd664 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Tue, 3 Nov 2009 10:55:48 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@89 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/optdl.hpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'interface') diff --git a/interface/optdl.hpp b/interface/optdl.hpp index 5f44733..7956155 100644 --- a/interface/optdl.hpp +++ b/interface/optdl.hpp @@ -8,21 +8,34 @@ #include #include #include -#include +//#include +#include namespace opt_utilities { + static class dl_init + { + public: + dl_init() + { + lt_dlinit(); + } + ~dl_init() + { + lt_dlexit(); + } + }_dl_init; + + template model* load_model(const char* fname) { - void* handle; - - handle=dlopen(fname,RTLD_LAZY); - + lt_dlhandle handle; + handle=lt_dlopen(fname); if(!handle) { throw opt_exception("faild loading object"); @@ -31,7 +44,7 @@ namespace opt_utilities model* (*func_create)(); - func_create=(model* (*)())dlsym(handle,"create_model_object"); + func_create=(model* (*)())lt_dlsym(handle,"create_model_object"); if(!func_create) { @@ -44,9 +57,9 @@ namespace opt_utilities typename Tp> opt_method* load_opt_method(const char* fname) { - void* handle; + lt_dlhandle handle; - handle=dlopen(fname,RTLD_LAZY); + handle=lt_dlopen(fname); if(!handle) { @@ -56,7 +69,7 @@ namespace opt_utilities opt_method* (*func_create)(); - func_create=(opt_method* (*)())dlsym(handle,"create_opt_method_object"); + func_create=(opt_method* (*)())lt_dlsym(handle,"create_opt_method_object"); if(!func_create) { @@ -69,9 +82,9 @@ namespace opt_utilities typename Tp> func_obj* load_func_obj(const char* fname) { - void* handle; + lt_dlhandle handle; - handle=dlopen(fname,RTLD_LAZY); + handle=lt_dlopen(fname); if(!handle) { @@ -81,7 +94,7 @@ namespace opt_utilities func_obj* (*func_create)(); - func_create=(func_obj* (*)())dlsym(handle,"create_func_obj_object"); + func_create=(func_obj* (*)())lt_dlsym(handle,"create_func_obj_object"); if(!func_create) { @@ -97,9 +110,9 @@ namespace opt_utilities typename Tstr> statistic* load_statistic(const char* fname) { - void* handle; + lt_dlhandle handle; - handle=dlopen(fname,RTLD_LAZY); + handle=lt_dlopen(fname); if(!handle) { @@ -109,7 +122,7 @@ namespace opt_utilities statistic* (*func_create)(); - func_create=(statistic* (*)())dlsym(handle,"create_statistic_object"); + func_create=(statistic* (*)())lt_dlsym(handle,"create_statistic_object"); if(!func_create) { -- cgit v1.2.2