/* station.h
 *
 * The station class.  A passenger arrives at a station and, according
 * to the passenger's destination, is moved onto one of the station's
 * platforms.  The station maintains an array of (destination,platform)
 * pairs to determine which platform the passenger goes to.
 */

#ifndef STATION_H
#define STATION_H

#include <string.h>
#include "seq.h"


class Platform;
class Passenger;
class Station;


class Station {

  friend void setupNetwork(char *c); // setupNetwork() can initialize
  friend class Statistics;

  seq<Platform*> destPlatforms;	// platform to wait on for a particular destination
  seq<float>     means;		// mean arrival time for a particular destination
  seq<Station*>  nextStation;	// next transfer station for a particular destination

  static int nextIdent;		// for generating identifiers
  int index;			// index in allStations array

public:

  char *name;			// name of station

  // Constructor

  Station( char *stationName ) {
    if (stationName != NULL)
      stationName = strdup(stationName);
    name = stationName;
    index = nextIdent++;
  }

  // Receive a passenger, p, into the station.  The passenger is moved
  // to the appropriate platform based on the passenger's destination

  void receivePassenger( Passenger *p );

  // Schedule the next appearance of a passenger at this station

  void scheduleNextAppearance( Station *destStation );

  // Output operators

  void draw();

  friend ostream& operator << ( ostream& stream, Station const &s ) {
    if (&s == NULL)
      stream << "(null)";
    else
      stream << s.name;
    return stream;
  }
};

#endif
