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

factory.c
Go to the documentation of this file.
00001 /*
00002  *  ClassFactory implementation for OBJSEL.dll
00003  *
00004  * Copyright (C) 2002 John K. Hohm
00005  * Copyright (C) 2002 Robert Shearman
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 
00022 #include "objsel_private.h"
00023 
00024 #include "wine/debug.h"
00025 
00026 WINE_DEFAULT_DEBUG_CHANNEL(objsel);
00027 
00028 
00029 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
00030 {
00031     return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
00032 }
00033 
00034 /**********************************************************************
00035  * OBJSEL_IClassFactory_QueryInterface (also IUnknown)
00036  */
00037 static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface(
00038     LPCLASSFACTORY iface,
00039     REFIID riid,
00040     LPVOID *ppvObj)
00041 {
00042     TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
00043 
00044     if (ppvObj == NULL) return E_POINTER;
00045 
00046     if (IsEqualGUID(riid, &IID_IUnknown) ||
00047     IsEqualGUID(riid, &IID_IClassFactory))
00048     {
00049         *ppvObj = iface;
00050     IClassFactory_AddRef(iface);
00051     return S_OK;
00052     }
00053     else if (IsEqualGUID(riid, &IID_IDsObjectPicker))
00054     {
00055         return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
00056     }
00057 
00058     FIXME("- no interface IID: %s\n", debugstr_guid(riid));
00059     return E_NOINTERFACE;
00060 }
00061 
00062 
00063 /**********************************************************************
00064  * OBJSEL_IClassFactory_AddRef (also IUnknown)
00065  */
00066 static ULONG WINAPI OBJSEL_IClassFactory_AddRef(LPCLASSFACTORY iface)
00067 {
00068     ClassFactoryImpl *This = impl_from_IClassFactory(iface);
00069     ULONG ref;
00070     
00071     TRACE("\n");
00072 
00073     if (This == NULL) return E_POINTER;
00074     
00075     ref = InterlockedIncrement(&This->ref);
00076     
00077     if (ref == 1)
00078     {
00079         InterlockedIncrement(&dll_refs);
00080     }
00081 
00082     return ref;
00083 }
00084 
00085 
00086 /**********************************************************************
00087  * OBJSEL_IClassFactory_Release (also IUnknown)
00088  */
00089 static ULONG WINAPI OBJSEL_IClassFactory_Release(LPCLASSFACTORY iface)
00090 {
00091     ClassFactoryImpl *This = impl_from_IClassFactory(iface);
00092     ULONG ref;
00093     
00094     TRACE("\n");
00095 
00096     if (This == NULL) return E_POINTER;
00097     
00098     ref = InterlockedDecrement(&This->ref);
00099     
00100     if (ref == 0)
00101     {
00102         InterlockedDecrement(&dll_refs);
00103     }
00104 
00105     return ref;
00106 }
00107 
00108 
00109 /**********************************************************************
00110  * OBJSEL_IClassFactory_CreateInstance
00111  */
00112 static HRESULT WINAPI OBJSEL_IClassFactory_CreateInstance(
00113     LPCLASSFACTORY iface,
00114     LPUNKNOWN pUnkOuter,
00115     REFIID riid,
00116     LPVOID *ppvObj)
00117 {
00118     TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
00119 
00120     if (ppvObj == NULL) return E_POINTER;
00121 
00122     /* Don't support aggregation (Windows doesn't) */
00123     if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
00124 
00125     if (IsEqualGUID(&IID_IDsObjectPicker, riid))
00126     {
00127         return OBJSEL_IDsObjectPicker_Create(ppvObj);
00128     }
00129 
00130     return CLASS_E_CLASSNOTAVAILABLE;
00131 }
00132 
00133 
00134 /**********************************************************************
00135  * OBJSEL_IClassFactory_LockServer
00136  */
00137 static HRESULT WINAPI OBJSEL_IClassFactory_LockServer(
00138     LPCLASSFACTORY iface,
00139     BOOL fLock)
00140 {
00141     TRACE("\n");
00142 
00143     if (fLock)
00144         IClassFactory_AddRef(iface);
00145     else
00146         IClassFactory_Release(iface);
00147     return S_OK;
00148 }
00149 
00150 
00151 /**********************************************************************
00152  * IClassFactory_Vtbl
00153  */
00154 static IClassFactoryVtbl IClassFactory_Vtbl =
00155 {
00156     OBJSEL_IClassFactory_QueryInterface,
00157     OBJSEL_IClassFactory_AddRef,
00158     OBJSEL_IClassFactory_Release,
00159     OBJSEL_IClassFactory_CreateInstance,
00160     OBJSEL_IClassFactory_LockServer
00161 };
00162 
00163 
00164 /**********************************************************************
00165  * static ClassFactory instance
00166  */
00167 
00168 ClassFactoryImpl OBJSEL_ClassFactory = { { &IClassFactory_Vtbl }, 0 };

Generated on Sat May 26 2012 04:20:01 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.