ldpk
ldpk_plugin_loader.h
Go to the documentation of this file.
1 #ifndef ldpk_plugin_loader_sdv
2 #define ldpk_plugin_loader_sdv
3 
4 #include <ldpk/tde4_ld_plugin.h>
5 #include <string>
6 
7 #ifdef _WIN32
8 // http://code.google.com/p/dlfcn-win32/downloads/list
9 #else
10 #include <dlfcn.h>
11 #endif
12 
15 
16 namespace ldpk
17  {
20  {
21  private:
22  tde4ldp_create_fct_t* _create_plugin;
23  tde4ldp_destroy_fct_t* _destroy_plugin;
24  tde4_ld_plugin* _model;
25 // Mode for dlopen, default is RTLD_LAZY
26  int _mode;
27  bool _verbose;
28  public:
29  plugin_loader(bool verbose = true):_create_plugin(0),_destroy_plugin(0),_model(0),_verbose(verbose),_mode(RTLD_LAZY)
30  { }
31  ~plugin_loader()
32  { close_plugin(); }
35  void set_mode(int mode)
36  { _mode = mode; }
38  void open_plugin(const std::string& path);
40  void close_plugin();
43  { return _model; }
45  tde4ldp_create_fct_t* get_create_function()
46  { return _create_plugin; }
48  tde4ldp_destroy_fct_t* get_destroy_function()
49  { return _destroy_plugin; }
50  };
51  };
52 
53 #endif
void open_plugin(const std::string &path)
Load and link plugin, will throw exceptions on fail.
Definition: ldpk_plugin_loader.C:9
tde4_ld_plugin * get_model()
Pointer to distortion model base class.
Definition: ldpk_plugin_loader.h:42
A simple plugin loader for testing and debugging purposes.
Definition: ldpk_plugin_loader.h:19
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:169
tde4ldp_create_fct_t * get_create_function()
The create-function for this plugin.
Definition: ldpk_plugin_loader.h:45
Lens Distortion Plugin Base Class.
Definition: tde4_ld_plugin.h:29
void close_plugin()
Close plugin, will be called by destructor.
Definition: ldpk_plugin_loader.C:45
tde4ldp_destroy_fct_t * get_destroy_function()
The destroy-function for this plugin.
Definition: ldpk_plugin_loader.h:48
void set_mode(int mode)
For a list of possible value, see man dlopen. Call this only if you are familiar with dlopen()...
Definition: ldpk_plugin_loader.h:35