Using my classic gamebasis naming convention I call nodes in the scenegraph a GlyphNode. A GlyphNode contains a single Glyph. A Glyph typically is a mesh, but could also be a vector graphics rectangle or something just thrown in the tree for fun. Also of significant note is a GlyphNode is never shared and a Glyph can be shared.
Ok, now that the jargon is out the way..
I did something a little different this time around and I think it might turn out pretty well. I'm not sure why I didn't think of it before.
Sometimes you want to put a constraint on what type of Glyph is inside a GlyphNode. Since it is a pain in the ass to make a stupid subclass of GlyphNode for every stupid type of Glyph you might want to throw in it, generics to the rescue(we'll see).
The problem that always comes up with generics is the stupid base class naming. For some reason c++ does not allow you have empty template arguments meaning.. I don't really give a shit what arguments, just let me store a pointer to it you bastard. This makes you go.. Oh.. IGlyphNode or AbstractGlyphNode or worst of all.. GlyphNodeBase [shudder].
My solution this time was this..
ref class GlyphNode
and
template <typename GLYPHTYPE>
ref class gamebasis::TypedGlyphNode : public gamebasis::GlyphNode
Yeah.. Brilliant eh.. [pfff]
So now if I want to constraint a GlyphNode based upon the type of Glyph it holds I can do something like this..
TypedGlyphNode<Viewport>^ viewport;
The only ugliness (I think) comes when I want to create new GlyphNodes, I need to use the TypeGlyphNode instead, which really is not too bad, which really is probably a good idea anyway.
Maybe I'll post back soon (soon considering my rate of progress might mean a long time) on why this was a dumb plan.