attribute bag class

3

3doutpost

looking for some advice on design here - i can do what i want using
casts but it feels wrong and it seems like there must be a better way.

i have some 'things' that need to be rendered to the display but the
way that happens will probably vary over time and each 'thing'
requires a different parameter - say colour for instance.

so, i have a renderer class derrived from an abstract renderer class
with a single pure virtual method called render ()

i also have a rendererAttr class derrived from a base rendererAttr
class with no pure virtual methods since there isn't anything that
will obviously be shared - e.g. this default might use colors but
another implementation might use bitmaps or something.

when creating and processing the 'things', i pass around pointers to
my base renderer and rendererAttr but eventually i need to downcast to
my rendererAttr implementation so i can call non-virtual methods on
it..

i don't know if this is clear without code - i guess what i'm wanting
is pattern that descibes how you create an "action" class and an
"attribute" class and make the two work together without the nasty
downcasting..

any comments?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top