8#ifndef SHARED_LIBRARY_HPP
9#define SHARED_LIBRARY_HPP
36 #elif defined(__APPLE__)
45 _handle = ::LoadLibraryA(_path.c_str());
47 _handle = ::dlopen(_path.c_str(), RTLD_NOW | RTLD_LOCAL);
50 throw std::runtime_error(
"SharedLibrary: " + _path);
55 if (_handle) ::FreeLibrary(_handle);
57 if (_handle) ::dlclose(_handle);
67 return reinterpret_cast<T
>(::GetProcAddress(_handle, name));
69 return reinterpret_cast<T
>(::dlsym(_handle, name));
73 const std::string &
path()
const {
return _path; }
Encapsule le handle d'une bibliotheque dynamique. Rien de plus.
Definition SharedLibrary.hpp:25
SharedLibrary & operator=(const SharedLibrary &)=delete
SharedLibrary(const SharedLibrary &)=delete
void * Handle
Definition SharedLibrary.hpp:30
Handle handle() const
Definition SharedLibrary.hpp:74
~SharedLibrary()
Definition SharedLibrary.hpp:53
SharedLibrary(std::string path)
Definition SharedLibrary.hpp:43
T symbol(const char *name) const
Definition SharedLibrary.hpp:65
static const char * extension()
Definition SharedLibrary.hpp:33
const std::string & path() const
Definition SharedLibrary.hpp:73