bool DeviceHandle::enumerateNext(const DeviceEnumerationArgs& args) { if (GetType() == Device_None) return false; Ptr<DeviceManagerImpl> managerKeepAlive; Lock::Locker lockScope(pImpl->GetLock()); DeviceCreateDesc* next = pImpl; // If manager was destroyed, we get removed from the list. if (!pImpl->pNext) return false; managerKeepAlive = next->GetManagerImpl(); OVR_ASSERT(managerKeepAlive); do { next = next->pNext; if (managerKeepAlive->Devices.IsNull(next)) { pImpl->Release(); pImpl = 0; return false; } } while(!args.MatchRule(next->Type, next->Enumerated)); next->AddRef(); pImpl->Release(); pImpl = next; return true; }
DeviceEnumerator<> DeviceManagerImpl::EnumerateDevicesEx(const DeviceEnumerationArgs& args) { Lock::Locker deviceLock(GetLock()); if (Devices.IsEmpty()) return DeviceEnumerator<>(); DeviceCreateDesc* firstDeviceDesc = Devices.GetFirst(); DeviceEnumerator<> e = enumeratorFromHandle(DeviceHandle(firstDeviceDesc), args); if (!args.MatchRule(firstDeviceDesc->Type, firstDeviceDesc->Enumerated)) { e.Next(); } return e; }