1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 //*****************************************************************************
9 // Class factories are used by the pluming in COM to activate new objects.
10 // This module contains the class factory code to instantiate the debugger
11 // objects described in RSPriv.h.
13 //*****************************************************************************
14 #ifndef __ClassFactory__h__
15 #define __ClassFactory__h__
20 // This typedef is for a function which will create a new instance of an object.
21 typedef HRESULT (__stdcall * PFN_CREATE_OBJ)(REFIID riid, void **ppvObject);
24 //*****************************************************************************
25 // One class factory object satifies all of our clsid's, to reduce overall
27 //*****************************************************************************
31 CClassFactory() { } // Can't use without data.
34 CClassFactory(PFN_CREATE_OBJ pfnCreateObject)
35 : m_cRef(1), m_pfnCreateObject(pfnCreateObject)
38 virtual ~CClassFactory() {}
44 virtual HRESULT STDMETHODCALLTYPE QueryInterface(
48 virtual ULONG STDMETHODCALLTYPE AddRef()
50 return (InterlockedIncrement(&m_cRef));
53 virtual ULONG STDMETHODCALLTYPE Release()
55 LONG cRef = InterlockedDecrement(&m_cRef);
63 // IClassFactory methods.
66 virtual HRESULT STDMETHODCALLTYPE CreateInstance(
71 virtual HRESULT STDMETHODCALLTYPE LockServer(
76 LONG m_cRef; // Reference count.
77 PFN_CREATE_OBJ m_pfnCreateObject; // Creation function for an instance.
82 #endif // __ClassFactory__h__