ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shorting_action_sequence.h
Go to the documentation of this file.
1 #pragma once
2 
18 #include <boost/mpl/apply.hpp>
19 #include <boost/mpl/assert.hpp>
20 #include <boost/mpl/begin_end.hpp>
21 #include <boost/mpl/bool.hpp>
22 #include <boost/mpl/deref.hpp>
23 #include <boost/mpl/is_sequence.hpp>
24 #include <boost/mpl/next_prior.hpp>
25 #include <boost/mpl/vector.hpp>
26 #include <boost/msm/front/functor_row.hpp>
27 #include <boost/type_traits/is_same.hpp>
28 
32 namespace boost {
36 namespace msm {
40 namespace front {
46 template <class Sequence> struct ShortingActionSequence_ {
50  typedef Sequence sequence;
51  // if one functor of the sequence defers events, the complete sequence does
55  typedef ::boost::mpl::bool_<
56  ::boost::mpl::count_if<
57  sequence,
58  has_deferring_action<::boost::mpl::placeholders::_1>>::value != 0>
60 
68  template <class Event, class FSM, class STATE> struct state_action_result {
72  typedef void type;
73  };
81  template <class EVT, class FSM, class STATE> struct Call {
89  Call(EVT const &evt, FSM &fsm, STATE &state)
90  : evt_(evt), fsm_(fsm), state_(state) {}
100  template <class FCT> bool operator()(::boost::msm::wrap<FCT> const &) {
101  return FCT()(evt_, fsm_, state_);
102  }
103 
104  private:
105  EVT const &evt_;
106  FSM &fsm_;
107  STATE &state_;
108  };
117  template <class EVT, class FSM, class SourceState, class TargetState>
122  typedef void type;
123  };
132  template <class EVT, class FSM, class SourceState, class TargetState>
142  CallSourceTarget(EVT const &evt, FSM &fsm, SourceState &src,
143  TargetState &tgt)
144  : evt_(evt), fsm_(fsm), src_(src), tgt_(tgt) {}
154  template <class FCT> bool operator()(::boost::msm::wrap<FCT> const &) {
155  return FCT()(evt_, fsm_, src_, tgt_);
156  }
157 
158  private:
159  EVT const &evt_;
160  FSM &fsm_;
161  SourceState &src_;
162  TargetState &tgt_;
163  };
164 
168  typedef ::boost::mpl::set<state_action_tag, action_tag> tag_type;
169 
182  template <class EVT, class FSM, class STATE>
183  bool operator()(EVT const &evt, FSM &fsm, STATE &state) {
185  Sequence, boost::msm::wrap<::boost::mpl::placeholders::_1>>(
186  Call<EVT, FSM, STATE>(evt, fsm, state));
187  }
202  template <class EVT, class FSM, class SourceState, class TargetState>
203  bool operator()(EVT const &evt, FSM &fsm, SourceState &src,
204  TargetState &tgt) {
206  Sequence, boost::msm::wrap<::boost::mpl::placeholders::_1>>(
208  tgt));
209  }
210 };
211 }
212 }
213 }
Sequence sequence
Sequence of elements that are instantiated and evaluated.
Definition: shorting_action_sequence.h:50
bool operator()(::boost::msm::wrap< FCT > const &)
operator function that instantiates the functor and evaluates it on the event, fsm, state
Definition: shorting_action_sequence.h:100
void type
Define the result type to void maybe?
Definition: shorting_action_sequence.h:72
::boost::mpl::bool_< ::boost::mpl::count_if< sequence, has_deferring_action<::boost::mpl::placeholders::_1 > >::value!=0 > some_deferring_actions
Deferring actions for the sequence.
Definition: shorting_action_sequence.h:59
CallSourceTarget(EVT const &evt, FSM &fsm, SourceState &src, TargetState &tgt)
Constructor to store event, statemachine, source, target.
Definition: shorting_action_sequence.h:142
Not sure what this is! Copied from boost main file.
Definition: shorting_action_sequence.h:118
Functor used to instantiate and evaluate elements in the sequence.
Definition: shorting_action_sequence.h:81
Copied from boost main file. Not sure what this is for!
Definition: shorting_action_sequence.h:68
bool operator()(EVT const &evt, FSM &fsm, SourceState &src, TargetState &tgt)
operator to evaluate the action sequence
Definition: shorting_action_sequence.h:203
bool operator()(::boost::msm::wrap< FCT > const &)
operator function that instantiates the functor and evaluates it on the event, fsm, source, target state
Definition: shorting_action_sequence.h:154
bool exec_if(F f, Sequence *=0, TransformOp *=0)
Function to go through elements of boost sequence and apply the functor F on each element...
Definition: exec_if.h:135
Functor used to instantiate and evaluate elements in the sequence.
Definition: shorting_action_sequence.h:133
::boost::mpl::set< state_action_tag, action_tag > tag_type
Tag type.
Definition: shorting_action_sequence.h:168
void type
Type of action result.
Definition: shorting_action_sequence.h:122
Action sequence that runs until one of the actions returns false.
Definition: shorting_action_sequence.h:46
Call(EVT const &evt, FSM &fsm, STATE &state)
Constructor to store event, state machine, state.
Definition: shorting_action_sequence.h:89
bool operator()(EVT const &evt, FSM &fsm, STATE &state)
operator to evaluate the action sequence
Definition: shorting_action_sequence.h:183