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

MapNode Class Reference

#include <mapnode.h>

List of all members.

Public Methods

 MapNode (void)
 ~MapNode ()
void get_name (char *, int)
void get_link (int, mode)
void get_join (int join)
bool is_link (mode)
bool is_link (int, mode)
vect find_vector (int)
int find_link (int)
int find_join (int link, int join)
char * find_name (int link)
int num_joins (int link)
void show_node (void)

Public Attributes

int x
int y
int numLinks
int numJoins

Private Attributes

Routelinks
char * name


Constructor & Destructor Documentation

MapNode::MapNode void    [inline]
 

Definition at line 34 of file mapnode.h.

References name, and numLinks.

00034 { numLinks= 0; links= NULL; name= NULL; }

MapNode::~MapNode   [inline]
 

Definition at line 35 of file mapnode.h.

References name.

00035 { delete [] links;  delete name; }


Member Function Documentation

int MapNode::find_join int    link,
int    join
[inline]
 

Definition at line 46 of file mapnode.h.

References Route::find_join().

Referenced by Map::connected_to().

00046 { return links[link].find_join(join); }

int MapNode::find_link int   
 

Definition at line 54 of file mapnode.c.

References between(), Route::destination, links, and numLinks.

Referenced by Map::connected_to().

00054                                    {
00055   if ( between(linkNum, 0, numLinks) ) return links[linkNum].destination;
00056   else {
00057     cerr << "Link " << linkNum << " out of range ("
00058          << 0 << ".." << numLinks << ")\n";
00059     return 0;  // node 0 points to NULL
00060   }
00061 }

char* MapNode::find_name int    link [inline]
 

Definition at line 47 of file mapnode.h.

References name.

Referenced by Map::get_name().

00047 { return name; }

vect MapNode::find_vector int   
 

Definition at line 42 of file mapnode.c.

References Route::destination, links, Route::type, and vect.

Referenced by Map::vehicle().

00042                                    {
00043 // Return the bit vector of a given link
00044 
00045   int i= 0;
00046 
00047   while (link != links[i].destination) i++;  // find the link...
00048   // ...and return its bit vector
00049   return links[i].type;
00050 }

void MapNode::get_join int    join [inline]
 

Definition at line 39 of file mapnode.h.

References numLinks.

Referenced by Map::get_field().

00040     { if (numLinks > 0) links[numLinks-1].get_join(join); }

void MapNode::get_link int   ,
mode   
 

Definition at line 77 of file mapnode.c.

References Route::destination, links, mode, numLinks, On, and Route::type.

Referenced by Map::get_field().

00077                                                      {
00078 // Input a link and establish its "transportation" type in the bit
00079 // vector
00080 
00081   Route *oldLinks= links;
00082   int   num= 0;
00083 
00084   if (numLinks > 0)
00085     while ((node != links[num].destination) && (num < numLinks)) num++;
00086 
00087   if (num >= numLinks) {
00088     num= numLinks;
00089 
00090     links= new Route[++numLinks];
00091     assert( links != 0 );
00092 
00093     for (int i= 0; i < num; i++)
00094       links[i]= oldLinks[i];  // copy the array 
00095 
00096     links[num].destination= node;
00097   }
00098   // turn transportation bit on
00099   links[num].type |= On << transportation;
00100 }

void MapNode::get_name char *   ,
int   
 

Definition at line 66 of file mapnode.c.

References name.

Referenced by Map::load_map().

00066                                                 {
00067 // Input a node name (if one exists) of size "size"
00068 
00069   if (size > 1) {
00070     name= new char[size];
00071     for (int i= 0; i < size; i++) name[i]= nodeName[i];
00072   }
00073 }

bool MapNode::is_link int   ,
mode   
 

Definition at line 30 of file mapnode.c.

References Route::destination, links, mode, On, and Route::type.

00030                                                     {
00031 // Determine if node is a taxi link
00032 
00033   int i= 0;
00034  
00035   while (link != links[i].destination) i++;  // find the link...
00036   // ...and return whether its transportation bit is on or off
00037   return (links[i].type & On << transportation);
00038 }

bool MapNode::is_link mode   
 

Definition at line 18 of file mapnode.c.

References False, links, mode, numLinks, On, True, and Route::type.

Referenced by Map::bus(), Map::subway(), and Map::taxi().

00018                                           {
00019 
00020   int i= 0;
00021 
00022   // if bit vector "transportation" is on...
00023   while ( (i < numLinks) && !(links[i].type & On << transportation) ) i++;
00024   // ...then "i" should be less than numLinks so return True, else False
00025   return (i < numLinks) ? True : False;
00026 }

int MapNode::num_joins int    link [inline]
 

Definition at line 49 of file mapnode.h.

References Route::numJoins.

Referenced by Map::num_connections().

00049 { return links[link].numJoins; }

void MapNode::show_node void   
 

Definition at line 104 of file mapnode.c.

References Bus, Route::destination, links, name, numLinks, On, Subway, Taxi, Route::type, x, and y.

Referenced by Map::show_map().

00104                              {
00105 // Output a node in a tabular (sort of) format for debugging purposes
00106 
00107   int i;
00108 
00109   cout << "\nTaxi: ";
00110   for (i= 0; i < numLinks; i++)  // find all taxi routes
00111     if (links[i].type & On << Taxi) cout << ' ' << links[i].destination;
00112   cout << "\nBus: ";
00113   for (i= 0; i < numLinks; i++)  // find all bus routes
00114     if (links[i].type & On << Bus) cout << ' ' << links[i].destination;
00115   cout << "\nSubway: ";
00116   for (i= 0; i < numLinks; i++)  // find all subway routes
00117     if (links[i].type & On << Subway) cout << ' ' << links[i].destination;
00118   cout << "\nAll:  ";
00119   for (i= 0; i < numLinks; i++)  // show all routes and (bit vector)s
00120     cout << links[i].destination << " (" << links[i].type << ") ";
00121   cout << "\nName: ``";
00122   if (name == NULL) cout << "(null)";
00123   else cout << name;
00124   cout << "''\n";
00125   cout << "x: " << x << "   y: " << y << "\n";
00126 }


Member Data Documentation

Route* MapNode::links [private]
 

Definition at line 26 of file mapnode.h.

Referenced by find_link(), find_vector(), get_link(), is_link(), and show_node().

char* MapNode::name [private]
 

Definition at line 27 of file mapnode.h.

Referenced by find_name(), get_name(), MapNode(), show_node(), and ~MapNode().

int MapNode::numJoins
 

Definition at line 30 of file mapnode.h.

int MapNode::numLinks
 

Definition at line 30 of file mapnode.h.

Referenced by find_link(), get_join(), get_link(), is_link(), MapNode(), Map::num_connections(), and show_node().

int MapNode::x
 

Definition at line 30 of file mapnode.h.

Referenced by Map::load_map(), show_node(), and Map::x().

int MapNode::y
 

Definition at line 30 of file mapnode.h.

Referenced by Map::load_map(), show_node(), and Map::y().


The documentation for this class was generated from the following files:
Generated on Sun Jul 6 23:07:17 2003 for Scotland Yard by doxygen1.2.15