ReactOS 0.4.16-dev-117-g38f21f9
classfactory.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Configuration of network devices
4 * FILE: dll/directx/dsound_new/classfactory.c
5 * PURPOSE: IClassFactory implementation
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9
10
11#include "precomp.h"
12
13typedef struct
14{
15 const IClassFactoryVtbl *lpVtbl;
19 const IID * riidInst;
21
22
23static
27 LPCLASSFACTORY iface,
29 LPVOID *ppvObj)
30{
32
33 *ppvObj = NULL;
34
35 /* check requested interface */
37 {
38 *ppvObj = This;
40 return S_OK;
41 }
42 return E_NOINTERFACE;
43}
44
45static
49 LPCLASSFACTORY iface)
50{
52
53 /* increment reference count */
54 ULONG refCount = InterlockedIncrement(&This->ref);
55
56 return refCount;
57}
58
59static
63 LPCLASSFACTORY iface)
64{
66 ULONG refCount = InterlockedDecrement(&This->ref);
67
68 /* decrement reference count */
69 if (!refCount)
70 {
71 /* free class factory */
73 return 0;
74 }
75 return refCount;
76}
77
78static
82 LPCLASSFACTORY iface,
83 LPUNKNOWN pUnkOuter,
86{
88
89 if (!ppvObject)
90 return E_INVALIDARG;
91
92 *ppvObject = NULL;
93
94 if ( This->riidInst==NULL || IsEqualCLSID(riid, This->riidInst) || IsEqualCLSID(riid, &IID_IUnknown) )
95 {
96 /* instantiate object */
97 return This->lpfnCI(pUnkOuter, riid, ppvObject);
98 }
99
100 return E_NOINTERFACE;
101}
102
103static
106 LPCLASSFACTORY iface,
107 BOOL fLock)
108{
109 //IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
110 return E_NOTIMPL;
111}
112
113
114static const IClassFactoryVtbl dclfvt =
115{
121};
122
123
127 PLONG pcRefDll,
128 REFIID riidInst)
129{
130 IClassFactoryImpl* lpclf;
131
132 lpclf = CoTaskMemAlloc(sizeof(IClassFactoryImpl));
133 lpclf->ref = 1;
134 lpclf->lpVtbl = &dclfvt;
135 lpclf->lpfnCI = lpfnCI;
136
137 if (pcRefDll)
138 InterlockedIncrement(pcRefDll);
139 lpclf->riidInst = riidInst;
140
141 return (LPCLASSFACTORY)lpclf;
142}
143
144
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
Definition: classfactory.c:62
static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
Definition: classfactory.c:26
static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
Definition: classfactory.c:105
static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
Definition: classfactory.c:48
IClassFactory * IClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
Definition: classfactory.c:125
static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: classfactory.c:81
static const IClassFactoryVtbl dclfvt
Definition: classfactory.c:114
#define NULL
Definition: types.h:112
HRESULT(CALLBACK * LPFNCREATEINSTANCE)(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: precomp.h:22
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
static LPUNKNOWN
Definition: ndr_ole.c:49
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
LPFNCREATEINSTANCE lpfnCI
Definition: classfactory.c:18
const IID * riidInst
Definition: classfactory.c:19
const IClassFactoryVtbl * lpVtbl
Definition: classfactory.c:15
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364