maptransform.h
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2004  Brian Gerkey gerkey@stanford.edu    
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 /*
00022  * $Id: maptransform.h 7305 2009-01-27 01:18:55Z gbiggs $
00023  *
00024  * Base class for map transform drivers, simply reimplement the transform method
00025  * with your trasformation function. See MapScale for example
00026  */
00027 
00028 #ifndef _MAPTRANSFORM_H_
00029 #define _MAPTRANSFORM_H_
00030 
00031 #include <sys/types.h> // required by Darwin
00032 #include <stdlib.h>
00033 #include <string.h>
00034 #include <math.h>
00035 
00036 #include <libplayercore/playercore.h>
00037 
00038 // compute linear index for given map coords
00039 #define MAP_IDX(mf, i, j) ((mf.width) * (j) + (i))
00040 
00041 // check that given coords are valid (i.e., on the map)
00042 #define MAP_VALID(mf, i, j) ((i >= 0) && (i < mf.width) && (j >= 0) && (j < mf.height))
00043 
00044 class MapTransform : public Driver
00045 {
00046   protected:
00047     player_map_info_t source_map;
00048     player_devaddr_t source_map_addr;
00049     char* source_data;
00050 
00051         player_map_info_t new_map;
00052     char* new_data;
00053 
00054     // get the map from the underlying map device
00055     int GetMap();
00056     // interpolate the map
00057     virtual int Transform() = 0;
00058     
00059   public:
00060     MapTransform(ConfigFile* cf, int section);
00061     virtual ~MapTransform();
00062 
00063     // MessageHandler
00064     public: virtual int ProcessMessage(QueuePointer &resp_queue, 
00065                                      player_msghdr * hdr, 
00066                                      void * data);   
00067                                      
00068     int Setup();
00069     int Shutdown();
00070 };
00071 
00072 #endif

Last updated 25 May 2011 21:17:00