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

The StorageTrack class implements a storage track. More...

#include <Station.h>

Public Member Functions

 StorageTrack (string name_="Track 0")
 Construct a storage track. More...
 
 ~StorageTrack ()
 Destructor. More...
 
const char * Name () const
 Return the name of the storage track. More...
 
void SetName (string name_)
 Set the storage track's name. More...
 
const OccupiedIncludesTime (double time) const
 Return the occupation that includes the specified time;. More...
 
const OccupiedStoreTrain (string train, double from, double to, string train2)
 Insert train onto storage track for a time. More...
 
bool RemovedStoredTrain (double from, double to)
 Remove stored train. More...
 
bool UsedTimeRange (double from, double to) const
 Return true if the time range is in use. More...
 
const OccupiedFindOccupied (double from, double to) const
 Return occupication structure for a given time tange. More...
 
const OccupiedUpdateStoredTrain (double from, double to, string train)
 Replace a stored arrrival train. More...
 
const OccupiedUpdateStoredTrain2 (double from, double to, string train)
 Replace a stored departure train. More...
 
const OccupiedUpdateStoredTrainArrival (double from, double to, double newArrival)
 Update a train's arrival time. More...
 
const OccupiedUpdateStoredTrainDeparture (double from, double to, double newDeparture)
 Update a train's departure time. More...
 
 StorageTrack (const StorageTrack &other)
 Clone a StorageTrack – copy constructor. More...
 
StorageTrackoperator= (const StorageTrack &other)
 Assign a StorageTrack to another StorageTrack. More...
 
ostream & Write (ostream &stream) const
 Write method. More...
 
istream & Read (istream &stream)
 Read Method. More...
 
OccupiedMap::const_iterator FirstOccupied () const
 Return a const iterator for the first occupation. More...
 
OccupiedMap::const_iterator LastOccupied () const
 Return a const iterator for the last occupation. More...
 

Private Attributes

string name
 Name of the storage track. More...
 
OccupiedMap occupations
 Map of occupations. More...
 

Detailed Description

The StorageTrack class implements a storage track.

Storage tracks store trains at stations. Each storage track can only store one train at a given time. No checks are made to determing if the track is actually long enough for the train.

Each storage track has a name.

Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ StorageTrack() [1/2]

TTSupport::StorageTrack::StorageTrack ( string  name_ = "Track 0")
inline

Construct a storage track.

The name of the track is initialized.

Parameters
name_The name of the storage track.

◆ ~StorageTrack()

TTSupport::StorageTrack::~StorageTrack ( )
inline

Destructor.

◆ StorageTrack() [2/2]

TTSupport::StorageTrack::StorageTrack ( const StorageTrack other)
inline

Clone a StorageTrack – copy constructor.

Parameters
otherThe other StorageTrack.

References name, and occupations.

Member Function Documentation

◆ FindOccupied()

const Occupied* TTSupport::StorageTrack::FindOccupied ( double  from,
double  to 
) const
inline

Return occupication structure for a given time tange.

Parameters
fromThe arrival time.
toThe departure time.

◆ FirstOccupied()

OccupiedMap::const_iterator TTSupport::StorageTrack::FirstOccupied ( ) const
inline

Return a const iterator for the first occupation.

◆ IncludesTime()

const Occupied* TTSupport::StorageTrack::IncludesTime ( double  time) const

Return the occupation that includes the specified time;.

Parameters
timeThe time to check for.

◆ LastOccupied()

OccupiedMap::const_iterator TTSupport::StorageTrack::LastOccupied ( ) const
inline

Return a const iterator for the last occupation.

◆ Name()

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

Return the name of the storage track.

◆ operator=()

StorageTrack& TTSupport::StorageTrack::operator= ( const StorageTrack other)
inline

◆ Read()

istream& TTSupport::StorageTrack::Read ( istream &  stream)

Read Method.

Read object from a stream.

Parameters
streamStream to read from.

◆ RemovedStoredTrain()

bool TTSupport::StorageTrack::RemovedStoredTrain ( double  from,
double  to 
)

Remove stored train.

Parameters
fromThe arrival time.
toThe departure time.

◆ SetName()

void TTSupport::StorageTrack::SetName ( string  name_)
inline

Set the storage track's name.

Parameters
name_The new name of the storage track.

References TTSupport::Occupied::from.

◆ StoreTrain()

const Occupied* TTSupport::StorageTrack::StoreTrain ( string  train,
double  from,
double  to,
string  train2 
)

Insert train onto storage track for a time.

Parameters
trainThe arriving train.
fromThe arrival time.
toThe departure time.
train2The departing train.

◆ UpdateStoredTrain()

const Occupied* TTSupport::StorageTrack::UpdateStoredTrain ( double  from,
double  to,
string  train 
)

Replace a stored arrrival train.

Parameters
fromThe arrival time.
toThe departure time.
trainThe new arriving train.

◆ UpdateStoredTrain2()

const Occupied* TTSupport::StorageTrack::UpdateStoredTrain2 ( double  from,
double  to,
string  train 
)

Replace a stored departure train.

Parameters
fromThe arrival time.
toThe departure time.
trainThe new departing train.

◆ UpdateStoredTrainArrival()

const Occupied* TTSupport::StorageTrack::UpdateStoredTrainArrival ( double  from,
double  to,
double  newArrival 
)

Update a train's arrival time.

Parameters
fromThe arrival time.
toThe departure time.
newArrivalThe new arrival time.

◆ UpdateStoredTrainDeparture()

const Occupied* TTSupport::StorageTrack::UpdateStoredTrainDeparture ( double  from,
double  to,
double  newDeparture 
)

Update a train's departure time.

Parameters
fromThe arrival time.
toThe departure time.
newDepartureThe new departure time.

◆ UsedTimeRange()

bool TTSupport::StorageTrack::UsedTimeRange ( double  from,
double  to 
) const

Return true if the time range is in use.

Parameters
fromThe arrival time.
toThe departure time.

◆ Write()

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

Write method.

Write object to a stream.

Parameters
streamStream to write to.

Member Data Documentation

◆ name

string TTSupport::StorageTrack::name
private

Name of the storage track.

Referenced by operator=(), and StorageTrack().

◆ occupations

OccupiedMap TTSupport::StorageTrack::occupations
private

Map of occupations.

Referenced by operator=(), and StorageTrack().