fipa_acl  1.4
Public Member Functions | List of all members
fipa::acl::ACLBaseEnvelope Class Reference

The ACLBaseEnvelope defines the layout for an envelope with which ACLMessage data can be wrapped. Multiple ACLBaseEnvelopes are part of the ACLEnvelope in order to implement the basic functionality of the Agent Communication Channel (ACC) More...

#include <acl_envelope.h>

Public Member Functions

 ACLBaseEnvelope ()
 
bool contains (envelope::ParameterId id) const
 
const AgentIDListgetTo () const
 
void addTo (const AgentID &agent)
 
void setTo (const AgentIDList &receivers)
 
bool removeTo (const AgentID &agentId)
 
void clearAllTo ()
 
const AgentIDgetFrom () const
 
void setFrom (const AgentID &from)
 
const CommentsgetComments () const
 
void setComments (const Comments &comments)
 
const representation::TypegetACLRepresentation () const
 
const std::string & getACLRepresentationString () const
 
void setACLRepresentation (representation::Type representation)
 
void setACLRepresentation (const std::string &represention)
 
const PayloadLengthgetPayloadLength () const
 
void setPayloadLength (const PayloadLength &length)
 
const PayloadEncodinggetPayloadEncoding () const
 
void setPayloadEncoding (const PayloadEncoding &encoding)
 
const base::Time & getDate () const
 
void setDate (const base::Time &date)
 
const AgentIDListgetIntendedReceivers () const
 
void setIntendedReceivers (const AgentIDList &receivers)
 
void addIntendedReceiver (const AgentID &agent)
 
bool removeIntendedReceiver (const AgentID &agent)
 
void clearAllIntendedReceivers ()
 
const ReceivedObjectgetReceivedObject () const
 
void setReceivedObject (const ReceivedObject &receivedObject)
 
bool hasReceivedObject (const ReceivedObject &receivedObject) const
 
const TransportBehaviourgetTransportBehaviour () const
 
void setTransportBehaviour (const TransportBehaviour &transportBehaviour)
 
const UserdefinedParameterListgetUserdefinedParameters () const
 
void setUserdefinedParameters (const UserdefinedParameterList &parameters)
 
ACLBaseEnvelope merge (const ACLBaseEnvelope &other) const
 
ACLBaseEnvelope flatten (const ACLBaseEnvelopeList &extraEnvelopes) const
 
void stamp (const ReceivedObject &receivedObject)
 
bool hasStamp (const ReceivedObject &receivedObject) const
 

Detailed Description

The ACLBaseEnvelope defines the layout for an envelope with which ACLMessage data can be wrapped. Multiple ACLBaseEnvelopes are part of the ACLEnvelope in order to implement the basic functionality of the Agent Communication Channel (ACC)

See also
http://www.fipa.org/specs/fipa00067/SC00067F.html

Definition at line 36 of file acl_envelope.h.

Constructor & Destructor Documentation

◆ ACLBaseEnvelope()

fipa::acl::ACLBaseEnvelope::ACLBaseEnvelope ( )

DefaultConstructor

Definition at line 22 of file acl_envelope.cpp.

23  : mParameters(NONE)
24  , mACLRepresentation(representation::UNKNOWN)
25  , mPayloadEncoding("US-ASCII")
26 {}

Member Function Documentation

◆ addIntendedReceiver()

void fipa::acl::ACLBaseEnvelope::addIntendedReceiver ( const AgentID agent)

Add intended receiver to the list of intended receivers

Definition at line 115 of file acl_envelope.cpp.

116 {
117  AgentIDList::const_iterator it = find_if(mIntendedReceivers.begin(), mIntendedReceivers.end(), arg1 == agentId);
118  if(it == mIntendedReceivers.end())
119  {
120  mIntendedReceivers.push_back(agentId);
121  }
122 }

◆ addTo()

void fipa::acl::ACLBaseEnvelope::addTo ( const AgentID agent)

