Objective Chart : PART II Programmer’s Guide : Chapter 18 Compound Component System : Compound Component Advantages
Compound Component Advantages
A compound component, like the SRGraph object, has an m_ComponentList member upon which sub-components may be stored. During the draw cycle the compound component may draw its own foreground data and then iteratively draw all of the components on its own list. If a sub-component itself is a compound component, then it too may have sub-components that are drawn in their turn.
There are two advantages to this system. First, a component may be created that encapsulates certain stock items and combines them in a preset fashion. This object may be reused repeatedly without recreating it every time you create a chart.
Secondly, it is possible to create an object that expects to use certain kinds of sub-components. Those sub-components are provided at initialization time by the programmer. As long as they conform to certain rules, they will behave similarly whether they are of the expected type or of a type derived from that original.
The basic component that makes all of these things possible is the SRGCompoundComponent class.