1
0

deviceprovider.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. ENUMDRIVES enumerator;
  37. HANDLE readyEvent;
  38. BOOL cancelDiscovery;
  39. protected:
  40. RECVS_DISPATCH;
  41. };