#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#define AGHAF_DYNAMIC_LIBRARY_INIT
struct pair_hash {
template <class T1, class T2>
std::size_t operator()(const std::pair<T1, T2> &pair) const {
return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
}
};
std::unordered_map<std::pair<std::string, std::string>,
AGHAF_Device, pair_hash>
devices;
void deviceEvent_callback(void *event, void *userContext) {
(void)userContext;
break;
std::pair<std::string, std::string> key(productNumber, serialNumber);
break;
devices.insert(
std::pair<std::pair<std::string, std::string>,
AGHAF_Device>(
key, device));
} break;
auto it = devices.find(key);
if (it != devices.end()) {
devices.erase(it);
}
} break;
break;
}
} break;
}
}
int main() {
#ifdef _WIN32
AGHAF_loadLibrary(AGHAF_DEFAULT_FILENAME);
#endif
std::string input;
while (input != "exit") {
std::cin >> input;
}
#ifdef _WIN32
AGHAF_unloadLibrary();
#endif
return 0;
}
@ AGHAF_TypeCanEvent
Event from CAN.
Definition: aghaf_global.h:202
@ AGHAF_TypeEthernetEvent
Event from Ethernet.
Definition: aghaf_global.h:201
@ AGHAF_TypeDoCanEvent
Event from DOCAN.
Definition: aghaf_global.h:203
@ AGHAF_TypeNoEvent
No event. Event is invalid.
Definition: aghaf_global.h:199
@ AGHAF_TypeDeviceEvent
Event from Device.
Definition: aghaf_global.h:200
@ AGHAF_Device_Present
A device was present.
Definition: aghaf_global.h:194
@ AGHAF_Device_Leave
A device was disconnected from this PC.
Definition: aghaf_global.h:193
@ AGHAF_Device_Arrival
A device was connected to this PC.
Definition: aghaf_global.h:192
@ AGHAF_Device_noEvent
No event. Event is invalid.
Definition: aghaf_global.h:191
char const * AGHAF_DeviceEvent_getProductName(AGHAF_Event event)
return the product name from the device which emitted the device event
Definition: aghaf_global.cpp:63
void AGHAF_deregisterCallback(AGHAF_Callback callback)
Deregister a callback.
Definition: aghaf_global.cpp:279
AGHAF_Device AGHAF_getDeviceBySN(const char *productNumber, const char *serialNumber)
Return the handle on the specified device.
Definition: aghaf_global.cpp:145
AGHAF_DeviceEvent
device event fot hotplug management
Definition: aghaf_global.h:190
void * AGHAF_Device
handle on an exxotest device
Definition: aghaf_global.h:175
void AGHAF_registerCallback(AGHAF_Callback callback, void *userContext)
Register a callback for the device event.
Definition: aghaf_global.cpp:271
char const * AGHAF_DeviceEvent_getSerialNumber(AGHAF_Event event)
return the serial number from the device which emitted the device event
Definition: aghaf_global.cpp:85
AGHAF_Status AGHAF_Event_getInfo(AGHAF_Event event, AGHAF_EventInfo *info)
AGHAF_Event_getInfo.
Definition: aghaf_global.cpp:260
char const * AGHAF_DeviceEvent_getProductNumber(AGHAF_Event event)
return the product number from the device which emitted the device event
Definition: aghaf_global.cpp:74
generic stucture to read an event in a callback
Definition: aghaf_global.h:229
AGHAF_TypeEvent type
Definition: aghaf_global.h:230
uint32_t event
Definition: aghaf_global.h:232