STDMETHODIMP CWVDevice::\r
QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
{\r
- UNREFERENCED_PARAMETER(riid);\r
- UNREFERENCED_PARAMETER(ppvObj);\r
-\r
- return E_NOTIMPL;\r
+ if (riid != IID_IUnknown && riid != IID_IWVDevice)\r
+ {\r
+ *ppvObj = NULL;\r
+ return E_NOINTERFACE;\r
+ }\r
+\r
+ *ppvObj = this;\r
+ InterlockedIncrement(&m_nRef);\r
+ return WV_SUCCESS;\r
}\r
\r
STDMETHODIMP_(ULONG) CWVDevice::\r
AddRef(void)\r
{\r
- return 0;\r
+ return InterlockedIncrement(&m_nRef);\r
}\r
\r
STDMETHODIMP_(ULONG) CWVDevice::\r
Release(void)\r
{\r
- return 0;\r
+ ULONG ref;\r
+\r
+ ref = (ULONG) InterlockedDecrement(&m_nRef);\r
+ if (ref == 0)\r
+ delete this;\r
+ return ref;\r
}\r
\r
STDMETHODIMP CWVDevice::\r
return E_NOTIMPL;\r
}\r
\r
+STDMETHODIMP CWVDevice::\r
+Open(UINT64 Guid)\r
+{\r
+ UNREFERENCED_PARAMETER(Guid);\r
+\r
+ return E_NOTIMPL;\r
+}\r
+\r
//static void\r
//SetDeviceCap(DWORD *pFlags, ib_ca_attr_t *pCaAttr)\r
//{\r
STDMETHODIMP CreateCompletionQueue(SIZE_T *pEntries, IWVCompletionQueue** ppCq);\r
STDMETHODIMP AllocateProtectionDomain(IWVProtectionDomain** ppPd);\r
STDMETHODIMP Notify(OVERLAPPED* pOverlapped, WV_EVENT* pEvent);\r
+\r
+ CWVDevice(IWVProvider *pProvider)\r
+ {\r
+ pProvider->AddRef();\r
+ m_pProvider = pProvider;\r
+ m_nRef = 0;\r
+ }\r
+ ~CWVDevice()\r
+ {\r
+ m_pProvider->Release();\r
+ }\r
+\r
+ STDMETHODIMP Open(UINT64 Guid);\r
+\r
+private:\r
+ volatile LONG m_nRef;\r
+ IWVProvider *m_pProvider;\r
};\r
\r
#endif // __WV_DEVICE_H_\r
\r
#include "wv_base.h"\r
#include "wv_provider.h"\r
+#include "wv_device.h"\r
\r
STDMETHODIMP CWVProvider::\r
QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
STDMETHODIMP CWVProvider::\r
QueryDevice(UINT64 Guid, WV_DEVICE_ATTRIBUTES* pAttributes)\r
{\r
- UNREFERENCED_PARAMETER(Guid);\r
- UNREFERENCED_PARAMETER(pAttributes);\r
-\r
- return E_NOTIMPL;\r
+ IWVDevice *dev;\r
+ HRESULT hr;\r
+\r
+ hr = OpenDevice(Guid, &dev);\r
+ if (hr != WV_SUCCESS)\r
+ goto out;\r
+ \r
+ hr = dev->Query(pAttributes);\r
+ dev->Release();\r
+out:\r
+ return hr;\r
}\r
\r
STDMETHODIMP CWVProvider::\r
STDMETHODIMP CWVProvider::\r
OpenDevice(UINT64 Guid, IWVDevice** ppDevice)\r
{\r
- UNREFERENCED_PARAMETER(Guid);\r
- UNREFERENCED_PARAMETER(ppDevice);\r
+ HRESULT hr;\r
+ CWVDevice *dev;\r
\r
- return E_NOTIMPL;\r
+ dev = new CWVDevice(this);\r
+ if (!dev)\r
+ {\r
+ hr = WV_NO_MEMORY;\r
+ goto err1;\r
+ }\r
+\r
+ dev->QueryInterface(IID_IWVDevice, (LPVOID*) ppDevice);\r
+\r
+ hr = dev->Open(Guid);\r
+ if (hr != WV_SUCCESS)\r
+ goto err2;\r
+\r
+ return WV_SUCCESS;\r
+\r
+err2:\r
+ dev->Release();\r
+err1:\r
+ *ppDevice = NULL;\r
+ return hr;\r
}\r
\r
STDMETHODIMP CWVProvider::\r