winevulkan: Update to VK spec version 1.2.188.
[wine.git] / dlls / gameux / factory.c
blob3ead6ac9dd267e34c7f54f5ab032a4006165abcc
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"
28 #include "shobjidl.h"
29 #include "initguid.h"
30 #include "gameux.h"
31 #include "gameux_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(gameux);
37 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, IUnknown **ppObj);
39 /***************************************************************
40 * gameux ClassFactory
42 typedef struct _gameuxcf
44 IClassFactory IClassFactory_iface;
45 fnCreateInstance pfnCreateInstance;
46 } gameuxcf;
48 static inline gameuxcf *impl_from_IClassFactory(IClassFactory *iface)
50 return CONTAINING_RECORD(iface, gameuxcf, IClassFactory_iface);
53 static HRESULT WINAPI gameuxcf_QueryInterface(
54 IClassFactory *iface,
55 REFIID riid,
56 LPVOID *ppObj)
58 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppObj);
60 *ppObj = NULL;
62 if(IsEqualGUID(riid, &IID_IUnknown) ||
63 IsEqualGUID(riid, &IID_IClassFactory))
65 IClassFactory_AddRef(iface);
66 *ppObj = iface;
67 return S_OK;
70 FIXME("interface %s not implemented\n", debugstr_guid(riid));
71 return E_NOINTERFACE;
74 static ULONG WINAPI gameuxcf_AddRef(
75 IClassFactory *iface)
77 TRACE("(%p)\n", iface);
78 return 2;
81 static ULONG WINAPI gameuxcf_Release(
82 IClassFactory *iface)
84 TRACE("(%p)\n", iface);
85 return 1;
88 static HRESULT WINAPI gameuxcf_CreateInstance(
89 IClassFactory *iface,
90 LPUNKNOWN pUnkOuter,
91 REFIID riid,
92 LPVOID *ppObj)
94 gameuxcf *This = impl_from_IClassFactory(iface);
95 HRESULT hr;
96 IUnknown *pUnk;
98 TRACE("(%p, %p, %s, %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppObj);
100 *ppObj = NULL;
102 if(pUnkOuter)
103 return CLASS_E_NOAGGREGATION;
105 hr = This->pfnCreateInstance(pUnkOuter, &pUnk);
106 if(FAILED(hr))
107 return hr;
109 hr = IUnknown_QueryInterface(pUnk, riid, ppObj);
110 IUnknown_Release(pUnk);
111 return hr;
114 static HRESULT WINAPI gameuxcf_LockServer(
115 IClassFactory *iface,
116 BOOL dolock)
118 gameuxcf *This = impl_from_IClassFactory(iface);
119 TRACE("(%p, %d)\n", This, dolock);
120 FIXME("stub\n");
121 return S_OK;
124 static const struct IClassFactoryVtbl gameuxcf_vtbl =
126 gameuxcf_QueryInterface,
127 gameuxcf_AddRef,
128 gameuxcf_Release,
129 gameuxcf_CreateInstance,
130 gameuxcf_LockServer
133 static gameuxcf gameexplorercf = { { &gameuxcf_vtbl }, GameExplorer_create };
134 static gameuxcf gamestatisticscf = { { &gameuxcf_vtbl }, GameStatistics_create };
136 /***************************************************************
137 * gameux ClassFactory
139 HRESULT WINAPI DllGetClassObject(
140 REFCLSID rclsid,
141 REFIID riid,
142 LPVOID *ppv)
144 IClassFactory *cf = NULL;
146 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
148 if(IsEqualCLSID(rclsid, &CLSID_GameExplorer))
150 cf = &gameexplorercf.IClassFactory_iface;
152 else if( IsEqualCLSID( rclsid, &CLSID_GameStatistics ))
154 cf = &gamestatisticscf.IClassFactory_iface;
157 if(!cf)
158 return CLASS_E_CLASSNOTAVAILABLE;
160 return IClassFactory_QueryInterface(cf, riid, ppv);