00001 //----------------------------------------------------------------------------------- 00002 // 00003 // Pro-Vocation Light Engine (PVLE) 00004 // Copyright (C) 2007-2009 Sukender, KinoX & Buzib 00005 // For more information, contact us : sukender@free.fr 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // For any use that is not compatible with the terms of the GNU 00013 // General Public License, please contact the authors for alternative 00014 // licensing options. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with this program; if not, write to the Free Software Foundation, Inc., 00023 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 // 00025 //----------------------------------------------------------------------------------- 00026 00027 #ifndef PHY_VISITOR_H 00028 #define PHY_VISITOR_H 00029 00030 //#include <PVLE/Export.h> 00031 //#include <PVLE/Physics/AbstractGeom.h> 00032 00033 namespace Physics { 00034 00035 class AbstractGeom; 00036 class Space; 00037 class Geom; 00038 class Body; 00039 class Joint; 00040 00045 class /*PVLE_EXPORT*/ Visitor { 00046 public: 00047 virtual void apply(AbstractGeom & geom) { traverse(geom); } 00048 virtual void apply(Space & geom) { apply(static_cast<AbstractGeom &>(geom)); } 00049 virtual void apply(Geom & geom) { apply(static_cast<AbstractGeom &>(geom)); } 00050 virtual void apply(Body & body) { traverse(body); } 00051 virtual void apply(Joint & joint) { traverse(joint); } 00052 00053 inline void traverse(AbstractGeom & aGeom) { 00054 //if (_traversalMode==TRAVERSE_PARENTS) aGeom.ascend(*this); 00055 //else if (_traversalMode!=TRAVERSE_NONE) aGeom.traverse(*this); 00056 aGeom.traverse(*this); 00057 } 00058 inline void traverse(Body & body) { 00059 //if (_traversalMode==TRAVERSE_PARENTS) aGeom.ascend(*this); 00060 //else if (_traversalMode!=TRAVERSE_NONE) aGeom.traverse(*this); 00061 body.traverse(*this); 00062 } 00063 inline void traverse(Joint & joint) { 00064 // Do nothing: joint.traverse() doesn't exist (yet?). 00065 } 00066 }; 00067 00068 } // namespace Physics 00069 00070 00071 #endif // PHY_VISITOR_H