Hello,
Chris said:
possibly some design-ideas?
There is too much open to reach an answer. And it starts to become
off-topic.
My first idea would be inheriting module in decorator and overriding the
things I want to change. But why not applying that color, texture,
normals on the module instance manually. The decoration makes only
sense if it happens often, and the decorated object has its own reasons
to exist.
Since this is on GUI code, many GUI frameworks have some facilities for
object destruction of the kind destruct and deallocate the window and
everything within. Better you try first to adjust to the usual ways of
your framework before trying something new.
What I really don't like about the way you have applied the decorator
pattern is, that there are 3 instances of subclasses of visual
involved, where only one should be, one visual decorated twice. In GUI
frameworks a base class like visual often has lots of state, which
probably needs to be copied for every level of applying decorator. That
seems pretty odd.
If your framework has been designed with all that in mind, e.g. the
decorators really are only thin wrappers, then it might be possible to
establish some owner relation between the decorators/decorated objects
and make their root responsible for the others (probably the outermost
decorator) and attach the outermost decorator to its embedding object
in a way that destruction can be done. If smart pointers are used then
only c'tors of the classes are involved
Bernd Strieder