jfreerails.server
Class TrainPathFinder

java.lang.Object
  extended by jfreerails.server.TrainPathFinder
All Implemented Interfaces:
java.io.Serializable, ServerAutomaton, FreerailsIntIterator

public class TrainPathFinder
extends java.lang.Object
implements FreerailsIntIterator, ServerAutomaton

This class provides methods that generate a path to a target as a series of PositionOnTrack objects encoded as ints, it also deals with stops at stations.

Author:
Luke Lindsay 28-Nov-2002
See Also:
Serialized Form

Field Summary
private  MoveReceiver mr
           
private  SimpleAStarPathFinder pathFinder
           
private  FreerailsPrincipal principal
           
private static long serialVersionUID
           
private  TrainStopsHandler stopsHandler
           
private  FlatTrackExplorer trackExplorer
           
private  int trainId
           
(package private)  ReadOnlyWorld w
           
 
Constructor Summary
TrainPathFinder(FlatTrackExplorer tx, ReadOnlyWorld w, int trainNumber, MoveReceiver newMr, FreerailsPrincipal p)
           
 
Method Summary
 boolean hasNextInt()
           
 void initAutomaton(MoveReceiver newMr)
          Initializes the automaton with a connection to the MoveExecuter.
(package private)  boolean isTrainMoving()
           
 int nextInt()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

pathFinder

private final SimpleAStarPathFinder pathFinder

principal

private final FreerailsPrincipal principal

stopsHandler

private final TrainStopsHandler stopsHandler

trackExplorer

private final FlatTrackExplorer trackExplorer

trainId

private final int trainId

mr

private transient MoveReceiver mr

w

ReadOnlyWorld w
Constructor Detail

TrainPathFinder

public TrainPathFinder(FlatTrackExplorer tx,
                       ReadOnlyWorld w,
                       int trainNumber,
                       MoveReceiver newMr,
                       FreerailsPrincipal p)
Method Detail

hasNextInt

public boolean hasNextInt()
Specified by:
hasNextInt in interface FreerailsIntIterator

initAutomaton

public void initAutomaton(MoveReceiver newMr)
Description copied from interface: ServerAutomaton
Initializes the automaton with a connection to the MoveExecuter.

Specified by:
initAutomaton in interface ServerAutomaton

isTrainMoving

boolean isTrainMoving()

nextInt

public int nextInt()
Specified by:
nextInt in interface FreerailsIntIterator
Returns:
a PositionOnTrack packed into an int