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

message.h

00001 /***************************************************************************
00002                         message.h  -  description
00003                             -------------------
00004     begin                : nov 29th 2005
00005     copyright            : (C) 2006 by Duong-Khang NGUYEN
00006     email                : neoneurone @ users sourceforge net
00007     author               : Victor STINNER
00008     
00009     $Id: message.h 32 2006-08-06 18:59:25Z neoneurone $
00010  ***************************************************************************/
00011 
00012 /***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   any later version.                                                    *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 
00022 #ifndef _OPENCITY_MESSAGE_H_
00023 #define _OPENCITY_MESSAGE_H_ 1
00024 
00025 #include "any.h"
00026 
00027 #include <vector>
00028 #include <list>
00029 #include <string>
00030 #include <ostream>
00031 
00032 // Forward declarations
00033 class Agent;
00034 
00035    /*=====================================================================*/
00039 class Message
00040 {
00041 public:
00042     typedef enum {
00043         MSG_UNDEFINED = 0,
00044         MSG_NEW_DEMONSTRATOR,
00045         MSG_NEW_ROBBER,
00046         MSG_KILL_AGENT,
00047         MSG_AGENT_DIE
00048     } Message_t;
00049 
00050     Message();
00051     Message(Message_t type, Agent *sender=NULL);
00052     Message& operator<< (int value);
00053     Message& operator<< (unsigned int value);
00054     Message& operator<< (double value);
00055     Message& operator<< (const std::string& value);
00056     
00057     Message_t getType() const;
00058     Agent* getSender() const;
00059     Message& setSender(Agent* sender);
00060     unsigned int size() const;
00061     Any& operator[] (unsigned int index);
00062     const Any& operator[] (unsigned int index) const;
00063 
00064     friend std::ostream& operator<<(std::ostream& os, const Message& msg);
00065 
00066 private:
00067     Agent* m_sender;
00068     Message_t m_type;
00069     std::vector<Any> arguments;
00070 };
00071 
00072 #endif
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 

Generated on Sat Nov 11 10:21:10 2006 for OpenCity by  doxygen 1.4.2