yasmine
transition_executor_impl.hpp
Go to the documentation of this file.
1 // //
3 // This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). //
4 // Copyright (C) 2016-2017 Seadex GmbH //
5 // //
6 // Licensing information is available in the folder "license" which is part of this distribution. //
7 // The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. //
8 // //
10 
11 
12 #ifndef TRANSITION_EXECUTOR_IMPL_D556EFC8_A5CE_4750_96D9_BDDBF8FFF10A
13 #define TRANSITION_EXECUTOR_IMPL_D556EFC8_A5CE_4750_96D9_BDDBF8FFF10A
14 
15 
16 #include "essentials/non_copyable.hpp"
17 
18 #include "state_fwd.hpp"
19 #include "region_fwd.hpp"
20 #include "choice_fwd.hpp"
22 #include "transition_step_fwd.hpp"
23 #include "execution_step_fwd.hpp"
25 #include "event_fwd.hpp"
26 #include "transition_kind.hpp"
27 
28 
29 namespace sxy
30 {
31 
32 
33 class event_processing_callback;
34 class composite_state;
35 class async_event_handler;
36 class choice;
37 class vertex;
38 class event_collector;
39 
40 
41 namespace impl
42 {
43 
44 
46 {
47 public:
49  virtual ~transition_executor_impl() SX_NOEXCEPT;
50  SX_NO_COPY(transition_executor_impl)
52  void get_active_states_from_regions( const state* const _state,
55  compound_transition_consumer& _compound_transition, raw_const_region_set& _entered_regions,
56  raw_states_by_nesting_level& _states_to_enter, const event& _event, event_collector& _event_collector );
58  compound_transition_consumer& _compound_transition,
59  const raw_states_by_nesting_level_ascending& _states_to_exit,
60  transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end );
62  compound_transition_consumer& _compound_transition, const raw_states_by_nesting_level& _states_to_enter,
63  transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end );
64  void calculate_execution_steps( compound_transition_consumer& _compound_transition,
65  const raw_states_by_nesting_level_ascending& _states_to_exit,
66  const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps,
67  raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector );
68  static bool run_execution_steps( const execution_steps& _execution_steps,
69  event_processing_callback* const _event_processing_callback, const event& _event,
70  events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector );
71  void conflict_check( const compound_transitions& _compound_transitions ) const;
73  const compound_transitions& _unsorted_compound_transitions );
74  void find_all_states_to_exit( compound_transition_consumer& _compound_transition,
75  raw_states_by_nesting_level_ascending& _states_to_exit );
76  void find_all_states_to_enter( compound_transition_consumer& _compound_transition,
77  raw_states_by_nesting_level& _states_to_enter, raw_const_region_set& _regions_to_enter, const event& _event,
78  event_collector& _event_collector );
79  void add_remaining_states_to_enter( const raw_states_by_nesting_level::const_iterator _state_start,
80  const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps );
81  void add_remaining_states_to_exit( const raw_states_by_nesting_level_ascending::const_iterator _state_start,
82  const raw_states_by_nesting_level_ascending& _states, execution_steps& _execution_steps );
83  void add_remained_transitions( transition_steps::const_iterator& _transition_start,
84  const transition_steps::const_iterator& _transition_end, execution_steps& _execution_steps );
85  void fill_vector_of_choices( raw_const_choices& _choices, const compound_transitions& _compound_transitions );
86  void find_already_entered_regions( compound_transition& new_compound_transition,
87  raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector );
90  raw_const_region_set& _entered_regions, const event& _event, bool _find_states_to_exit,
91  event_collector& _event_collector );
92  void check_conflicts_from_source_state_to_LCA( const state& _state, raw_const_state_set& _unique_exit_states,
93  const composite_state* _LCA ) const;
94 
95 
96 private:
97  void get_all_parent_states_to_enter( raw_states_by_nesting_level& _states_to_enter, choice& _choice,
98  const vertex& source_vertex ) const;
99  void fill_vector_of_states_to_exit( region* _LCA_region, raw_states_by_nesting_level_ascending& _states_to_exit,
100  const transition_kind _compound_transition_kind );
101 };
102 
103 
104 }
105 
106 
107 }
108 
109 #endif
void calculate_execution_steps(compound_transition_consumer &_compound_transition, const raw_states_by_nesting_level_ascending &_states_to_exit, const raw_states_by_nesting_level &_states_to_enter, execution_steps &_execution_steps, raw_const_region_set &_entered_regions, const event &_event, event_collector &_event_collector)
Definition: transition_executor_impl.cpp:295
static bool run_execution_steps(const execution_steps &_execution_steps, event_processing_callback *const _event_processing_callback, const event &_event, events &_exception_events, async_event_handler *const _async_event_handler, event_collector &_event_collector)
Definition: transition_executor_impl.cpp:333
std::vector< compound_transition_uptr > compound_transitions
Definition: compound_transition_fwd.hpp:32
void add_remaining_states_to_exit(const raw_states_by_nesting_level_ascending::const_iterator _state_start, const raw_states_by_nesting_level_ascending &_states, execution_steps &_execution_steps)
Definition: transition_executor_impl.cpp:515
Definition: event_collector.hpp:25
void get_active_states_from_region(region &_region, raw_states_by_nesting_level_ascending &_states)
Definition: transition_executor_impl.cpp:60
void check_conflicts_from_source_state_to_LCA(const state &_state, raw_const_state_set &_unique_exit_states, const composite_state *_LCA) const
Definition: transition_executor_impl.cpp:595
Definition: state.hpp:33
void conflict_check(const compound_transitions &_compound_transitions) const
Definition: transition_executor_impl.cpp:355
void merge_transitions_steps_with_enter_states_steps(execution_steps &_execution_steps, compound_transition_consumer &_compound_transition, const raw_states_by_nesting_level &_states_to_enter, transition_steps::const_iterator &_transition_start, transition_steps::const_iterator &_transition_end)
Definition: transition_executor_impl.cpp:210
void fill_vector_of_choices(raw_const_choices &_choices, const compound_transitions &_compound_transitions)
Definition: transition_executor_impl.cpp:544
static raw_compound_transitions sort_compound_transitions(const compound_transitions &_unsorted_compound_transitions)
Definition: transition_executor_impl.cpp:388
void get_active_states_from_regions(const state *const _state, raw_states_by_nesting_level_ascending &_states)
Definition: transition_executor_impl.cpp:80
Definition: composite_state.hpp:28
transition_executor_impl()
Definition: transition_executor_impl.cpp:48
Definition: region.hpp:42
void find_all_states_to_enter(compound_transition_consumer &_compound_transition, raw_states_by_nesting_level &_states_to_enter, raw_const_region_set &_regions_to_enter, const event &_event, event_collector &_event_collector)
Definition: transition_executor_impl.cpp:436
std::set< const state *> raw_const_state_set
Definition: state_fwd.hpp:31
Interface of an event. An event has an ID, a name and a priority (for processing by the async state m...
Definition: event.hpp:28
void find_all_states_to_exit(compound_transition_consumer &_compound_transition, raw_states_by_nesting_level_ascending &_states_to_exit)
Definition: transition_executor_impl.cpp:415
Definition: async_event_handler.hpp:22
Definition: adapter_cpp11.hpp:21
Definition: transition_executor_impl.hpp:45
Callback interface that is called by a state machine during event processing. See the different metho...
Definition: event_processing_callback.hpp:37
void find_states_to_enter_and_to_exit_and_calculate_execution_steps(compound_transition_consumer &compound_transition, execution_steps &_execution_steps, raw_const_region_set &_entered_regions, const event &_event, bool _find_states_to_exit, event_collector &_event_collector)
Definition: transition_executor_impl.cpp:571
void find_already_entered_regions(compound_transition &new_compound_transition, raw_const_region_set &_entered_regions, const event &_event, event_collector &_event_collector)
Definition: transition_executor_impl.cpp:563
void merge_transitions_steps_with_exit_state_steps(execution_steps &_execution_steps, compound_transition_consumer &_compound_transition, const raw_states_by_nesting_level_ascending &_states_to_exit, transition_steps::const_iterator &_transition_start, transition_steps::const_iterator &_transition_end)
Definition: transition_executor_impl.cpp:151
Definition: vertex.hpp:36
virtual ~transition_executor_impl() SX_NOEXCEPT
Definition: transition_executor_impl.cpp:54
std::vector< execution_step_uptr > execution_steps
Definition: execution_step_fwd.hpp:27
Definition: choice.hpp:24
Definition: compound_transition_consumer.hpp:32
std::vector< compound_transition *> raw_compound_transitions
Definition: compound_transition_fwd.hpp:31
Definition: compound_transition.hpp:33
std::vector< const choice *> raw_const_choices
Definition: choice_fwd.hpp:28
std::set< const region *> raw_const_region_set
Definition: region_fwd.hpp:30
transition_kind
Definition: transition_kind.hpp:25
void add_remained_transitions(transition_steps::const_iterator &_transition_start, const transition_steps::const_iterator &_transition_end, execution_steps &_execution_steps)
Definition: transition_executor_impl.cpp:531
std::set< state *, states_nesting_comparer_ascending > raw_states_by_nesting_level_ascending
Definition: state_fwd.hpp:34
void add_remaining_states_to_enter(const raw_states_by_nesting_level::const_iterator _state_start, const raw_states_by_nesting_level &_states_to_enter, execution_steps &_execution_steps)
Definition: transition_executor_impl.cpp:498
void get_all_states_to_enter_from_regions_that_are_not_explicitly_entered(compound_transition_consumer &_compound_transition, raw_const_region_set &_entered_regions, raw_states_by_nesting_level &_states_to_enter, const event &_event, event_collector &_event_collector)
Definition: transition_executor_impl.cpp:103
std::set< state *, states_nesting_comparer > raw_states_by_nesting_level
Definition: state_fwd.hpp:33
std::vector< event_sptr > events
Definition: event_fwd.hpp:27