68 std::recursive_mutex system_mtx;
69 std::vector<std::shared_ptr<System> > system_list;
70 std::string system_path;
71 std::string system_ignore;
73 int find(
const std::vector<std::shared_ptr<System> > &list,
const std::string &filename)
75 for (
size_t i=0; i<list.size(); i++)
77 if (list[i]->getFilename() == filename)
79 return static_cast<int>(i);
87 static std::string getPathToThisDll()
90 if (GetModuleHandleExA(
91 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
92 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
93 reinterpret_cast<LPCSTR
>(&getPathToThisDll), &hm) == 0)
99 if (GetModuleFileNameA(hm, path,
sizeof(path)) == 0)
104 std::string p{ path };
105 const auto bs_pos = p.rfind(
'\\');
106 if (bs_pos != std::string::npos)
108 p = p.substr(0, bs_pos);
120 std::lock_guard<std::recursive_mutex> lock(system_mtx);
122 if (system_list.size() == 0)
127 if (path == 0 || path[0] ==
'\0')
134 std::string path_to_exe;
135 if (GetModuleFileNameA(NULL, procpath, n-1) > 0)
139 char *p=strrchr(procpath,
'\\');
142 path_to_exe=procpath;
144 if (system_path.size() > 0) system_path+=
";";
146 system_path += path_to_exe;
151 const auto path_to_this_dll = getPathToThisDll();
152 if (!path_to_this_dll.empty() && path_to_this_dll != path_to_exe)
154 if (system_path.size() > 0) system_path+=
";";
156 system_path += path_to_this_dll;
162 WIN32_FIND_DATAA file_info;
164 file_handle=FindFirstFileA((path_to_this_dll+
"\\*").c_str(), &file_info);
166 if (file_handle != INVALID_HANDLE_VALUE)
170 if ((file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && file_info.cFileName[0] !=
'.' )
172 system_path +=
";" + path_to_this_dll +
"\\" + file_info.cFileName;
175 while (FindNextFileA(file_handle, &file_info));
177 FindClose(file_handle);
182 system_path=GENTL_INSTALL_PATH;
192 system_ignore=ignore;
203 std::lock_guard<std::recursive_mutex> lock(system_mtx);
204 std::vector<std::shared_ptr<System> > ret;
208 if (system_path.size() == 0)
211 if (
sizeof(
size_t) == 8)
213 env=
"GENICAM_GENTL64_PATH";
217 env=
"GENICAM_GENTL32_PATH";
231 for (
size_t i=0; i<name.size(); i++)
233 int k=find(system_list, name[i]);
235 if (system_ignore.size() > 0)
239 if (name[i].size() >= system_ignore.size() &&
240 name[i].substr(name[i].size()-system_ignore.size()) == system_ignore)
248 ret.push_back(system_list[
static_cast<size_t>(k)]);
255 ret.push_back(std::shared_ptr<System>(p));
257 catch (
const std::exception &ex)
262 info << ex.what() << std::endl;
275 info <<
"No transport layers found in path: " << system_path;
284 std::lock_guard<std::recursive_mutex> lock(system_mtx);
287 for (
size_t i=0; i<system_list.size(); i++)
289 system_list[i]->clearInterfaces();
302 std::lock_guard<std::recursive_mutex> lock(
mtx);
317 std::lock_guard<std::recursive_mutex> lock(
mtx);
337 int find(
const std::vector<std::shared_ptr<Interface> > &list,
const std::string &
id)
339 for (
size_t i=0; i<list.size(); i++)
341 if (list[i]->getID() ==
id)
343 return static_cast<int>(i);
354 std::lock_guard<std::recursive_mutex> lock(
mtx);
355 std::vector<std::shared_ptr<Interface> > ret=
ilist;
362 if (
tl != 0 &&
ilist.size() == 0)
366 std::vector<std::shared_ptr<Interface> > current;
395 for (uint32_t i=0; i<n; i++)
398 size_t size=
sizeof(tmp);
405 int k=find(current, tmp);
409 ret.push_back(current[
static_cast<size_t>(k)]);
413 ret.push_back(std::shared_ptr<Interface>(
new Interface(shared_from_this(),
gentl, tmp)));
420 for (
size_t i=0; i<ret.size(); i++)
422 ilist.push_back(ret[i]);
427 for (
size_t i=0; i<ret.size(); i++)
439 std::string cTLGetInfo(
GenTL::TL_HANDLE tl,
const std::shared_ptr<const GenTLWrapper> &gentl,
446 size_t tmp_size=
sizeof(tmp);
451 err=gentl->TLGetInfo(tl, info, &type, tmp, &tmp_size);
455 err=gentl->GCGetInfo(info, &type, tmp, &tmp_size);
460 for (
size_t i=0; i<tmp_size && tmp[i] !=
'\0'; i++)
462 ret.push_back(tmp[i]);
473 std::lock_guard<std::recursive_mutex> lock(
mtx);
479 std::lock_guard<std::recursive_mutex> lock(
mtx);
485 std::lock_guard<std::recursive_mutex> lock(
mtx);
491 std::lock_guard<std::recursive_mutex> lock(
mtx);
497 std::lock_guard<std::recursive_mutex> lock(
mtx);
503 std::lock_guard<std::recursive_mutex> lock(
mtx);
509 std::lock_guard<std::recursive_mutex> lock(
mtx);
515 std::lock_guard<std::recursive_mutex> lock(
mtx);
521 std::lock_guard<std::recursive_mutex> lock(
mtx);
526 size_t size=
sizeof(v);
549 std::lock_guard<std::recursive_mutex> lock(
mtx);
553 size_t size=
sizeof(ret);
564 return static_cast<int>(ret);
569 std::lock_guard<std::recursive_mutex> lock(
mtx);
573 size_t size=
sizeof(ret);
584 return static_cast<int>(ret);
589 std::lock_guard<std::recursive_mutex> lock(
mtx);
607 for (
size_t i=0; i<
ilist.size(); i++)