#ifdef __linux__ #ifndef OPTDL_HPP #define OPTDL_HPP #define OPT_HEADER #include #include #include #include #include #include namespace opt_utilities { template model* load_model(const char* fname) { void* handle; handle=dlopen(fname,RTLD_LAZY); if(!handle) { throw opt_exception("faild loading object"); } model* (*func_create)(); func_create=(model* (*)())dlsym(handle,"create_model_object"); if(!func_create) { throw opt_exception("symble undefined"); } 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(); } 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(); } } #endif #endif //EOF