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/deviceSupportedCommand.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/devices/deviceSupportedCommand.cpp')
-rw-r--r-- | Src/devices/deviceSupportedCommand.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/Src/devices/deviceSupportedCommand.cpp b/Src/devices/deviceSupportedCommand.cpp new file mode 100644 index 00000000..b5e09147 --- /dev/null +++ b/Src/devices/deviceSupportedCommand.cpp @@ -0,0 +1,120 @@ +#include "main.h" +#include "./deviceSupportedCommand.h" + +DeviceSupportedCommand::DeviceSupportedCommand() + : ref(1), name(NULL), flags(DeviceCommandFlag_None) +{ +} + +DeviceSupportedCommand::~DeviceSupportedCommand() +{ + AnsiString_Free(name); +} + +HRESULT DeviceSupportedCommand::CreateInstance(const char *name, DeviceSupportedCommand **instance) +{ + DeviceSupportedCommand *self; + + if (NULL == instance) + return E_POINTER; + + *instance = NULL; + + self = new DeviceSupportedCommand(); + if (NULL == self) + return E_OUTOFMEMORY; + + self->name = AnsiString_Duplicate(name); + + *instance = self; + return S_OK; +} + +size_t DeviceSupportedCommand::AddRef() +{ + return InterlockedIncrement((LONG*)&ref); +} + +size_t DeviceSupportedCommand::Release() +{ + if (0 == ref) + return ref; + + LONG r = InterlockedDecrement((LONG*)&ref); + if (0 == r) + delete(this); + + return r; +} + +int DeviceSupportedCommand::QueryInterface(GUID interface_guid, void **object) +{ + if (NULL == object) + return E_POINTER; + + if (IsEqualIID(interface_guid, IFC_DeviceSupportedCommand)) + *object = static_cast<ifc_devicesupportedcommand*>(this); + else + { + *object = NULL; + return E_NOINTERFACE; + } + + if (NULL == *object) + return E_UNEXPECTED; + + AddRef(); + return S_OK; +} + +const char *DeviceSupportedCommand::GetName() +{ + return name; +} + +HRESULT DeviceSupportedCommand::GetFlags(DeviceCommandFlags *flagsOut) +{ + if (NULL == flagsOut) + return E_POINTER; + + *flagsOut = flags; + + return S_OK; +} + +HRESULT DeviceSupportedCommand::SetFlags(DeviceCommandFlags mask, DeviceCommandFlags value) +{ + DeviceCommandFlags temp; + temp = (flags & mask) | (mask & value); + + if (temp == flags) + return S_FALSE; + + flags = temp; + + return S_OK; +} + +HRESULT DeviceSupportedCommand::Clone(DeviceSupportedCommand **instance) +{ + HRESULT hr; + + hr = DeviceSupportedCommand::CreateInstance(name, instance); + if (SUCCEEDED(hr)) + { + (*instance)->flags = flags; + } + + return hr; + +} + +#define CBCLASS DeviceSupportedCommand +START_DISPATCH; +CB(ADDREF, AddRef) +CB(RELEASE, Release) +CB(QUERYINTERFACE, QueryInterface) +CB(API_GETNAME, GetName) +CB(API_GETFLAGS, GetFlags) +END_DISPATCH; +#undef CBCLASS
\ No newline at end of file |