Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 2.45 KB

changing-the-default-class-factory-and-aggregation-model.md

File metadata and controls

27 lines (18 loc) · 2.45 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Changing the Default Class Factory and Aggregation Model
Changing the Default Class Factory and Aggregation Model
11/04/2016
CComClassFactory class, making the default
aggregation [C++], using ATL
aggregation [C++], aggregation models
defaults [C++], aggregation model in ATL
default class factory
class factories, changing default
CComCoClass class, default class factory and aggregation model
default class factory, ATL
defaults [C++], class factory
6e040e95-0f38-4839-8a8b-c9800dd47e8c

Changing the Default Class Factory and Aggregation Model

ATL uses CComCoClass to define the default class factory and aggregation model for your object. CComCoClass specifies the following two macros:

You can override either of these defaults by specifying another macro in your class definition. For example, to use CComClassFactory2 instead of CComClassFactory, specify the DECLARE_CLASSFACTORY2 macro:

[!code-cppNVC_ATL_COM#2]

Two other macros that define a class factory are DECLARE_CLASSFACTORY_AUTO_THREAD and DECLARE_CLASSFACTORY_SINGLETON.

ATL also uses the typedef mechanism to implement default behavior. For example, the DECLARE_AGGREGATABLE macro uses typedef to define a type called _CreatorClass, which is then referenced throughout ATL. Note that in a derived class, a typedef using the same name as the base class's typedef results in ATL using your definition and overriding the default behavior.

See also

Fundamentals of ATL COM Objects
Aggregation and Class Factory Macros