| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef _OPENCITY_MAS_MESSAGE_H_ |
| 23 |
#define _OPENCITY_MAS_MESSAGE_H_ 1 |
| 24 |
|
| 25 |
#include "any.h" |
| 26 |
|
| 27 |
#include <vector> |
| 28 |
#include <list> |
| 29 |
#include <string> |
| 30 |
#include <ostream> |
| 31 |
|
| 32 |
typedef enum { |
| 33 |
MSG_UNDEFINED = 0, |
| 34 |
MSG_NEW_DEMONSTRATOR, |
| 35 |
MSG_NEW_ROBBER, |
| 36 |
MSG_KILL_AGENT, |
| 37 |
MSG_AGENT_DIE |
| 38 |
} MAS_MESSAGE_TYPE; |
| 39 |
|
| 40 |
|
| 41 |
class Agent; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
class Message |
| 49 |
{ |
| 50 |
public: |
| 51 |
Message(); |
| 52 |
Message(MAS_MESSAGE_TYPE type, Agent* sender = NULL); |
| 53 |
Message& operator<< (int value); |
| 54 |
Message& operator<< (unsigned int value); |
| 55 |
Message& operator<< (double value); |
| 56 |
Message& operator<< (const std::string& value); |
| 57 |
|
| 58 |
MAS_MESSAGE_TYPE getType() const; |
| 59 |
Agent* getSender() const; |
| 60 |
Message& setSender(Agent* sender); |
| 61 |
unsigned int size() const; |
| 62 |
Any& operator[] (unsigned int index); |
| 63 |
const Any& operator[] (unsigned int index) const; |
| 64 |
|
| 65 |
friend std::ostream& operator<<(std::ostream& os, const Message& msg); |
| 66 |
|
| 67 |
private: |
| 68 |
Agent* _sender; |
| 69 |
MAS_MESSAGE_TYPE _type; |
| 70 |
std::vector<Any> _arguments; |
| 71 |
}; |
| 72 |
|
| 73 |
#endif |