6 #include <boost/assign/list_of.hpp>
7 #include <boost/date_time.hpp>
8 #include <boost/foreach.hpp>
15 std::map<ACLMessage::Performative, std::string>
PerformativeTxt = boost::assign::map_list_of
44 std::map<ACLMessage::Performative, std::string>::const_iterator it =
PerformativeTxt.begin();
47 if(it->second == performative)
52 std::string msg =
"String '" + performative +
"' does not match any existing performative definition";
53 throw std::runtime_error(msg);
71 snprintf(buffer, 512,
"Illegal characters in given performative: %s", perf.c_str());
72 throw std::runtime_error(buffer);
123 std::map<Performative, std::string>::iterator it;
127 throw std::runtime_error(
"Cannot set performative. Performative unknown");
130 mPerformative = it->second;
139 snprintf(buffer, 512,
"Illegal characters in given performative: %s", str.c_str());
140 throw std::runtime_error(buffer);
150 if ( find(mReceivers.begin(), mReceivers.end(),aid) == mReceivers.end() )
152 mReceivers.insert(mReceivers.begin(),aid);
160 std::vector<AgentID>::iterator it = find(mReceivers.begin(), mReceivers.end(),aid);
161 if ( it != mReceivers.end())
163 mReceivers.erase(it);
176 if ( find(mReplyTo.begin(), mReplyTo.end(),aid) == mReplyTo.end() )
178 mReplyTo.insert(mReplyTo.begin(),aid);
186 std::vector<AgentID>::iterator it = find(mReplyTo.begin(), mReplyTo.end(),aid);
187 if (it != mReplyTo.end() )
203 snprintf(buffer, 512,
"Protocol name contains illegal characters: %s", str.c_str());
204 throw std::runtime_error(buffer);
213 return ( strlen(mContent.c_str()) != mContent.size() );
218 if (find (mParameters.begin(),mParameters.end(),p) == mParameters.end() )
220 mParameters.insert(mParameters.begin(),p);
227 mParameters.insert(mParameters.begin(),p.begin(),p.end());
258 AgentIDList::iterator ait = agentsA.begin();
259 AgentIDList::iterator bit = agentsB.begin();
263 while (ait != agentsA.end())
266 bit = agentsB.begin();
267 while (bit != agentsB.end())
272 ait = agentsA.begin();
288 if (!agentsA.empty() || !agentsB.empty())
294 ait = agentsA.begin();
295 bit = agentsB.begin();
296 while (ait != agentsA.end())
299 bit = agentsB.begin();
300 while (bit != agentsB.end())
305 ait = agentsA.begin();
320 if (!agentsA.empty())
322 if (!agentsB.empty())
328 std::vector<UserdefParam>::iterator pita = paramsA.begin();
329 std::vector<UserdefParam>::iterator pitb = paramsB.begin();
331 while (pita != paramsA.end())
334 pitb = paramsB.begin();
335 while (pitb != paramsB.end())
340 pita = paramsA.begin();
342 pitb = paramsB.end();
354 if (!paramsA.empty())
357 if (!paramsB.empty())
365 std::stringstream ss;
367 ss << mPerformative << std::endl;
368 ss <<
":sender (agent-identifier :name " << mSender.
getName() <<
" )" << std::endl;
370 if(!mReceivers.empty())
372 ss <<
":receiver (set "<< std::endl;
373 BOOST_FOREACH(
const AgentID& agent, mReceivers)
375 ss <<
"\t(agent-identifier ";
376 ss <<
":name " << agent.
getName();
377 ss <<
") " << std::endl;
379 ss <<
")" << std::endl;
382 if(!mLanguage.empty())
384 ss <<
":language " << mLanguage << std::endl;
387 if(!mEncoding.empty())
389 ss <<
":encoding " << mEncoding << std::endl;
392 if(!mOntology.empty())
394 ss <<
":ontology " << mOntology << std::endl;
397 if(!mProtocol.empty())
399 ss <<
":protocol " << mProtocol << std::endl;
402 if(!mConversationId.empty())
404 ss <<
":conversation-id " << mConversationId << std::endl;
407 if(!mReplyWith.empty())
409 ss <<
":reply-with " << mReplyWith << std::endl;
412 if(!mInReplyTo.empty())
414 ss <<
":in-reply-to " << mInReplyTo << std::endl;
417 if(!mReplyBy.isNull())
419 ss <<
":reply-by " << mReplyBy.toString() << std::endl;
422 if(!mParameters.empty())
430 if(!mContent.empty())
432 ss <<
":content " << mContent << std::endl;
436 ss <<
")" << std::endl;
std::string getEncoding() const
std::string getContent() const
static bool compareEqual(const AgentID &a, const AgentID &b, int depth)
alternative function for equality operator; the depth can be specified through the depth param ...
std::vector< UserdefParam > getUserdefParams() const
const std::string & getName() const
setter and getter methods for all fields; they do not result in deep-copies assignments/retreivals, but this can be easily changed if needed through the overloaded operator which do
base::Time getReplyBy() const
std::string getPerformative() const
void setUserdefParams(const std::vector< UserdefParam > &p)
void deleteReplyTo(const AgentID &aid)
bool hasBinaryContent() const
std::string getReplyWith() const
std::vector< AgentID > AgentIDList
std::string getOntology() const
AgentIDList getAllReplyTo() const
void addReplyTo(const AgentID &aid)
const std::string & getValue() const
const std::string illegalWordStart
Performative
an enum of all the predefined fipa message performatives so far, presented in the order used in the m...
describes the general data structure of a message in conformity with the fipa specifications. The methods are pretty straight forward getter and setter methods. The set container is used for various colective fields, in order to avoid duplicates
std::string getLanguage() const
void addUserdefParam(const UserdefParam &p)
std::string getInReplyTo() const
static int msResolverComparisonDepth
std::map< ACLMessage::Performative, std::string > PerformativeTxt
const std::string & getName() const
AgentID getSender() const
std::string getProtocol() const
This class provides a representation of a message conforming to the FIPA specification SC00061...
bool operator==(const ACLMessage &other) const
static Performative performativeFromString(const std::string &performative)
overloaded equality operator for UserdefParam class objects
void addReceiver(const AgentID &aid)
void deleteReceiver(const AgentID &aid)
std::string toString() const
void setPerformative(Performative perf)
Set performative.
const std::string illegalWordChars
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
AgentIDList getAllReceivers() const
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
ACLMessage()
Default constructor.