wined3d: Drop support for WINED3DFMT_D32_UNORM.
[wine.git] / dlls / gameux / factory.c
blobd9ac6de70f7467c50f4d52faf629078e58b1eb4e
1 /*
2 * Gameux library IClassFactory implementation
4 * Copyright (C) 2010 Mariusz PluciƄski
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "ole2.h"
29 #include "gameux.h"
30 #include "gameux_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(gameux);
36 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, IUnknown **ppObj);
38 /***************************************************************
39 * gameux ClassFactory
41 typedef struct _gameuxcf
43 IClassFactory IClassFactory_iface;
44 fnCreateInstance pfnCreateInstance;
45 } gameuxcf;
47 static inline gameuxcf *impl_from_IClassFactory(IClassFactory *iface)
49 return CONTAINING_RECORD(iface, gameuxcf, IClassFactory_iface);
52 static HRESULT WINAPI gameuxcf_QueryInterface(
53 IClassFactory *iface,
54 REFIID riid,
55 LPVOID *ppObj)
57 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppObj);
59 *ppObj = NULL;
61 if(IsEqualGUID(riid, &IID_IUnknown) ||
62 IsEqualGUID(riid, &IID_IClassFactory))
64 IClassFactory_AddRef(iface);
65 *ppObj = iface;
66 return S_OK;
69 FIXME("interface %s not implemented\n", debugstr_guid(riid));
70 return E_NOINTERFACE;
73 static ULONG WINAPI gameuxcf_AddRef(
74 IClassFactory *iface)
76 TRACE("(%p)\n", iface);
77 return 2;
80 static ULONG WINAPI gameuxcf_Release(
81 IClassFactory *iface)
83 TRACE("(%p)\n", iface);
84 return 1;
87 static HRESULT WINAPI gameuxcf_CreateInstance(
88 IClassFactory *iface,
89 LPUNKNOWN pUnkOuter,
90 REFIID riid,
91 LPVOID *ppObj)
93 gameuxcf *This = impl_from_IClassFactory(iface);
94 HRESULT hr;
95 IUnknown *pUnk;
97 TRACE("(%p, %p, %s, %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppObj);
99 *ppObj = NULL;
101 if(pUnkOuter)
102 return CLASS_E_NOAGGREGATION;
104 hr = This->pfnCreateInstance(pUnkOuter, &pUnk);
105 if(FAILED(hr))
106 return hr;
108 hr = IUnknown_QueryInterface(pUnk, riid, ppObj);
109 IUnknown_Release(pUnk);
110 return hr;
113 static HRESULT WINAPI gameuxcf_LockServer(
114 IClassFactory *iface,
115 BOOL dolock)
117 gameuxcf *This = impl_from_IClassFactory(iface);
118 TRACE("(%p, %d)\n", This, dolock);
119 FIXME("stub\n");
120 return S_OK;
123 static const struct IClassFactoryVtbl gameuxcf_vtbl =
125 gameuxcf_QueryInterface,
126 gameuxcf_AddRef,
127 gameuxcf_Release,
128 gameuxcf_CreateInstance,
129 gameuxcf_LockServer
132 static gameuxcf gameexplorercf = { { &gameuxcf_vtbl }, GameExplorer_create };
133 static gameuxcf gamestatisticscf = { { &gameuxcf_vtbl }, GameStatistics_create };
135 /***************************************************************
136 * gameux ClassFactory
138 HRESULT WINAPI DllGetClassObject(
139 REFCLSID rclsid,
140 REFIID riid,
141 LPVOID *ppv)
143 IClassFactory *cf = NULL;
145 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
147 if(IsEqualCLSID(rclsid, &CLSID_GameExplorer))
149 cf = &gameexplorercf.IClassFactory_iface;
151 else if( IsEqualCLSID( rclsid, &CLSID_GameStatistics ))
153 cf = &gamestatisticscf.IClassFactory_iface;
156 if(!cf)
157 return CLASS_E_CLASSNOTAVAILABLE;
159 return IClassFactory_QueryInterface(cf, riid, ppv);