To get system notifications about events on USB devices, we are using a library called libudev. It provides only a plain C interface, and so we created simple C++ wrappers to make coding easier.
For our wrapper classes, we declared a namespace named usb:
namespace usb {
It contains two classes. The first class is Device, which gives us a C++ interface to a low-level libudev object called udev_device.
We defined a constructor that created an instance of Device from a udev_device pointer and a destructor to release the udev_device. Internally, libudev uses reference counting for its object, and so our destructor calls a function to decrease the reference count of the udev_device:
~Device() { udev_device_unref(dev); }
Device(const ...