Exemple #1
0
bool DeviceIndex::fill_device_info (DeviceInfo& info) const
{
    if (!info.get_serial().empty())
    {
        for (const auto& d : device_list)
        {
            if (info.get_serial() == d.get_serial())
            {
                info = d;
                return true;
            }
        }
        return false;
    }

    if (!info.get_identifier().empty())
    {
        for (const auto& d : device_list)
        {
            if (info.get_identifier() == d.get_identifier())
            {
                info = d;
                return true;
            }
        }
    }
    return false;
}
Exemple #2
0
void DeviceIndex::fire_device_lost (const DeviceInfo& d)
{
    mtx.lock();
    for (auto& c : callbacks)
    {
        if (c.serial.empty() || c.serial.compare(d.get_serial()) == 0)
        {
            c.callback(d, c.data);
        }
    }
    mtx.unlock();
}