| 1 | // LAF Base Library | 
|---|
| 2 | // Copyright (c) 2020-2021 Igara Studio S.A. | 
|---|
| 3 | // Copyright (c) 2016 David Capello | 
|---|
| 4 | // | 
|---|
| 5 | // This file is released under the terms of the MIT license. | 
|---|
| 6 | // Read LICENSE.txt for more information. | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef BASE_DLL_H_INCLUDED | 
|---|
| 9 | #define BASE_DLL_H_INCLUDED | 
|---|
| 10 | #pragma once | 
|---|
| 11 |  | 
|---|
| 12 | #include <string> | 
|---|
| 13 |  | 
|---|
| 14 | namespace base { | 
|---|
| 15 |  | 
|---|
| 16 | typedef void* dll; | 
|---|
| 17 | typedef void* dll_proc; | 
|---|
| 18 |  | 
|---|
| 19 | dll load_dll(const std::string& filename); | 
|---|
| 20 | void unload_dll(dll lib); | 
|---|
| 21 | dll_proc get_dll_proc_base(dll lib, const char* procName); | 
|---|
| 22 |  | 
|---|
| 23 | template<typename T> | 
|---|
| 24 | inline T get_dll_proc(dll lib, const char* procName) { | 
|---|
| 25 | return reinterpret_cast<T>(get_dll_proc_base(lib, procName)); | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | #if LAF_WINDOWS | 
|---|
| 29 | class Version; | 
|---|
| 30 | // TODO get_dll_filename() could be implemented on Linux with the | 
|---|
| 31 | //      non-standard dlinfo() function | 
|---|
| 32 | std::string get_dll_filename(dll lib); | 
|---|
| 33 | Version get_dll_version(dll lib); | 
|---|
| 34 | #endif | 
|---|
| 35 |  | 
|---|
| 36 | } // namespace base | 
|---|
| 37 |  | 
|---|
| 38 | #endif | 
|---|
| 39 |  | 
|---|