SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SDL::SharedObjectRef Struct Reference

An opaque datatype that represents a loaded shared object. More...

Inheritance diagram for SDL::SharedObjectRef:
Inheritance graph
[legend]

Public Member Functions

FunctionPointer LoadFunction (StringParam name)
 Look up the address of the named function in a shared object.
 
constexpr Resource (T resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< T > > auto &resource)
 Constructs from pointer like.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
- Public Member Functions inherited from SDL::Resource< SDL_SharedObject * >
constexpr Resource (SDL_SharedObject * resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< SDL_SharedObject * > > auto &resource)
 Constructs from pointer like.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr operator value_type () const
 Converts back to underlying type.
 
constexpr bool operator== (const Resource &other) const=default
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr SDL_SharedObject * get () const
 Return contained resource;.
 
constexpr const SDL_SharedObject * operator-> () const
 Access to fields.
 
constexpr SDL_SharedObject * operator-> ()
 Access to fields.
 

Static Public Member Functions

static void reset (SDL_SharedObject *resource)
 Unload a shared object from memory.
 

Additional Inherited Members

- Public Types inherited from SDL::Resource< SDL_SharedObject * >
using value_type = SDL_SharedObject *
 The raw resource type.
 

Detailed Description

Since
This datatype is available since SDL 3.2.0.
Category:
Resource
See also
SharedObject.Load
SharedObjectRef.LoadFunction
SharedObject.Unload
SharedObject

Member Function Documentation

◆ LoadFunction()

FunctionPointer SDL::SharedObjectRef::LoadFunction ( StringParam  name)
inline

This function pointer is no longer valid after calling SharedObject.Unload().

This function can only look up C function names. Other languages may have name mangling and intrinsic language support that varies from compiler to compiler.

Make sure you declare your function pointers with the same calling convention as the actual library function. Your code will crash mysteriously if you do not do this.

If the requested function doesn't exist, nullptr is returned.

Parameters
namethe name of the function to look up.
Returns
a pointer to the function or nullptr on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SharedObject.Load

◆ reset()

static void SDL::SharedObjectRef::reset ( SDL_SharedObject *  resource)
inlinestatic

Note that any pointers from this object looked up through SharedObjectRef.LoadFunction() will no longer be valid.

Parameters
resourcea valid shared object handle returned.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
SharedObject.Load

The documentation for this struct was generated from the following file: