Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

map.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 *       FILE:     MAP.h
00003 *       AUTHOR:   E. Otis O
00004 *       DATE:     17 April 1993
00005 *       MODIFIED: 30 April 1993 (5:00 pm)
00006 *       PURPOSE:
00007 *         Functions to store and relay information about the "Scotland
00008 *         Yard" network
00009 ***********************************************************************/
00010 
00011 #ifndef _MAP_H
00012 #define _MAP_H
00013 
00014 #include <fstream.h>
00015 #include "mapnode.h"
00016 
00017 /**********************************************************************
00018 *       Class Definition
00019 ***********************************************************************/
00020 
00021   const int  FIRST= 1;  // node-count starts from this value
00022   const char FIELD= ';';
00023   const char SUB1= '(';
00024   const char SUB2= ')';
00025   const char EOLN= '\n';
00026 
00027 class Map {
00028 
00029  private:
00030 
00031   int       numNodes,  // number of nodes on the map
00032             maxX,
00033             maxY;
00034 
00035   MapNode   *nodes;    // array to store adjecency list
00036   ifstream  mapFile;   // input file
00037 
00038   void initialize(int *array, int size);
00039   void get_field(int, mode);
00040 
00041  public:
00042   Map(void) { numNodes= 0; nodes= NULL; maxX= 0; maxY= 0; }
00043   ~Map()    { delete [] nodes; }
00044 
00045   bool load_map(char*);
00046   void show_map(void);  // a debugging function
00047 
00048   int max_x(void) { return maxX; }
00049   int max_y(void) { return maxY; }
00050 
00051   int x(int node) { return nodes[node].x; }
00052   int y(int node) { return nodes[node].y; }
00053 
00054   int first_node(void) { return FIRST; }
00055   int num_nodes(void)  { return numNodes; }
00056 
00057   // connected_to(node, iteration, <iteration>)
00058   int   connected_to(int, int, int= -1);
00059   int   num_connections(int, int= -1);
00060   char* get_name(int node) { return nodes[node].find_name(node); }
00061 
00062   int next_short(int, int, bool, bool, bool);
00063 
00064   bool taxi(int node)   { return nodes[node].is_link(Taxi); }
00065   bool bus(int node)    { return nodes[node].is_link(Bus); }
00066   bool subway(int node) { return nodes[node].is_link(Subway); }
00067 
00068   bool taxi(int fromNode, int toNode)
00069     { return nodes[fromNode].is_link(toNode, Taxi); }
00070 
00071   bool bus(int fromNode, int toNode)
00072     { return nodes[fromNode].is_link(toNode, Bus); }
00073 
00074   bool subway(int fromNode, int toNode)
00075     { return nodes[fromNode].is_link(toNode, Subway); }
00076 
00077   vect vehicle(int fromNode, int toNode)
00078     { return nodes[fromNode].find_vector(toNode); }
00079 };
00080 
00081 
00082 extern Map theMap;
00083 
00084 
00085 #endif
00086 
00087 
00088 
00089 
00090 

Generated on Sun Jul 6 23:07:15 2003 for Scotland Yard by doxygen1.2.15