Aggregation is a composition of COM objects. One or more inner or aggregated objects is combined with an outer COM object in such a way that the outer COM object appears to implement all the interfaces in the inner COM objects, as well as its own interfaces. A COM client interacts with an aggregation as if one COM object, the outer COM object, was implementing all the interfaces. The inner COM objects are not visible to the client.
To implement aggregation, we have to answer two questions:
- How can aggregated (inner) COM objects work with the outer COM object to support interface navigation?
- How can aggregated (inner) COM objects work with the outer COM object to support lifetime management?
The implementation of both the outer and the aggregated objects must support interface navigation and reference counting across multiple COM objects in such a way that they appear to be one COM object. Supporting these requirements means that, unlike reusing inner objects via containment/delegation, inner COM objects that are part of an aggregation are aware that they are being aggregated and actively participate by
working with the outer COM object.
COM provides a set of implementation guidelines to support aggregation.
These can be broken into inner object, outer object, and information exchange guidelines. We will study these guidelines in the few lessons.