Developers Workshop to COM and ATL 3.0
| < Free Open Study > |
|
When developing coclasses with ATL, you become dependent upon a table driven implementation of QueryInterface(). As we have seen in Chapter 7, the COM map is a NULL-terminated array of _ATL_INTMAP_ENTRY structures. Most of the time this array is populated by the COM_INTERFACE_ENTRY macro, used whenever you are supporting a COM interface using C++ multiple inheritance:
// A typical COM map. BEGIN_COM_MAP(CoSalesEmployee) COM_INTERFACE_ENTRY(ICalcCommission) COM_INTERFACE_ENTRY(ISmileAlot) COM_INTERFACE_ENTRY(IPersonalInfo) END_COM_MAP()
COM_INTERFACE_ENTRY makes use of the offsetofclass() macro to calculate the correct vPtr for a given COM interface:
// The de facto ATL COM map macro. #define COM_INTERFACE_ENTRY(x)\ {&_ATL_IIDOF(x), \ offsetofclass(x, _ComMapClass), \ _ATL_SIMPLEMAPENTRY},
This chapter discusses a number of additional coclass implementation techniques (and related COM map macros) beyond simple multiple inheritance. We begin by examining some advanced topics such as nested classes, tear-off interfaces, and resolution of method name clashes. To wrap up this chapter, you will learn how to achieve binary reuse using COM containment and COM aggregation.
| < Free Open Study > |
|