1 #ifndef __PBIO_DLL_HANDLE_H_989601403fee4b0d83e85ee9b5292036
2 #define __PBIO_DLL_HANDLE_H_989601403fee4b0d83e85ee9b5292036
10 #include "c_api_functions_list_macro.h"
16 #ifndef __STATIC_LIBFACEREC_BUILD__
26 #ifdef __STATIC_LIBFACEREC_BUILD__
30 #define __META_STATIC_DECL(rtype, name, typed_args, args, return) \
31 extern "C" rtype name typed_args;
33 __TDV_METASDK_FLIST(__META_STATIC_DECL)
35 #define __583e_STATIC_DECL(rtype, name, typed_args, args, return) \
36 rtype _583e_ADD_NAMESPACE(name) typed_args;
38 __583e_FLIST(__583e_STATIC_DECL)
39 __TDV_FLIST(__583e_STATIC_DECL)
52 int32_t refcounter4light_shared_ptr;
54 friend class object_with_ref_counter<DllHandle>;
57 #ifdef __STATIC_LIBFACEREC_BUILD__
62 const int _placeholder;
65 #define __583e_STATIC_F_INIT(rtype, name, typed_args, args, return) \
66 , name( _583e_ADD_NAMESPACE(name) )
67 #define __META_STATIC_F_INIT(rtype, name, typed_args, args, return) \
72 __583e_FLIST(__583e_STATIC_F_INIT)
73 __TDV_FLIST(__583e_STATIC_F_INIT)
74 __TDV_METASDK_FLIST(__META_STATIC_F_INIT)
87 #define __583e_SHARED_F_INIT(rtype, name, typed_args, args, return) \
88 , name( (FuncType_##name) getSymbol( _583e_STR_ADD_NAMESPACE(name) ) )
90 #define __TDV_SHARED_F_INIT(rtype, name, typed_args, args, return) \
91 , name( (FuncType_##name) getSymbol( _583e_STRINGISE2(name) ) )
93 DllHandle(
const char*
const dll_path) :
96 _dll_sense4( loadDll(make_sense4_dll_path(dll_path).c_str()) ),
98 _dll( loadDll(dll_path) )
99 __583e_FLIST(__583e_SHARED_F_INIT)
100 __TDV_FLIST(__TDV_SHARED_F_INIT)
101 __TDV_METASDK_FLIST(__TDV_SHARED_F_INIT)
110 FreeLibrary(_dll_sense4);
119 typedef void* HINSTANCE;
124 std::string make_sense4_dll_path(
char const*
const dll_path)
127 for(
int i = 0; dll_path[i]; ++i)
128 if(dll_path[i] ==
'/' || dll_path[i] ==
'\\')
131 return std::string(dll_path, dll_path + (pos + 1)) +
"sense4.dll";
136 HINSTANCE loadDll(
char const*
const dll_path)
139 HINSTANCE
const result = LoadLibraryA(dll_path);
141 HINSTANCE
const result = dlopen( dll_path, RTLD_NOW|RTLD_LOCAL);
149 char error_buffer[1024];
151 const DWORD err_code = GetLastError();
153 std::ostringstream oss;
155 oss <<
" last error: " << std::hex << err_code;
158 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
163 sizeof(error_buffer) - 1,
166 oss <<
" : '" << error_buffer <<
"'";
173 char const*
const error_c_str = dlerror();
175 error =
" dlerror: '" + std::string(error_c_str) +
"'";
179 throw pbio::Error(0xbd2483c0,
"Error in pbio::FacerecService::createService"
180 " can't open dll file'" + std::string(dll_path) +
"', error code: 0xbd2483c0" + error);
186 void* getSymbol(
char const*
const name)
const
189 void*
const result =
reinterpret_cast<void*
>( GetProcAddress(_dll, name) );
191 void*
const result = dlsym(_dll, name);
196 throw pbio::Error(0x5146c155,
"Error in pbio::FacerecService::createService"
197 " can't fynd symbol '" + std::string(name) +
"' in dll '" + _dll_path +
"', error code: 0x5146c155");
203 const std::string _dll_path;
206 HINSTANCE
const _dll_sense4;
209 HINSTANCE
const _dll;
218 #define __583e_F_FIELD_DECL(rtype, name, typed_args, args, return) \
219 typedef rtype (*FuncType_##name) typed_args; \
220 const FuncType_##name name;
222 #define __TDV_F_FIELD_DECL(rtype, name, typed_args, args, return) \
223 typedef rtype (*FuncType_##name) typed_args; \
224 const FuncType_##name name;
226 __583e_FLIST(__583e_F_FIELD_DECL)
227 __TDV_FLIST(__TDV_F_FIELD_DECL)
228 __TDV_METASDK_FLIST(__583e_F_FIELD_DECL)
238 #endif // __PBIO_DLL_HANDLE_H_989601403fee4b0d83e85ee9b5292036
Error - класс исключений, выбрасываемых при возникновении ошибок.
Класс исключений, выбрасываемых при возникновении ошибок.
Definition: Error.h:26