ReactOS  0.4.14-dev-342-gdc047f9
classfactory.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy
4  * FILE: dll/directx/ksproxy/classfactory.cpp
5  * PURPOSE: IClassFactory interface
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
11 class CClassFactory : public IClassFactory
12 {
13 public:
15 
17  {
19  return m_Ref;
20  }
22  {
24 
25  if (!m_Ref)
26  {
27  delete this;
28  return 0;
29  }
30  return m_Ref;
31  }
32 
35 
36  CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst)
37  {};
38 
39  virtual ~CClassFactory(){};
40 
41 protected:
42  LONG m_Ref;
44  IID * m_IID;
45 };
46 
47 HRESULT
48 WINAPI
50  REFIID riid,
51  LPVOID *ppvObj)
52 {
53  *ppvObj = NULL;
55  {
56  *ppvObj = PVOID(this);
58  return S_OK;
59  }
60  return E_NOINTERFACE;
61 }
62 
63 HRESULT
64 WINAPI
66  LPUNKNOWN pUnkOuter,
67  REFIID riid,
69 {
72 
73  *ppvObject = NULL;
74 
76 
77  swprintf(Buffer, L"riid %s", lpstr);
79 
80 
82  {
83  return m_lpfnCI(pUnkOuter, riid, ppvObject);
84  }
85 
86  return E_NOINTERFACE;
87 }
88 
89 HRESULT
90 WINAPI
92  BOOL fLock)
93 {
94  return E_NOTIMPL;
95 }
96 
100  PLONG pcRefDll,
101  IID * riidInst)
102 {
103  CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst);
104 
105  if (!factory)
106  return NULL;
107 
108  if (pcRefDll)
109  InterlockedIncrement(pcRefDll);
110 
111  return (LPCLASSFACTORY)factory;
112 }
#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()
static LPOLESTR
Definition: stg_prop.c:27
STDMETHODIMP_(ULONG) Release()
HRESULT(CALLBACK * LPFNCREATEINSTANCE)(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: precomp.h:22
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
LPFNCREATEINSTANCE m_lpfnCI
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:440
static LPUNKNOWN
Definition: ndr_ole.c:49
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI LockServer(BOOL fLock)
Definition: bufpool.h:45
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:8
ULONG AddRef()
STDMETHODIMP_(ULONG) AddRef()
static const WCHAR L[]
Definition: oid.c:1250
#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
static LPCSTR lpstr
Definition: font.c:51
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
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412