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::LibraryManager Class Referencefinal

Manages dynamic libraries, providing loading and caching mechanisms. More...

#include <LibraryManager.hpp>

Collaboration diagram for rtp::sys::LibraryManager:

Public Member Functions

 LibraryManager (void)=default
 
 ~LibraryManager () noexcept=default
 
 LibraryManager (const LibraryManager &)=delete
 
LibraryManageroperator= (const LibraryManager &)=delete
 
 LibraryManager (LibraryManager &&) noexcept=delete
 
LibraryManageroperator= (LibraryManager &&) noexcept=delete
 
auto load (std::string_view path) -> std::expected< const DynamicLibrary *, rtp::Error >
 Main API.
 
auto loadShared (std::string_view path) -> std::expected< std::shared_ptr< DynamicLibrary >, rtp::Error >
 Shared API.
 

Static Public Member Functions

static auto loadStandalone (std::string_view path) -> std::expected< std::unique_ptr< DynamicLibrary >, rtp::Error >
 Isolated API (Factory).
 

Private Member Functions

auto getOrLoadInternal (std::string_view path) -> std::expected< std::shared_ptr< DynamicLibrary >, rtp::Error >
 Get an existing library or load it if not present.
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< DynamicLibrary > > _libraries
 
std::shared_mutex _mutex
 Mutex for thread-safe access.
 

Detailed Description

Manages dynamic libraries, providing loading and caching mechanisms.

Definition at line 63 of file LibraryManager.hpp.

Constructor & Destructor Documentation

◆ LibraryManager() [1/3]

rtp::sys::LibraryManager::LibraryManager ( void  )
default

◆ ~LibraryManager()

rtp::sys::LibraryManager::~LibraryManager ( )
defaultnoexcept

◆ LibraryManager() [2/3]

rtp::sys::LibraryManager::LibraryManager ( const LibraryManager )
delete

◆ LibraryManager() [3/3]

rtp::sys::LibraryManager::LibraryManager ( LibraryManager &&  )
deletenoexcept

Member Function Documentation

◆ getOrLoadInternal()

auto rtp::sys::LibraryManager::getOrLoadInternal ( std::string_view  path) -> std::expected<std::shared_ptr<DynamicLibrary>, rtp::Error>
private

Get an existing library or load it if not present.

Parameters
pathThe path to the dynamic library.
Returns
std::expected<std::shared_ptr<DynamicLibrary>, rtp::Error>

Definition at line 91 of file LibraryManager.cpp.

References rtp::Error::failure(), rtp::LibraryLoadFailed, and rtp::sys::impl::LibraryBackend::open().

◆ load()

auto rtp::sys::LibraryManager::load ( std::string_view  path) -> std::expected<const DynamicLibrary *, rtp::Error>

Main API.

Load a dynamic library, and return a raw pointer to the instance (Observer).

Parameters
pathThe path to the dynamic library.
Returns
std::expected<const DynamicLibrary *, rtp::Error>

Definition at line 58 of file LibraryManager.cpp.

References rtp::sys::DynamicLibrary::get().

◆ loadShared()

auto rtp::sys::LibraryManager::loadShared ( std::string_view  path) -> std::expected<std::shared_ptr<DynamicLibrary>, rtp::Error>

Shared API.

Load a dynamic library from the given path. If the library is already loaded, return the existing instance.

Parameters
pathThe path to the dynamic library.
Returns
std::expected<std::shared_ptr<DynamicLibrary>, rtp::Error>

Definition at line 69 of file LibraryManager.cpp.

◆ loadStandalone()

auto rtp::sys::LibraryManager::loadStandalone ( std::string_view  path) -> std::expected<std::unique_ptr<DynamicLibrary>, rtp::Error>
static

Isolated API (Factory).

Load a dynamic library, and create a unique instance of it, out of the manager's cache nor tracking.

Parameters
pathThe path to the dynamic library.
Returns
std::expected<std::unique_ptr<DynamicLibrary>, rtp::Error>

Definition at line 75 of file LibraryManager.cpp.

References rtp::Error::failure(), rtp::LibraryLoadFailed, and rtp::sys::impl::LibraryBackend::open().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

LibraryManager & rtp::sys::LibraryManager::operator= ( LibraryManager &&  )
deletenoexcept

Member Data Documentation

◆ _libraries

std::unordered_map<std::string, std::shared_ptr<DynamicLibrary> > rtp::sys::LibraryManager::_libraries
private

Definition at line 110 of file LibraryManager.hpp.

◆ _mutex

std::shared_mutex rtp::sys::LibraryManager::_mutex
private

Mutex for thread-safe access.

Definition at line 111 of file LibraryManager.hpp.


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