From 32cf6beee3936ed60ddf0664bdac4983ffd55284 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 18 Feb 2023 22:05:58 -0800 Subject: common: dynamic_library: Add ctor for existing handle. --- src/common/dynamic_library.cpp | 2 ++ src/common/dynamic_library.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/common/dynamic_library.cpp b/src/common/dynamic_library.cpp index 054277a2b..4fabe7e52 100644 --- a/src/common/dynamic_library.cpp +++ b/src/common/dynamic_library.cpp @@ -22,6 +22,8 @@ DynamicLibrary::DynamicLibrary(const char* filename) { void(Open(filename)); } +DynamicLibrary::DynamicLibrary(void* handle_) : handle{handle_} {} + DynamicLibrary::DynamicLibrary(DynamicLibrary&& rhs) noexcept : handle{std::exchange(rhs.handle, nullptr)} {} diff --git a/src/common/dynamic_library.h b/src/common/dynamic_library.h index f42bdf441..662d454d4 100644 --- a/src/common/dynamic_library.h +++ b/src/common/dynamic_library.h @@ -20,6 +20,9 @@ public: /// Automatically loads the specified library. Call IsOpen() to check validity before use. explicit DynamicLibrary(const char* filename); + /// Initializes the dynamic library with an already opened handle. + explicit DynamicLibrary(void* handle_); + /// Moves the library. DynamicLibrary(DynamicLibrary&&) noexcept; DynamicLibrary& operator=(DynamicLibrary&&) noexcept; -- cgit v1.2.3