V
vsgdp
I have a set of brush classes that inherit from Brush. They override a pure
virtual paint method. When the user selects a new brush, I just have a
Brush pointer point to an instance of the particular selected type of brush.
The problem is that some brush settings don't apply to every kind of brush.
So it is difficult to set the particular brush property with the abstract
brush pointer. I see two ways to handle this:
Add a virtual "set" function that takes an AllBrushProperties structure
(some properties will be unused depending on the brush) so that each brush
can update itself correctly.
Use runtime type checking and downcast to the type to call the appropriate
set method.
I don't really like either as it sort of ruins my otherwise clean
polymorphic system.
virtual paint method. When the user selects a new brush, I just have a
Brush pointer point to an instance of the particular selected type of brush.
The problem is that some brush settings don't apply to every kind of brush.
So it is difficult to set the particular brush property with the abstract
brush pointer. I see two ways to handle this:
Add a virtual "set" function that takes an AllBrushProperties structure
(some properties will be unused depending on the brush) so that each brush
can update itself correctly.
Use runtime type checking and downcast to the type to call the appropriate
set method.
I don't really like either as it sort of ruins my otherwise clean
polymorphic system.