1 | /******************************************************************************* |
2 | Copyright (c) The Taichi Authors (2016- ). All Rights Reserved. |
3 | The use of this software is governed by the LICENSE file. |
4 | *******************************************************************************/ |
5 | |
6 | #pragma once |
7 | |
8 | #include "taichi/common/core.h" |
9 | |
10 | namespace taichi { |
11 | |
12 | class DynamicLoader { |
13 | private: |
14 | void load_dll(const std::string &dll_path); |
15 | |
16 | void close_dll(); |
17 | |
18 | public: |
19 | explicit DynamicLoader(const std::string &dll_path); |
20 | |
21 | void *load_function(const std::string &func_name); |
22 | |
23 | template <typename T> |
24 | void load_function(const std::string &func_name, T &f) { |
25 | f = (T)load_function(func_name); |
26 | } |
27 | |
28 | bool loaded() const; |
29 | |
30 | ~DynamicLoader(); |
31 | |
32 | private: |
33 | void *dll_ = nullptr; |
34 | }; |
35 | |
36 | } // namespace taichi |
37 | |