#ifndef OPTDL_HPP #define OPTDL_HPP #define OPT_HEADER #include #include #include #include #include //#include #include namespace opt_utilities { static class dl_init { public: dl_init() { lt_dlinit(); } ~dl_init() { // lt_dlexit(); } }_dl_init; template model* load_model(const char* fname) { lt_dlhandle handle; handle=lt_dlopen(fname); if(!handle) { throw opt_exception("faild loading object"); } model* (*func_create)(); func_create=(model* (*)())lt_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) { lt_dlhandle handle; handle=lt_dlopen(fname); if(!handle) { throw opt_exception("faild loading object"); } opt_method* (*func_create)(); func_create=(opt_method* (*)())lt_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) { lt_dlhandle handle; handle=lt_dlopen(fname); if(!handle) { throw opt_exception("faild loading object"); } func_obj* (*func_create)(); func_create=(func_obj* (*)())lt_dlsym(handle,"create_func_obj_object"); if(!func_create) { throw opt_exception("symble undefined"); } return func_create(); } template statistic* load_statistic(const char* fname) { lt_dlhandle handle; handle=lt_dlopen(fname); if(!handle) { throw opt_exception("faild loading object"); } statistic* (*func_create)(); func_create=(statistic* (*)())lt_dlsym(handle,"create_statistic_object"); if(!func_create) { throw opt_exception("symble undefined"); } return func_create(); } } #endif //EOF