00001 #ifndef QPID_SYS_SHLIB_H
00002 #define QPID_SYS_SHLIB_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <boost/noncopyable.hpp>
00026 #include <iostream>
00027 #include <dlfcn.h>
00028
00029 namespace qpid {
00030 namespace sys {
00031
00035 class Shlib {
00036 public:
00038 Shlib(const char* libname) { load(libname); }
00039
00041 Shlib(const std::string& libname) { load(libname.c_str()); }
00042
00044 void unload();
00045
00047 void* getSymbol(const char* symbol);
00048
00052 template <class T>
00053 T getSymbol(const char* symbol) {
00054
00055 return reinterpret_cast<T>(reinterpret_cast<intptr_t>(
00056 this->getSymbol(symbol)));
00057 }
00058
00059 private:
00060 void* handle;
00061 void load(const char* libname);
00062 };
00063
00065 class AutoShlib : public Shlib {
00066 public:
00068 AutoShlib(const std::string& libname) : Shlib(libname) {}
00070 ~AutoShlib() throw();
00071 };
00072
00073
00074 }}
00075
00076 #endif