vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
dynamic_library.h
1#pragma once
2
3#include <filesystem>
4#include <string>
5
6namespace Vkm::Engine {
7
13class DynamicLibrary {
14 public:
15 DynamicLibrary() = default;
16 ~DynamicLibrary();
17
18 DynamicLibrary(const DynamicLibrary& other) = delete;
19 DynamicLibrary& operator=(const DynamicLibrary& other) = delete;
20
21 DynamicLibrary(DynamicLibrary && other) = delete;
22 DynamicLibrary& operator=(DynamicLibrary && other) = delete;
23
24 public:
34 [[nodiscard]] bool load(const std::filesystem::path& path);
35
39 void unload();
40
48 void* symbol(const char* name) const;
49
57 static std::string platformName(const std::string& baseName);
58
59 bool isLoaded() const { return m_handle != nullptr; }
60
61 private:
62 void* m_handle = nullptr;
63};
64
65} // namespace Vkm::Engine
void unload()
Unload the library if currently loaded; idempotent.
bool load(const std::filesystem::path &path)
Load the library at path, unloading any loaded before it.
void * symbol(const char *name) const
Resolve name to a symbol address.
static std::string platformName(const std::string &baseName)
Map a base name to its platform filename: "game" -> "game.dll" (Windows) or "libgame....