68 std::mutex system_mtx;
69 std::vector<std::shared_ptr<System> > slist;
71 int find(
const std::vector<std::shared_ptr<System> > &list,
const std::string &
filename)
73 for (
size_t i=0; i<list.size(); i++)
77 return static_cast<int>(i);
85 static std::string getPathToThisDll()
88 if (GetModuleHandleEx(
89 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
90 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
91 reinterpret_cast<LPCSTR>(&getPathToThisDll), &hm) == 0)
97 if (GetModuleFileName(hm, path,
sizeof(path)) == 0)
102 std::string p{ path };
103 const auto bs_pos = p.rfind(
'\\');
104 if (bs_pos != std::string::npos)
106 p = p.substr(0, bs_pos);
118 std::lock_guard<std::mutex> lock(system_mtx);
119 std::vector<std::shared_ptr<System> > ret;
124 if (
sizeof(
size_t) == 8)
126 env=
"GENICAM_GENTL64_PATH";
130 env=
"GENICAM_GENTL32_PATH";
135 const char *envpath=std::getenv(env);
141 if (path.size() == 0)
148 std::string path_to_exe;
149 if (GetModuleFileName(NULL, procpath, n-1) > 0)
153 char *p=strrchr(procpath,
'\\');
156 path_to_exe=procpath;
157 path+=
";" + path_to_exe;
160 const auto path_to_this_dll = getPathToThisDll();
161 if (!path_to_this_dll.empty() && path_to_this_dll != path_to_exe)
163 path +=
";" + path_to_this_dll;
168 path=GENTL_INSTALL_PATH;
177 for (
size_t i=0; i<name.size(); i++)
179 int k=find(slist, name[i]);
183 ret.push_back(slist[static_cast<size_t>(k)]);
190 ret.push_back(std::shared_ptr<System>(p));
192 catch (
const std::exception &)
207 throw GenTLException(std::string(
"No transport layers found in path ")+path);
215 std::lock_guard<std::mutex> lock(system_mtx);
218 for (
size_t i=0; i<slist.size(); i++)
220 slist[i]->clearInterfaces();
233 std::lock_guard<std::recursive_mutex> lock(
mtx);
248 std::lock_guard<std::recursive_mutex> lock(
mtx);
268 int find(
const std::vector<std::shared_ptr<Interface> > &list,
const std::string &
id)
270 for (
size_t i=0; i<list.size(); i++)
272 if (list[i]->
getID() == id)
274 return static_cast<int>(i);
285 std::lock_guard<std::recursive_mutex> lock(
mtx);
286 std::vector<std::shared_ptr<Interface> > ret=
ilist;
293 if (
tl != 0 &&
ilist.size() == 0)
297 std::vector<std::shared_ptr<Interface> > current;
326 for (uint32_t i=0; i<n; i++)
329 size_t size=
sizeof(tmp);
336 int k=find(current, tmp);
340 ret.push_back(current[static_cast<size_t>(k)]);
344 ret.push_back(std::shared_ptr<Interface>(
new Interface(shared_from_this(),
gentl, tmp)));
351 for (
size_t i=0; i<ret.size(); i++)
353 ilist.push_back(ret[i]);
358 for (
size_t i=0; i<ret.size(); i++)
377 size_t tmp_size=
sizeof(tmp);
382 err=gentl->TLGetInfo(tl, info, &type, tmp, &tmp_size);
386 err=gentl->GCGetInfo(info, &type, tmp, &tmp_size);
391 for (
size_t i=0; i<tmp_size && tmp[i] !=
'\0'; i++)
393 ret.push_back(tmp[i]);
404 std::lock_guard<std::recursive_mutex> lock(
mtx);
410 std::lock_guard<std::recursive_mutex> lock(
mtx);
416 std::lock_guard<std::recursive_mutex> lock(
mtx);
422 std::lock_guard<std::recursive_mutex> lock(
mtx);
428 std::lock_guard<std::recursive_mutex> lock(
mtx);
434 std::lock_guard<std::recursive_mutex> lock(
mtx);
440 std::lock_guard<std::recursive_mutex> lock(
mtx);
446 std::lock_guard<std::recursive_mutex> lock(
mtx);
452 std::lock_guard<std::recursive_mutex> lock(
mtx);
457 size_t size=
sizeof(v);
480 std::lock_guard<std::recursive_mutex> lock(
mtx);
484 size_t size=
sizeof(ret);
495 return static_cast<int>(ret);
500 std::lock_guard<std::recursive_mutex> lock(
mtx);
504 size_t size=
sizeof(ret);
515 return static_cast<int>(ret);
520 std::lock_guard<std::recursive_mutex> lock(
mtx);
538 for (
size_t i=0; i<
ilist.size(); i++)
System(const std::string &_filename)
std::string getDisplayName()
Returns the display name of the GenTL provider.
std::shared_ptr< GenApi::CNodeMapRef > nodemap
const std::string & getFilename() const
Get file name from which this system was created.
This is the port definition that connects GenAPI to GenTL.
static std::vector< std::shared_ptr< System > > getSystems()
Returns a list of systems (i.e.
void * getHandle() const
Get internal handle of open transport layer.
std::shared_ptr< CPort > cport
std::vector< std::shared_ptr< Interface > > getInterfaces()
Returns the currently available interfaces.
void close()
Closes the system.
The system class encapsulates a Genicam transport layer.
std::shared_ptr< const GenTLWrapper > gentl
static void clearSystems()
Clears the internal list of systems.
std::string getVendor()
Returns the vendor name of the GenTL provider.
int getMinorVersion()
Returns the minor version number.
void open()
Opens the system for working with it.
std::shared_ptr< GenApi::CNodeMapRef > getNodeMap()
Returns the node map of this object.
std::string getName()
Returns the file name of the GenTL provider.
std::vector< std::string > getAvailableGenTLs(const char *paths)
The function uses the given list files of paths that is separated by colons or semicolons, depending on the used operating system, and returns all files with the suffix .cti.
Wrapper for dynamically loaded GenICam transport layers.
std::shared_ptr< GenApi::CNodeMapRef > allocNodeMap(std::shared_ptr< const GenTLWrapper > gentl, void *port, CPort *cport, const char *xml)
Convenience function that returns a GenICam node map from the given port.
bool isCharEncodingASCII()
Returns the character encoding.
std::string getVersion()
Returns the version of the GenTL provider.
std::string getModel()
Returns the model of the GenTL provider.
std::string getPathname()
Returns the full path name of the GenTL provider.
std::string getTLType()
Returns the transport layer type of the GenTL provider.
int getMajorVersion()
Returns the major version number.
The interface class encapsulates a Genicam interface.
std::vector< std::shared_ptr< Interface > > ilist
std::string getID()
Returns the ID of the GenTL provider.