diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/devices/deviceManager.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/devices/deviceManager.h')
-rw-r--r-- | Src/devices/deviceManager.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/Src/devices/deviceManager.h b/Src/devices/deviceManager.h new file mode 100644 index 00000000..df076cb9 --- /dev/null +++ b/Src/devices/deviceManager.h @@ -0,0 +1,111 @@ +#ifndef _NULLSOFT_WINAMP_DEVICES_DEVICE_MANAGER_HEADER +#define _NULLSOFT_WINAMP_DEVICES_DEVICE_MANAGER_HEADER + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +#include "./api_devicemanager.h" +#include "./deviceObjectStore.h" +#include "./discoveryMonitor.h" +#include <vector> + +class DeviceManager : public api_devicemanager +{ + +protected: + DeviceManager(); + ~DeviceManager(); + +public: + static HRESULT CreateInstance(DeviceManager **instance); + +public: + /* Dispatchable */ + size_t AddRef(); + size_t Release(); + int QueryInterface(GUID interface_guid, void **object); + + /* api_devicemanager */ + size_t TypeRegister(ifc_devicetype **types, size_t count); + size_t TypeRegisterIndirect(const char **names, size_t count, DeviceTypeCreator callback, void *user); + HRESULT TypeUnregister(const char *name); + HRESULT TypeFind(const char *name, ifc_devicetype **type); + HRESULT TypeEnumerate(ifc_deviceobjectenum **enumerator); + + size_t ConnectionRegister(ifc_deviceconnection **connections, size_t count); + size_t ConnectionRegisterIndirect(const char **names, size_t count, DeviceConnectionCreator callback, void *user); + HRESULT ConnectionUnregister(const char *name); + HRESULT ConnectionFind(const char *name, ifc_deviceconnection **connection); + HRESULT ConnectionEnumerate(ifc_deviceobjectenum **enumerator); + + size_t CommandRegister(ifc_devicecommand **commands, size_t count); + size_t CommandRegisterIndirect(const char **names, size_t count, DeviceCommandCreator callback, void *user); + HRESULT CommandUnregister(const char *name); + HRESULT CommandFind(const char *name, ifc_devicecommand **command); + HRESULT CommandEnumerate(ifc_deviceobjectenum **enumerator); + + size_t DeviceRegister(ifc_device **devices, size_t count); + HRESULT DeviceUnregister(const char *name); + HRESULT DeviceFind(const char *name, ifc_device **device); + HRESULT DeviceEnumerate(ifc_deviceobjectenum **enumerator); + + HRESULT IsDiscoveryActive(); + HRESULT BeginDiscovery(); + HRESULT CancelDiscovery(); + HRESULT RegisterProvider(ifc_deviceprovider *provider); + HRESULT UnregisterProvider(ifc_deviceprovider *provider); + HRESULT SetProviderActive(ifc_deviceprovider *provider, BOOL activeState); + + HRESULT Advise(ifc_devicemanagerevent *handler); + HRESULT Unadvise(ifc_devicemanagerevent *handler); + + HRESULT CreateDeviceEventManager(ifc_deviceeventmanager **eventManager); + HRESULT CreateSupportedCommandStore(ifc_devicesupportedcommandstore **store); + HRESULT CreateSupportedCommandEnum(ifc_devicesupportedcommand **commands, size_t count, ifc_devicesupportedcommandenum **enumerator); + HRESULT CreateIconStore(ifc_deviceiconstore **store); + HRESULT CreateType(const char *name, ifc_devicetype **type); + HRESULT CreateCommand(const char *name, ifc_devicecommand **command); + HRESULT CreateConnection(const char *name, ifc_deviceconnection **connection); + +protected: + void EventTypeAdded(ifc_devicetype *type); + void EventTypeRemoved(ifc_devicetype *type); + void EventConnectionAdded(ifc_deviceconnection *connection); + void EventConnectionRemoved(ifc_deviceconnection *connection); + void EventCommandAdded(ifc_devicecommand *command); + void EventCommandRemoved(ifc_devicecommand *command); + void EventDeviceAdded(ifc_device *device); + void EventDeviceRemoved(ifc_device *device); + void EventDiscoveryStarted(); + void EventDiscoveryFinished(); + +protected: + static void ObjectAddedCallback(DeviceObjectStore *store, ifc_deviceobject *object, void *userData); + static void ObjectRemovedCallback(DeviceObjectStore *store, ifc_deviceobject *object, void *userData); + +protected: + typedef std::vector<ifc_devicemanagerevent*> EventList; + typedef std::vector<ifc_deviceprovider*> ProviderList; + +protected: + size_t ref; + + DeviceObjectStore typeStore; + DeviceObjectStore connectionStore; + DeviceObjectStore commandStore; + DeviceObjectStore deviceStore; + + CRITICAL_SECTION eventLock; + EventList eventList; + + CRITICAL_SECTION providerLock; + ProviderList providerList; + + DiscoveryMonitor discoveryMonitor; + +protected: + RECVS_DISPATCH; +}; + +#endif // _NULLSOFT_WINAMP_DEVICES_DEVICE_MANAGER_HEADER |