Add an agent identifier to the destination list

Definition at line 28 of file acl_envelope.cpp.

29 {
30  AgentID agent = agentId;
31  AgentIDList::const_iterator it = find_if(mTo.begin(), mTo.end(), arg1 == agentId );
32  if(it == mTo.end())
33  {
34  mTo.push_back(agentId);
35  }
36 }
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Definition: agent_id.h:37

◆ clearAllIntendedReceivers()

void fipa::acl::ACLBaseEnvelope::clearAllIntendedReceivers ( )
inline

Clear list of intended receivers

Definition at line 276 of file acl_envelope.h.

276 { mIntendedReceivers.clear(); }

◆ clearAllTo()

void fipa::acl::ACLBaseEnvelope::clearAllTo ( )
inline

Clear 'to' list

Definition at line 173 of file acl_envelope.h.

173 { mTo.clear(); }

◆ contains()

bool fipa::acl::ACLBaseEnvelope::contains ( envelope::ParameterId  id) const
inline
  • Test wether a certain content element is set in this envelope object

Definition at line 144 of file acl_envelope.h.

144 { return mParameters & id; }

◆ flatten()

ACLBaseEnvelope fipa::acl::ACLBaseEnvelope::flatten ( const ACLBaseEnvelopeList extraEnvelopes) const

