blob: 97293358f4535f36e82e99dcb8d632e968ef0e18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#ifdef __linux__
#ifndef DL_MODEL_HPP
#define DL_MODEL_HPP
#define OPT_HEADER
#include <core/fitter.hpp>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <dlfcn.h>
namespace opt_utilities
{
template <typename T>
model<T,T,std::vector<T>,std::string>* load_model(const char* fname)
{
void* handle;
handle=dlopen(fname,RTLD_LAZY);
if(!handle)
{
throw opt_exception("faild loading object");
}
model<T,T,std::vector<T>,std::string>* (*func_create)();
func_create=(model<T,T,std::vector<T>,std::string>* (*)())dlsym(handle,"create_model_object");
if(!func_create)
{
throw opt_exception("symble undefined");
}
return func_create();
}
}
#endif
#endif
//EOF
|