/// This file is part of the X3DToolKit library /// Copyright (C) 2002-2004 Yannick Le Goc (legoc@imag.fr) /// http://artis.imag.fr/Members/Yannick.Legoc/X3D/ /// This library is free software; you can redistribute it and/or /// modify it under the terms of the GNU Lesser General Public /// License as published by the Free Software Foundation; either /// version 2.1 of the License, or (at your option) any later version. /// This library is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// Lesser General Public License for more details. /// You should have received a copy of the GNU Lesser General Public /// License along with this library; if not, write to the Free Software /// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifndef X3DTK_X3DCOMPONENTVISITOR_H #define X3DTK_X3DCOMPONENTVISITOR_H #include "X3DComponent.h" #include "GraphTraversal.h" #include "EnterFunction.h" #include "WalkOnFunction.h" #include "LeaveFunction.h" #include "X3DAbstractNode.h" #include "SFSceneGraph.h" #include "Recorder.h" namespace X3DTK { /*! \brief Abstract class declared in defining the concept of component visitor. * * A component visitor is a visitor for a component of the X3D nodes. It records callbacks * of three different types. Enter, walkOn and leave functions can be recorded. For more * details about defining and recording callbacks, see the processor * page. Two syntaxes can be used depending on the compiler used. * * \ingroup processor */ class X3DComponentVisitor : public X3DComponent { public: /// Constructor. X3DComponentVisitor(); /// Destructor. virtual ~X3DComponentVisitor() = 0; /// Gets the enter function of SFType type. EnterFunction *getEnterFunctionOf(const SFType *type) const; /// Gets the WalkOn function of SFType type. WalkOnFunction *getWalkOnFunctionOf(const SFType *type) const; /// Gets the leave function of SFType type. LeaveFunction *getLeaveFunctionOf(const SFType *type) const; protected: #ifdef TEMPLATE_SPECIALIZATION_SUPPORTED /// Define a new enter function. The node of type T must belong to the component, otherwise /// the function is not recorded. Preferred syntax. template void defineEnterFunction(void (*ptrF)(T *)); /// Define a new walk On function. The node of type T must belong to the component, otherwise /// the function is not recorded. Preferred syntax. template void defineWalkOnFunction(bool (*ptrF)(T *, SFNode)); /// Define a new leave function. The node of type T must belong to the component, otherwise /// the function is not recorded. Preferred syntax. template void defineLeaveFunction(void (*ptrF)(T *)); #endif /// Define a new enter function. The node of type T must belong to the component, otherwise /// the function is not recorded. Portable syntax. void define(const std::pair &entry); /// Define a new walk On function. The node of type T must belong to the component, otherwise /// the function is not recorded. Portable syntax. void define(const std::pair &entry); /// Define a new leave function. The node of type T must belong to the component, otherwise /// the function is not recorded. Portable syntax. void define(const std::pair &entry); private: EnterDict _enterDict; WalkOnDict _walkonDict; LeaveDict _leaveDict; }; } #include "X3DComponentVisitor.inl" #endif