d3d8: Finish the COM cleanup of the IDirect3DDevice8 iface.
[wine.git] / dlls / objsel / factory.c
blobcb0fb491cb4a6ef8aec85c4822745d2b40a163ea
1 /*
2 * ClassFactory implementation for OBJSEL.dll
4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "objsel_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(objsel);
29 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
31 return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
34 /**********************************************************************
35 * OBJSEL_IClassFactory_QueryInterface (also IUnknown)
37 static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface(
38 LPCLASSFACTORY iface,
39 REFIID riid,
40 LPVOID *ppvObj)
42 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
44 if (ppvObj == NULL) return E_POINTER;
46 if (IsEqualGUID(riid, &IID_IUnknown) ||
47 IsEqualGUID(riid, &IID_IClassFactory))
49 *ppvObj = iface;
50 IClassFactory_AddRef(iface);
51 return S_OK;
53 else if (IsEqualGUID(riid, &IID_IDsObjectPicker))
55 return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
58 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
59 return E_NOINTERFACE;
63 /**********************************************************************
64 * OBJSEL_IClassFactory_AddRef (also IUnknown)
66 static ULONG WINAPI OBJSEL_IClassFactory_AddRef(LPCLASSFACTORY iface)
68 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
69 ULONG ref;
71 TRACE("\n");
73 if (This == NULL) return E_POINTER;
75 ref = InterlockedIncrement(&This->ref);
77 if (ref == 1)
79 InterlockedIncrement(&dll_refs);
82 return ref;
86 /**********************************************************************
87 * OBJSEL_IClassFactory_Release (also IUnknown)
89 static ULONG WINAPI OBJSEL_IClassFactory_Release(LPCLASSFACTORY iface)
91 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
92 ULONG ref;
94 TRACE("\n");
96 if (This == NULL) return E_POINTER;
98 ref = InterlockedDecrement(&This->ref);
100 if (ref == 0)
102 InterlockedDecrement(&dll_refs);
105 return ref;
109 /**********************************************************************
110 * OBJSEL_IClassFactory_CreateInstance
112 static HRESULT WINAPI OBJSEL_IClassFactory_CreateInstance(
113 LPCLASSFACTORY iface,
114 LPUNKNOWN pUnkOuter,
115 REFIID riid,
116 LPVOID *ppvObj)
118 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
120 if (ppvObj == NULL) return E_POINTER;
122 /* Don't support aggregation (Windows doesn't) */
123 if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
125 if (IsEqualGUID(&IID_IDsObjectPicker, riid))
127 return OBJSEL_IDsObjectPicker_Create(ppvObj);
130 return CLASS_E_CLASSNOTAVAILABLE;
134 /**********************************************************************
135 * OBJSEL_IClassFactory_LockServer
137 static HRESULT WINAPI OBJSEL_IClassFactory_LockServer(
138 LPCLASSFACTORY iface,
139 BOOL fLock)
141 TRACE("\n");
143 if (fLock)
144 IClassFactory_AddRef(iface);
145 else
146 IClassFactory_Release(iface);
147 return S_OK;
151 /**********************************************************************
152 * IClassFactory_Vtbl
154 static IClassFactoryVtbl IClassFactory_Vtbl =
156 OBJSEL_IClassFactory_QueryInterface,
157 OBJSEL_IClassFactory_AddRef,
158 OBJSEL_IClassFactory_Release,
159 OBJSEL_IClassFactory_CreateInstance,
160 OBJSEL_IClassFactory_LockServer
164 /**********************************************************************
165 * static ClassFactory instance
168 ClassFactoryImpl OBJSEL_ClassFactory = { { &IClassFactory_Vtbl }, 0 };