vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::DynamicLibrary Class Reference

Cross-platform handle to a loaded shared library (.dll / .so). More...

#include <dynamic_library.h>

Public Member Functions

bool load (const std::filesystem::path &path)
 Load the library at path, unloading any loaded before it.
void unload ()
 Unload the library if currently loaded; idempotent.
void * symbol (const char *name) const
 Resolve name to a symbol address.

Static Public Member Functions

static std::string platformName (const std::string &baseName)
 Map a base name to its platform filename: "game" -> "game.dll" (Windows) or "libgame.so" (elsewhere).

Detailed Description

Cross-platform handle to a loaded shared library (.dll / .so).

Owns the OS handle and unloads on destruction.

Member Function Documentation

◆ load()

bool Vkm::Engine::DynamicLibrary::load ( const std::filesystem::path & path)
nodiscard

Load the library at path, unloading any loaded before it.

A path, not a string: narrowing through the Windows code page cannot spell every directory name, so the loader gets the native encoding.

Parameters
pathLibrary file to open.
Returns
Whether it opened; a failure is logged.

◆ symbol()

void * Vkm::Engine::DynamicLibrary::symbol ( const char * name) const

Resolve name to a symbol address.

Parameters
nameThe exported symbol's name.
Returns
Its address, to be cast to the expected function-pointer type; nullptr if absent or nothing is loaded.

◆ platformName()

std::string Vkm::Engine::DynamicLibrary::platformName ( const std::string & baseName)
static

Map a base name to its platform filename: "game" -> "game.dll" (Windows) or "libgame.so" (elsewhere).

Parameters
baseNameThe library's name without prefix or extension.
Returns
The filename the platform's loader expects.

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