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

Message.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: Message.h,v $
00023  * Date modified: $Date: 2003/09/30 04:10:24 $
00024  * Version:       $Revision: 1.3 $
00025  * -----------------------------------------------------------------
00026  *
00027  ************************************************************** lm-cpr-end */
00028 #ifndef LM_MESSAGE_H
00029 #define LM_MESSAGE_H
00030 
00031 #include <iostream>
00032 #include <vpr/IO/BufferObjectWriter.h>
00033 
00034 #include "../Defs.h"
00035 
00036 namespace lm
00037 {
00038    namespace message
00039    {
00040       class Message : public vpr::SerializableObject
00041       {
00042       public:
00043          Message(std::string* message)
00044          {
00045             mMessage = message;
00046          }
00047          virtual ~Message(){;}
00048 
00049          vpr::ReturnStatus readObject(vpr::ObjectReader* reader)
00050          {
00051             mMessage = &std::string(reader->readString());
00052             return vpr::ReturnStatus::Succeed;
00053          }
00054 
00055          vpr::ReturnStatus writeObject(vpr::ObjectWriter* writer)
00056          {
00057             writer->writeString(*mMessage);
00058             return vpr::ReturnStatus::Succeed;
00059          }
00060          
00061       private:
00062          std::string* mMessage;
00063       };
00064             
00065       
00066       inline plx::MulticastMessagePtr
00067       constructMulticastMessage(UUID* agentName, MESSAGE_TYPE t, Message message)
00068       {
00069          vpr::BufferObjectWriter writer;
00070          message.writeObject(&writer);
00071          
00072          plx::MulticastMessagePtr msg(new plx::MulticastMessage);
00073          msg->setDomain(vpr::GUID(agentName->str()));
00074          msg->setDomainGroup(vpr::GUID(t.str()));
00075          msg->wrapData(*(writer.getData()));
00076 
00077          return msg;
00078       }
00079    } // end namespace message
00080 } // end namespace lm
00081 
00082 #endif

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