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

CommCenter Class Reference

#include <commcenter.h>

Collaboration diagram for CommCenter:

Collaboration graph
[legend]
List of all members.

Public Methods

 CommCenter ()
 ~CommCenter ()
void loop ()
void getMessages ()
ClientgetClientForMigration (string name)

Protected Methods

New Conections
Methods to create new conections, or wait if there is not pending conection

void newClient ()
void newGraphicClient ()
void newControlClient ()
void newServer ()
Parts of the Main Thread Loop
The main loop makes several tasks. Each of this methos is one of these tasks

void checkForConections ()
void checkForDeadClients ()
void removeDeadClients ()
void waitForClients ()
void makeMovements ()

Protected Attributes

vector< baseClient * > clients
Worldworld
 The world that this commcenter controls.

map< string, vector< Client * >,
less< string > > 
clientMap
 A dictionary of name of AgentClients and lists of AgentClients.

Ports
Ports that wait for incomming connections, that later are redirected to channels

ost::TCPSocket * clientPort
ost::TCPSocket * graphicClientPort
ost::TCPSocket * controlClientPort
ost::TCPSocket * serverPort

Detailed Description

The communication center open several ports to accept incomming conections, and when a new conection arrives, it redirects it to the client creator (newClient, newGraphicClient...), which creates a thread with the client, and go back to the check-for-new-conections loop.

Definition at line 47 of file commcenter.h.


Constructor & Destructor Documentation

CommCenter::CommCenter  
 

Creates the communication center. It opens several ports to accept incomming conections; these ports include:

* client port (2002) * graphic client port (3003) * control client port (3004) * server port (8888)

Definition at line 46 of file commcenter.cc.

References clientPort, controlClientPort, graphicClientPort, log, serverPort, and world.

CommCenter::~CommCenter  
 

Destroys the comm center; the open ports are closed.

Definition at line 70 of file commcenter.cc.

References clientPort, clients, controlClientPort, graphicClientPort, log, and serverPort.


Member Function Documentation

void CommCenter::checkForConections   [protected]
 

Checks if there are new conections on any of the client ports, or in the server port, and creates the threads and clients

Definition at line 153 of file commcenter.cc.

References clientPort, controlClientPort, graphicClientPort, newClient(), newControlClient(), newGraphicClient(), newServer(), and serverPort.

Referenced by loop().

void CommCenter::checkForDeadClients   [protected]
 

Checks if there are dead clients, and decrements the numClients to wait

Definition at line 164 of file commcenter.cc.

References clients, World::numClients, and world.

Referenced by waitForClients().

Client * CommCenter::getClientForMigration string    name
 

Searches a suitable client for migration of an agent

Actually it does it selecting one pseudo-random agentClient from the list of clients with the same name of actual agent

Definition at line 222 of file commcenter.cc.

References clientMap, and log.

Referenced by World::newAgent().

void CommCenter::getMessages  
 

void CommCenter::loop  
 

Loops thruogh the open ports to check for new conections; if one appears the correct handler is called

Definition at line 93 of file commcenter.cc.

References andTimePasses(), checkForConections(), clients, World::getQuit(), log, makeMovements(), waitForClients(), and world.

void CommCenter::makeMovements   [protected]
 

Make the movements done

Definition at line 212 of file commcenter.cc.

References World::step(), and world.

Referenced by loop().

void CommCenter::newClient   [protected]
 

Creates a new client, and starts it.

Definition at line 112 of file commcenter.cc.

References clientMap, clientPort, clients, Client::getName(), and world.

Referenced by checkForConections().

void CommCenter::newControlClient   [protected]
 

Creates a new control client, and starts it.

Definition at line 135 of file commcenter.cc.

References clients, controlClientPort, and world.

Referenced by checkForConections().

void CommCenter::newGraphicClient   [protected]
 

Creates a new graphic client, starts it, and stop it's execution (I can ensure that it's safe to let it run any time before dontWalk is issued

Definition at line 126 of file commcenter.cc.

References clients, graphicClientPort, and world.

Referenced by checkForConections().

void CommCenter::newServer   [protected]
 

Creates a new server channel, and starts it.

Definition at line 144 of file commcenter.cc.

References log.

Referenced by checkForConections().

void CommCenter::removeDeadClients   [protected]
 

Deletes not Alive clients

Definition at line 174 of file commcenter.cc.

References clients.

Referenced by waitForClients().

void CommCenter::waitForClients   [protected]
 

Waits till all clients have finished the run cycle

Definition at line 186 of file commcenter.cc.

References checkForDeadClients(), clients, World::numClients, removeDeadClients(), and world.

Referenced by loop().


Member Data Documentation

map<string, vector<Client *>, less<string> > CommCenter::clientMap [protected]
 

A dictionary of name of AgentClients and lists of AgentClients.

Definition at line 90 of file commcenter.h.

Referenced by getClientForMigration(), and newClient().

ost::TCPSocket* CommCenter::clientPort [protected]
 

Definition at line 55 of file commcenter.h.

Referenced by checkForConections(), CommCenter(), newClient(), and ~CommCenter().

vector<baseClient *> CommCenter::clients [protected]
 

Definition at line 61 of file commcenter.h.

Referenced by checkForDeadClients(), loop(), newClient(), newControlClient(), newGraphicClient(), removeDeadClients(), waitForClients(), and ~CommCenter().

ost::TCPSocket* CommCenter::controlClientPort [protected]
 

Definition at line 57 of file commcenter.h.

Referenced by checkForConections(), CommCenter(), newControlClient(), and ~CommCenter().

ost::TCPSocket* CommCenter::graphicClientPort [protected]
 

Definition at line 56 of file commcenter.h.

Referenced by checkForConections(), CommCenter(), newGraphicClient(), and ~CommCenter().

ost::TCPSocket* CommCenter::serverPort [protected]
 

Definition at line 58 of file commcenter.h.

Referenced by checkForConections(), CommCenter(), and ~CommCenter().

World* CommCenter::world [protected]
 

The world that this commcenter controls.

Definition at line 88 of file commcenter.h.

Referenced by checkForDeadClients(), CommCenter(), loop(), makeMovements(), newClient(), newControlClient(), newGraphicClient(), and waitForClients().


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