From 3de58cdbfed2bedef00f791994398b5ba13321f4 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Tue, 20 Oct 2009 11:41:47 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@87 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/optdl.hpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'interface') diff --git a/interface/optdl.hpp b/interface/optdl.hpp index 4ff4d9d..5f44733 100644 --- a/interface/optdl.hpp +++ b/interface/optdl.hpp @@ -1,7 +1,7 @@ #ifdef __linux__ -#ifndef DL_MODEL_HPP -#define DL_MODEL_HPP +#ifndef OPTDL_HPP +#define OPTDL_HPP #define OPT_HEADER #include #include @@ -90,7 +90,33 @@ namespace opt_utilities return func_create(); } - + template + statistic* load_statistic(const char* fname) + { + void* handle; + + handle=dlopen(fname,RTLD_LAZY); + + if(!handle) + { + throw opt_exception("faild loading object"); + } + + + statistic* (*func_create)(); + + func_create=(statistic* (*)())dlsym(handle,"create_statistic_object"); + + if(!func_create) + { + throw opt_exception("symble undefined"); + } + return func_create(); + } } -- cgit v1.2.2