forked from microsoft/FX11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IUnknownImp.h
57 lines (55 loc) · 1.56 KB
/
IUnknownImp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//--------------------------------------------------------------------------------------
// File: IUnknownImp.h
//
// Direct3D 11 Effects Helper for COM interop
//
// Lifetime for most Effects objects is based on the the lifetime of the master
// effect, so the reference count is not used.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
//--------------------------------------------------------------------------------------
#pragma once
#define IUNKNOWN_IMP(Class, Interface, BaseInterface) \
\
HRESULT STDMETHODCALLTYPE Class##::QueryInterface(REFIID iid, _COM_Outptr_ LPVOID *ppv) override \
{ \
if( !ppv ) \
return E_INVALIDARG; \
\
*ppv = nullptr; \
if(IsEqualIID(iid, IID_IUnknown)) \
{ \
*ppv = (IUnknown*)((Interface*)this); \
} \
else if(IsEqualIID(iid, IID_##Interface)) \
{ \
*ppv = (Interface *)this; \
} \
else if(IsEqualIID(iid, IID_##BaseInterface)) \
{ \
*ppv = (BaseInterface *)this; \
} \
else \
{ \
return E_NOINTERFACE; \
} \
\
return S_OK; \
} \
\
ULONG STDMETHODCALLTYPE Class##::AddRef() override \
{ \
return 1; \
} \
\
ULONG STDMETHODCALLTYPE Class##::Release() override \
{ \
return 0; \
}