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 BDA Proxy
00004  * FILE:            dll/directx/msvidctl/classfactory.cpp
00005  * PURPOSE:         ClassFactory interface
00006  *
00007  * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
00008  */
00009 #include "precomp.h"
00010 
00011 const GUID IID_IUnknown           = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
00012 const GUID IID_IClassFactory      = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
00013 
00014 class CClassFactory : public IClassFactory
00015 {
00016 public:
00017     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
00018 
00019     STDMETHODIMP_(ULONG) AddRef()
00020     {
00021         InterlockedIncrement(&m_Ref);
00022         return m_Ref;
00023     }
00024     STDMETHODIMP_(ULONG) Release()
00025     {
00026         InterlockedDecrement(&m_Ref);
00027         if (!m_Ref)
00028         {
00029             delete this;
00030             return 0;
00031         }
00032         return m_Ref;
00033     }
00034 
00035     HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
00036     HRESULT WINAPI LockServer(BOOL fLock);
00037 
00038     CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst)
00039     {};
00040 
00041     virtual ~CClassFactory(){};
00042 
00043 protected:
00044     LONG m_Ref;
00045     LPFNCREATEINSTANCE m_lpfnCI;
00046     IID * m_IID;
00047 };
00048 
00049 HRESULT
00050 WINAPI
00051 CClassFactory::QueryInterface(
00052     REFIID riid,
00053     LPVOID *ppvObj)
00054 {
00055     *ppvObj = NULL;
00056     if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
00057     {
00058         *ppvObj = PVOID(this);
00059         InterlockedIncrement(&m_Ref);
00060         return S_OK;
00061     }
00062     return E_NOINTERFACE;
00063 }
00064 
00065 HRESULT
00066 WINAPI
00067 CClassFactory::CreateInstance(
00068     LPUNKNOWN pUnkOuter,
00069     REFIID riid,
00070     LPVOID *ppvObject)
00071 {
00072     *ppvObject = NULL;
00073 
00074     if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown))
00075     {
00076         return m_lpfnCI(pUnkOuter, riid, ppvObject);
00077     }
00078 
00079     return E_NOINTERFACE;
00080 }
00081 
00082 HRESULT
00083 WINAPI
00084 CClassFactory::LockServer(
00085     BOOL fLock)
00086 {
00087     return E_NOTIMPL;
00088 }
00089 
00090 IClassFactory * 
00091 CClassFactory_fnConstructor(
00092     LPFNCREATEINSTANCE lpfnCI, 
00093     PLONG pcRefDll, 
00094     IID * riidInst)
00095 {
00096     CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst);
00097 
00098     if (!factory)
00099         return NULL;
00100 
00101     if (pcRefDll)
00102         InterlockedIncrement(pcRefDll);
00103 
00104     return (LPCLASSFACTORY)factory;
00105 }
00106 

Generated on Fri May 25 2012 04:19:08 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.