fipa_acl  1.4
acl_message.h
Go to the documentation of this file.
1 
8 #ifndef FIPA_ACL_ACLMESSAGE_H
9 #define FIPA_ACL_ACLMESSAGE_H
10 
11 #include <vector>
12 #include <map>
13 #include <string>
14 #include <fipa_acl/message_generator/agent_id.h>
15 #include <fipa_acl/message_generator/userdef_param.h>
16 #include <base/Time.hpp>
17 
21 namespace fipa {
22 
26 namespace acl {
27 
28  typedef std::string ConversationID;
29  typedef std::string Protocol;
30  typedef std::string ContentLanguage;
31 
35  const extern std::string illegalWordChars;
36 
40  const extern std::string illegalWordStart;
41 
55 class ACLMessage {
56 
57  friend class MessageFormat;
58 
59 public:
67  };
68 
69 private:
70  std::string mPerformative;
72  AgentID mSender;
74  std::vector<AgentID> mReceivers;
76  std::vector<AgentID> mReplyTo;
78  std::string mLanguage;
80  std::string mEncoding;
82  std::string mOntology;
84  std::string mProtocol;
86  std::string mConversationId;
88  std::string mReplyWith;
90  std::string mInReplyTo;
92  base::Time mReplyBy;
94  std::vector<UserdefParam> mParameters;
96  std::string mContent;
97 
98 public:
99 
103  ACLMessage();
104 
109  ACLMessage(Performative performative);
110 
115  ACLMessage(const std::string& perf);
116 
121  bool operator==(const ACLMessage& other) const;
122 
127  void setPerformative(Performative perf);
128 
133  void setPerformative(const std::string& str);
134 
139  std::string getPerformative() const { return mPerformative; }
140 
145  Performative getPerformativeAsEnum() const { return performativeFromString(mPerformative); }
146 
150  void addReceiver(const AgentID& aid);
151 
155  void deleteReceiver(const AgentID& aid);
156 
160  void clearReceivers();
161 
166  AgentIDList getAllReceivers() const { return mReceivers; }
167 
171  void setAllReceivers(const AgentIDList& receivers) { mReceivers = receivers; }
172 
176  void addReplyTo(const AgentID& aid);
177 
181  void deleteReplyTo(const AgentID& aid);
182 
186  void clearReplyTo();
187 
192  AgentIDList getAllReplyTo() const { return mReplyTo; }
193 
197  void setAllReplyTo(const AgentIDList& replyTo) { mReplyTo = replyTo; }
198 
202  void setInReplyTo(const std::string& str) { mInReplyTo = str; }
203 
207  std::string getInReplyTo() const { return mInReplyTo; }
208 
212  void setReplyWith(const std::string& str) { mReplyWith = str; }
213 
217  std::string getReplyWith() const { return mReplyWith; }
218 
222  void setConversationID(const std::string& str) { mConversationId = str; }
223 
227  std::string getConversationID() const { return mConversationId; }
228 
233  void setProtocol(const std::string& str);
234 
238  std::string getProtocol() const { return mProtocol; }
239 
243  void setOntology(const std::string& str) { mOntology = str; }
244 
248  std::string getOntology() const { return mOntology; }
249 
253  void setEncoding(const std::string& str) { mEncoding = str; }
254 
258  std::string getEncoding() const { return mEncoding; }
259 
263  void setLanguage(const std::string& str) { mLanguage = str; }
264 
268  std::string getLanguage() const { return mLanguage; }
269 
274  void setContent(const std::string& content) { mContent = content; }
275 
280  void setBinaryContent(const std::vector<uint8_t>& content) { mContent.assign(content.begin(), content.end()); }
281 
287  bool hasBinaryContent() const;
288 
294  std::string getContent() const { return mContent; }
295 
299  const std::string* getContentPtr() const { return &mContent; }
300 
305  void setSender(const AgentID& sender) { mSender = sender; }
306 
311  AgentID getSender() const { return mSender; }
312 
317  void addUserdefParam(const UserdefParam& p);
318 
323  std::vector<UserdefParam> getUserdefParams() const { return mParameters; }
324 
329  void setUserdefParams(const std::vector<UserdefParam>& p);
330 
334  base::Time getReplyBy() const { return mReplyBy; }
335 
340  void setReplyBy(const base::Time& time) { mReplyBy = time; }
341 
346  static Performative performativeFromString(const std::string& performative);
347 
352  std::string toString() const;
353 
354 };
355 
356 extern std::map<ACLMessage::Performative, std::string> PerformativeTxt;
357 
358 }//end of acl namespace
359 
360 }// end of fipa namespace
361 #endif
std::string ConversationID
Definition: acl_message.h:28
std::string getEncoding() const
Definition: acl_message.h:258
std::string Protocol
Definition: acl_message.h:29
void setReplyWith(const std::string &str)
Definition: acl_message.h:212
void setConversationID(const std::string &str)
Definition: acl_message.h:222
std::string getContent() const
Definition: acl_message.h:294
void setLanguage(const std::string &str)
Definition: acl_message.h:263
std::vector< UserdefParam > getUserdefParams() const
Definition: acl_message.h:323
base::Time getReplyBy() const
Definition: acl_message.h:334
std::string getPerformative() const
Definition: acl_message.h:139
void setUserdefParams(const std::vector< UserdefParam > &p)
void deleteReplyTo(const AgentID &aid)
Abstract class which should be implemented by a specific format to encode an ACLMessage according to ...
bool hasBinaryContent() const
void setInReplyTo(const std::string &str)
Definition: acl_message.h:202
std::string getReplyWith() const
Definition: acl_message.h:217
std::vector< AgentID > AgentIDList
Definition: agent_id.h:20
std::string getOntology() const
Definition: acl_message.h:248
AgentIDList getAllReplyTo() const
Definition: acl_message.h:192
void addReplyTo(const AgentID &aid)
void setAllReceivers(const AgentIDList &receivers)
Definition: acl_message.h:171
const std::string illegalWordStart
Definition: acl_message.cpp:40
Performative
an enum of all the predefined fipa message performatives so far, presented in the order used in the m...
Definition: acl_message.h:64
const std::string * getContentPtr() const
Definition: acl_message.h:299
void setContent(const std::string &content)
Definition: acl_message.h:274
void setSender(const AgentID &sender)
Definition: acl_message.h:305
std::string getLanguage() const
Definition: acl_message.h:268
void addUserdefParam(const UserdefParam &p)
std::string getInReplyTo() const
Definition: acl_message.h:207
void setAllReplyTo(const AgentIDList &replyTo)
Definition: acl_message.h:197
std::map< ACLMessage::Performative, std::string > PerformativeTxt
Definition: acl_message.cpp:15
AgentID getSender() const
Definition: acl_message.h:311
void setBinaryContent(const std::vector< uint8_t > &content)
Definition: acl_message.h:280
std::string ContentLanguage
Definition: acl_message.h:30
std::string getProtocol() const
Definition: acl_message.h:238
This class provides a representation of a message conforming to the FIPA specification SC00061...
Definition: acl_message.h:55
void setReplyBy(const base::Time &time)
Definition: acl_message.h:340
bool operator==(const ACLMessage &other) const
static Performative performativeFromString(const std::string &performative)
Definition: acl_message.cpp:42
Performative getPerformativeAsEnum() const
Definition: acl_message.h:145
overloaded equality operator for UserdefParam class objects
Definition: userdef_param.h:25
void addReceiver(const AgentID &aid)
void deleteReceiver(const AgentID &aid)
std::string toString() const
void setPerformative(Performative perf)
Set performative.
const std::string illegalWordChars
Definition: acl_message.cpp:39
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Definition: agent_id.h:37
Foundation of Physical Intelligent Agents.
Definition: conversation.cpp:6
AgentIDList getAllReceivers() const
Definition: acl_message.h:166
void setEncoding(const std::string &str)
Definition: acl_message.h:253
void setProtocol(const std::string &str)
the method checks whether the passed protocol string is a word or not(according to the fipa spec) ...
std::string getConversationID() const
Definition: acl_message.h:227
ACLMessage()
Default constructor.
Definition: acl_message.cpp:56
void setOntology(const std::string &str)
Definition: acl_message.h:243