From: Markus R. <rol...@us...> - 2006-02-18 19:52:20
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16039 Added Files: roselements.h roselements.cpp Log Message: - implemented a lookup table for RoSimML XML-Element names --- NEW FILE: roselements.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: roselements.h,v 1.1 2006/02/18 19:52:14 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ROSELEMENTS_H #define ROSELEMENTS_H #include <map> #include <string> //! RoSim XML Attributes // common #define RA_NAME "name" // AppearanceDefinition #define RA_COLOR "Color" #define RA_R "r" #define RA_G "g" #define RA_B "b" #define RA_A "a" // Vector #define RA_X "x" #define RA_Y "y" #define RA_Z "z" // Box #define RA_LENGTH "length" #define RA_WIDTH "width" #define RA_HEIGHT "height" // Sphere #define RA_RADIUS "radius" // Appearance #define RA_REF "ref" // GlobalPhysicalParameters #define RA_GRAVITY "gravity" #define RA_ERP "erp" #define RA_CFM "cfm" // PhysicalAttributes #define RA_VALUE "value" class RosElements { public: enum ERosElement { RE_INVALID = 0, RE_ROSIINCLUDEFILE, RE_SIMULATION, RE_SCENE, RE_ELEMENTS, RE_MOVABLE, RE_TRANSLATION, RE_ROTATION, RE_BOX, RE_SPHERE, RE_CYLINDER, RE_CAPPEDCYLINDER, RE_GLOBALPHYSICALPARAMETERS, RE_PHYSICALATTRIBUTES, RE_MASS, RE_CENTEROFMASS, RE_APPEARANCEDEFINITION, RE_APPEARANCE, RE_DEFAULTAPPEARANCE, RE_AMBIENTLIGHTCOLOR, RE_COLOR }; typedef std::map<std::string, ERosElement> TElementMap; typedef std::map<ERosElement, std::string> TReverseMap; public: static RosElements& GetInstance(); ~RosElements(); ERosElement Lookup(const std::string& value) const; std::string Lookup(ERosElement element) const; protected: void SetupMap(); private: RosElements(); protected: TElementMap mMap; TReverseMap mReverseMap; }; #endif // ROSELEMENTS_H --- NEW FILE: roselements.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: roselements.cpp,v 1.1 2006/02/18 19:52:14 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "roselements.h" using namespace std; RosElements::RosElements() { SetupMap(); } RosElements::~RosElements() { } RosElements& RosElements::GetInstance() { static RosElements theInstance; return theInstance; } #define ROS_DEFINE_ELEMENT(_elem, _str)\ mMap[_str] = _elem;\ mReverseMap[_elem] = _str; void RosElements::SetupMap() { mMap.clear(); ROS_DEFINE_ELEMENT(RE_ROSIINCLUDEFILE,"RoSiIncludeFile"); ROS_DEFINE_ELEMENT(RE_SIMULATION,"Simulation"); ROS_DEFINE_ELEMENT(RE_SCENE,"Scene"); ROS_DEFINE_ELEMENT(RE_ELEMENTS,"Elements"); ROS_DEFINE_ELEMENT(RE_MOVABLE,"Movable"); ROS_DEFINE_ELEMENT(RE_TRANSLATION, "Translation"); ROS_DEFINE_ELEMENT(RE_ROTATION, "Rotation"); ROS_DEFINE_ELEMENT(RE_BOX,"Box"); ROS_DEFINE_ELEMENT(RE_SPHERE,"Sphere"); ROS_DEFINE_ELEMENT(RE_CYLINDER,"Cylinder"); ROS_DEFINE_ELEMENT(RE_CAPPEDCYLINDER,"CappedCylinder"); ROS_DEFINE_ELEMENT(RE_GLOBALPHYSICALPARAMETERS,"GlobalPhysicalParameters"); ROS_DEFINE_ELEMENT(RE_PHYSICALATTRIBUTES,"PhysicalAttributes"); ROS_DEFINE_ELEMENT(RE_MASS,"Mass"); ROS_DEFINE_ELEMENT(RE_CENTEROFMASS, "CenterOfMass"); ROS_DEFINE_ELEMENT(RE_APPEARANCEDEFINITION, "AppearanceDefinition"); ROS_DEFINE_ELEMENT(RE_APPEARANCE, "Appearance"); ROS_DEFINE_ELEMENT(RE_DEFAULTAPPEARANCE, "DefaultAppearance"); ROS_DEFINE_ELEMENT(RE_AMBIENTLIGHTCOLOR,"AmbientLightColor"); ROS_DEFINE_ELEMENT(RE_COLOR, "Color"); } string RosElements::Lookup(ERosElement element) const { TReverseMap::const_iterator iter = mReverseMap.find(element); if (iter == mReverseMap.end()) { return ""; } return (*iter).second; } RosElements::ERosElement RosElements::Lookup(const std::string& value) const { TElementMap::const_iterator iter = mMap.find(value); if (iter == mMap.end()) { return RE_INVALID; } return (*iter).second; } |