ReactOS 0.4.16-dev-297-gc569aee
classfactory.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/msvidctl/classfactory.cpp
5 * PURPOSE: ClassFactory interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9#include "precomp.h"
10
11const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
12const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
13
14class CClassFactory : public IClassFactory
15{
16public:
18
20 {
22 return m_Ref;
23 }
25 {
27 if (!m_Ref)
28 {
29 delete this;
30 return 0;
31 }
32 return m_Ref;
33 }
34
37
38 CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst)
39 {};
40
41 virtual ~CClassFactory(){};
42
43protected:
44 LONG m_Ref;
46 IID * m_IID;
47};
48
53 LPVOID *ppvObj)
54{
55 *ppvObj = NULL;
57 {
58 *ppvObj = PVOID(this);
60 return S_OK;
61 }
62 return E_NOINTERFACE;
63}
64
68 LPUNKNOWN pUnkOuter,
71{
72 *ppvObject = NULL;
73
75 {
76 return m_lpfnCI(pUnkOuter, riid, ppvObject);
77 }
78
79 return E_NOINTERFACE;
80}
81
85 BOOL fLock)
86{
87 return E_NOTIMPL;
88}
89
93 PLONG pcRefDll,
94 IID * riidInst)
95{
96 CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst);
97
98 if (!factory)
99 return NULL;
100
101 if (pcRefDll)
102 InterlockedIncrement(pcRefDll);
103
104 return (LPCLASSFACTORY)factory;
105}
106
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
IClassFactory * CClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst)
const GUID IID_IClassFactory
LPFNCREATEINSTANCE m_lpfnCI
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
virtual ~CClassFactory()
STDMETHODIMP_(ULONG) AddRef()
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst)
HRESULT WINAPI LockServer(BOOL fLock)
STDMETHODIMP_(ULONG) Release()
#define E_NOTIMPL
Definition: ddrawi.h:99
#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
REFIID riid
Definition: atlbase.h:39
ULONG AddRef()
ULONG Release()
#define S_OK
Definition: intsafe.h:52
const GUID IID_IUnknown
const GUID IID_IClassFactory
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
Definition: main.c:439
void * PVOID
Definition: typedefs.h:50
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_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