Loading...
Searching...
No Matches
dlib.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "indep/common.hpp"
5#include "indep/def.hpp"
6#include "indep/macro.hpp"
7#include "tres.inl"
8#ifdef BY_BUILD_PLATFORM_IS_WINDOWS
9# include <windows.h> // for dll loading
10#endif
11
12namespace by {
13
14#ifdef BY_BUILD_PLATFORM_IS_WINDOWS
15 typedef HMODULE dlibHandle;
16#else
17 typedef void* dlibHandle;
18#endif
19 template <typename F> using tmayFunc = tres<F, std::string>;
20
66 class _nout dlib {
67 BY(ME(dlib))
68
69 public:
70 public:
71 dlib();
72 dlib(const char* path);
73 dlib(const std::string& path);
74 dlib(const me& rhs);
75 virtual ~dlib();
76
77 public:
78 me& operator=(const me& rhs);
79
80 public:
81 const std::string& getPath() const;
82 void setPath(const std::string& path);
83 void setPath(const std::string* it) BY_SIDE_FUNC(setPath);
84
91 tmay<std::string> load();
92
93 nbool isLoaded() const;
94
102 template <typename F> tmayFunc<F> accessFunc(const std::string& name) { return accessFunc<F>(name.c_str()); }
103
104 template <typename F> tmayFunc<F> accessFunc(const std::string* it) BY_SIDE_FUNC(accessFunc<F>);
105
106 template <typename F> tmayFunc<F> accessFunc(const nchar* name) {
107 auto&& res = _accessFunc(name);
108 return res.has() ? tmayFunc<F>((F&) *res) : tmayFunc<F>(res.getErr());
109 }
110
111 void rel();
112
113 private:
114 tmayFunc<void*> _accessFunc(const nchar* name);
115
116 private:
117 std::string _path;
118 dlibHandle _handle;
119 };
120
121 typedef std::vector<dlib> dlibs;
122} // namespace by
#define BY_SIDE_FUNC(...)
Side function macros for safe pointer operations.
Definition sideFunc.hpp:24
to Top