gcspy.interpreter
Class Interpreter

java.lang.Object
  extended by gcspy.comm.CommandStream
      extended by gcspy.interpreter.Interpreter
Direct Known Subclasses:
ClientInterpreter, ServerInterpreter

public abstract class Interpreter
extends CommandStream

Facilities shared by the client and server interpreters

Author:
Tony Printezis

Nested Class Summary
protected  class Interpreter.BootstrapParameters
          Inner Classes
 
Field Summary
protected  Client client
          The client
protected static byte CONTROL_CMD
          Start new control stream command
protected static int DEFAULT_MAX_LEN
           
protected static byte EVENT_CMD
          Event occurred command
protected static byte EVENT_COUNT_CMD
          Event count command
protected static byte EVENT_FILTERS_CMD
          Event filters command
protected  int[] eventCount
          Counts of each event
protected  EventFilters eventFilters
          The event filters
protected  Events events
          The events
protected  java.lang.String generalInfo
          General information presented to the client
protected  java.lang.String name
          The name of the interpreter
protected static byte PAUSE_CMD
          Server has paused command
protected static byte PAUSE_REQ_CMD
          Client has requested pause command
protected static byte PLAY_ONE_CMD
          Client has requested play one event command
protected static byte RESTART_CMD
          Client has requested restart command
protected static byte SHUTDOWN_CMD
          Server has shut down command
protected static byte SHUTDOWN_REQ_CMD
          Client has requested shutdown command
protected static byte SPACE_CMD
          Space command
protected static byte SPACE_INFO_CMD
          Space information command
protected  int spaceNum
          The number of spaces
protected  Space[] spaces
          The spaces
protected static byte STREAM_CMD
          Start new stream command
protected static byte SUMMARY_CMD
          Summary information command
 
Fields inherited from class gcspy.comm.CommandStream
cmds, FIRST_AVAILABLE_CMD, max, output
 
Constructor Summary
Interpreter()
          Create an interpreter
Interpreter(java.lang.String name)
          Create an interpreter
 
Method Summary
 void deserialise(BufferedInput input)
          S Deserialise the space number, the general information and the events
 void deserialiseEverything(InputGenerator generator)
          Deserialise everything (space number, general information, events, spaces)
 void dump()
          Debugging
 void dumpSpaces()
           
 int[] getEventCount()
          Get the counts for each event
 EventFilters getEventFilters()
          Get the event filters
 Events getEvents()
          Get the events
 java.lang.String getGeneralInfo()
          Get the general information for this interpreter
 java.lang.String getName()
          Get the interpreter's name
 Space getSpace(int i)
          Return a space
 int getSpaceNum()
          Get the number of spaces
protected  void println(int type, java.lang.String text)
          Print a message
protected  void receiveBootInfo(boolean server, Interpreter.BootstrapParameters params)
          Receive boot information
protected  void sendBootInfo(boolean server, Interpreter.BootstrapParameters params)
          Send boot information
protected  void sendSingleCommand(byte cmd)
          Send a single command
 void serialise(BufferedOutput output)
          Serialise the space number, the general information and the events
 void serialiseEverything(OutputGenerator generator)
          Serialise everything (space number, general information, events, spaces)
 void setEventCount(int[] eventCount)
          Set the event counts
 void setGeneralInfo(java.lang.String generalInfo)
          Set the general information
 void setSpace(Space space)
          Set one space
protected  void setupEventCount()
          Setup counts of events for all events
protected  void setupEventFilters()
          Setup the event filters for all events
 void setVerbose(boolean v)
          Set verbosity
 
Methods inherited from class gcspy.comm.CommandStream
execute, finish, finish, getCmd, putCmd, putCmd, setBufferedOutput, start, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_LEN

protected static final int DEFAULT_MAX_LEN
See Also:
Constant Field Values

name

protected java.lang.String name
The name of the interpreter


client

protected Client client
The client


spaces

protected Space[] spaces
The spaces


spaceNum

protected int spaceNum
The number of spaces


events

protected Events events
The events


eventFilters

protected EventFilters eventFilters
The event filters


eventCount

protected int[] eventCount
Counts of each event


generalInfo

protected java.lang.String generalInfo
General information presented to the client


PAUSE_REQ_CMD

protected static final byte PAUSE_REQ_CMD
Client has requested pause command

See Also:
Constant Field Values

PAUSE_CMD

protected static final byte PAUSE_CMD
Server has paused command

See Also:
Constant Field Values

RESTART_CMD

protected static final byte RESTART_CMD
Client has requested restart command

See Also:
Constant Field Values

PLAY_ONE_CMD

