Using Polymorphic Attributes in IGrafBundle

For ease of use, IGrafBundle has an API of copy semantics for setting standard attributes by passing the references of instances of attributes as parameters. The attribute object is copied and stored in the IGrafBundle object. Every standard attribute is extensible by subclassing. However, the attribute class must provide the typeid and polymorphic GraphicCopy::copy support to avoid "slicing" subclass of an attribute. Slicing the subclass of an attribute means that subclass specific information is lost because the subclass object is copied using a base class copy function which only has access to the base class data.

For example, the IPen object should have typeid and copy functions that the subclass IStyledPen overrides. Whenever an IPen object is referenced in IGrafBundle, if the source is an IStyledPen, IGrafBundle detects if the source is an IPen type by using the typeid support and calls the copy function IStyledPen stored in the resultant pointer instead of a copy of the concrete IPen object. This is true for all IAttributeState subclasses and for complex attribute classes such as IPaint.

In addition to subclassing one of the attribute classes in order to use polymorphic attributes, there are classes subclassed from IMStreamable available for such purpose. These classes use the typeid and polymorphic copy functions from IMStreamable. The classes subclassed from IMStreamable are:

You can also use polymorphic attributes without using IMStreamable. However, you must subclass one of the attribute classes.

 

Using Bundles in the Modeling Hierarchy