fipa_acl  1.4
acl_envelope.h
Go to the documentation of this file.
1 #ifndef FIPA_ACL_MESSAGE_ENVELOPE_H
2 #define FIPA_ACL_MESSAGE_ENVELOPE_H
3 
4 #include <stdint.h>
5 #include <fipa_acl/message_generator/acl_message.h>
6 #include <fipa_acl/message_generator/received_object.h>
7 #include <fipa_acl/message_generator/types.h>
8 
9 namespace fipa {
10 namespace acl {
11 
12 typedef std::string Comments;
13 typedef uint32_t PayloadLength;
14 typedef std::string PayloadEncoding;
15 typedef std::string ACLRepresentation;
16 typedef std::string TransportBehaviour;
17 typedef std::vector<ReceivedObject> ReceivedObjectList;
18 
20 typedef std::vector<ACLBaseEnvelope> ACLBaseEnvelopeList;
21 
22 namespace envelope {
23 
24  // Parameter id to allow checking whether certain field in an envelope
25  // have been set
26  enum ParameterId { NONE = 0x00, TO = 0x01, FROM = 0x02, COMMENTS = 0x04,
28 }
29 
37 {
38 private:
39  envelope::ParameterId mParameters;
40 
46  AgentIDList mTo;
47 
53  AgentID mFrom;
54 
61  Comments mComments;
62 
68  representation::Type mACLRepresentation;
69 
75  PayloadLength mPayloadLength;
76 
82  PayloadEncoding mPayloadEncoding;
83 
89  base::Time mDate;
90 
108  AgentIDList mIntendedReceivers;
109 
119  ReceivedObject mReceivedObject;
120 
126  TransportBehaviour mTransportBehaviour;
127 
132  UserdefinedParameterList mUserdefinedParameters;
133 
134 public:
138  ACLBaseEnvelope();
139 
144  bool contains(envelope::ParameterId id) const { return mParameters & id; }
145 
150  const AgentIDList& getTo() const { return mTo; }
151 
155  void addTo(const AgentID& agent);
156 
161  void setTo(const AgentIDList& receivers);
162 
168  bool removeTo(const AgentID& agentId);
169 
173  void clearAllTo() { mTo.clear(); }
174 
179  const AgentID& getFrom() const { return mFrom; }
180 
185  void setFrom(const AgentID& from);
186 
191  const Comments& getComments() const { return mComments; }
192 
197  void setComments(const Comments& comments);
198 
203  const representation::Type& getACLRepresentation() const { return mACLRepresentation; }
204 
209  const std::string& getACLRepresentationString() const { return representation::TypeTxt[mACLRepresentation]; }
210 
215  void setACLRepresentation(representation::Type representation);
216 
221  void setACLRepresentation(const std::string& represention);
222 
226  const PayloadLength& getPayloadLength() const { return mPayloadLength; }
227 
231  void setPayloadLength(const PayloadLength& length);
232 
236  const PayloadEncoding& getPayloadEncoding() const { return mPayloadEncoding; }
237 
241  void setPayloadEncoding(const PayloadEncoding& encoding);
242 
246  const base::Time& getDate() const { return mDate; }
247 
251  void setDate(const base::Time& date);
252 
256  const AgentIDList& getIntendedReceivers() const { return mIntendedReceivers; }
257 
261  void setIntendedReceivers(const AgentIDList& receivers);
262 
266  void addIntendedReceiver(const AgentID& agent);
267 
271  bool removeIntendedReceiver(const AgentID& agent);
272 
276  void clearAllIntendedReceivers() { mIntendedReceivers.clear(); }
277 
281  const ReceivedObject& getReceivedObject() const { return mReceivedObject; }
282 
286  void setReceivedObject(const ReceivedObject& receivedObject);
287 
292  bool hasReceivedObject(const ReceivedObject& receivedObject) const;
293 
297  const TransportBehaviour& getTransportBehaviour() const { return mTransportBehaviour; }
298 
302  void setTransportBehaviour(const TransportBehaviour& transportBehaviour);
303 
307  const UserdefinedParameterList& getUserdefinedParameters() const { return mUserdefinedParameters; }
308 
312  void setUserdefinedParameters(const UserdefinedParameterList& parameters);
313 
317  ACLBaseEnvelope merge(const ACLBaseEnvelope& other) const;
318 
325  ACLBaseEnvelope flatten(const ACLBaseEnvelopeList& extraEnvelopes) const;
326 
330  void stamp(const ReceivedObject& receivedObject) { setReceivedObject(receivedObject); }
331 
336  bool hasStamp(const ReceivedObject& receivedObject) const { return hasReceivedObject(receivedObject); }
337 
338 };
339 
340 
341 class EnvelopeFormat;
350 {
351  friend class EnvelopeFormat;
352 
357  ACLBaseEnvelopeList mExtraEnvelopes;
358 
362  ACLBaseEnvelope mBaseEnvelope;
363 
364  // The payload data that is transported within this envelope
365  std::string mPayload;
366 
370  static uint32_t mStampCounter;
371 
376  static ID createLocalId();
377 
378 public:
379 
383  ACLEnvelope();
384 
394  ACLEnvelope(const ACLMessage& msg, const fipa::acl::representation::Type& format);
395 
402  void insert(const ACLMessage& msg, const fipa::acl::representation::Type& format);
403 
411  const ACLBaseEnvelopeList& getExtraEnvelopes() const { return mExtraEnvelopes; }
412 
417  void addExtraEnvelope(const ACLBaseEnvelope& envelope) { mExtraEnvelopes.push_back(envelope); }
418 
424  void setExtraEnvelopes(const ACLBaseEnvelopeList& envelopes) { mExtraEnvelopes = envelopes; }
425 
430  const ACLBaseEnvelope& getBaseEnvelope() const { return mBaseEnvelope; }
431 
436  void setBaseEnvelope(const ACLBaseEnvelope& envelope) { mBaseEnvelope = envelope; }
437 
444  ACLBaseEnvelope flattened() const { return mBaseEnvelope.flatten(mExtraEnvelopes); }
445 
453  AgentIDList getDeliveryPath() const;
454 
460  std::string getDeliveryPathString() const;
461 
467  void setPayload(const std::string& payload) { mPayload = payload; }
468 
473  const std::string& getPayload() const { return mPayload; }
474 
480  fipa::acl::ACLMessage getACLMessage() const;
481 
490  void stamp(const fipa::acl::AgentID& id);
491 
497  bool hasStamp(fipa::acl::AgentID id) const;
498 
504  ACLEnvelope createDedicatedEnvelope(const AgentID& receiverId) const;
505 };
506 
512 
513 } // end namespace acl
514 } // end namespace fipa
515 #endif // FIPA_ACL_MESSAGE_ENVELOPE_H
std::string TransportBehaviour
Definition: acl_envelope.h:16
std::string ID
std::string Comments
Definition: acl_envelope.h:12
ACLBaseEnvelope flattened() const
Definition: acl_envelope.h:444
const std::string & getPayload() const
Definition: acl_envelope.h:473
The ACLBaseEnvelope defines the layout for an envelope with which ACLMessage data can be wrapped...
Definition: acl_envelope.h:36
const representation::Type & getACLRepresentation() const
Definition: acl_envelope.h:203
const ACLBaseEnvelopeList & getExtraEnvelopes() const
Definition: acl_envelope.h:411
ACLMessage envelope (also typed as fipa::acl::Letter) includes the base envelope and updated fields...
Definition: acl_envelope.h:349
const PayloadLength & getPayloadLength() const
Definition: acl_envelope.h:226
const PayloadEncoding & getPayloadEncoding() const
Definition: acl_envelope.h:236
const ACLBaseEnvelope & getBaseEnvelope() const
Definition: acl_envelope.h:430
const TransportBehaviour & getTransportBehaviour() const
Definition: acl_envelope.h:297
uint32_t PayloadLength
Definition: acl_envelope.h:13
std::string ACLRepresentation
Definition: acl_envelope.h:15
std::vector< UserdefParam > UserdefinedParameterList
Definition: userdef_param.h:94
void setExtraEnvelopes(const ACLBaseEnvelopeList &envelopes)
Definition: acl_envelope.h:424
void setPayload(const std::string &payload)
Definition: acl_envelope.h:467
const std::string & getACLRepresentationString() const
Definition: acl_envelope.h:209
std::vector< AgentID > AgentIDList
Definition: agent_id.h:20
bool contains(envelope::ParameterId id) const
Definition: acl_envelope.h:144
const base::Time & getDate() const
Definition: acl_envelope.h:246
const Comments & getComments() const
Definition: acl_envelope.h:191
const std::string TypeTxt[]
Definition: types.h:28
std::vector< ReceivedObject > ReceivedObjectList
Definition: acl_envelope.h:17
void setBaseEnvelope(const ACLBaseEnvelope &envelope)
Definition: acl_envelope.h:436
std::vector< ACLBaseEnvelope > ACLBaseEnvelopeList
Definition: acl_envelope.h:19
const AgentID & getFrom() const
Definition: acl_envelope.h:179
void stamp(const ReceivedObject &receivedObject)
Definition: acl_envelope.h:330
bool hasStamp(const ReceivedObject &receivedObject) const
Definition: acl_envelope.h:336
This class provides a representation of a message conforming to the FIPA specification SC00061...
Definition: acl_message.h:55
void addExtraEnvelope(const ACLBaseEnvelope &envelope)
Definition: acl_envelope.h:417
std::string PayloadEncoding
Definition: acl_envelope.h:14
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
const ReceivedObject & getReceivedObject() const
Definition: acl_envelope.h:281
ACLBaseEnvelope flatten(const ACLBaseEnvelopeList &extraEnvelopes) const
const AgentIDList & getIntendedReceivers() const
Definition: acl_envelope.h:256
const AgentIDList & getTo() const
Definition: acl_envelope.h:150
ACLEnvelope Letter
Define a letter to be the envelope including the payload.
Definition: acl_envelope.h:511
const UserdefinedParameterList & getUserdefinedParameters() const
Definition: acl_envelope.h:307