6 #ifndef BOOST_DLL_HPP_VP_2004_08_24
7 #define BOOST_DLL_HPP_VP_2004_08_24
11 #include <boost/shared_ptr.hpp>
12 #include <boost/bind.hpp>
13 #include <boost/type_traits/remove_pointer.hpp>
20 namespace utilmm {
namespace plugin {
28 std::cout <<
"Killing DLL\n";
37 dll(
const std::string& name) : m_name(name) {}
39 template<
typename SymbolType>
41 typename boost::remove_pointer<SymbolType>::type>
42 get(
const std::string& symbol_name)
const
45 typedef typename boost::remove_pointer<SymbolType>::type PointedType;
49 void* handle = dlopen(m_name.c_str(), RTLD_LAZY|RTLD_GLOBAL);
51 throw std::logic_error(
"Could not open DLL");
55 void* address = dlsym(handle, symbol_name.c_str());
56 char* error = dlerror();
58 throw std::logic_error(error);
61 SymbolType s = (SymbolType)(address);
63 boost::shared_ptr<PointedType> result(s,
65 boost::bind(dlclose, handle));
dll(const std::string &name)
Definition: dll.hh:37
killer(void *h)
Definition: dll.hh:24
void operator()(T)
Definition: dll.hh:26
dll()
Definition: dll.hh:36
void * h
Definition: dll.hh:31