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 // ===========================================================================
5 // File: ClassFactory.h
8 // ===========================================================================
10 //*****************************************************************************
13 // Class factories are used by the pluming in COM to activate new objects.
14 // This module contains the class factory code to instantiate the
15 // ISymUnmanaged Reader,Writer and Binder
16 //*****************************************************************************
17 #ifndef __ILDBClassFactory__h__
18 #define __ILDBClassFactory__h__
20 // This typedef is for a function which will create a new instance of an object.
21 typedef HRESULT (* PFN_CREATE_OBJ)(REFIID riid, void**ppvObject);
23 //*****************************************************************************
24 // This structure is used to declare a global list of coclasses. The class
25 // factory object is created with a pointer to the correct one of these, so
26 // that when create instance is called, it can be created.
27 //*****************************************************************************
28 struct COCLASS_REGISTER
30 const GUID *pClsid; // Class ID of the coclass.
31 LPCWSTR szProgID; // Prog ID of the class.
32 PFN_CREATE_OBJ pfnCreateObject; // Creation function for an instance.
37 //*****************************************************************************
38 // One class factory object satifies all of our clsid's, to reduce overall
40 //*****************************************************************************
41 class CIldbClassFactory :
44 CIldbClassFactory() { } // Can't use without data.
47 CIldbClassFactory(const COCLASS_REGISTER *pCoClass)
48 : m_cRef(1), m_pCoClass(pCoClass)
51 virtual ~CIldbClassFactory() {}
57 virtual HRESULT STDMETHODCALLTYPE QueryInterface(
61 virtual ULONG STDMETHODCALLTYPE AddRef()
63 return InterlockedIncrement(&m_cRef);
66 virtual ULONG STDMETHODCALLTYPE Release()
68 LONG cRef = InterlockedDecrement(&m_cRef);
76 // IClassFactory methods.
79 virtual HRESULT STDMETHODCALLTYPE CreateInstance(
84 virtual HRESULT STDMETHODCALLTYPE LockServer(
89 LONG m_cRef; // Reference count.
90 const COCLASS_REGISTER *m_pCoClass; // The class we belong to.
95 #endif // __ClassFactory__h__