6#include <aegis2d/core/export.hpp>
22inline constexpr std::string_view
library_entry =
"aegis2d_library_entry";
40 const char*
name =
nullptr;
45class AEGIS2D_CORE_EXPORT
LibraryError :
public std::runtime_error {
47 using std::runtime_error::runtime_error;
76 [[nodiscard]]
void*
symbol(
const std::string& name)
const noexcept;
82 template <
typename Function>
83 [[nodiscard]] Function*
function(
const std::string& name)
const noexcept {
84 return reinterpret_cast<Function*
>(symbol(name));
89 [[nodiscard]]
const std::filesystem::path&
path() const noexcept {
return path_; }
92 void close() noexcept;
94 std::filesystem::path path_;
95 void* handle_ =
nullptr;
116load_library(
const std::filesystem::path& path, std::uint32_t api_version = library_api_version);
A shared library could not be opened or is not one the engine can load.
Definition shared_library.hpp:45
A shared library opened at run time (.so, .dylib or .dll), closed when destroyed.
Definition shared_library.hpp:54
SharedLibrary(const std::filesystem::path &path)
Opens a library, with every symbol resolved now.
SharedLibrary(const SharedLibrary &)=delete
SharedLibrary(SharedLibrary &&other) noexcept
Takes the library over; other no longer holds one.
Function * function(const std::string &name) const noexcept
An exported function, with its type.
Definition shared_library.hpp:83
void * symbol(const std::string &name) const noexcept
Address of an exported symbol.
SharedLibrary & operator=(const SharedLibrary &)=delete
const std::filesystem::path & path() const noexcept
Path the library was opened from.
Definition shared_library.hpp:89
~SharedLibrary()
Closes the library.
SharedLibrary & operator=(SharedLibrary &&other) noexcept
Closes the library held, then takes other's over.
Logging, time, main loop, events and configuration shared by client and server.
Definition clock.hpp:11
EngineLibrary load_library(const std::filesystem::path &path, std::uint32_t api_version=library_api_version)
Opens an Aegis2D library and checks that the engine can use it.
constexpr std::string_view library_entry
Name of the C function every Aegis2D library exports (see LibraryInfo).
Definition shared_library.hpp:22
constexpr std::uint32_t library_api_version
Version of the interface between the engine and the libraries it loads.
Definition shared_library.hpp:19
Definition endpoint.hpp:85
An Aegis2D library, opened and checked by load_library().
Definition shared_library.hpp:99
std::string name
Its name, from its LibraryInfo; empty if it gives none.
Definition shared_library.hpp:103
SharedLibrary library
The opened library.
Definition shared_library.hpp:101
What an Aegis2D library tells about itself, from its C entry point.
Definition shared_library.hpp:36
std::uint32_t api_version
library_api_version the library was built with.
Definition shared_library.hpp:38
const char * name
Name of the library, a static string; may be null.
Definition shared_library.hpp:40