00001
00019 #ifndef COIL_DYNAMICLIB_H
00020 #define COIL_DYNAMICLIB_H
00021
00022 #include <dlfcn.h>
00023 #include <string>
00024 #include <coil/config_coil.h>
00025
00026 #define COIL_DEFAULT_DYNLIB_MODE RTLD_LAZY
00027
00028 extern "C"
00029 {
00030 int ForExternTest(void);
00031 }
00032
00033 namespace coil
00034 {
00048 class DynamicLib
00049 {
00050 public:
00051
00071 DynamicLib(int close_handle_on_destruction = 1);
00072
00096 DynamicLib(const char* dynlib_name,
00097 int open_mode = COIL_DEFAULT_DYNLIB_MODE,
00098 int close_handle_on_destruction = 1);
00099
00115 virtual ~DynamicLib();
00116
00136 DynamicLib(const DynamicLib& rhs);
00137
00161 DynamicLib& operator=(const DynamicLib& rhs);
00162
00190 virtual int open(const char* dll_name,
00191 int open_mode = COIL_DEFAULT_DYNLIB_MODE,
00192 int close_handle_on_destruction = 1);
00193
00213 virtual int close(void);
00214
00238 void *symbol (const char* symbol_name);
00239
00259 const char* error(void) const;
00260
00280 static int ForExternTest(void) { return 0xdeadbeef; }
00281
00282 private:
00283 std::string m_name;
00284 int m_mode;
00285 int m_closeflag;
00286 void* m_handle;
00287 int m_error;
00288 };
00289
00290 };
00291
00292 #endif // DynamicLib_h