gps.protocol
Class Agent

java.lang.Object
  extended by gps.protocol.Agent
All Implemented Interfaces:
SimEventHandler
Direct Known Subclasses:
Peer, Server

public class Agent
extends java.lang.Object
implements SimEventHandler

Agent base class, all specific protocol agents inherit from it.

Version:
1.2, 6/20/2005
Author:
Weishuai Yang

Constructor Summary
Agent()
          constructs a new Agent object with next available id
Agent(int i)
          constructs a new Agent object with giving id
 
Method Summary
 void agentDraw(java.awt.Graphics g, int x, int y)
          do some agent specific drawing on the graph to be implemented in sub class
 void attachTo(Node n)
          attach this agent to a node
 int getID()
          gets agent id, agent id is different from node id
 Node getNode()
          gets the node that this agent is attached to
 boolean handle(SimEvent e)
          handles agent level event
 boolean isActive()
          check activity
 void reset()
          dettach from the node
 java.lang.String toString()
          generates string description
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Agent

public Agent()
constructs a new Agent object with next available id


Agent

public Agent(int i)
constructs a new Agent object with giving id

Method Detail

getID

public int getID()
gets agent id, agent id is different from node id

Returns:
id

attachTo

public void attachTo(Node n)
attach this agent to a node

Parameters:
n - the node to be attached

getNode

public Node getNode()
gets the node that this agent is attached to

Returns:
the node

agentDraw

public void agentDraw(java.awt.Graphics g,
                      int x,
                      int y)
do some agent specific drawing on the graph to be implemented in sub class


isActive

public boolean isActive()
check activity

Returns:
true if activated

handle

public boolean handle(SimEvent e)
handles agent level event

Specified by:
handle in interface SimEventHandler
Parameters:
e - the event to be handled
Returns:
true if already handled

toString

public java.lang.String toString()
generates string description

Overrides:
toString in class java.lang.Object
Returns:
string description

reset

public void reset()
dettach from the node