gecco.server.qmanager
Class QManager

java.lang.Object
  |
  +--gecco.server.qmanager.QManager
All Implemented Interfaces:
Runnable

public class QManager
extends Object
implements Runnable

This class manages the queue of AutomatonEvents and QueuedAutomatons.

Author:
Henrik Bäärnielm, Karl Hasselström, Henrik Hägerström

Field Summary
(package private)  AutomatonMap aMap
          Description of the Field
private  TreeSet automatonQueue
          Description of the Field
private  LinkedList eventQueue
          Description of the Field
private  HashMap timeToAutomatonMap
          Description of the Field
 
Constructor Summary
QManager(AutomatonMap aMap)
          Constructor for the QManager object
 
Method Summary
 void addEventToQueue(AutomatonEvent event, int x, int y)
          Adds an event to the event queue
private  void addUpdateToQueue(int x, int y, long msToExecution)
          Adds an automaton to the automaton queue.
private  void checkAutomatonReturn(AutomatonReturn autRet, int x, int y)
          Checks the return from an automaton update method, and possibly inserts the automaton and its neighbours into the queue.
static void debug(String s)
          Outputs to stdout.
 LinkedList getAutomatonEventQueue()
          Gets the queue of AutomatonEvents
 TreeSet getAutomatonQueue()
          Gets the queue of automatons
 long getCurrentTime()
          Gets the current system time.
static void log(String s)
          Prints to the system log.
 void run()
          Main processing method for the QManager object
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

aMap

AutomatonMap aMap
Description of the Field

automatonQueue

private TreeSet automatonQueue
Description of the Field

timeToAutomatonMap

private HashMap timeToAutomatonMap
Description of the Field

eventQueue

private LinkedList eventQueue
Description of the Field
Constructor Detail

QManager

public QManager(AutomatonMap aMap)
Constructor for the QManager object
Parameters:
aMap - A reference to the AutomatonMap
Method Detail

getAutomatonQueue

public TreeSet getAutomatonQueue()
Gets the queue of automatons
Returns:
The queue

getAutomatonEventQueue

public LinkedList getAutomatonEventQueue()
Gets the queue of AutomatonEvents
Returns:
The queue

getCurrentTime

public long getCurrentTime()
Gets the current system time.
Returns:
The current system time.

addEventToQueue

public void addEventToQueue(AutomatonEvent event,
                            int x,
                            int y)
Adds an event to the event queue
Parameters:
event - The event to be added.
x - The x coordinate of the position of the event.
y - The y coordinate of the position of the event.

run

public void run()
Main processing method for the QManager object
Specified by:
run in interface Runnable

addUpdateToQueue

private void addUpdateToQueue(int x,
                              int y,
                              long msToExecution)
Adds an automaton to the automaton queue.
Parameters:
x - The x coordinate of the automaton.
y - The y coordinate of the automaton.
msToExecution - The time until the automaton should be updated.

checkAutomatonReturn

private void checkAutomatonReturn(AutomatonReturn autRet,
                                  int x,
                                  int y)
Checks the return from an automaton update method, and possibly inserts the automaton and its neighbours into the queue.
Parameters:
autRet - The return object from the update method.
x - The x coordinate of the automaton that was updated.
y - The y coordinate of the automaton that was updated.

log

public static void log(String s)
Prints to the system log.
Parameters:
s - The message to print.

debug

public static void debug(String s)
Outputs to stdout.
Parameters:
s - The message to output.