dynamic_cast
operator. Nevertheless the "double dispatching" technique requires that the RTTI is more precise than just a downcast that succeeds or fails.SFType::printInheritanceTree();
This tree is dynamic meaning that its shape depends on the execution and contains only the types that are in used.
Inherited type and name can be accessed:
X3DTK::SFNode N; // Gets the name of the type const X3DTK::SFString &name = N->getype->getName(); // Gets the parent of the type X3DTK::SFType *type = N->getType()->getParent(); // Gets the children of the type X3DTK::MFType mtype = N->getType()->getChildren();
You access to the component and the scene graph of a X3DTK::SFType by:
X3DTK::SFNode N; // Gets the component of the type X3DTK::SFComponent *com = N->getType()->getComponent(); // Gets the component of the type X3DTK::SFSceneGraph *sg = com->getSceneGraph();
These informations are not really useful but are necessary to the working of the "double dispatching" technique.
Usually, node creation is not explicit, but is made by an abstract factory X3DTK::X3D::Creator that creates a node from its name, and is called by an X3DTK::X3DLoader, or by a processor that converts a scene graph to another one.
You can delete the node by calling explictly the delete operator, but it suppresses only the node and not its children. For that use the generic processor called X3DTK::MemReleaser that ensures you to delete all the sub-tree, except for shared nodes that are not deleted.
X3DTK::SFNode N = new X3D::Group(); // Gets the name of the type const X3DTK::SFString &name = N->getTypeName(); // Gets the component name of the type const X3DTK::SFString &com = N->getComponentName(); // Gets the scene graph name of the type const X3DTK::SFString &sg = N->getSceneGraphName(); // "X3D::Group" is displayed cout << sg << "::" << name << endl;
When a node is cloned and has children, they are not cloned but shared, nevertheless the clone has no father, otherwise the integrity of the scene graph would be in great danger!
Let's see how to delete a sub-tree where nodes are shared, and let's take the former nodes.
#include <X3DTK/memreleaser.h> // Getting the instance of MemReleaser X3DTK::MemReleaser *releaser = X3DTK::Singleton<X3DTK::MemReleaser>::getInstance(); // releases C, but not B because B is shared by S releaser->release(C); // releases S and B because B is not shared releaser->release(S);