From 372caea057ff88b2fb1327c45f77b7e4205293ea Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Mon, 19 Oct 2009 17:02:42 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@85 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/optdl.hpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ makefile | 2 +- models/dl_model.hpp | 45 --------------------------------------------- models/models.cc | 1 - 4 files changed, 46 insertions(+), 47 deletions(-) create mode 100644 interface/optdl.hpp delete mode 100644 models/dl_model.hpp diff --git a/interface/optdl.hpp b/interface/optdl.hpp new file mode 100644 index 0000000..9729335 --- /dev/null +++ b/interface/optdl.hpp @@ -0,0 +1,45 @@ +#ifdef __linux__ + +#ifndef DL_MODEL_HPP +#define DL_MODEL_HPP +#define OPT_HEADER +#include +#include +#include +#include +#include +#include + +namespace opt_utilities +{ + + template + model,std::string>* load_model(const char* fname) + { + void* handle; + + handle=dlopen(fname,RTLD_LAZY); + + if(!handle) + { + throw opt_exception("faild loading object"); + } + + + model,std::string>* (*func_create)(); + + func_create=(model,std::string>* (*)())dlsym(handle,"create_model_object"); + + if(!func_create) + { + throw opt_exception("symble undefined"); + } + return func_create(); + } +} + + + +#endif +#endif +//EOF diff --git a/makefile b/makefile index ee38e29..bd59956 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,7 @@ OPT_HEADS=models/beta1d.hpp statistics/chisq.hpp models/lin1d.hpp\ core/freeze_param.hpp\ models/gauss1d.hpp core/optimizer.hpp\ misc/bootstrap.hpp\ - models/dl_model.hpp\ + interface/optdl.hpp\ models/mul_model.hpp\ models/add_model.hpp\ diff --git a/models/dl_model.hpp b/models/dl_model.hpp deleted file mode 100644 index 9729335..0000000 --- a/models/dl_model.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifdef __linux__ - -#ifndef DL_MODEL_HPP -#define DL_MODEL_HPP -#define OPT_HEADER -#include -#include -#include -#include -#include -#include - -namespace opt_utilities -{ - - template - model,std::string>* load_model(const char* fname) - { - void* handle; - - handle=dlopen(fname,RTLD_LAZY); - - if(!handle) - { - throw opt_exception("faild loading object"); - } - - - model,std::string>* (*func_create)(); - - func_create=(model,std::string>* (*)())dlsym(handle,"create_model_object"); - - if(!func_create) - { - throw opt_exception("symble undefined"); - } - return func_create(); - } -} - - - -#endif -#endif -//EOF diff --git a/models/models.cc b/models/models.cc index e1c6d34..6cb6536 100644 --- a/models/models.cc +++ b/models/models.cc @@ -16,7 +16,6 @@ #include "dbeta2d2.hpp" #include "dbeta2d3.hpp" #include "dbeta2d.hpp" -#include "dl_model.hpp" #include using namespace std; -- cgit v1.2.2