Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Agent Class Reference

#include <agent.h>

Collaboration diagram for Agent:

Collaboration graph
[legend]
List of all members.

Public Methods

 Agent (Client *, const Point3d &position, const char *creationMessage, unsigned long int messageSize)
 Creates an empty agent. The Client pointer is the agent owner.

 Agent (Client *, Cylinder *, const char *creationMessage, unsigned long int messageSize)
 Creates an agent based on a cylinder and it's old-agent properties.

 ~Agent ()
 Destroy the client.

void receiveMessage (unsigned long int _agentId, const char *message, unsigned long int size)
 Receives a message from another agent.

bool into (BoundingBox &bbox)
 Checks if the agent is in the bounding box.

vector< Cylinder * > performActions ()
 Performs desired intentions, as each cylinder can have only one.

some gets
some properties that can be consulted

unsigned long int getId (void)
ClientgetClient ()
short int getCylinderCount (bool increment=false)
 Returns (and maybe generate) a new cylinder id.

short int getNumCylinders (void)
Cylinderoperator() (unsigned short int i)
 Get the specified cylinder. By number (see numCylinders()).

Cylinderoperator[] (unsigned short int i)
 Get specified cylinder by id.

WorldgetWorld ()

Protected Attributes

unsigned long int id
 The id of the actual agent.

Cylindercylinder
Clientclient
short int cylinderCount

Static Protected Attributes

unsigned long int agentMaxId = 0

Detailed Description

The agents are the organisms of this world. They are composed of cylinders; It have a maximum of 256 cylinders (as array for speed). One cylinder is created at constructor time.

Definition at line 40 of file agent.h.


Constructor & Destructor Documentation

Agent::Agent Client   _client,
const Point3d &    _position,
const char *    creationMessage,
unsigned long int    messageSize
 

Creates an empty agent. The Client pointer is the agent owner.

Creates an empty agent; default sizes and energies, position... Just to begin an agentClient

Definition at line 37 of file agent.cc.

References agentMaxId, client, cylinder, cylinderCount, getId(), baseClient::getWorld(), id, messageNewAgent, Cylinder::movePosition(), Point3d, Client::sendMessage(), and Cylinder::setNewAgent().

Agent::Agent Client   cli,
Cylinder   cyl,
const char *    creationMessage,
unsigned long int    messageSize
 

Creates an agent based on a cylinder and it's old-agent properties.

Creates an Agent based on a dropCylinder cylinder drop. Position, energy... all is deduced from cylinder

Definition at line 56 of file agent.cc.

References agentMaxId, client, cylinder, cylinderCount, getId(), id, log, messageNewAgent, Client::sendMessage(), and Cylinder::setNewAgent().

Agent::~Agent  
 

Destroy the client.

Definition at line 71 of file agent.cc.

References cylinder.


Member Function Documentation

Client* Agent::getClient   [inline]
 

Definition at line 71 of file agent.h.

Referenced by World::newAgent().

short int Agent::getCylinderCount bool    increment = false [inline]
 

Returns (and maybe generate) a new cylinder id.

Definition at line 73 of file agent.h.

References cylinderCount.

Referenced by Cylinder::Cylinder(), and Client::newCylinder().

unsigned long int Agent::getId void    [inline]
 

Definition at line 70 of file agent.h.

References id.

Referenced by Agent(), and Cylinder::sendMessage().

short int Agent::getNumCylinders void    [inline]
 

Definition at line 74 of file agent.h.

References Cylinder::getNumCylinders().

World * Agent::getWorld void   
 

Return the world in which the agent lives

Definition at line 97 of file agent.cc.

References client, and baseClient::getWorld().

bool Agent::into BoundingBox   bbox [inline]
 

Checks if the agent is in the bounding box.

Definition at line 86 of file agent.h.

References BoundingBox::contains(), and Cylinder::getPosition().

Cylinder* Agent::operator() unsigned short int    i [inline]
 

Get the specified cylinder. By number (see numCylinders()).

Definition at line 76 of file agent.h.

Cylinder* Agent::operator[] unsigned short int    i [inline]
 

Get specified cylinder by id.

Definition at line 78 of file agent.h.

vector< Cylinder * > Agent::performActions  
 

Performs desired intentions, as each cylinder can have only one.

Performs the actions that cylinders said they wanted to perform.

As usually this involves energy consumption, a list of energy cylinders created is returned

Definition at line 81 of file agent.cc.

References Cylinder::performAction().

void Agent::receiveMessage unsigned long int    _agentId,
const char *    message,
unsigned long int    size
 

Receives a message from another agent.

Referenced by Cylinder::sendMessage().


Member Data Documentation

unsigned long int Agent::agentMaxId = 0 [static, protected]
 

Max id reached by agents. Each new agent need to have a brand new id

Definition at line 31 of file agent.cc.

Referenced by Agent().

Client* Agent::client [protected]
 

The client to which the agent belongs

Definition at line 51 of file agent.h.

Referenced by Agent(), and getWorld().

Cylinder* Agent::cylinder [protected]
 

The parent cylinder in the agent, all the rest cylinder hangs from it

Definition at line 49 of file agent.h.

Referenced by Agent(), and ~Agent().

short int Agent::cylinderCount [protected]
 

The count of cylinders, if a new cylinder is created in this agent this number increases, and the old number is returned.

Definition at line 56 of file agent.h.

Referenced by Agent(), and getCylinderCount().

unsigned long int Agent::id [protected]
 

The id of the actual agent.

Definition at line 46 of file agent.h.

Referenced by Agent(), and getId().


The documentation for this class was generated from the following files:
Generated on Mon Jun 17 19:54:12 2002 for Svas Server by doxygen1.2.16