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);
226 std::lock_guard<std::mutex> lock(
mtx);
241 std::lock_guard<std::mutex> lock(
mtx);
261 int find(
const std::vector<std::shared_ptr<Interface> > &list,
const std::string &
id)
263 for (
size_t i=0; i<list.size(); i++)
265 if (list[i]->
getID() == id)
267 return static_cast<int>(i);
278 std::lock_guard<std::mutex> lock(
mtx);
279 std::vector<std::shared_ptr<Interface> > ret;
285 std::vector<std::shared_ptr<Interface> > current;
287 for (
size_t i=0; i<
ilist.size(); i++)
289 std::shared_ptr<Interface> p=
ilist[i].lock();
292 current.push_back(p);
312 for (uint32_t i=0; i<n; i++)
315 size_t size=
sizeof(tmp);
322 int k=find(current, tmp);
326 ret.push_back(current[static_cast<size_t>(k)]);
330 ret.push_back(std::shared_ptr<Interface>(
new Interface(shared_from_this(),
gentl, tmp)));
337 for (
size_t i=0; i<ret.size(); i++)
339 ilist.push_back(ret[i]);
356 size_t tmp_size=
sizeof(tmp);
361 err=gentl->TLGetInfo(tl, info, &type, tmp, &tmp_size);
365 err=gentl->GCGetInfo(info, &type, tmp, &tmp_size);
370 for (
size_t i=0; i<tmp_size && tmp[i] !=
'\0'; i++)
372 ret.push_back(tmp[i]);
383 std::lock_guard<std::mutex> lock(
mtx);
389 std::lock_guard<std::mutex> lock(
mtx);
395 std::lock_guard<std::mutex> lock(
mtx);
401 std::lock_guard<std::mutex> lock(
mtx);
407 std::lock_guard<std::mutex> lock(
mtx);
413 std::lock_guard<std::mutex> lock(
mtx);
419 std::lock_guard<std::mutex> lock(
mtx);
425 std::lock_guard<std::mutex> lock(
mtx);
431 std::lock_guard<std::mutex> lock(
mtx);
436 size_t size=
sizeof(v);
459 std::lock_guard<std::mutex> lock(
mtx);
463 size_t size=
sizeof(ret);
474 return static_cast<int>(ret);
479 std::lock_guard<std::mutex> lock(
mtx);
483 size_t size=
sizeof(ret);
494 return static_cast<int>(ret);
499 std::lock_guard<std::mutex> lock(
mtx);
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::vector< std::weak_ptr< Interface > > ilist
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::string getID()
Returns the ID of the GenTL provider.