The Layers of
ATL
ATL's support for building COM objects is
separated into several layers, as shown in Figure 4.1.
These layers break down
into services exposed by ATL for building objects:
-
CComObjectRootEx uses a
CComXxxThreadModel to provide "just thread-safe enough"
object lifetime management and object locking.
-
CComObjectRootBase and
CComObjectRootEx provide helper functions used in
implementing IUnknown.
-
Your class, which derives from
CComObjectRootEx, also derives from any interfaces it
wants to implement, as well as providing the method
implementations. You or one of the ATL IXxxImpl classes
can provide method implementations.
-
CComObject et al, provides the actual
implementation of the methods of IUnknown in a way
consistent with your desires for object and server lifetime
management requirements. This final layer actually derives from
your class.
Your choice of base classes and the most derived
class determines the way the methods of IUnknown are
implemented. If your choices change, using different classes at
compile time (or runtime) will change how ATL implements
IUnknown, independently of the rest of the behavior of
your object. The following sections explore each layer of ATL.
|