11#ifndef LODESTONE_LIBRARYHANDLE_H
12#define LODESTONE_LIBRARYHANDLE_H
18#elif defined(__unix__) || defined (__APPLE__)
58 using handle_t = HMODULE;
59 using function_t = FARPROC;
61 static constexpr const handle_t NULL_HANDLE = NULL;
62 static constexpr const function_t NULL_FUNCTION =
nullptr;
63#elif defined(__unix__) || defined (__APPLE__)
64 using handle_t =
void *;
65 using function_t =
void *;
67 static constexpr const handle_t NULL_HANDLE =
nullptr;
68 static constexpr const function_t NULL_FUNCTION =
nullptr;
90 bool valid()
const noexcept;
93 template <
typename Func>
94 requires std::is_function_v<std::remove_pointer_t<std::remove_reference_t<Func>>>
96 return reinterpret_cast<Func
>(this->
getFunction(name));
std::filesystem::path m_path
The path of the library file.
Definition LibraryHandle.h:103
void load()
Loads a library at the stored path.
Definition LibraryHandle.cpp:32
LibraryHandle(const std::filesystem::path &path)
Creates a new LibraryHandle.
Definition LibraryHandle.cpp:30
bool valid() const noexcept
Returns true if the library handle is valid.
Definition LibraryHandle.cpp:89
void unload()
Unloads the library.
Definition LibraryHandle.cpp:60
handle_t m_handle
The library handle.
Definition LibraryHandle.h:105
Func getFunction(const char *name)
Returns the address of an exported function by name, casts to the given function type.
Definition LibraryHandle.h:95
Definition LibraryException.cpp:10