protected static final byte PLAY_ONE_CMD
Client has requested play one event command

See Also:
Constant Field Values

SHUTDOWN_REQ_CMD

protected static final byte SHUTDOWN_REQ_CMD
Client has requested shutdown command

See Also:
Constant Field Values

SHUTDOWN_CMD

protected static final byte SHUTDOWN_CMD
Server has shut down command

See Also:
Constant Field Values

STREAM_CMD

protected static final byte STREAM_CMD
Start new stream command

See Also:
Constant Field Values

EVENT_CMD

protected static final byte EVENT_CMD
Event occurred command

See Also:
Constant Field Values

CONTROL_CMD

protected static final byte CONTROL_CMD
Start new control stream command

See Also:
Constant Field Values

EVENT_FILTERS_CMD

protected static final byte EVENT_FILTERS_CMD
Event filters command

See Also:
Constant Field Values

EVENT_COUNT_CMD

protected static final byte EVENT_COUNT_CMD
Event count command

See Also:
Constant Field Values

SUMMARY_CMD

protected static final byte SUMMARY_CMD
Summary information command

See Also:
Constant Field Values

SPACE_INFO_CMD

protected static final byte SPACE_INFO_CMD
Space information command

See Also:
Constant Field Values

SPACE_CMD

protected static final byte SPACE_CMD
Space command

See Also:
Constant Field Values
Constructor Detail

Interpreter

public Interpreter()
Create an interpreter


Interpreter

public Interpreter(java.lang.String name)
Create an interpreter

Parameters:
name - The nane of the interpreter
Method Detail

setVerbose

public void setVerbose(boolean v)
Set verbosity

Parameters:
v - verbosity on/off

setEventCount

public void setEventCount(int[] eventCount)
Set the event counts

Parameters:
eventCount - The event counts

setGeneralInfo

public void setGeneralInfo(java.lang.String generalInfo)
Set the general information

Parameters:
generalInfo - the general information

setSpace

public void setSpace(Space space)
Set one space

Parameters:
space - the space

getName

public java.lang.String getName()
Get the interpreter's name

Returns:
the name of the interpreter

getSpaceNum

public int getSpaceNum()
Get the number of spaces

Returns:
the number of spaces

getSpace

public Space getSpace(int i)
Return a space

Parameters:
i - The space's ID
Returns:
the space with this ID

getEvents

public Events getEvents()
Get the events

Returns:
the events

getEventFilters

public EventFilters getEventFilters()
Get the event filters

Returns:
the event filterss

getEventCount

public int[] getEventCount()
Get the counts for each event

Returns:
the numbers of events

getGeneralInfo

public java.lang.String getGeneralInfo()
Get the general information for this interpreter

Returns:
the general information

sendSingleCommand

protected void sendSingleCommand(byte cmd)
                          throws java.io.IOException
Send a single command

Parameters:
cmd - the command to send
Throws:
java.io.IOException

println

protected void println(int type,
                       java.lang.String text)
Print a message

Parameters:
type - 0 for server, 1 for client
text - the message

sendBootInfo

protected void sendBootInfo(boolean server,
                            Interpreter.BootstrapParameters params)
                     throws java.io.IOException
Send boot information

Parameters:
server - True if this is the server
params - the BootStrapParameters
Throws:
java.io.IOException

receiveBootInfo

protected void receiveBootInfo(boolean server,
                               Interpreter.BootstrapParameters params)
                        throws java.io.IOException
Receive boot information

Parameters:
server - True if this is the server
params - the BootStrapParameters
Throws:
java.io.IOException
InterpreterException - if magic string or endianness do not match

serialise

public void serialise(BufferedOutput output)
Serialise the space number, the general information and the events

Parameters:
output - the BufferedOutput on which to serialise

deserialise

public void deserialise(BufferedInput input)
S Deserialise the space number, the general information and the events

Parameters:
input - the BufferedInput from which to deserialise

serialiseEverything

public void serialiseEverything(OutputGenerator generator)
                         throws java.io.IOException
Serialise everything (space number, general information, events, spaces)

Parameters:
generator - A generator that will create a new BufferedOutput
Throws:
java.io.IOException

deserialiseEverything

public void deserialiseEverything(InputGenerator generator)
                           throws java.io.IOException
Deserialise everything (space number, general information, events, spaces)

Parameters:
generator - A generator that will create a new BufferedInput
Throws:
java.io.IOException

dump

public void dump()
Debugging


dumpSpaces

public void dumpSpaces()

setupEventFilters

protected void setupEventFilters()
Setup the event filters for all events


setupEventCount

protected void setupEventCount()
Setup counts of events for all events