COM Aggregation   «Prev  Next»
Lesson 8 Aggregation guidelines: outer objects
Objective List guidelines for aggregating outer objects.

Aggregation Guidelines and Outer Objects


To aggregate other COM objects, an outer COM object must adhere to the following guidelines:
  1. The outer COM object must create an instance of each inner/aggregated COM object. Normally, as part of its initialization sequence, the outer object creates instances of the COM objects it aggregates.
  2. The outer object must release the inner object's nondelegating IUnknown when it is released. This guideline tells us to release the inner COM object when the outer COM object is released.

Guidelines 1 and 2 tell the outer object to keep the aggregated objects in synch with its own state. When the outer object is created, it creates and aggregates the inner objects. When the outer object terminates, it releases the inner objects. The outer object's implementation of IUnknown::QueryInterface must be able to use the inner object's nondelegating IUnknown to obtain interface pointers into the inner object to provide them to the client.

Interface Pointers

This guideline states that the outer object uses the nondelegating IUnknown interfaces of each aggregated object. When a client asks the outer COM object for an interface it does not support, the outer object can query each aggregated object for the requested interface by calling QueryInterface in the nondelegating IUnknown.
Outer objects can handle interface navigation into inner objects in two ways:
  1. explicitly or via
  2. blind aggregation.

Fix Bug Outer-Com Object - Exercise

Click the Exercise link below to apply what you have learned about aggregated outer COM objects.
Fix Bug Outer-Com Object - Exercise