Debian Codegraph @

src/mas/message.h

raw symbols SCIP
1 /***************************************************************************
2 message.h - description
3 -------------------
4 begin : nov 29th, 2005
5 copyright : (C) 2006-2010 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7 author : Victor STINNER
8
9 $Id: message.h 448 2010-05-09 15:18:32Z neoneurone $
10 ***************************************************************************/
11
12 /***************************************************************************
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * any later version. *
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 // Forward declarations
41 class Agent;
42
43
44 /*=====================================================================*/
45 /** The agents send "messages" to each other
46 @author Victor STINNER
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