29 SharedObject(std::string
const& objectName) : handle_{SDL_LoadObject(objectName.c_str())}
31 if (!handle_)
throw Exception(
"SDL_LoadObject");
46 if (handle_ != other.handle_)
52 SDL_UnloadObject(handle_);
56 handle_ = other.handle_;
57 other.handle_ =
nullptr;
72 const auto address = SDL_LoadFunction(handle_, functionName.c_str());
73 if (!address)
throw Exception(
"SDL_LoadFunction");
80 template<
typename FunctionPo
interSignature>
83 return reinterpret_cast<FunctionPointerSignature
>(
function_pointer(functionName));
SharedObject(SharedObject &&other) noexcept
Move ctor.
SharedObject & operator=(SharedObject &&other) noexcept
Move shared object into this one.
void * SharedObjectHandle
Types should be at least named. Alias void* to "SharedObjectHandle*.
FunctionPointerSignature function_pointer(std::string const &functionName) const
Syntactic sugar overload, provide you a way to specify the actual type of the function pointer e...
SharedObjectHandle handle_
This class wrap an handle to a shared object.
Represent a shared object (dynamic library, dynamically loaded library, module, plugin...).
Define to deactivate exception support.
SharedObject(std::string const &objectName)
Get a shared object ( = Load the named library dynamically)
FunctionAddress function_pointer(std::string const &functionName) const
Retrieve the raw address of a function inside the owned object. User has to cast this to the correct ...
void * FunctionAddress
Alias void* to a descriptive "pointer to function" typename.
Define to deactivate exception support.
~SharedObject()
Automatically unload the library for you.
SharedObject()=default
Construct an empty shared object handler. You can move assign to it.