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 {
00035 class DynamicLib
00036 {
00037 public:
00038 DynamicLib(int close_handle_on_destruction = 1);
00039 DynamicLib(const char* dynlib_name,
00040 int open_mode = COIL_DEFAULT_DYNLIB_MODE,
00041 int close_handle_on_destruction = 1);
00042 virtual ~DynamicLib();
00043 DynamicLib(const DynamicLib& rhs);
00044 DynamicLib& operator=(const DynamicLib& rhs);
00045
00046 virtual int open(const char* dll_name,
00047 int open_mode = COIL_DEFAULT_DYNLIB_MODE,
00048 int close_handle_on_destruction = 1);
00049 virtual int close(void);
00050 void *symbol (const char* symbol_name);
00051 static int ForExternTest(void) { return 0xdeadbeef; }
00052 const char* error(void) const;
00053 private:
00054 std::string m_name;
00055 int m_mode;
00056 int m_closeflag;
00057 void* m_handle;
00058 int m_error;
00059 };
00060
00061 };
00062
00063 #endif // DynamicLib_h