Flatten the current envelope plus the extra envelopes (the most current/latest has to be at the end of the list

Parameters
extraEnvelopeslist of overlay envelopes
Returns
the most current ACLBaseEnvelope representation

Definition at line 224 of file acl_envelope.cpp.

225 {
226  ACLBaseEnvelope envelope = *this;
227  ACLBaseEnvelopeList::const_iterator cit = extraEnvelopes.begin();
228  for(; cit != extraEnvelopes.end(); ++cit)
229  {
230  envelope = envelope.merge(*cit);
231  }
232 
233  return envelope;
234 }
The ACLBaseEnvelope defines the layout for an envelope with which ACLMessage data can be wrapped...
Definition: acl_envelope.h:36
ACLBaseEnvelope merge(const ACLBaseEnvelope &other) const

◆ getACLRepresentation()

const representation::Type& fipa::acl::ACLBaseEnvelope::getACLRepresentation ( ) const
inline

Get the ACLRepresentation in use

Returns
acl representation

Definition at line 203 of file acl_envelope.h.

203 { return mACLRepresentation; }

◆ getACLRepresentationString()

const std::string& fipa::acl::ACLBaseEnvelope::getACLRepresentationString ( ) const
inline

Get the ACLRepresentation in use

Returns
acl representation

Definition at line 209 of file acl_envelope.h.

209 { return representation::TypeTxt[mACLRepresentation]; }
const std::string TypeTxt[]
Definition: types.h:28

◆ getComments()

const Comments& fipa::acl::ACLBaseEnvelope::getComments ( ) const
inline

Get comments

Returns
comments

Definition at line 191 of file acl_envelope.h.

191 { return mComments; }

◆ getDate()

const base::Time& fipa::acl::ACLBaseEnvelope::getDate ( ) const
inline

Retrieve creation date and time of the message envelope

Definition at line 246 of file acl_envelope.h.

246 { return mDate; }

◆ getFrom()

const AgentID& fipa::acl::ACLBaseEnvelope::getFrom ( ) const
inline

Get sender id

Returns
agent id of sender

Definition at line 179 of file acl_envelope.h.

179 { return mFrom; }

◆ getIntendedReceivers()

const AgentIDList& fipa::acl::ACLBaseEnvelope::getIntendedReceivers ( ) const
inline

Get intended receivers

Definition at line 256 of file acl_envelope.h.

256 { return mIntendedReceivers; }

◆ getPayloadEncoding()

const PayloadEncoding& fipa::acl::ACLBaseEnvelope::getPayloadEncoding ( ) const
inline

Get the payload encoding (default is US-ASCII)

Definition at line 236 of file acl_envelope.h.

236 { return mPayloadEncoding; }

◆ getPayloadLength()

const PayloadLength& fipa::acl::ACLBaseEnvelope::getPayloadLength ( ) const
inline

Get the length of the payload

Definition at line 226 of file acl_envelope.h.

226 { return mPayloadLength; }

◆ getReceivedObject()

const ReceivedObject& fipa::acl::ACLBaseEnvelope::getReceivedObject ( ) const
inline

Get the associated received object

Definition at line 281 of file acl_envelope.h.

281 { return mReceivedObject; }

◆ getTo()

const AgentIDList& fipa::acl::ACLBaseEnvelope::getTo ( ) const
inline

Get destination

Returns
destination of this message envelope as list of agents

Definition at line 150 of file acl_envelope.h.

150 { return mTo; }

◆ getTransportBehaviour()

const TransportBehaviour& fipa::acl::ACLBaseEnvelope::getTransportBehaviour ( ) const
inline

Get the transport behaviour

Definition at line 297 of file acl_envelope.h.

297 { return mTransportBehaviour; }

◆ getUserdefinedParameters()

const UserdefinedParameterList& fipa::acl::ACLBaseEnvelope::getUserdefinedParameters ( ) const
inline

Get userdefined parameter list

Definition at line 307 of file acl_envelope.h.

307 { return mUserdefinedParameters; }

◆ hasReceivedObject()

bool fipa::acl::ACLBaseEnvelope::hasReceivedObject ( const ReceivedObject receivedObject) const

Test whether the received object has the same sender

Returns
true if the By field is the same, false otherwise

Definition at line 141 of file acl_envelope.cpp.

142 {
143  if (mParameters & RECEIVED_OBJECT)
144  {
145  return receivedObject.getBy() == mReceivedObject.getBy();
146  }
147 
148  return false;
149 }
const URL & getBy() const

◆ hasStamp()

bool fipa::acl::ACLBaseEnvelope::hasStamp ( const ReceivedObject receivedObject) const
inline

Test whether this envelope has been stamped. This is an alias for hasReceivedObject

Returns
true if the sender has already stamped this message

Definition at line 336 of file acl_envelope.h.

336 { return hasReceivedObject(receivedObject); }
bool hasReceivedObject(const ReceivedObject &receivedObject) const

◆ merge()

ACLBaseEnvelope fipa::acl::ACLBaseEnvelope::merge ( const ACLBaseEnvelope other) const

Merges the information of two envelopes – only empty field in this will be overwritten by other

Definition at line 163 of file acl_envelope.cpp.

164 {
165  ACLBaseEnvelope envelope(*this);
166  if(other.contains(TO))
167  {
168  envelope.setTo(other.getTo());
169  }
170 
171  if(other.contains(FROM))
172  {
173  envelope.setFrom(other.getFrom());
174  }
175 
176  if(other.contains(COMMENTS))
177  {
178  envelope.setComments(other.getComments());
179  }
180 
181  if(other.contains(ACL_REPRESENTATION))
182  {
183  envelope.setACLRepresentation(other.getACLRepresentation());
184  }
185 
186  if(other.contains(PAYLOAD_LENGTH))
187  {
188  envelope.setPayloadLength(other.getPayloadLength());
189  }
190 
191  if(other.contains(PAYLOAD_ENCODING))
192  {
193  envelope.setPayloadEncoding(other.getPayloadEncoding());
194  }
195 
196  if(other.contains(DATE))
197  {
198  envelope.setDate(other.getDate());
199  }
200 
201  if(other.contains(INTENDED_RECEIVERS))
202  {
203  envelope.setIntendedReceivers(other.getIntendedReceivers());
204  }
205 
206  if(other.contains(RECEIVED_OBJECT))
207  {
208  envelope.setReceivedObject(other.getReceivedObject());
209  }
210 
211  if(other.contains(TRANSPORT_BEHAVIOUR))
212  {
213  envelope.setTransportBehaviour(other.getTransportBehaviour());
214  }
215 
217  {
218  envelope.setUserdefinedParameters(other.getUserdefinedParameters());
219  }
220 
221  return envelope;
222 }
const ReceivedObject & getReceivedObject() const
Definition: acl_envelope.h:281
The ACLBaseEnvelope defines the layout for an envelope with which ACLMessage data can be wrapped...
Definition: acl_envelope.h:36
const TransportBehaviour & getTransportBehaviour() const
Definition: acl_envelope.h:297
const PayloadLength & getPayloadLength() const
Definition: acl_envelope.h:226
const PayloadEncoding & getPayloadEncoding() const
Definition: acl_envelope.h:236
const AgentIDList & getIntendedReceivers() const
Definition: acl_envelope.h:256
const base::Time & getDate() const
Definition: acl_envelope.h:246
const UserdefinedParameterList & getUserdefinedParameters() const
Definition: acl_envelope.h:307
bool contains(envelope::ParameterId id) const
Definition: acl_envelope.h:144
const representation::Type & getACLRepresentation() const
Definition: acl_envelope.h:203
const Comments & getComments() const
Definition: acl_envelope.h:191
const AgentIDList & getTo() const
Definition: acl_envelope.h:150
const AgentID & getFrom() const
Definition: acl_envelope.h:179

◆ removeIntendedReceiver()

bool fipa::acl::ACLBaseEnvelope::removeIntendedReceiver ( const AgentID agent)

Remove an intended receiver from this list of intended receivers

Definition at line 124 of file acl_envelope.cpp.

125 {
126  AgentIDList::iterator it = find_if(mIntendedReceivers.begin(), mIntendedReceivers.end(), arg1 == agentId);
127  if(it != mIntendedReceivers.end())
128  {
129  mIntendedReceivers.erase(it);
130  return true;
131  }
132  return false;
133 }

◆ removeTo()

bool fipa::acl::ACLBaseEnvelope::removeTo ( const AgentID agentId)

Remove an agents from the 'to' list

Returns
true upon success, i.e. if the agent was is this list false otherwise

Definition at line 44 of file acl_envelope.cpp.

45 {
46  AgentIDList::iterator it = find_if(mTo.begin(), mTo.end(), arg1 == agentId);
47  if(it != mTo.end())
48  {
49  mTo.erase(it);
50  return true;
51  }
52  return false;
53 }

◆ setACLRepresentation() [1/2]

void fipa::acl::ACLBaseEnvelope::setACLRepresentation ( representation::Type  representation)

Set the acl representation in use "This is the name of the syntax representation of the message payload." [http://www.fipa.org/specs/fipa00067/SC00067F.html#_Toc26669814]

Definition at line 69 of file acl_envelope.cpp.

70 {
71  mParameters = (ParameterId) (mParameters | ACL_REPRESENTATION);
72  mACLRepresentation = representation;
73 }

◆ setACLRepresentation() [2/2]

void fipa::acl::ACLBaseEnvelope::setACLRepresentation ( const std::string &  represention)

Set ACLRepresentation from string as defined in standard specification

Exceptions
ifthe ACLRepresentation in unknown to the system

Definition at line 76 of file acl_envelope.cpp.

77 {
78  for(int i = (int) representation::UNKNOWN; i < (int) representation::END_MARKER; ++i)
79  {
80  if(representation == representation::TypeTxt[i])
81  {
83  return;
84  }
85  }
86  std::string msg = "Trying to set unknown representation '" + representation + "'";
87  LOG_ERROR_S << msg;
88  throw std::runtime_error(msg);
89 }
const std::string TypeTxt[]
Definition: types.h:28
void setACLRepresentation(representation::Type representation)

◆ setComments()

void fipa::acl::ACLBaseEnvelope::setComments ( const Comments comments)

Set comments

Parameters
commentsComments to be set

Definition at line 63 of file acl_envelope.cpp.

64 {
65  mParameters = (ParameterId) (mParameters | COMMENTS);
66  mComments = comments;
67 }

◆ setDate()

void fipa::acl::ACLBaseEnvelope::setDate ( const base::Time &  date)

Set creation date and time of the message envelope

Definition at line 103 of file acl_envelope.cpp.

104 {
105  mParameters = (ParameterId) (mParameters | DATE);
106  mDate = date;
107 }

◆ setFrom()

void fipa::acl::ACLBaseEnvelope::setFrom ( const AgentID from)

Set sender id

Parameters
from

Definition at line 56 of file acl_envelope.cpp.

57 {
58  mParameters = (ParameterId) (mParameters | FROM);
59  mFrom = from;
60 }

◆ setIntendedReceivers()

void fipa::acl::ACLBaseEnvelope::setIntendedReceivers ( const AgentIDList receivers)

Set intended receivers

Definition at line 109 of file acl_envelope.cpp.

110 {
111  mParameters = (ParameterId) (mParameters | INTENDED_RECEIVERS);
112  mIntendedReceivers = receivers;
113 }

◆ setPayloadEncoding()

void fipa::acl::ACLBaseEnvelope::setPayloadEncoding ( const PayloadEncoding encoding)

Set the payload encoding (default is US-ASCII)

Definition at line 97 of file acl_envelope.cpp.

98 {
99  mParameters = (ParameterId) (mParameters | PAYLOAD_ENCODING);
100  mPayloadEncoding = encoding;
101 }

◆ setPayloadLength()

void fipa::acl::ACLBaseEnvelope::setPayloadLength ( const PayloadLength length)

Set the length of the payload

Definition at line 91 of file acl_envelope.cpp.

92 {
93  mParameters = (ParameterId) (mParameters | PAYLOAD_LENGTH);
94  mPayloadLength = length;
95 }

◆ setReceivedObject()

void fipa::acl::ACLBaseEnvelope::setReceivedObject ( const ReceivedObject receivedObject)

Set the received object list

Definition at line 135 of file acl_envelope.cpp.

136 {
137  mParameters = (ParameterId) (mParameters | RECEIVED_OBJECT);
138  mReceivedObject = receivedObject;
139 }

◆ setTo()

void fipa::acl::ACLBaseEnvelope::setTo ( const AgentIDList receivers)

Set destination

Parameters
receiversreceiver list

Definition at line 38 of file acl_envelope.cpp.

39 {
40  mParameters = (ParameterId) (mParameters | TO);
41  mTo = receivers;
42 }

◆ setTransportBehaviour()

void fipa::acl::ACLBaseEnvelope::setTransportBehaviour ( const TransportBehaviour transportBehaviour)

Set the transport behaviour

Definition at line 151 of file acl_envelope.cpp.

152 {
153  mParameters = (ParameterId) (mParameters | TRANSPORT_BEHAVIOUR);
154  mTransportBehaviour = transportBehaviour;
155 }

◆ setUserdefinedParameters()

void fipa::acl::ACLBaseEnvelope::setUserdefinedParameters ( const UserdefinedParameterList parameters)

Set userdefined parameters

Definition at line 157 of file acl_envelope.cpp.

158 {
159  mParameters = (ParameterId) (mParameters | USERDEFINED_PARAMETERS);
160  mUserdefinedParameters = parameters;
161 }

◆ stamp()

void fipa::acl::ACLBaseEnvelope::stamp ( const ReceivedObject receivedObject)
inline

Add a receipt for this message, i.e. add a received object to the envelope. This function is an alias for setReceivedObject

Definition at line 330 of file acl_envelope.h.

330 { setReceivedObject(receivedObject); }
void setReceivedObject(const ReceivedObject &receivedObject)

The documentation for this class was generated from the following files: