Home
FAQ
Player
Utilities
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

WorldFile.hh

Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /*
00022  * Desc: A class for reading and writing the world file.
00023  * Author: Andrew Howard
00024  * Date: 15 Nov 2001
00025  * CVS info: $Id: WorldFile.hh,v 1.22 2004/11/14 07:39:04 inspectorg Exp $
00026  */
00027 
00028 #ifndef WORLDFILE_HH
00029 #define WORLDFILE_HH
00030 
00031 #include <libxml/parser.h>
00032 
00033 #include "Vector.hh"
00034 #include "Color.hh"
00035 
00036 // Forward declarations
00037 class WorldFileNode;
00038 
00039 
00041 class WorldFile
00042 {
00044   public: WorldFile();
00045 
00047   public: ~WorldFile();
00048 
00050   public: int Load( const char *filename );
00051 
00053   public: int LoadString( const char *str );
00054 
00057   public: int Save( const char *filename );
00058 
00061   public: bool WarnUnused();
00062   
00064   public: WorldFileNode *GetRootNode() const;
00065 
00066   // Create wrappers
00067   private: WorldFileNode *CreateNodes( WorldFileNode *parent, 
00068                                        xmlNodePtr xmlNode );
00069 
00071   public: char *filename;
00072   
00073   // XML data
00074   private: xmlDocPtr xmlDoc;
00075 
00076   // The root of the tree
00077   private: WorldFileNode *root;
00078 };
00079 
00080 
00082 class WorldFileNode
00083 {
00085   public: WorldFileNode( WorldFile *file, WorldFileNode *parent, 
00086                          xmlNodePtr xmlNode, xmlDocPtr xmlDoc );
00087 
00089   public: ~WorldFileNode();
00090 
00092   public: const char *GetName();
00093 
00095   public: const char *GetNSPrefix();
00096 
00098   public: WorldFileNode *GetNext();
00099 
00101   public: WorldFileNode *GetChild();
00102 
00105   public: WorldFileNode *GetChild( const char *name );
00106 
00108   public: WorldFileNode *GetChildByNSPrefix( const char *prefix);
00109 
00111   private: char* GetNodeValue( const char *key );
00112 
00114   private: void SetNodeValue( const char *key, const char* value );
00115 
00117   public: void Print();
00118 
00120   public: bool WarnUnused();
00121 
00123   public: bool IsDefined( const char *key ) {return GetNodeValue(key) != NULL;}
00124 
00126   public: const char *GetString( const char *key, const char *def, int require = 0 );
00127 
00129   public: void SetString( const char *key, const char *v);
00130 
00136   public: const char *GetFilename( const char *key, const char *def, 
00137                                    int require = 0);
00138 
00146   public: const char *SearchFilename( const char *key, const char *path, const char *def,
00147                                       int require = 0);
00148 
00150   public: int GetInt( const char *key, int def, int require = 0 );
00151 
00153   public: double GetDouble( const char *key, double def, int require = 0 );
00154 
00156   public: bool GetBool( const char *key, bool def, int require = 0 );
00157 
00159   public: double GetLength( const char *key, double def, int require = 0 );
00160 
00162   public: double GetAngle( const char *key, double def, int require = 0 );
00163 
00165   public: double GetTime( const char *key, double def, int require = 0 );
00166 
00168   public: GzVector GetPosition( const char *key, GzVector def );
00169 
00171   public: void SetPosition( const char *key, GzVector v );
00172 
00174   public: GzQuatern GetRotation( const char *key, GzQuatern def );
00175 
00177   public: void SetRotation( const char *key, GzQuatern v );
00178 
00179   /* REMOVE
00180   // @brief Read a pose
00181   //
00182   // Poses are specfied with three vectors: @htmlonly<lookat>pos_x
00183   // pos_y pos_z at_x at_y at_z up_x up_y up_z</lookat>@endhtmlonly.
00184   // The object will be positioned at @c pos, with the x-axis pointing
00185   // at @c at, and the z-axis pointing in the @c up direction.  The @c
00186   // up vector may be omitted.
00187   public: GzPose GetPose( const char *key, GzPose def );
00188   */
00189 
00191   public: GzColor GetColor( const char *key, GzColor def );
00192 
00194   public: const char *GetTupleString( const char *key, int index, 
00195                                       const char *def );
00196 
00198   public: double GetTupleDouble( const char *key, int index, double def );
00199 
00201   public: int GetTupleInt( const char *key, int index, int def );
00202 
00204   public: double GetTupleLength( const char *key, int index, double def );
00205 
00207   public: double GetTupleAngle( const char *key, int index, double def );
00208 
00209   // Our document
00210   private: WorldFile *file;
00211   
00212   // Our parent
00213   private: WorldFileNode *parent;
00214   
00215   // Our siblings
00216   private: WorldFileNode *next, *prev;
00217   
00218   // Our children
00219   private: WorldFileNode *child_first, *child_last;
00220 
00221   // XML data
00222   private: xmlNodePtr xmlNode;
00223 
00224   // XML data
00225   private: xmlDocPtr xmlDoc;
00226 
00227   // Flag set if the node has been accessed
00228   private: bool used;
00229 
00230   // Warts
00231   friend class WorldFile;
00232 };
00233 
00234 #endif
00235 


Last updated $Date: 2004/12/21 01:49:15 $
Generated on Sun May 22 18:39:08 2005 for Gazebo by doxygen 1.4.2