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

LoomMessageHandler.h

Go to the documentation of this file.
00001 /***************************************************************** lm-cpr beg
00002  *
00003  * AI Loom - A cross platform artificial intelligence framework
00004  * AI Loom is (c) Copyright 2003 Josh Brown
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the
00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  *
00021  * -----------------------------------------------------------------
00022  * File:          $RCSfile: LoomMessageHandler.h,v $
00023  * Date modified: $Date: 2003/10/16 05:53:28 $
00024  * Version:       $Revision: 1.11 $
00025  * -----------------------------------------------------------------
00026  *
00027  ************************************************************** lm-cpr-end */
00028 #ifndef LM_LOOM_MESSAGE_HANDLER_H
00029 #define LM_LOOM_MESSAGE_HANDLER_H
00030 
00031 #include <plx/Router/MessageHandler.h>
00032 
00033 #include "Agent.h"
00034 #include "../Defs.h"
00035 #include "LoomKernel.h"
00036 #include "NetworkConnection.h"
00037 #include "../Output.h"
00038 
00039 
00040 namespace lm
00041 {
00042    class Agent;
00043 
00044    
00048    class LoomMessageHandler : public plx::MessageHandler
00049    {
00050       public:
00051          LoomMessageHandler(NetworkConnection* network, LoomKernel* ac) : 
00052             mNetwork(network),
00053             mLoomKernel(ac)
00054          {
00055          }
00056 
00057          void handleMessage(plx::MessagePtr plxMsg)
00058          {
00059             // first check if this message is for any of the agents in our AC
00060             UUID targetAgent(plxMsg->getDomain().toString());
00061             std::list<Agent*> agentList = mLoomKernel->getAgents();
00062             for(std::list<Agent*>::iterator itr = agentList.begin(); itr!=agentList.end(); itr++)
00063             {
00064                if((*itr)->getUUID()==targetAgent)
00065                {
00066                   std::string group = plxMsg->getDomainGroup().toString();
00067                   mLoomKernel->mPostQueueMap.find(*itr)->second->push(group);
00068                }
00069             }
00070          }
00071 
00072       private:
00073          NetworkConnection* mNetwork;
00074          LoomKernel* mLoomKernel;
00075    };
00076 } // end namespace lm
00077 
00078 #endif

Generated on Wed Oct 22 21:33:21 2003 for AI Loom by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002