Model Railroad System  2.2.1
Public Member Functions | Private Attributes | List of all members
TTSupport::Train Class Reference

This class implements a train. More...

#include <Train.h>

Public Member Functions

 Train (TimeTableSystem *timetable=NULL, string name="", string number="", int speed=0, int classnumber=0, int departure=0, int start=0, int end=-1)
 Create and initialize a train object. More...
 
const char * Name () const
 Return the name of the train. More...
 
const char * Number () const
 Return the number (or symbol) of the train. More...
 
int Departure () const
 Return the departure time. More...
 
void SetDeparture (int depart)
 Update departure time. More...
 
int Speed () const
 Return the train's speed. More...
 
int ClassNumber () const
 Return the class number. More...
 
int NumberOfNotes () const
 Number of notes. More...
 
int Note (int i) const
 Return the ith note. More...
 
void AddNoteToTrain (int note)
 Add a note. More...
 
void RemoveNoteFromTrain (int note)
 Remove a note. More...
 
void UpdateStopLayover (int istop, double layover)
 Update stop layover. More...
 
void UpdateStopCab (int istop, Cab *cab)
 Update the cab. More...
 
void AddNoteToStop (int istop, int note)
 Add a note to a stop. More...
 
void RemoveNoteFromStop (int istop, int note)
 Remove a note from a stop. More...
 
void SetOriginStorageTrack (string trackname)
 Set the origin storage track. More...
 
void SetDestinationStorageTrack (string trackname)
 Set the destination storage track. More...
 
void SetTransitStorageTrack (int istop, string trackname)
 Set an intermediate storage track. More...
 
int NumberOfStops () const
 Return the number of stops. More...
 
const StopStopI (int i) const
 Return the ith stop object. More...
 
double StartSMile () const
 Return the start Scale Mile. More...
 
ostream & Write (ostream &stream) const
 Write object to a stream. More...
 
istream & Read (istream &stream, const CabNameMap cabs)
 Read an object from a stream. More...
 

Private Attributes

string name
 Name of the train. More...
 
string number
 Number or symbol of the train;. More...
 
int speed
 The train's speed. More...
 
int classnumber
 The train's class. More...
 
vector< int > notes
 Notes about the train. More...
 
int departure
 Departure time. More...
 
StopVector stops
 The train's stops. More...
 
double startSMile
 Start scale mile. More...
 

Detailed Description

This class implements a train.

A train travels down the track passing or stoping at stations along the way.

Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ Train()

TTSupport::Train::Train ( TimeTableSystem timetable = NULL,
string  name = "",
string  number = "",
int  speed = 0,
int  classnumber = 0,
int  departure = 0,
int  start = 0,
int  end = -1 
)

Create and initialize a train object.

Parameters
timetableThe parent time table object.
nameThe name of the train.
numberThe number (or symbol) of the train.
speedThe maximum (scale) speed of the train.
classnumberThe class of the train.
departureThe train's departure time.
startThe originating station index.
endThe terminating station index.

Member Function Documentation

◆ AddNoteToStop()

void TTSupport::Train::AddNoteToStop ( int  istop,
int  note 
)

Add a note to a stop.

Parameters
istopThe stop number to update.
noteThe note to add.

◆ AddNoteToTrain()

void TTSupport::Train::AddNoteToTrain ( int  note)
inline

Add a note.

Parameters
noteThe note number to add.

References i, and TTSupport::Stop::notes.

◆ ClassNumber()

int TTSupport::Train::ClassNumber ( ) const
inline

Return the class number.

◆ Departure()

int TTSupport::Train::Departure ( ) const
inline

Return the departure time.

◆ Name()

const char* TTSupport::Train::Name ( ) const
inline

Return the name of the train.

◆ Note()

int TTSupport::Train::Note ( int  i) const
inline

Return the ith note.

Returns -1 if the index is out of range.

Parameters
iThe index of the note.

References i, and TTSupport::Stop::notes.

◆ Number()

const char* TTSupport::Train::Number ( ) const
inline

Return the number (or symbol) of the train.

◆ NumberOfNotes()

int TTSupport::Train::NumberOfNotes ( ) const
inline

Number of notes.

References TTSupport::Stop::notes.

◆ NumberOfStops()

int TTSupport::Train::NumberOfStops ( ) const
inline

Return the number of stops.

◆ Read()

istream& TTSupport::Train::Read ( istream &  stream,
const CabNameMap  cabs 
)

Read an object from a stream.

Parameters
streamStream to read from.
cabsThe cab name map.

◆ RemoveNoteFromStop()

void TTSupport::Train::RemoveNoteFromStop ( int  istop,
int  note 
)

Remove a note from a stop.

Parameters
istopThe stop number to update.
noteThe note to remove.

◆ RemoveNoteFromTrain()

void TTSupport::Train::RemoveNoteFromTrain ( int  note)
inline

Remove a note.

Parameters
noteThe note number to remove.

References TTSupport::Stop::cab, TTSupport::Stop::layover, and TTSupport::Stop::notes.

◆ SetDeparture()

void TTSupport::Train::SetDeparture ( int  depart)
inline

Update departure time.

Parameters
departThe new departure time.

◆ SetDestinationStorageTrack()

void TTSupport::Train::SetDestinationStorageTrack ( string  trackname)

Set the destination storage track.

Parameters
tracknameThe terminating storage track name.

◆ SetOriginStorageTrack()

void TTSupport::Train::SetOriginStorageTrack ( string  trackname)

Set the origin storage track.

Parameters
tracknameThe originating storage track name.

◆ SetTransitStorageTrack()

void TTSupport::Train::SetTransitStorageTrack ( int  istop,
string  trackname 
)

Set an intermediate storage track.

Parameters
istopThe stop index.
tracknameThe intermediate storage track name.

◆ Speed()

int TTSupport::Train::Speed ( ) const
inline

Return the train's speed.

◆ StartSMile()

double TTSupport::Train::StartSMile ( ) const
inline

Return the start Scale Mile.

References TTSupport::Stop::Read(), lcc::stream, and TTSupport::Stop::Write().

◆ StopI()

const Stop* TTSupport::Train::StopI ( int  i) const
inline

Return the ith stop object.

Returns NULL if the index is out of range.

Parameters
iThe index of the stop.

References i.

◆ UpdateStopCab()

void TTSupport::Train::UpdateStopCab ( int  istop,
Cab cab 
)

Update the cab.

Parameters
istopThe stop number to update.
cabThe new cab.

◆ UpdateStopLayover()

void TTSupport::Train::UpdateStopLayover ( int  istop,
double  layover 
)

Update stop layover.

Parameters
istopThe stop number to update.
layoverThe new layover time.

◆ Write()

ostream& TTSupport::Train::Write ( ostream &  stream) const

Write object to a stream.

Parameters
streamStream to write to.

Member Data Documentation

◆ classnumber

int TTSupport::Train::classnumber
private

The train's class.

◆ departure

int TTSupport::Train::departure
private

Departure time.

◆ name

string TTSupport::Train::name
private

Name of the train.

◆ notes

vector<int> TTSupport::Train::notes
private

Notes about the train.

◆ number

string TTSupport::Train::number
private

Number or symbol of the train;.

◆ speed

int TTSupport::Train::speed
private

The train's speed.

◆ startSMile

double TTSupport::Train::startSMile
private

Start scale mile.

◆ stops

StopVector TTSupport::Train::stops
private

The train's stops.