8 #include <boost/regex.hpp> 9 #include <base-logging/Logging.hpp> 17 , mPerformativeRegExp()
24 : mSenderRole(senderRole)
25 , mReceiverRole(receiverRole)
27 , mSourceStateId(sourceState)
28 , mTargetStateId(targetState)
34 : mSenderRole(senderRole)
35 , mReceiverRole(receiverRole)
36 , mPerformativeRegExp(performativeRegExp)
37 , mSourceStateId(sourceState)
38 , mTargetStateId(targetState)
50 LOG_DEBUG(
"Message validation failed: message does not apply to transition");
66 boost::regex performativeRegex(mPerformativeRegExp);
69 LOG_DEBUG(
"Performative validation failed: was '%s' but expected: '%s'", msg.
getPerformative().c_str(), mPerformativeRegExp.c_str());
77 if(!roleMapping.
isExpected(mSenderRole, senderAgent))
79 LOG_DEBUG(
"Sender validation failed: '%s' unexpected for role '%s'", senderAgent.
getName().c_str(), mSenderRole.
getId().c_str());
86 if(!validateReceivers(msg, roleMapping))
88 LOG_DEBUG(
"Receivers validation failed");
106 LOG_DEBUG(
"Protocol validation failed: was '%s' but expected: '%s'", msg.
getProtocol().c_str(), validatorMsg.
getProtocol().c_str());
115 LOG_DEBUG(
"Encoding validation failed: was '%s' but expected: '%s'", msg.
getEncoding().c_str(), validatorMsg.
getEncoding().c_str());
124 LOG_DEBUG(
"Language validation failed: was '%s' but expected: '%s'", msg.
getLanguage().c_str(), validatorMsg.
getLanguage().c_str());
133 LOG_DEBUG(
"Ontology validation failed: was '%s' but expected: '%s'", msg.
getOntology().c_str(), validatorMsg.
getOntology().c_str());
142 LOG_DEBUG(
"InReplyTo validation failed: was '%s' but expected: '%s'", msg.
getInReplyTo().c_str(), validatorMsg.
getInReplyTo().c_str());
152 std::stringstream transition;
153 transition <<
"transition: sender role: '" << mSenderRole.
getId() <<
"', ";
154 transition <<
"receiver role: '" << mReceiverRole.
getId() <<
"', ";
155 transition <<
"performative: '" << mPerformativeRegExp <<
"', ";
156 transition <<
"source state: '" << mSourceStateId <<
"', ";
157 transition <<
"target state: '" << mTargetStateId <<
"'";
159 return transition.str();
164 std::stringstream transition;
165 transition <<
"<transition ";
166 transition <<
"performative=\"" << mPerformativeRegExp <<
"\" ";
167 transition <<
"from=\"" << mSenderRole.
getId() <<
"\" ";
168 transition <<
"to=\"" << mReceiverRole.
getId() <<
"\" ";
169 transition <<
"target=\"" << mTargetStateId <<
"\" ";
172 return transition.str();
178 if(actualReceivers.empty())
181 LOG_ERROR(
"%s",errorMsg.c_str());
182 throw std::runtime_error(errorMsg);
186 AgentIDList::const_iterator ait = actualReceivers.begin();
187 for(; ait != actualReceivers.end(); ++ait)
189 if(!roleMapping.
isExpected(mReceiverRole, *ait))
200 if(mSourceStateId != other.mSourceStateId)
203 }
else if (mTargetStateId != other.mTargetStateId)
206 }
else if (mSenderRole != other.mSenderRole)
209 }
else if (mReceiverRole != other.mReceiverRole)
212 }
else if (mPerformativeRegExp != other.mPerformativeRegExp)
223 namespace default_transition
226 NotUnderstood::NotUnderstood(
const Role& senderRole,
const Role& receiverRole,
const StateId& sourceState)
std::string getLanguage() const
describes the structure and operation of a transition of the state machine
bool isExpected(const Role &role, const AgentID &agent) const
std::string getConversationID() const
ConversationCancelFailure()
AgentID getSender() const
implements a state of the StateMachine class
std::string toString() const
GeneralFailure(const StateId &sourceState)
describes the structure and operation of a state machine
bool validateMessage(const ACLMessage &msg, const ACLMessage &validatorMsg, const RoleMapping &roleMapping, validation::Flags flags=validation::ALL) const
method that validates all parameters of a message
bool operator==(const Transition &t) const
std::vector< AgentID > AgentIDList
AgentIDList getAllReceivers() const
Performative
an enum of all the predefined fipa message performatives so far, presented in the order used in the m...
std::string getEncoding() const
std::string toXML() 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
Mapping between roles and actual agent ids.
ConversationCancelSuccess()
std::map< ACLMessage::Performative, std::string > PerformativeTxt
bool triggers(const ACLMessage &msg, const ACLMessage &initiatingMsg, const RoleMapping &roleMapping) const
check whether a certain message trigger the execution of the transition
std::string getPerformative() const
describes the structure and operation of a state, as part of a state machine
This class provides a representation of a message conforming to the FIPA specification SC00061...
ConversationCancelling(const Role &senderRole, const Role &receiverRole, const StateId &stateId)
Transition()
empty constructor for the transition class; initializes fields
std::string getInReplyTo() const
std::string getProtocol() const
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Foundation of Physical Intelligent Agents.
std::string getOntology() const