Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This class derives from CComClassFactory and uses CComObjectGlobal to construct a single object.
Important
This class and its members cannot be used in applications that execute in the Windows Runtime.
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.
Members
Public Methods
Name |
Description |
---|---|
Queries m_spObj for an interface pointer. |
Public Data Members
Name |
Description |
---|---|
The CComObjectGlobal object constructed by CComClassFactorySingleton. |
Remarks
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 ATL_NO_VTABLE CMySingletonClass :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMySingletonClass, &CLSID_MySingletonClass>,
public IMySingletonClass
{
public:
DECLARE_CLASSFACTORY_SINGLETON(CMySingletonClass)
// Remainder of class declaration omitted.
Inheritance Hierarchy
CComObjectRootBase
IClassFactory
CComClassFactorySingleton
Requirements
Header: atlcom.h
See Also
Reference
CComClassFactoryAutoThread Class