template< class T >
class CComClassFactorySingleton : public CComClassFactory
Parameters
T Your class.
CComClassFactorySingleton derives from CComClassFactory and uses CComObjectGlobal to construct a single object. Each call to the CreateInstance method simply queries this object for an interface pointer.
ATL objects normally acquire a class factory by deriving from CComCoClass. This class includes the macro DECLARE_CLASSFACTORY, which declares CComClassFactory as the default class factory. To use CComClassFactorySingleton, specify the DECLARE_CLASSFACTORY_SINGLETON macro in your object's class definition. For example:
class CMyClass : ..., public CComCoClass< ... > { public: DECLARE_CLASSFACTORY_SINGLETON(CMyClass)
... };
#include <atlcom.h>
See Also CComClassFactory2, CComClassFactoryAutoThread, CComObjectRootEx, CComGlobalsThreadModel, IClassFactory in the Win32 SDK
IClassFactory Methods | |
CreateInstance | Queries m_Obj for an interface pointer. |
Data Members | |
m_Obj | The CComObjectGlobal object constructed by CComClassFactorySingleton. |
CComClassFactorySingleton Overview
HRESULT CreateInstance( LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj );
Return Value
A standard HRESULT value.
Parameters
pUnkOuter [in] If the object is being created as part of an aggregate, then pUnkOuter must be the outer unknown. Otherwise, pUnkOuter must be NULL.
riid [in] The IID of the requested interface. If pUnkOuter is non-NULL, riid must be IID_IUnknown.
ppvObj [out] A pointer to the interface pointer identified by riid. If the object does not support this interface, ppvObj is set to NULL.
Remarks
Calls QueryInterface through m_Obj to retrieve an interface pointer.
CComClassFactorySingleton Overview | Class Members
See Also CoCreateInstance and CoGetClassObject in the Win32 SDK
CComObjectGlobal< T > m_Obj;
Remarks
The CComObjectGlobal object constructed by CComClassFactorySingleton, where T is the class template parameter. Each call to the CreateInstance method simply queries this object for an interface pointer.