31 #include <boost/filesystem.hpp>
58 explicit WSharedLib( boost::filesystem::path lib );
99 template <
typename FuncType >
100 void fetchFunction(
const std::string& name, FuncType& func )
const;
120 template <
typename PtrType >
121 void fetchVariable(
const std::string& name, PtrType& variable )
const;
185 template <
typename FuncType >
188 func =
reinterpret_cast< FuncType
>(
findFunction( name ) );
191 template <
typename PtrType >
194 variable =
static_cast< PtrType
>(
findVariable( name ) );
This class loads shared libraries and provides function pointers.
static std::string getSystemSuffix()
Returns the suffix for libraries used on the system.
static std::string getSystemPrefix()
Returns the prefix used for libraries on the system.
static std::string getSystemLibPath()
Returns the default path for libraries on the current system.
data * m_data
internal data
void fetchFunction(const std::string &name, FuncType &func) const
Search for a function in the shared library.
boost::filesystem::path m_libPath
path to lib
virtual ~WSharedLib()
Destructor.
void * findVariable(const std::string &name) const
Find the specified symbol in the library.
func_ptr_type findFunction(const std::string &name) const
Find the specified function pointer in the library.
friend void swap(WSharedLib &lhs, WSharedLib &rhs)
Swap to shared libraries.
bool existsFunction(const std::string &name) const
Check whether the function exists.
void(* func_ptr_type)(void)
neutral function pointer type
WSharedLib(boost::filesystem::path lib)
Constructor.
void fetchVariable(const std::string &name, PtrType &variable) const
Search for an variable in the shared library.
std::string getLibraryName()
Returns the filename of the library without path.
WSharedLib & operator=(const WSharedLib &rhs)
Copy assignment for shared libraries.
Simple class holding an opened library.