I think you can avoid templates. Why not using only a factory class + an abstract(basically for preventing instantiating this meaningless class) node class + node implementations?
The factory class will return Node(abstract) objects which you could identify later by adding a getType pure virtual method which subclasses actually implement.
For example:
AbstractNode *node = NodeFactory.CreateNode...;
switch(node->type())
{
...
case AbstractNode::eTypeANode:
{
dynamic_cast<TypeANode*>(node)->SomeTypeANodeSpecializedMethod();
break;
}
...
}
AbstractNode *node = NodeFactory.CreateNode...;
switch(node->type())
{
...
case AbstractNode::eTypeANode:
{
dynamic_cast<TypeANode*>(node)->SomeTypeANodeSpecializedMethod();
break;
}
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks