4#ifndef GREM_CORE_SYSTEM_SHARED_LIBRARY_HPP
5#define GREM_CORE_SYSTEM_SHARED_LIBRARY_HPP
61 open(filesystem, filepath);
69 explicit operator bool() const noexcept {
78 [[nodiscard]]
bool is_open() const noexcept {
79 return static_cast<bool>(library);
117 template <
typename T>
119 return *(T*)getSymbolAddress(name);
123 struct LibraryDeleter {
124 GREM_API(core)
void operator()(
void* handle)
const noexcept;
127 [[nodiscard]] GREM_API(core)
void* getSymbolAddress(
CStringView name)
const;
129 UniqueHandle<void*, LibraryDeleter> library{};
Base exception type for runtime errors.
Definition Error.hpp:38
Error(CStringView message)
Definition Error.hpp:55
Base interface for a filesystem.
Definition Filesystem.hpp:25
void open(const Filesystem &filesystem, CStringView filepath)
Open the shared library from a file.
bool is_open() const noexcept
Check if the shared library is currently open.
Definition SharedLibrary.hpp:78
static CStringView getLibraryFilenameExtension()
Get the proper filename extension for shared libraries on the current platform.
T & getSymbol(CStringView name)
Get a reference to the symbol with a specific name in the library.
Definition SharedLibrary.hpp:118
SharedLibrary() noexcept=default
Construct a closed shared library.
void close()
Close the shared library if it is currently open, invalidating all current pointers to its symbols fr...
CStringViewBase< char, std::char_traits< char > > CStringView
Definition CStringView.hpp:635
Error(CStringView message)
Definition Error.hpp:55