fipa_acl  1.4
transition.h
Go to the documentation of this file.
1 
7 #ifndef _FIPAACL_CONVMONITOR_TRANSITION_H_
8 #define _FIPAACL_CONVMONITOR_TRANSITION_H_
9 
10 #include <fipa_acl/bitefficient_message.h>
11 #include <algorithm>
12 #include <fipa_acl/conversation_monitor/role.h>
13 #include <fipa_acl/conversation_monitor/state.h>
14 
15 namespace fipa {
16 namespace acl {
17 
18 namespace validation {
19  enum Flags { NONE = 0x00, ALL = 0xFFFF, PERFORMATIVE=0x01, SENDER = 0x02, RECEIVERS = 0x04, CONVERSATION_ID = 0x08,
20  PROTOCOL = 0x10, ENCODING = 0x20, LANGUAGE=0x40, ONTOLOGY = 0x80, IN_REPLY_TO=0x100 };
21 }
22 
26 class Transition
27 {
28  private:
30  Role mSenderRole;
31 
33  Role mReceiverRole;
34 
36  std::string mPerformativeRegExp;
37 
38  // Source state where this transition starts from
39  StateId mSourceStateId;
40 
41  // state that this transition ends in
42  StateId mTargetStateId;
43 
44  public:
45 
49  Transition();
50 
54  Transition(const Role& senderRole, const Role& receiverRole, const fipa::acl::ACLMessage::Performative& performative, const fipa::acl::StateId& sourceState, const fipa::acl::StateId& targetState);
55 
59  Transition(const Role& senderRole, const Role& receiverRole, const std::string& performativeRegExp, const StateId& sourceState, const StateId& targetState);
60 
69  bool triggers(const ACLMessage &msg, const ACLMessage& initiatingMsg, const RoleMapping& roleMapping) const;
70 
79  bool validateMessage(const ACLMessage &msg, const ACLMessage& validatorMsg, const RoleMapping& roleMapping, validation::Flags flags = validation::ALL) const;
80 
85  void setPerformativeRegExp(const std::string& performativeRegExp) { mPerformativeRegExp = performativeRegExp; }
86 
91  void setPerformative(const fipa::acl::ACLMessage::Performative& performative) { mPerformativeRegExp = fipa::acl::PerformativeTxt[performative]; }
92 
96  void setSourceState(const StateId& stateId) { mSourceStateId = stateId; }
97 
101  void setTargetState(const StateId& stateId) { mTargetStateId = stateId; }
102 
106  void setSenderRole(const Role& role) { mSenderRole = role; }
107 
111  void setReceiverRole(const Role& role) { mReceiverRole = role; }
112 
116  Role getSenderRole() const { return mSenderRole; }
117 
121  Role getReceiverRole() const { return mReceiverRole; }
122 
123 
128  std::string getPerformativeRegExp() const { return mPerformativeRegExp; }
129 
133  StateId getSourceStateId() const { return mSourceStateId; }
134 
138  StateId getTargetStateId() const { return mTargetStateId; }
139 
143  std::string toString() const;
144 
148  std::string toXML() const;
149 
153  bool operator==(const Transition& t) const;
154 
155  private:
156 
158  bool validateReceivers(const ACLMessage& msg, const RoleMapping& roleMapping) const;
159 };
160 
164 namespace default_transition
165 {
170  class NotUnderstood : public Transition
171  {
172  public:
173  NotUnderstood(const Role& senderRole, const Role& receiverRole, const StateId& stateId);
174  };
175 
180  {
181  public:
182  ConversationCancelling(const Role& senderRole, const Role& receiverRole, const StateId& stateId);
183 
184  };
185 
190  {
191  public:
193 
194  };
195 
200  {
201  public:
203 
204  };
205 
212  class GeneralFailure : public Transition
213  {
214  public:
215  GeneralFailure(const StateId& sourceState);
216  };
217 }
218 
219 
220 } // end of acl
221 } // end of fipa
222 
223 #endif
void setPerformativeRegExp(const std::string &performativeRegExp)
setter methods for various fields of the class
Definition: transition.h:85
void setSenderRole(const Role &role)
Definition: transition.h:106
void setReceiverRole(const Role &role)
Definition: transition.h:111
void setSourceState(const StateId &stateId)
Definition: transition.h:96
std::string StateId
Definition: state.h:35
Role getReceiverRole() const
Definition: transition.h:121
Role getSenderRole() const
Definition: transition.h:116
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
Mapping between roles and actual agent ids.
Definition: role.h:98
std::map< ACLMessage::Performative, std::string > PerformativeTxt
Definition: acl_message.cpp:15
void setPerformative(const fipa::acl::ACLMessage::Performative &performative)
setter methods for various fields of the class
Definition: transition.h:91
This class provides a representation of a message conforming to the FIPA specification SC00061...
Definition: acl_message.h:55
StateId getSourceStateId() const
Definition: transition.h:133
void setTargetState(const StateId &stateId)
Definition: transition.h:101
std::string getPerformativeRegExp() const
getter methods for various fields of the class
Definition: transition.h:128
StateId getTargetStateId() const
Definition: transition.h:138
Foundation of Physical Intelligent Agents.
Definition: conversation.cpp:6