ReactOS  0.4.14-dev-608-gd495a4f
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/bdaplgin/classfactory.cpp
5  * PURPOSE: ClassFactory interface
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
11 const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
12 const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
13 
15 {
16 public:
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 
43 protected:
44  LONG m_Ref;
47 };
48 
49 HRESULT
50 WINAPI
52  REFIID riid,
53  LPVOID *ppvObj)
54 {
55  *ppvObj = NULL;
57  {
58  *ppvObj = PVOID(this);
60  return S_OK;
61  }
62  return E_NOINTERFACE;
63 }
64 
65 HRESULT
66 WINAPI
68  LPUNKNOWN pUnkOuter,
69  REFIID riid,
71 {
72  *ppvObject = NULL;
73 
75  {
76  return m_lpfnCI(pUnkOuter, riid, ppvObject);
77  }
78 
79  return E_NOINTERFACE;
80 }
81 
82 HRESULT
83 WINAPI
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 }
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst)
REFIID riid
Definition: precomp.h:44
IUnknown * LPUNKNOWN
Definition: unknwn.idl:40
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
virtual ~CClassFactory()
STDMETHODIMP_(ULONG) Release()
HRESULT(CALLBACK * LPFNCREATEINSTANCE)(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: precomp.h:22
LPFNCREATEINSTANCE m_lpfnCI
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:438
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI LockServer(BOOL fLock)
void * PVOID
Definition: retypes.h:9
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
IClassFactory * CClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst)
HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
ULONG AddRef()
STDMETHODIMP_(ULONG) AddRef()
#define InterlockedDecrement
Definition: armddk.h:52
REFIID LPVOID * ppvObject
Definition: precomp.h:44
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int ULONG
Definition: retypes.h:1
static ClassFactoryImpl factory
Definition: ole_server.c:234
const GUID IID_IClassFactory
signed int * PLONG
Definition: retypes.h:5
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95