[Previous] [Next]

As you saw in this chapter, you can compose COM classes in many ways. As long as you understand and follow the rules of COM identity, you'll live a productive and prosperous life as a COM class author. Unfortunately, COM identity is not given much airtime in the current COM literature. The COM spec from Microsoft covers identity in a few paragraphs. Dale Rogerson's book Inside COM (Microsoft Press, 1997) covers the topic in a bit more detail. Be sure to check out Don Box's Essential COM (Addison-Wesley, 1997), as it gives quite a good treatment of the notion of COM identity.

As an object implementor, you have a lot more options for creating COM classes once you understand the rules of COM identity. In addition to composing classes by inheriting multiply from several interfaces, one useful way of implementing COM classes is to include tear-off interfaces. This method focuses on composing classes instead of using implementation inheritance to create classes. Tear-off interfaces are handy for creating COM classes whose interfaces are not used by clients frequently or for very long.

In addition, COM specifies the binary equivalent of tear-offs known as COM aggregation. COM aggregation is an interesting way of composing two separate binary objects and fooling the client into thinking it's only one object. Aggregation is a bit hard to swallow using regular C++. Fortunately, ATL has good support for tear-off interfaces. As long as you use the appropriate macros and include entries in your interface map, your objects will conform to the COM spec.

Inside Atl
Inside ATL (Programming Languages/C)
ISBN: 1572318589
EAN: 2147483647
Year: 1998
Pages: 127 © 2008-2017.
If you may any questions please contact us: