From 67e53335ef07eb17409f875bb552e3b53c5678b0 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Tue, 20 Oct 2009 06:39:15 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@86 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/optdl.hpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) (limited to 'interface') diff --git a/interface/optdl.hpp b/interface/optdl.hpp index 9729335..4ff4d9d 100644 --- a/interface/optdl.hpp +++ b/interface/optdl.hpp @@ -13,8 +13,11 @@ namespace opt_utilities { - template - model,std::string>* load_model(const char* fname) + template + model* load_model(const char* fname) { void* handle; @@ -26,9 +29,9 @@ namespace opt_utilities } - model,std::string>* (*func_create)(); + model* (*func_create)(); - func_create=(model,std::string>* (*)())dlsym(handle,"create_model_object"); + func_create=(model* (*)())dlsym(handle,"create_model_object"); if(!func_create) { @@ -36,6 +39,59 @@ namespace opt_utilities } return func_create(); } + + template + opt_method* load_opt_method(const char* fname) + { + void* handle; + + handle=dlopen(fname,RTLD_LAZY); + + if(!handle) + { + throw opt_exception("faild loading object"); + } + + + opt_method* (*func_create)(); + + func_create=(opt_method* (*)())dlsym(handle,"create_opt_method_object"); + + if(!func_create) + { + throw opt_exception("symble undefined"); + } + return func_create(); + } + + template + func_obj* load_func_obj(const char* fname) + { + void* handle; + + handle=dlopen(fname,RTLD_LAZY); + + if(!handle) + { + throw opt_exception("faild loading object"); + } + + + func_obj* (*func_create)(); + + func_create=(func_obj* (*)())dlsym(handle,"create_func_obj_object"); + + if(!func_create) + { + throw opt_exception("symble undefined"); + } + return func_create(); + } + + + } -- cgit v1.2.2