IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_interface.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10
16#include <peak/dll_interface/peak_dll_interface_util.hpp>
17#include <peak/generic/peak_t_callback_manager.hpp>
19
20#include <unordered_map>
21#include <cstdint>
22#include <functional>
23#include <memory>
24#include <mutex>
25#include <string>
26#include <vector>
27
28
29namespace peak
30{
31namespace core
32{
33
34class System;
35
36struct DeviceFoundCallbackContainer;
37
47 , public std::enable_shared_from_this<Interface>
48{
49public:
51 using DeviceFoundCallback = std::function<void(const std::shared_ptr<DeviceDescriptor>& foundDevice)>;
55 using DeviceDisconnectedCallback = std::function<void(const std::shared_ptr<DeviceDescriptor>& disconnectedDevice)>;
59 using DeviceReconnectedCallback = std::function<void(
60 const std::shared_ptr<DeviceDescriptor>& reconnectedDevice, DeviceReconnectInformation reconnectInformation)>;
64 using DeviceLostCallback = std::function<void(const std::string& lostDeviceId)>;
68 using DeviceListChangedCallback = std::function<void()>;
71
72 Interface() = delete;
73 ~Interface() override;
74 Interface(const Interface& other) = delete;
75 Interface& operator=(const Interface& other) = delete;
76 Interface(Interface&& other) = delete;
77 Interface& operator=(Interface&& other) = delete;
78
80 PEAK_COMMON_NO_DISCARD std::string Key() const;
81
83 PEAK_COMMON_NO_DISCARD RawInformation Info(int32_t infoCommand) const;
85 PEAK_COMMON_NO_DISCARD std::string ID() const;
87 PEAK_COMMON_NO_DISCARD std::string DisplayName() const;
89 PEAK_COMMON_NO_DISCARD std::string TLType() const;
90
105 void UpdateDevices(Timeout timeout_ms);
106
116 PEAK_COMMON_NO_DISCARD std::vector<std::shared_ptr<DeviceDescriptor>> Devices() const;
117
119 PEAK_COMMON_NO_DISCARD std::shared_ptr<System> ParentSystem() const;
120
136
149
165
178
196
209
226
239
256
269
270private:
271 struct DeviceFoundCallbackContainer
272 {
273 std::weak_ptr<Interface> _Interface;
275 };
276 struct DeviceDisconnectedCallbackContainer
277 {
278 std::weak_ptr<Interface> _Interface;
280 };
281 struct DeviceReconnectedCallbackContainer
282 {
283 std::weak_ptr<Interface> _Interface;
285 };
286 static void PEAK_CALL_CONV DeviceFoundCallbackCWrapper(
287 PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice, void* context);
288 static void PEAK_CALL_CONV DeviceLostCallbackCWrapper(
289 const char* lostDeviceId, size_t lostDeviceIdSize, void* context);
290 static void PEAK_CALL_CONV DeviceDisconnectedCallbackCWrapper(
291 PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice, void* context);
292 static void PEAK_CALL_CONV DeviceReconnectedCallbackCWrapper(PEAK_DEVICE_DESCRIPTOR_HANDLE reconnectedDevice,
293 PEAK_DEVICE_RECONNECT_INFORMATION reconnectInformation, void* context);
294 static void PEAK_CALL_CONV DeviceListChangedCallbackCWrapper(void* context);
295
296 std::shared_ptr<DeviceDescriptor> GetOrAddFoundDevice(PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice);
297
298 PEAK_MODULE_HANDLE ModuleHandle() const override;
300
301 void InitializeUpdateMechanismIfNecessary();
302
303 friend ClassCreator<Interface>;
304 Interface(PEAK_INTERFACE_HANDLE interfaceHandle, const std::weak_ptr<System>& parentSystem);
305 PEAK_INTERFACE_HANDLE m_backendHandle;
306
307 std::weak_ptr<System> m_parentSystem;
308
309 std::unique_ptr<TCallbackManager<PEAK_DEVICE_FOUND_CALLBACK_HANDLE, DeviceFoundCallbackContainer>>
310 m_deviceFoundCallbackManager;
311 std::unique_ptr<TCallbackManager<PEAK_DEVICE_LOST_CALLBACK_HANDLE, DeviceLostCallback>>
312 m_deviceLostCallbackManager;
313
314 std::unique_ptr<TCallbackManager<PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE, DeviceDisconnectedCallbackContainer>>
315 m_deviceDisconnectedCallbackManager;
316 std::unique_ptr<TCallbackManager<PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE, DeviceReconnectedCallbackContainer>>
317 m_deviceReconnectedCallbackManager;
318
319 std::unique_ptr<TCallbackManager<PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE, DeviceListChangedCallback>>
320 m_deviceListChangedCallbackManager;
321
322 std::vector<std::shared_ptr<DeviceDescriptor>> m_devices;
323 std::unordered_map<std::string, std::shared_ptr<DeviceDescriptor>> m_devicesByKey;
324 std::unordered_map<std::string, std::string> m_devicesKeyById;
325 mutable std::mutex m_devicesMutex;
326 std::once_flag m_updateMechanismInitializedFlag;
327
328 std::string m_key;
329};
330
331} /* namespace core */
332} /* namespace peak */
333
334/* Implementation */
335namespace peak
336{
337namespace core
338{
339
340inline Interface::Interface(PEAK_INTERFACE_HANDLE interfaceHandle, const std::weak_ptr<System>& parentSystem)
341 : m_backendHandle(interfaceHandle)
342 , m_parentSystem(parentSystem)
343 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
344 return PEAK_C_ABI_PREFIX PEAK_Interface_GetKey(interfaceHandle, key, keySize);
345 }))
346{
347 m_deviceFoundCallbackManager =
348 std::make_unique<TCallbackManager<PEAK_DEVICE_FOUND_CALLBACK_HANDLE, DeviceFoundCallbackContainer>>(
349 [&](void* callbackContext) {
350 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_FOUND_CALLBACK_HANDLE>(
351 [&](PEAK_DEVICE_FOUND_CALLBACK_HANDLE* deviceFoundCallbackHandle) {
353 m_backendHandle, DeviceFoundCallbackCWrapper, callbackContext, deviceFoundCallbackHandle);
354 });
355 },
356 [&](PEAK_DEVICE_FOUND_CALLBACK_HANDLE callbackHandle) {
357 CallAndCheckCInterfaceFunction([&] {
359 m_backendHandle, callbackHandle);
360 });
361 });
362
363 m_deviceLostCallbackManager =
364 std::make_unique<TCallbackManager<PEAK_DEVICE_LOST_CALLBACK_HANDLE, DeviceLostCallback>>(
365 [&](void* callbackContext) {
366 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_LOST_CALLBACK_HANDLE>(
367 [&](PEAK_DEVICE_LOST_CALLBACK_HANDLE* deviceLostCallbackHandle) {
369 m_backendHandle, DeviceLostCallbackCWrapper, callbackContext, deviceLostCallbackHandle);
370 });
371 },
372 [&](PEAK_DEVICE_LOST_CALLBACK_HANDLE callbackHandle) {
373 CallAndCheckCInterfaceFunction([&] {
375 m_backendHandle, callbackHandle);
376 });
377 });
378
379 m_deviceDisconnectedCallbackManager = std::make_unique<
380 TCallbackManager<PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE, DeviceDisconnectedCallbackContainer>>(
381 [&](void* callbackContext) {
382 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE>(
383 [&](PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE* deviceDisconnectedCallbackHandle) {
385 DeviceDisconnectedCallbackCWrapper, callbackContext, deviceDisconnectedCallbackHandle);
386 });
387 },
388 [&](PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE callbackHandle) {
389 CallAndCheckCInterfaceFunction([&] {
391 m_backendHandle, callbackHandle);
392 });
393 });
394
395 m_deviceReconnectedCallbackManager = std::make_unique<
396 TCallbackManager<PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE, DeviceReconnectedCallbackContainer>>(
397 [&](void* callbackContext) {
398 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE>(
399 [&](PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE* deviceReconnectedCallbackHandle) {
401 DeviceReconnectedCallbackCWrapper, callbackContext, deviceReconnectedCallbackHandle);
402 });
403 },
404 [&](PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE callbackHandle) {
405 CallAndCheckCInterfaceFunction([&] {
407 m_backendHandle, callbackHandle);
408 });
409 });
410
411 m_deviceListChangedCallbackManager =
412 std::make_unique<TCallbackManager<PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE, DeviceListChangedCallback>>(
413 [&](void* callbackContext) {
414 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE>(
415 [&](PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE* deviceListChangedCallbackHandle) {
417 DeviceListChangedCallbackCWrapper, callbackContext, deviceListChangedCallbackHandle);
418 });
419 },
420 [&](PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE callbackHandle) {
421 CallAndCheckCInterfaceFunction([&] {
423 m_backendHandle, callbackHandle);
424 });
425 });
426}
427
429{
430 try
431 {
432 m_deviceFoundCallbackManager->UnregisterAllCallbacks();
433 m_deviceLostCallbackManager->UnregisterAllCallbacks();
434
435 m_deviceDisconnectedCallbackManager->UnregisterAllCallbacks();
436 m_deviceReconnectedCallbackManager->UnregisterAllCallbacks();
437
438 m_deviceListChangedCallbackManager->UnregisterAllCallbacks();
439 }
440 catch (const Exception&)
441 {}
442
443 (void)PEAK_C_ABI_PREFIX PEAK_Interface_Destruct(m_backendHandle);
444}
445
446inline std::string Interface::Key() const
447{
448 return m_key;
449}
450
451inline RawInformation Interface::Info(int32_t infoCommand) const
452{
453 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer, size_t* bufferSize) {
455 m_backendHandle, infoCommand, dataType, buffer, bufferSize);
456 });
457}
458
459inline std::string Interface::ID() const
460{
461 return QueryStringFromCInterfaceFunction([&](char* id, size_t* idSize) {
462 return PEAK_C_ABI_PREFIX PEAK_Interface_GetID(m_backendHandle, id, idSize);
463 });
464}
465
466inline std::string Interface::DisplayName() const
467{
468 return QueryStringFromCInterfaceFunction([&](char* displayName, size_t* displayNameSize) {
469 return PEAK_C_ABI_PREFIX PEAK_Interface_GetDisplayName(m_backendHandle, displayName, displayNameSize);
470 });
471}
472
473inline std::string Interface::TLType() const
474{
475 return QueryStringFromCInterfaceFunction([&](char* tlType, size_t* tlTypeSize) {
476 return PEAK_C_ABI_PREFIX PEAK_Interface_GetTLType(m_backendHandle, tlType, tlTypeSize);
477 });
478}
479
480inline void Interface::UpdateDevices(Timeout timeout_ms)
481{
482 InitializeUpdateMechanismIfNecessary();
483
484 CallAndCheckCInterfaceFunction(
485 [&] { return PEAK_C_ABI_PREFIX PEAK_Interface_UpdateDevices(m_backendHandle, timeout_ms); });
486}
487
488inline std::vector<std::shared_ptr<DeviceDescriptor>> Interface::Devices() const
489{
490 std::lock_guard<std::mutex> lock(m_devicesMutex);
491 return m_devices;
492}
493
494inline std::shared_ptr<System> Interface::ParentSystem() const
495{
496 return LockOrThrow(m_parentSystem);
497}
498
500 const Interface::DeviceFoundCallback& callback)
501{
502 return reinterpret_cast<DeviceFoundCallbackHandle>(
503 m_deviceFoundCallbackManager->RegisterCallback(DeviceFoundCallbackContainer{ shared_from_this(), callback }));
504}
505
507{
508 m_deviceFoundCallbackManager->UnregisterCallback(
509 reinterpret_cast<PEAK_DEVICE_FOUND_CALLBACK_HANDLE>(callbackHandle));
510}
511
513 const DeviceReconnectedCallback& callback)
514{
515 return reinterpret_cast<DeviceReconnectedCallbackHandle>(m_deviceReconnectedCallbackManager->RegisterCallback(
516 DeviceReconnectedCallbackContainer{ shared_from_this(), callback }));
517}
518
520{
521 m_deviceReconnectedCallbackManager->UnregisterCallback(
522 reinterpret_cast<PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE>(callbackHandle));
523}
524
526 const DeviceDisconnectedCallback& callback)
527{
528 return reinterpret_cast<DeviceDisconnectedCallbackHandle>(m_deviceDisconnectedCallbackManager->RegisterCallback(
529 DeviceDisconnectedCallbackContainer{ shared_from_this(), callback }));
530}
531
533{
534 m_deviceDisconnectedCallbackManager->UnregisterCallback(
535 reinterpret_cast<PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE>(callbackHandle));
536}
537
539 const Interface::DeviceLostCallback& callback)
540{
541 return reinterpret_cast<DeviceLostCallbackHandle>(m_deviceLostCallbackManager->RegisterCallback(callback));
542}
543
545{
546 m_deviceLostCallbackManager->UnregisterCallback(
547 reinterpret_cast<PEAK_DEVICE_LOST_CALLBACK_HANDLE>(callbackHandle));
548}
549
552{
553 return reinterpret_cast<DeviceListChangedCallbackHandle>(
554 m_deviceListChangedCallbackManager->RegisterCallback(callback));
555}
556
558{
559 m_deviceListChangedCallbackManager->UnregisterCallback(
560 reinterpret_cast<PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE>(callbackHandle));
561}
562
563inline void PEAK_CALL_CONV Interface::DeviceFoundCallbackCWrapper(
564 PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice, void* context)
565{
566 auto callbackContainer = static_cast<DeviceFoundCallbackContainer*>(context);
567
568 auto interfaceDescriptor = callbackContainer->_Interface.lock()->GetOrAddFoundDevice(foundDevice);
569
570 callbackContainer->Callback(interfaceDescriptor);
571}
572
573inline void PEAK_CALL_CONV Interface::DeviceLostCallbackCWrapper(
574 const char* lostDeviceId, size_t lostDeviceIdSize, void* context)
575{
576 auto callback = static_cast<Interface::DeviceLostCallback*>(context);
577
578 callback->operator()(std::string(lostDeviceId, lostDeviceIdSize - 1));
579}
580
581inline void PEAK_CALL_CONV Interface::DeviceDisconnectedCallbackCWrapper(
582 PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice, void* context)
583{
584 auto callbackContainer = static_cast<DeviceDisconnectedCallbackContainer*>(context);
585
586 auto deviceDescriptor = callbackContainer->_Interface.lock()->GetOrAddFoundDevice(foundDevice);
587
588 callbackContainer->Callback(deviceDescriptor);
589}
590
591inline void PEAK_CALL_CONV Interface::DeviceReconnectedCallbackCWrapper(PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice,
592 PEAK_DEVICE_RECONNECT_INFORMATION reconnectInformation, void* context)
593{
594 auto callbackContainer = static_cast<DeviceReconnectedCallbackContainer*>(context);
595
596 auto deviceDescriptor = callbackContainer->_Interface.lock()->GetOrAddFoundDevice(foundDevice);
597
598 callbackContainer->Callback(deviceDescriptor, DeviceReconnectInformation(std::move(reconnectInformation)));
599}
600
601inline void PEAK_CALL_CONV Interface::DeviceListChangedCallbackCWrapper(void* context)
602{
603 auto callback = static_cast<Interface::DeviceListChangedCallback*>(context);
604 callback->operator()();
605}
606
607inline std::shared_ptr<DeviceDescriptor> Interface::GetOrAddFoundDevice(PEAK_DEVICE_DESCRIPTOR_HANDLE foundDevice)
608{
609 std::lock_guard<std::mutex> lock(m_devicesMutex);
610
611 const auto deviceKey = QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
612 return PEAK_C_ABI_PREFIX PEAK_DeviceDescriptor_GetKey(foundDevice, key, keySize);
613 });
614 auto keyDevicePairIterator = m_devicesByKey.find(deviceKey);
615 if (keyDevicePairIterator == m_devicesByKey.end())
616 {
617 auto deviceDescriptor = std::static_pointer_cast<DeviceDescriptor>(
618 std::make_shared<ClassCreator<DeviceDescriptor>>(
619 foundDevice, std::weak_ptr<Interface>{ shared_from_this() }));
620 m_devices.emplace_back(deviceDescriptor);
621 m_devicesByKey.emplace(deviceKey, deviceDescriptor);
622 m_devicesKeyById.emplace(deviceDescriptor->ID(), deviceKey);
623
624 return deviceDescriptor;
625 }
626
627 return keyDevicePairIterator->second;
628}
629
631{
632 auto moduleHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_HANDLE>(
633 [&](PEAK_MODULE_HANDLE* _moduleHandle) {
634 return PEAK_C_ABI_PREFIX PEAK_Interface_ToModule(m_backendHandle, _moduleHandle);
635 });
636
637 return moduleHandle;
638}
639
641{
642 auto eventSupportingModuleHandle = QueryNumericFromCInterfaceFunction<PEAK_EVENT_SUPPORTING_MODULE_HANDLE>(
643 [&](PEAK_EVENT_SUPPORTING_MODULE_HANDLE* _eventSupportingModuleHandle) {
645 m_backendHandle, _eventSupportingModuleHandle);
646 });
647
648 return eventSupportingModuleHandle;
649}
650
651inline void Interface::InitializeUpdateMechanismIfNecessary()
652{
653 std::call_once(m_updateMechanismInitializedFlag, [&] {
654 (void)RegisterDeviceFoundCallback([](const std::shared_ptr<DeviceDescriptor>&) {
655 // Registering an empty callback is enough since DeviceFoundCallbackCWrapper() handles everything else.
656 });
657
658 (void)RegisterDeviceLostCallback([&](const std::string& lostDeviceId) {
659 {
660 std::lock_guard<std::mutex> lock(m_devicesMutex);
661 const auto lostDeviceKey = m_devicesKeyById.at(lostDeviceId);
662 m_devices.erase(std::remove_if(std::begin(m_devices), std::end(m_devices),
663 [lostDeviceKey](const std::shared_ptr<DeviceDescriptor>& device) {
664 return device->Key() == lostDeviceKey;
665 }),
666 std::end(m_devices));
667 m_devicesByKey.erase(lostDeviceKey);
668 m_devicesKeyById.erase(lostDeviceId);
669 }
670 });
671 });
672}
673
674} /* namespace core */
675} /* namespace peak */
Definition reconnect_information.hpp:19
virtual PEAK_EVENT_SUPPORTING_MODULE_HANDLE EventSupportingModuleHandle() const =0
The base class for all exceptions thrown by the library.
Definition peak_exception.hpp:24
std::function< void()> DeviceListChangedCallback
Definition peak_interface.hpp:68
~Interface() override
Definition peak_interface.hpp:428
PEAK_COMMON_NO_DISCARD std::shared_ptr< System > ParentSystem() const
Returns the parent system.
Definition peak_interface.hpp:494
PEAK_COMMON_NO_DISCARD std::string TLType() const
Returns the TL (transport layer) type.
Definition peak_interface.hpp:473
PEAK_COMMON_NO_DISCARD RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_interface.hpp:451
Interface(Interface &&other)=delete
Interface(const Interface &other)=delete
Interface & operator=(const Interface &other)=delete
DeviceReconnectedCallback * DeviceReconnectedCallbackHandle
Definition peak_interface.hpp:62
void UpdateDevices(Timeout timeout_ms)
Searches for devices.
Definition peak_interface.hpp:480
void UnregisterDeviceReconnectedCallback(DeviceReconnectedCallbackHandle callbackHandle)
Unregisters a device reconnected callback.
Definition peak_interface.hpp:519
void UnregisterDeviceListChangedCallback(DeviceListChangedCallbackHandle callbackHandle)
Unregisters a device list changed callback.
Definition peak_interface.hpp:557
DeviceDisconnectedCallbackHandle RegisterDeviceDisconnectedCallback(const DeviceDisconnectedCallback &callback)
Registers a callback for signaling a disconnected device.
Definition peak_interface.hpp:525
DeviceReconnectedCallbackHandle RegisterDeviceReconnectedCallback(const DeviceReconnectedCallback &callback)
Registers a callback for signaling a reconnected device.
Definition peak_interface.hpp:512
PEAK_COMMON_NO_DISCARD std::string ID() const
Returns the ID.
Definition peak_interface.hpp:459
DeviceListChangedCallbackHandle RegisterDeviceListChangedCallback(const DeviceListChangedCallback &callback)
Registers a callback for signaling a device list changed.
Definition peak_interface.hpp:550
std::function< void( const std::shared_ptr< DeviceDescriptor > &reconnectedDevice, DeviceReconnectInformation reconnectInformation)> DeviceReconnectedCallback
Definition peak_interface.hpp:59
void UnregisterDeviceDisconnectedCallback(DeviceDisconnectedCallbackHandle callbackHandle)
Unregisters a device disconnected callback.
Definition peak_interface.hpp:532
std::function< void(const std::shared_ptr< DeviceDescriptor > &foundDevice)> DeviceFoundCallback
Definition peak_interface.hpp:51
DeviceListChangedCallback * DeviceListChangedCallbackHandle
Definition peak_interface.hpp:70
PEAK_COMMON_NO_DISCARD std::vector< std::shared_ptr< DeviceDescriptor > > Devices() const
Returns the device list.
Definition peak_interface.hpp:488
PEAK_COMMON_NO_DISCARD std::string DisplayName() const
Returns the display name.
Definition peak_interface.hpp:466
DeviceLostCallbackHandle RegisterDeviceLostCallback(const DeviceLostCallback &callback)
Registers a callback for signaling a lost device.
Definition peak_interface.hpp:538
DeviceLostCallback * DeviceLostCallbackHandle
Definition peak_interface.hpp:66
Interface & operator=(Interface &&other)=delete
DeviceFoundCallback * DeviceFoundCallbackHandle
Definition peak_interface.hpp:53
void UnregisterDeviceFoundCallback(DeviceFoundCallbackHandle callbackHandle)
Unregisters a device found callback.
Definition peak_interface.hpp:506
void UnregisterDeviceLostCallback(DeviceLostCallbackHandle callbackHandle)
Unregisters a device lost callback.
Definition peak_interface.hpp:544
DeviceFoundCallbackHandle RegisterDeviceFoundCallback(const DeviceFoundCallback &callback)
Registers a callback for signaling a found device.
Definition peak_interface.hpp:499
PEAK_COMMON_NO_DISCARD std::string Key() const
Returns the unique key.
Definition peak_interface.hpp:446
DeviceDisconnectedCallback * DeviceDisconnectedCallbackHandle
Definition peak_interface.hpp:57
std::function< void(const std::string &lostDeviceId)> DeviceLostCallback
Definition peak_interface.hpp:64
std::function< void(const std::shared_ptr< DeviceDescriptor > &disconnectedDevice)> DeviceDisconnectedCallback
Definition peak_interface.hpp:55
virtual PEAK_MODULE_HANDLE ModuleHandle() const =0
Represents a GenTL System module.
Definition peak_system.hpp:49
Represents a timeout value in milliseconds.
Definition peak_timeout.hpp:28
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
PEAK_C_API PEAK_DeviceDescriptor_GetKey(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *key, size_t *keySize)
Asks the given device descriptor for its key.
struct PEAK_MODULE * PEAK_MODULE_HANDLE
Definition peak_backend.h:419
PEAK_C_API PEAK_Interface_ToEventSupportingModule(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_EVENT_SUPPORTING_MODULE_HANDLE *eventSupportingModuleHandle)
Casts the given interface to an event-supporting module.
PEAK_C_API PEAK_Interface_GetInfo(PEAK_INTERFACE_HANDLE interfaceHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given interface for an information based on a specific command.
PEAK_C_API PEAK_Interface_UnregisterDeviceFoundCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_FOUND_CALLBACK_HANDLE callbackHandle)
Unregisters the device-found callback with the given handle from the given interface.
PEAK_C_API PEAK_Interface_ToModule(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_MODULE_HANDLE *moduleHandle)
Casts the given interface to a module.
struct PEAK_INTERFACE * PEAK_INTERFACE_HANDLE
Definition peak_backend.h:379
PEAK_C_API PEAK_Interface_GetTLType(PEAK_INTERFACE_HANDLE interfaceHandle, char *tlType, size_t *tlTypeSize)
Asks the given interface for its TL type.
PEAK_DEVICE_DISCONNETED_CALLBACK * PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE
Definition peak_backend.h:568
PEAK_C_API PEAK_Interface_UnregisterDeviceListChangedCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE callbackHandle)
Unregisters the device-list-changed callback with the given handle from the given interface.
struct PEAK_EVENT_SUPPORTING_MODULE * PEAK_EVENT_SUPPORTING_MODULE_HANDLE
Definition peak_backend.h:475
PEAK_C_API PEAK_Interface_RegisterDeviceLostCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_LOST_CALLBACK callback, void *callbackContext, PEAK_DEVICE_LOST_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling a lost device at the given interface.
PEAK_DEVICE_LOST_CALLBACK * PEAK_DEVICE_LOST_CALLBACK_HANDLE
Definition peak_backend.h:570
PEAK_DEVICE_RECONNECTED_CALLBACK * PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE
Definition peak_backend.h:566
PEAK_C_API PEAK_Interface_UnregisterDeviceDisconnectedCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE callbackHandle)
Unregisters the device disconnected callback with the given handle from the given interface.
PEAK_DEVICE_FOUND_CALLBACK * PEAK_DEVICE_FOUND_CALLBACK_HANDLE
Definition peak_backend.h:564
PEAK_DEVICE_LIST_CHANGED_CALLBACK * PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE
Definition peak_backend.h:572
PEAK_C_API PEAK_Interface_RegisterDeviceFoundCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_FOUND_CALLBACK callback, void *callbackContext, PEAK_DEVICE_FOUND_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling a found device at the given interface.
PEAK_C_API PEAK_Interface_RegisterDeviceDisconnectedCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_DISCONNETED_CALLBACK callback, void *callbackContext, PEAK_DEVICE_DISCONNECTED_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling a disconnected device that is now waiting to be reconnected at the giv...
PEAK_C_API PEAK_Interface_RegisterDeviceReconnectedCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_RECONNECTED_CALLBACK callback, void *callbackContext, PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling a reconnected device at the given interface.
PEAK_C_API PEAK_Interface_UnregisterDeviceLostCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_LOST_CALLBACK_HANDLE callbackHandle)
Unregisters the device-lost callback with the given handle from the given interface.
PEAK_C_API PEAK_Interface_RegisterDeviceListChangedCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_LIST_CHANGED_CALLBACK callback, void *callbackContext, PEAK_DEVICE_LIST_CHANGED_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling a change in the device list at the given interface.
PEAK_C_API PEAK_Interface_Destruct(PEAK_INTERFACE_HANDLE interfaceHandle)
Destroys the given interface.
PEAK_C_API PEAK_Interface_UnregisterDeviceReconnectedCallback(PEAK_INTERFACE_HANDLE interfaceHandle, PEAK_DEVICE_RECONNECTED_CALLBACK_HANDLE callbackHandle)
Unregisters the device-reconnected callback with the given handle from the given interface.
PEAK_C_API PEAK_Interface_GetDisplayName(PEAK_INTERFACE_HANDLE interfaceHandle, char *displayName, size_t *displayNameSize)
Asks the given interface for its display name.
struct PEAK_DEVICE_DESCRIPTOR * PEAK_DEVICE_DESCRIPTOR_HANDLE
Definition peak_backend.h:383
PEAK_C_API PEAK_Interface_GetKey(PEAK_INTERFACE_HANDLE interfaceHandle, char *key, size_t *keySize)
Asks the given interface for its key.
PEAK_C_API PEAK_Interface_GetID(PEAK_INTERFACE_HANDLE interfaceHandle, char *id, size_t *idSize)
Asks the given interface for its ID.
PEAK_C_API PEAK_Interface_UpdateDevices(PEAK_INTERFACE_HANDLE interfaceHandle, uint64_t timeout_ms)
Tells the given interface to update its devices with the given timeout.
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:89
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:13
Definition peak_backend.h:534
The struct returned by all raw information functions.
Definition peak_common_structs.hpp:21