00001 /************************************************************************* 00002 * FILE: moves.h 00003 * AUTHOR: CAL 00004 * DATE: 29 April 1993 00005 * PURPOSE: 00006 * Declares a struct which represents a move: a destination 00007 * node and a mode of transportation. 00008 * The struct can also be used to represent the connections between 00009 * any two nodes, because the transportation is a bit vector. 00010 **************************************************************************/ 00011 00012 #ifndef _MOVE_H 00013 #define _MOVE_H 00014 00015 #include "typedefs.h" 00016 00017 00018 /********************************************************************** 00019 * Token Types 00020 ***********************************************************************/ 00021 00022 typedef enum mode TokenType; 00023 const byte NTokenTypes = 3; 00024 00025 00026 /********************************************************************** 00027 * STRUCT: Move 00028 ***********************************************************************/ 00029 00030 struct Move { 00031 int Source; // Source node; 00032 int Node; // Destination node 00033 byte Trans; // Transportation type (bit vector) 00034 Move* Next; // (for linking) 00035 Move (void) { Source = Node = Trans = 0; Next = 0; } 00036 Move (int s, int n, int t) 00037 { Source = s; Node = n; Trans = t; Next = 0; } 00038 int operator == (Move& m) 00039 { return ((Source==m.Source)&&(Node==m.Node)&&(Trans==m.Trans)); } 00040 int operator != (Move& m) 00041 { return ((Source!=m.Source)||(Node!=m.Node)||(Trans!=m.Trans)); } 00042 ~Move (void) { delete Next; } 00043 }; 00044 00045 const Move NullMove; 00046 00047 /********************************************************************** 00048 * Bit Masks 00049 * 00050 * To set bit: 00051 * Trans |= <Mask> 00052 * Or, to change entire vector: 00053 * Trans = <Mask1> | <Mask2> | ... 00054 * To check whether bit is set: 00055 * (bool) Trans & <Mask> 00056 * 00057 * Where <Mask> is one of the following bit masks: 00058 ***********************************************************************/ 00059 00060 const byte TaxiMask = 0x01; 00061 const byte BusMask = 0x02; 00062 const byte SubwayMask = 0x04; 00063 00064 00065 /********************************************************************** 00066 * CLASS: MoveList 00067 ***********************************************************************/ 00068 00069 class MoveList 00070 { 00071 Move *First; 00072 Move *Last; 00073 Move *Current; 00074 int Len; 00075 void Insert (Move *a); 00076 public: 00077 MoveList () { First = Last = Current = 0; Len = 0;} 00078 ~MoveList () { Nuke (); } 00079 void Append (Move *a); 00080 Move* GetCurrent (void) { return Current; } 00081 Move* GetLast (void) { return Last; } 00082 bool Reset (void); 00083 bool Next (void); 00084 int Length (void) { return Len; } 00085 void Nuke (void); 00086 }; 00087 00088 00089 #endif