#include "X3DComponentVisitor.h" #include "EnterFunction.h" #include "WalkOnFunction.h" #include "LeaveFunction.h" #include using namespace std; namespace X3DTK { X3DComponentVisitor::X3DComponentVisitor() { } X3DComponentVisitor::~X3DComponentVisitor() { //delete the functions for (EnterDict::iterator e = _enterDict.begin(); e != _enterDict.end(); ++e) delete (*e).second; for (WalkOnDict::iterator w = _walkonDict.begin(); w != _walkonDict.end(); ++w) delete (*w).second; for (LeaveDict::iterator l = _leaveDict.begin(); l != _leaveDict.end(); ++l) delete (*l).second; } EnterFunction *X3DComponentVisitor::getEnterFunctionOf(const SFType *type) const { SFString nodeName = type->getEncodedName(); EnterDict::const_iterator it = _enterDict.find(nodeName); if (it != _enterDict.end()) return (*it).second; return 0; } WalkOnFunction *X3DComponentVisitor::getWalkOnFunctionOf(const SFType *type) const { SFString nodeName = type->getEncodedName(); WalkOnDict::const_iterator it = _walkonDict.find(nodeName); if (it != _walkonDict.end()) return (*it).second; return 0; } LeaveFunction *X3DComponentVisitor::getLeaveFunctionOf(const SFType *type) const { SFString nodeName = type->getEncodedName(); LeaveDict::const_iterator it = _leaveDict.find(nodeName); if (it != _leaveDict.end()) return (*it).second; //not found return 0; } void X3DComponentVisitor::define(const std::pair &entry) { StringType st = entry.first; if (st.component != component->getName() || st.sceneGraph != component->getSceneGraphName()) { SFString sg; if (component->getSceneGraphName() != "") sg = " of the " + component->getSceneGraphName() + " scene graph"; cx3d << "warning: defineEnterFunction for " << st.type << " which doesn't belong to the " << component->getName() << " component" << sg << "," << std::endl; cx3d << " but to the " << st.component << " component" << std::endl; } _enterDict[st.encodedName] = entry.second; } void X3DComponentVisitor::define(const std::pair &entry) { StringType st = entry.first; if (st.component != component->getName() || st.sceneGraph != component->getSceneGraphName()) { SFString sg; if (component->getSceneGraphName() != "") sg = " of the " + component->getSceneGraphName() + " scene graph"; cx3d << "warning: defineWalkOnFunction for " << st.type << " which doesn't belong to the " << component->getName() << " component" << sg << "," << std::endl; cx3d << " but to the " << st.component << " component" << std::endl; } _walkonDict[st.encodedName] = entry.second; } void X3DComponentVisitor::define(const std::pair &entry) { StringType st = entry.first; if (st.component != component->getName() || st.sceneGraph != component->getSceneGraphName()) { SFString sg; if (component->getSceneGraphName() != "") sg = " of the " + component->getSceneGraphName() + " scene graph"; cx3d << "warning: defineLeaveFunction for " << st.type << " which doesn't belong to the " << component->getName() << " component" << sg << "," << std::endl; cx3d << " but to the " << st.component << " component" << std::endl; } _leaveDict[st.encodedName] = entry.second; } }