1
0

deviceprovider.h 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <wtypes.h>
  3. #include "../devices/ifc_deviceprovider.h"
  4. #include "..\..\Library\ml_pmp/pmp.h"
  5. class DeviceProvider : public ifc_deviceprovider
  6. {
  7. protected:
  8. DeviceProvider();
  9. ~DeviceProvider();
  10. public:
  11. static HRESULT CreateInstance(DeviceProvider **instance);
  12. public:
  13. /* Dispatchable */
  14. size_t AddRef();
  15. size_t Release();
  16. int QueryInterface(GUID interface_guid, void **object);
  17. /* ifc_deviceprovider */
  18. HRESULT BeginDiscovery(api_devicemanager *manager);
  19. HRESULT CancelDiscovery();
  20. HRESULT GetActive();
  21. public:
  22. HRESULT Register(api_devicemanager *manager);
  23. HRESULT Unregister();
  24. size_t IncrementActivity();
  25. size_t DecrementActivity();
  26. private:
  27. void Lock();
  28. void Unlock();
  29. DWORD DiscoveryThread();
  30. friend static int DeviceProvider_DiscoveryThreadStarter(HANDLE handle, void *user_data, intptr_t id);
  31. protected:
  32. size_t ref;
  33. size_t activity;
  34. CRITICAL_SECTION lock;
  35. api_devicemanager *manager;
  36. HANDLE readyEvent;
  37. BOOL cancelDiscovery;
  38. protected:
  39. RECVS_DISPATCH;
  40. };