fipa_acl  1.4
state.h
Go to the documentation of this file.
1 
8 #ifndef _FIPAACL_CONVMONITOR_STATE_H_
9 #define _FIPAACL_CONVMONITOR_STATE_H_
10 
11 #include <map>
12 #include <vector>
13 
14 #include <fipa_acl/message_generator/acl_message.h>
15 #include <fipa_acl/conversation_monitor/role.h>
16 
17 namespace fipa {
18 namespace acl {
19 
20 struct EmbeddedStateMachine;
21 class StateMachine;
22 class MessageArchive;
23 class Transition;
24 namespace default_transition {
25  class NotUnderstood;
29  class GeneralFailure;
30 }
31 
35 typedef std::string StateId;
36 
41 class State
42 {
43  friend class Transition;
49  friend class StateMachineReader;
50  friend class StateMachine;
51 
52 private:
56  StateId mId;
57 
61  bool mIsFinal;
62 
66  std::vector<Transition> mTransitions;
67 
74  std::vector<EmbeddedStateMachine> mEmbeddedStateMachines;
75 
79  std::vector<fipa::acl::StateMachine> mSubStateMachines;
80 
86  std::vector<Transition> mSubstateMachineProxiedTransitions;
87 
88  static std::vector<StateId> msDefaultStates;
89 
90 protected:
97  void setFinal(bool final) { mIsFinal = final; }
98 
99 public:
103  const static StateId UNDEFINED_ID;
104  const static StateId NOT_UNDERSTOOD;
105  const static StateId CONVERSATION_CANCELLING;
106  const static StateId CONVERSATION_CANCEL_SUCCESS;
107  const static StateId CONVERSATION_CANCEL_FAILURE;
108  const static StateId GENERAL_FAILURE_STATE;
109 
113  State();
114 
119  State(const StateId& id);
120 
125  Transition addTransition(const Transition& t);
126 
132  const Transition& getTransition(const ACLMessage &msg, const MessageArchive& archive, const RoleMapping& roleMapping) const;
133 
138  void consumeSubStateMachineMessage(const ACLMessage& msg, const fipa::acl::StateMachine& stateMachine, const fipa::acl::RoleMapping& roleMapping, int numberOfSubConversations);
139 
146  const Transition& getSubstateMachineProxiedTransition(const ACLMessage &msg, const MessageArchive& archive, const RoleMapping& roleMapping);
147 
154  void generateDefaultTransitions();
155 
156  bool isFinal() const { return mIsFinal; }
157 
163  bool isFinished() const;
164 
169  bool isDefaultState() const;
170 
176  void setId(const StateId& id) { mId = id; }
177 
181  std::string getId() const { return mId; }
182 
187  const std::vector<Transition>& getTransitions() const { return mTransitions; }
188 
193  const std::vector<EmbeddedStateMachine>& getEmbeddedStatemachines() const { return mEmbeddedStateMachines; }
194 
198  void addEmbeddedStateMachine(fipa::acl::EmbeddedStateMachine embeddedStateMachine);
199 
203  std::string toString() const;
204 
208  std::string toXML() const;
209 
210 };
211 
212 class FinalState : public State
213 {
214 public:
215  FinalState(const StateId& id);
216 };
217 
218 class UndefinedState : public State
219 {
220 public:
221  UndefinedState();
222 };
223 
224 namespace default_state
225 {
229  class NotUnderstood : public FinalState
230  {
231  public:
232  NotUnderstood() : FinalState(State::NOT_UNDERSTOOD)
233  {}
234  };
235 
240  {
241  public:
243  };
244 
249  {
250  public:
251  ConversationCancelSuccess() : FinalState(State::CONVERSATION_CANCEL_SUCCESS)
252  {}
253  };
254 
259  {
260  public:
261  ConversationCancelFailure() : FinalState(State::CONVERSATION_CANCEL_FAILURE)
262  {}
263  };
264 
265  class GeneralFailure : public FinalState
266  {
267  public:
268  GeneralFailure() : FinalState(State::GENERAL_FAILURE_STATE)
269  {}
270  };
271 }
272 
273 } // end of acl
274 } // end of fipa
275 
276 #endif
implements a state of the StateMachine class
Definition: state.h:41
static const StateId GENERAL_FAILURE_STATE
Definition: state.h:108
static const StateId CONVERSATION_CANCEL_FAILURE
Definition: state.h:107
static const StateId CONVERSATION_CANCELLING
Definition: state.h:105
void setId(const StateId &id)
setter method for the uid field of the state NOTE: maybe should be taken out and name only be allowed...
Definition: state.h:176
std::string StateId
Definition: state.h:35
std::string getId() const
getter method for the uid field of the class
Definition: state.h:181
implements a XML parser that generates a state machine from a given spec. file; uses the tinyXML libr...
void setFinal(bool final)
setter method for the final field of the class When changing the final state flag make sure you eithe...
Definition: state.h:97
Mapping between roles and actual agent ids.
Definition: role.h:98
An embedded state machine with mappings.
Definition: statemachine.h:200
const std::vector< Transition > & getTransitions() const
Definition: state.h:187
const std::vector< EmbeddedStateMachine > & getEmbeddedStatemachines() const
Definition: state.h:193
This class provides a representation of a message conforming to the FIPA specification SC00061...
Definition: acl_message.h:55
bool isFinal() const
Definition: state.h:156
static const StateId CONVERSATION_CANCEL_SUCCESS
Definition: state.h:106
static const StateId UNDEFINED_ID
Definition: state.h:103
static const StateId NOT_UNDERSTOOD
Definition: state.h:104
Foundation of Physical Intelligent Agents.
Definition: conversation.cpp:6