ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

classfactory.cpp
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
00004  * FILE:            dll/directx/ksproxy/classfactory.cpp
00005  * PURPOSE:         IClassFactory interface
00006  *
00007  * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
00008  */
00009 #include "precomp.h"
00010 
00011 class CClassFactory : public IClassFactory
00012 {
00013 public:
00014     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
00015 
00016     STDMETHODIMP_(ULONG) AddRef()
00017     {
00018         InterlockedIncrement(&m_Ref);
00019         return m_Ref;
00020     }
00021     STDMETHODIMP_(ULONG) Release()
00022     {
00023         InterlockedDecrement(&m_Ref);
00024 
00025         if (!m_Ref)
00026         {
00027             delete this;
00028             return 0;
00029         }
00030         return m_Ref;
00031     }
00032 
00033     HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
00034     HRESULT WINAPI LockServer(BOOL fLock);
00035 
00036     CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst)
00037     {};
00038 
00039     virtual ~CClassFactory(){};
00040 
00041 protected:
00042     LONG m_Ref;
00043     LPFNCREATEINSTANCE m_lpfnCI;
00044     IID * m_IID;
00045 };
00046 
00047 HRESULT
00048 WINAPI
00049 CClassFactory::QueryInterface(
00050     REFIID riid,
00051     LPVOID *ppvObj)
00052 {
00053     *ppvObj = NULL;
00054     if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
00055     {
00056         *ppvObj = PVOID(this);
00057         InterlockedIncrement(&m_Ref);
00058         return S_OK;
00059     }
00060     return E_NOINTERFACE;
00061 }
00062 
00063 HRESULT
00064 WINAPI
00065 CClassFactory::CreateInstance(
00066     LPUNKNOWN pUnkOuter,
00067     REFIID riid,
00068     LPVOID *ppvObject)
00069 {
00070     WCHAR Buffer[MAX_PATH];
00071     LPOLESTR lpstr;
00072 
00073     *ppvObject = NULL;
00074 
00075     StringFromCLSID(riid, &lpstr);
00076 
00077     swprintf(Buffer, L"riid %s", lpstr);
00078     OutputDebugStringW(Buffer);
00079 
00080 
00081     if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown))
00082     {
00083         return m_lpfnCI(pUnkOuter, riid, ppvObject);
00084     }
00085 
00086     return E_NOINTERFACE;
00087 }
00088 
00089 HRESULT
00090 WINAPI
00091 CClassFactory::LockServer(
00092     BOOL fLock)
00093 {
00094     return E_NOTIMPL;
00095 }
00096 
00097 IClassFactory * 
00098 CClassFactory_fnConstructor(
00099     LPFNCREATEINSTANCE lpfnCI, 
00100     PLONG pcRefDll, 
00101     IID * riidInst)
00102 {
00103     CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst);
00104 
00105     if (!factory)
00106         return NULL;
00107 
00108     if (pcRefDll)
00109         InterlockedIncrement(pcRefDll);
00110 
00111     return (LPCLASSFACTORY)factory;
00112 }

Generated on Sun May 27 2012 04:21:10 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.