Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::sys::DynamicLibrary Class Referencefinal

Represents a dynamically loaded library. More...

#include <DynamicLibrary.hpp>

Collaboration diagram for rtp::sys::DynamicLibrary:

Public Member Functions

 DynamicLibrary (void *handle) noexcept
 Construct a DynamicLibrary with the given handle.
 
 ~DynamicLibrary () noexcept
 Destructor.
 
 DynamicLibrary (DynamicLibrary &&other) noexcept
 
DynamicLibraryoperator= (DynamicLibrary &&other) noexcept
 
 DynamicLibrary (const DynamicLibrary &)=delete
 
DynamicLibraryoperator= (const DynamicLibrary &)=delete
 
template<typename T >
auto get (std::string_view name) const -> std::expected< T, rtp::Error >
 Get a symbol from the dynamic library.
 

Private Member Functions

auto getSymbolAddress (std::string_view name) const -> std::expected< void *, rtp::Error >
 Get the address of a symbol from the dynamic library.
 

Private Attributes

void * _handle {nullptr}
 The handle to the dynamic library.
 

Detailed Description

Represents a dynamically loaded library.

Provides methods to retrieve symbols from the library.

Definition at line 56 of file DynamicLibrary.hpp.

Constructor & Destructor Documentation

◆ DynamicLibrary() [1/3]

rtp::sys::DynamicLibrary::DynamicLibrary ( void *  handle)
explicitnoexcept

Construct a DynamicLibrary with the given handle.

Parameters
handleThe handle to the dynamic library.
Note
expect handle to be a valid pointer to an handler.

Definition at line 52 of file DynamicLibrary.cpp.

◆ ~DynamicLibrary()

rtp::sys::DynamicLibrary::~DynamicLibrary ( )
noexcept

Destructor.

Closes the dynamic library.

Definition at line 56 of file DynamicLibrary.cpp.

References _handle, rtp::sys::impl::LibraryBackend::close(), and rtp::log::warning().

◆ DynamicLibrary() [2/3]

rtp::sys::DynamicLibrary::DynamicLibrary ( DynamicLibrary &&  other)
noexcept

Definition at line 67 of file DynamicLibrary.cpp.

◆ DynamicLibrary() [3/3]

rtp::sys::DynamicLibrary::DynamicLibrary ( const DynamicLibrary )
delete

Member Function Documentation

◆ get()

template<typename T >
auto rtp::sys::DynamicLibrary::get ( std::string_view  name) const -> std::expected< T, rtp::Error >

Get a symbol from the dynamic library.

Template Parameters
TThe expected type of the symbol.
Parameters
nameThe name of the symbol to retrieve.
Returns
std::expected<T, rtp::Error>

Referenced by rtp::sys::LibraryManager::load().

◆ getSymbolAddress()

auto rtp::sys::DynamicLibrary::getSymbolAddress ( std::string_view  name) const -> std::expected<void *, rtp::Error>
private

Get the address of a symbol from the dynamic library.

Parameters
nameThe name of the symbol to retrieve.
Returns
std::expected<void *, rtp::Error>

Definition at line 90 of file DynamicLibrary.cpp.

References rtp::sys::impl::LibraryBackend::getSymbol().

◆ operator=() [1/2]

DynamicLibrary & rtp::sys::DynamicLibrary::operator= ( const DynamicLibrary )
delete

◆ operator=() [2/2]

DynamicLibrary & rtp::sys::DynamicLibrary::operator= ( DynamicLibrary &&  other)
noexcept

Member Data Documentation

◆ _handle

void* rtp::sys::DynamicLibrary::_handle {nullptr}
private

The handle to the dynamic library.

Definition at line 89 of file DynamicLibrary.hpp.

Referenced by ~DynamicLibrary().


The documentation for this class was generated from the following files: