8#ifndef SHARED_LIBRARY_HPP
9#define SHARED_LIBRARY_HPP
39 #elif defined(__APPLE__)
48 _handle = ::LoadLibraryA(_path.c_str());
50 _handle = ::dlopen(_path.c_str(), RTLD_NOW | RTLD_LOCAL);
53 throw std::runtime_error(
"SharedLibrary: " + _path);
58 if (_handle) ::FreeLibrary(_handle);
60 if (_handle) ::dlclose(_handle);
76 return reinterpret_cast<T
>(::GetProcAddress(_handle, name));
78 return reinterpret_cast<T
>(::dlsym(_handle, name));
83 const std::string &
path()
const {
return _path; }
Une bibliotheque dynamique ouverte : elle se ferme avec l'objet.
Definition SharedLibrary.hpp:27
SharedLibrary & operator=(const SharedLibrary &)=delete
SharedLibrary(const SharedLibrary &)=delete
void * Handle
Definition SharedLibrary.hpp:32
Handle handle() const
Le handle systeme, pour qui en a besoin.
Definition SharedLibrary.hpp:86
~SharedLibrary()
Definition SharedLibrary.hpp:56
SharedLibrary(std::string path)
Definition SharedLibrary.hpp:46
T symbol(const char *name) const
Un symbole exporte, rendu comme un T.
Definition SharedLibrary.hpp:74
static const char * extension()
L'extension des bibliotheques de cette plateforme.
Definition SharedLibrary.hpp:36
const std::string & path() const
Le chemin dont elle a ete ouverte.
Definition SharedLibrary.hpp:83