diff options
author | Alan Conway <aconway@apache.org> | 2007-07-04 03:24:48 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-07-04 03:24:48 +0000 |
commit | ae896d73d4914fa96f053a0443f6b05003c12b35 (patch) | |
tree | 0aac1abf592704282ab5860a0f69dcfd9610f2cd /cpp/src/qpid/sys/Module.h | |
parent | 7865fcf6689f96219365995e8ad09b3332205176 (diff) | |
download | qpid-python-ae896d73d4914fa96f053a0443f6b05003c12b35.tar.gz |
2007-07-02 <aconway@redhat.com
* qpid/sys/Shlib.h, .cpp: Portable shared library abstraction.
- Shlib: load, unload, getSymbol
- AutoShlib: unload in destructor.
* qpid/sys/apr/Shlib.cpp sys/posix/Shlib.cpp: APR/Posix impls
* qpid/sys/Module.h: Reimplemented Module in terms of AutoShlib.
* qpid/Plugin.cpp, .h: Removed dlopen - use Shlib instead.
* qpid/broker/Broker.cpp: Added missing #include "qpid/log/Statement.h"
* tests/Shlib.cpp, shlibtest.cpp: Unit test
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@553056 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/Module.h')
-rw-r--r-- | cpp/src/qpid/sys/Module.h | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/cpp/src/qpid/sys/Module.h b/cpp/src/qpid/sys/Module.h index e812f57d7a..79793ed0ca 100644 --- a/cpp/src/qpid/sys/Module.h +++ b/cpp/src/qpid/sys/Module.h @@ -1,5 +1,5 @@ -#ifndef _sys_Module_h -#define _sys_Module_h +#ifndef QPID_SYS_MODULE_H +#define QPID_SYS_MODULE_H /* * @@ -21,11 +21,30 @@ * under the License. * */ - -#ifdef USE_APR_PLATFORM -#include "apr/Module.h" -#else -#include "posix/Module.h" -#endif -#endif //ifndef _sys_Module_h +#include "qpid/sys/Shlib.h" +#include <boost/noncopyable.hpp> + +namespace qpid { +namespace sys { + +template <class T> class Module : public AutoShlib, private boost::noncopyable +{ + public: + Module(const std::string& name) : + AutoShlib(name), + ptr(getSymbol<T*(*)()>("create")()) {} + + T* get() { return ptr; } + T* operator->() { return ptr; } + ~Module() throw() { + getSymbol<void (*)(T*)>("destroy")(ptr); + } + + private: + T* ptr; +}; + +}} + +#endif /*!QPID_SYS_MODULE_H*/ |