deviceObjectStore.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _NULLSOFT_WINAMP_DEVICES_DEVICE_OBJECT_STORE_HEADER
  2. #define _NULLSOFT_WINAMP_DEVICES_DEVICE_OBJECT_STORE_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include "./ifc_deviceobject.h"
  7. #include "./deviceObjectEnum.h"
  8. #include <vector>
  9. class DeviceObjectStore;
  10. typedef void (__cdecl *DeviceObjectCallback)(DeviceObjectStore * /*store*/,
  11. ifc_deviceobject * /*object*/,
  12. void * /*user*/);
  13. typedef ifc_deviceobject *(_cdecl *DeviceObjectCreator)(const char * /*name*/,
  14. void * /*user*/);
  15. class DeviceObjectStore
  16. {
  17. public:
  18. DeviceObjectStore(DeviceObjectCallback addCallback,
  19. DeviceObjectCallback removeCallback,
  20. void *callbackData);
  21. ~DeviceObjectStore();
  22. public:
  23. void Lock();
  24. void Unlock();
  25. CRITICAL_SECTION *GetLock();
  26. HRESULT Add(ifc_deviceobject *object);
  27. size_t AddRange(ifc_deviceobject **objects, size_t count);
  28. size_t AddIndirect(const char **names, size_t count, DeviceObjectCreator callback, void *user);
  29. HRESULT Remove(const char *name);
  30. void RemoveAll();
  31. HRESULT Find(const char *name, ifc_deviceobject **object);
  32. HRESULT Enumerate(DeviceObjectEnum **enumerator);
  33. private:
  34. std::vector<ifc_deviceobject*> list;
  35. CRITICAL_SECTION lock;
  36. DeviceObjectCallback addCallback;
  37. DeviceObjectCallback removeCallback;
  38. void *callbackData;
  39. };
  40. #endif // _NULLSOFT_WINAMP_DEVICES_DEVICE_OBJECT_STORE_HEADER