Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Arbitrator Class Reference

basically, this is a thread of execution in the Simulator most likely a robot, or set of robots. More...

#include <Simulation/Arbitrator.h>

Inheritance diagram for Arbitrator:

Entity List of all members.

Public Types

enum  State { ARB_STARTING, ARB_ENDING, ARB_WAITING, ARB_RUNNING }
 enum defining the current current state of the arbitrator

Public Member Functions

 Arbitrator (const ConStruct &con)
 create's an arbitror, spawning off the other threads.
virtual ~Arbitrator ()
 Destructor Makes sure the thread exits and such like stuff.
virtual void Render ()=0
 Render function may be useful for displaying states, possible paths etc. Should be overridden in subclass.
std::vector< Robot * > & GetRobots ()
 gets the list of robots that this Arbitrator controls
void WakeUp ()
 Wakes the Arbitrator's thread up.
void Wait (const int cond_id)
 Tell's the arbitrator to stop it's thread for a bit.
virtual void Execute ()=0
 Main execution function of arbitrator. This function is run in it's own thread in an arbitrator, and should therefore probobly contains an infinite loop.
virtual bool ConditionHandler ()=0
 All wait conditions are defined in a big switch statement in this function.
virtual void OnWakeUp ()=0
 Will be executed in the simulation thread (not the Arbitrator's thread) when the Simulation wake's the thread up after having put it to sleep.

Public Attributes

State state
 This is basically the current state of the Arbitrator, waiting, running, exiting, etc.

Protected Attributes

std::vector< Robot * > robots
 ordered list of robots arbitrator controls
int cur_cond_id
 cond_id ConditionHandler is using. TODO: what is this?

Detailed Description

basically, this is a thread of execution in the Simulator most likely a robot, or set of robots.

To create you're own classes that use the Simulator, derive from Arbitrator. Think of it like co-operative multitasking.


Constructor & Destructor Documentation

Arbitrator::Arbitrator const ConStruct &  con  ) 
 

create's an arbitror, spawning off the other threads.

Parameters:
con,: the ConStruct specifying the Arbitrators configuration


Member Function Documentation

virtual bool Arbitrator::ConditionHandler  )  [pure virtual]
 

All wait conditions are defined in a big switch statement in this function.

If it returns false, then we don't we stop the Execute thread. If it returns true then we we run the Execute thread. It should not contain a loop.

OVERRIDE THIS FUNCTION!

virtual void Arbitrator::Execute  )  [pure virtual]
 

Main execution function of arbitrator. This function is run in it's own thread in an arbitrator, and should therefore probobly contains an infinite loop.

OVERRIDE THIS FUNCTION!

void Arbitrator::Wait const int  cond_id  ) 
 

Tell's the arbitrator to stop it's thread for a bit.

Parameters:
cond_id,: the current condition of the thread
Called by an arbitrator thread, causes the thread to go to sleep until WakeUp() is called by the main thread.

void Arbitrator::WakeUp  ) 
 

Wakes the Arbitrator's thread up.

This would be called from the main thread to wakup the Arbitrator thread. Presumably after Wait() has been called.


Member Data Documentation

std::vector<Robot*> Arbitrator::robots [protected]
 

ordered list of robots arbitrator controls

necessary so that Simulation can access robot data


The documentation for this class was generated from the following files:
Generated on Fri Jan 12 14:15:02 2007 for Construct by  doxygen 1.4.3-20050530