map.h

Go to the documentation of this file.
00001 /*
00002  * map.h
00003  *
00004  * Copyright (C) 2007-2009  Thomas A. Vaughan
00005  * All rights reserved.
00006  *
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *     * Redistributions of source code must retain the above copyright
00011  *       notice, this list of conditions and the following disclaimer.
00012  *     * Redistributions in binary form must reproduce the above copyright
00013  *       notice, this list of conditions and the following disclaimer in the
00014  *       documentation and/or other materials provided with the distribution.
00015  *     * Neither the name of the <organization> nor the
00016  *       names of its contributors may be used to endorse or promote products
00017  *       derived from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY
00020  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY
00023  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  *
00031  * Definition of the basic aesop::map object.
00032  */
00033 
00034 #ifndef AESOP_MAP_MAP_H__
00035 #define AESOP_MAP_MAP_H__
00036 
00037 // includes --------------------------------------------------------------------
00038 #include "zone.h"                       // zone objects
00039 
00040 #include <iostream>
00041 
00042 
00043 namespace aesop {
00044 
00057 
00060 
00061 struct destination_t {
00062         // constructor, manipulators
00063         destination_t(void) throw() { this->clear(); }
00064         void clear(void) throw() {
00065                         id[0] = 0;
00066                         rect.clear();
00067                 }
00068 
00069         // data fields
00070         char                    id[eAESOP_IdBufferSize];
00071         rect3d_t                rect;           
00072 };
00073 
00074 
00075 
00077 typedef void (*zone_iteration_fn)(IN Zone * zone,
00078                                 IN void * context);
00079 
00080 
00102 class Map {
00103 public:
00104         // virtual destructor --------------------------------------------------
00105         virtual ~Map(void) throw();
00106 
00107         // aesop::Map class interface methods -----------------------------------
00108         virtual const char * getId(void) const throw() = 0;
00109         virtual Zone * getRootZone(void) throw() = 0;
00110         virtual Zone * getZone(IN const char * zone_id) = 0;
00111         virtual void iterateZones(IN zone_iteration_fn,
00112                                 IN void * context) = 0;
00113         virtual const char * getDefaultStartingPointId(void) const throw() = 0;
00114         virtual void getStartingPointIds(OUT VecString& ids) const = 0;
00115         virtual void getStartingPoint(IN const char * id,
00116                                 OUT destination_t& start) const = 0;
00117 };
00118 
00119 
00120 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00151 
00152 
00153 
00154 smart_ptr<Map> loadMap(IN const char * id,
00155                                 IN const char * path_to_map_file);
00156 
00157 
00158 
00165 class MapFormatReader {
00166 public:
00167         // virtual destructor --------------------------------------------------
00168         virtual ~MapFormatReader(void) throw();
00169 
00170         // aesop::MapFormatReader class interface methods -----------------------
00171         virtual const char * getDescription(void) = 0;
00172         virtual bool isMyFormat(IN const char * mapId,
00173                                 IN const char * path_to_map_file) = 0;
00174         virtual smart_ptr<Map> loadMap(IN const char * mapId,
00175                                 IN const char * path_to_map_file) = 0;
00176 };
00177 
00178 
00179 
00181 void registerMapFormatReader(IN smart_ptr<MapFormatReader>& reader);
00182 
00183 
00184 
00185 };      // aesop namespace
00186 
00187 #endif  // AESOP_MAP_MAP_H__
00188