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

lm::LoomKernel Class Reference

#include <LoomKernel.h>

List of all members.

Public Types

typedef std::map< Agent *,
std::queue< std::string > * > 
QueueMap

Public Methods

 LoomKernel ()
bool hasAgent (const std::string &name)
void init (int port=-1)
void connectTo (std::string hostname, int port)
void sendMessageWith (Agent *agent, Effector *e)
void update ()
 ~LoomKernel ()
void add (const Sensor &newSensor)
void add (const Effector &newEffect)
void registerAgent (Agent *a)
void unregisterAgent (Agent *a)
std::string popPostQueue (Agent *a)
std::list< Agent * > getAgents ()

Public Attributes

boost::function< void() bindedRun )
QueueMap mPostQueueMap
QueueMap mPreQueueMap

Private Methods

void run (Agent *a)

Private Attributes

std::list< Agent * > mAgents
std::list< Effector * > effectorPool
std::list< Sensor * > sensorPool
boost::thread_group thrds
boost::thread * mThreadPtr


Detailed Description

The LoomKernel class is the micro-kernel for the loom system. All agents must register with the LoomKernel in order to operate. A developer would create a loomKernel for all agents on a system, even if there is only 1 agent on the system. The LoomKernel also handles all the communication for the agent relieving that burden from the developer.


Member Typedef Documentation

typedef std::map<Agent*, std::queue<std::string>* > lm::LoomKernel::QueueMap
 

here is a mapping from agent so in linear time given an agent we can find his queue.


Constructor & Destructor Documentation

lm::LoomKernel::LoomKernel  
 

constructor

lm::LoomKernel::~LoomKernel  
 

destructor


Member Function Documentation

void lm::LoomKernel::add const Effector   newEffect
 

this method adds an effector to the global pool that all agents at this agentCollector have access to.

void lm::LoomKernel::add const Sensor   newSensor
 

this method adds a sensor to the global pool that all agents at this agentCollector have access to.

void lm::LoomKernel::connectTo std::string    hostname,
int    port
 

connect to another plexus node at the given hostname and port

std::list< Agent * > lm::LoomKernel::getAgents  
 

bool lm::LoomKernel::hasAgent const std::string &    name
 

hasAgent returns true if an agent with the given name exists on this agent Collector, otherwise returns false

void lm::LoomKernel::init int    port = -1
 

initialization method for the agentCollector. All the setup for the agents is done here, so it must be called before update gets called. NOTE: this method must be called before update get's called.

std::string lm::LoomKernel::popPostQueue Agent   a
 

this method returns the queue's front element and removes it from that agent's queue.

void lm::LoomKernel::registerAgent Agent   a
 

registerAgent adds an agent to the agentCollector which spawns a thread for it and starts calling update on it.

void lm::LoomKernel::run Agent   a [private]
 

this method is needed for boost threads so that we have a function to run. The function sits and continually calls update on the agent until it recieves an unregisterAgent Command at which time we stop the thread of execution.

void lm::LoomKernel::sendMessageWith Agent   agent,
Effector   e
 

pack up a message with an effector in it and send it over the network to the agent that it is supposed to go to

void lm::LoomKernel::unregisterAgent Agent   a
 

unregisterAgent removes the agent from the agentCollector, which kills the thread for it and removes it from the list of agents on the collector.

void lm::LoomKernel::update  
 

The update method should be called every frame to update all the agents of pending changes on them and to get any messages or effects from them. NOTE for non-distributed system: Actually if the system is not distributed then the update method doesn't need to be called it is just recommended. The reason is that if the agentCollector goes out of scope then the primordial thread for the whole system stops thus stopping all the agent. Making the update call every frame insures that the developer has kept this in mind. NOTE: init must be called before update.


Member Data Documentation

boost::function<void () lm::LoomKernel::bindedRun)
 

std::list<Effector*> lm::LoomKernel::effectorPool [private]
 

std::list<Agent*> lm::LoomKernel::mAgents [private]
 

QueueMap lm::LoomKernel::mPostQueueMap
 

QueueMap lm::LoomKernel::mPreQueueMap
 

boost::thread* lm::LoomKernel::mThreadPtr [private]
 

we also need a pointer to a thread so that we can pass a thread around

std::list<Sensor*> lm::LoomKernel::sensorPool [private]
 

boost::thread_group lm::LoomKernel::thrds [private]
 

this is the boost thread group so we can run each agent in it's own thread


The documentation for this class was generated from the following files:
Generated on Wed Oct 22 21:33:22 2003 for AI Loom by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002