The Layers of ATL


ATL's support for building COM objects is separated into several layers, as shown in Figure 4.1.

Figure 4.1. The layers of ATL


These layers break down into services exposed by ATL for building objects:

  1. CComObjectRootEx uses a CComXxxThreadModel to provide "just thread-safe enough" object lifetime management and object locking.

  2. CComObjectRootBase and CComObjectRootEx provide helper functions used in implementing IUnknown.

  3. 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.

  4. 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.




ATL Internals. Working with ATL 8
ATL Internals: Working with ATL 8 (2nd Edition)
ISBN: 0321159624
EAN: 2147483647
Year: 2004
Pages: 172

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net