12 #ifndef STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 13 #define STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 16 #include "essentials/compatibility/thread.hpp" 36 class async_event_handler;
37 class event_processing_callback;
64 sxe::uint32_t get_number_of_processed_events()
const;
176 virtual bool run() = 0;
196 virtual std::string
get_name()
const;
212 virtual const events& get_deferred_events()
const SX_OVERRIDE;
213 virtual raw_const_states get_active_state_configuration()
const SX_OVERRIDE;
214 void get_active_states_from_region(
raw_const_states& _active_state_configuration,
const region& _region )
const;
215 void check_regions_for_active_states(
raw_const_states& _active_state_configuration,
const state& _state )
const;
216 void add_deferred_event(
const event_sptr& _event_id );
218 static void stop_all_async_states_from_region(
region_uptr& _region );
219 virtual void interrupt_impl();
220 void handle_unhandled_event(
const event_sptr& _event );
222 const std::string name_;
227 sxe::atomic<bool> state_machine_is_running_;
228 sxe::atomic<bool> interrupt_;
230 sxe::uint32_t processed_events_;
sxe::SX_UNIQUE_PTR< transition > transition_uptr
Definition: transition_fwd.hpp:25
Definition: event_collector.hpp:25
std::vector< state_machine_defect > state_machine_defects
Definition: state_machine_defect_fwd.hpp:23
The interface for state machine introspection. It is inherited by the state machine class state_machi...
Definition: state_machine_introspection.hpp:28
virtual std::string get_name() const
Get the name of the state machine.
Definition: state_machine_base.cpp:248
virtual void halt()
Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors...
Definition: state_machine_base.cpp:215
virtual bool is_interrupted() const SX_OVERRIDE
Get the internal flag of the state machine that specify if the run of state machine is interrupted...
Definition: state_machine_base.cpp:236
sxe::uint32_t event_id
The type alias for yasmine's event IDs.
Definition: event_id.hpp:26
composite_state & get_root_state() const
Returns the root state of the state machine. Commonly used to add regions to the root state and to cr...
Definition: state_machine_base.cpp:70
Definition: composite_state.hpp:28
Definition: region.hpp:42
sxe::SX_UNIQUE_PTR< region > region_uptr
Definition: region_fwd.hpp:26
bool process_event(const event_sptr &_event, async_event_handler *const _async_event_handler)
Definition: state_machine_base.cpp:299
virtual ~state_machine_base() SX_NOEXCEPT SX_OVERRIDE
Definition: state_machine_base.cpp:56
Definition: async_event_handler.hpp:22
Definition: adapter_cpp11.hpp:21
Callback interface that is called by a state machine during event processing. See the different metho...
Definition: event_processing_callback.hpp:37
virtual bool fire_event(const event_sptr &_event)=0
bool check(state_machine_defects &_defects) const
Check the state machine for defects by checking the constraints of each component.
Definition: state_machine_base.cpp:195
Definition: vertex.hpp:36
Definition: interruptible.hpp:22
std::vector< const state *> raw_const_states
Definition: state_fwd.hpp:29
sxe::shared_ptr< event > event_sptr
Definition: event_fwd.hpp:25
Definition: transition.hpp:34
virtual void set_behavior_of_unhandled_event_handler(const behavior_function &_behavior)
Sets the behavior for handler of unhandled events.
Definition: state_machine_base.cpp:242
state_machine_base(const std::string &_name, event_processing_callback *const _event_processing_callback=SX_NULLPTR)
Constructor.
Definition: state_machine_base.cpp:35
sxe::SX_UNIQUE_PTR< composite_state > composite_state_uptr
Definition: composite_state_fwd.hpp:25
static void stop_all_async_states(state &_state)
Definition: state_machine_base.cpp:484
sxe::function< void(const event &, event_collector &) > behavior_function
Definition: behavior_fwd.hpp:29
std::vector< event_id > event_ids
The type alias for yasmine's event ID list.
Definition: event_id.hpp:29
virtual void interrupt()
Set the internal flag of the state machine, to interrupt all processes inside the state machine and t...
Definition: state_machine_base.cpp:229
transition_kind
Definition: transition_kind.hpp:25
Definition: state_machine_base.hpp:45
sxe::function< bool(const event &, event_collector &) > constraint_function
Definition: constraint_fwd.hpp:28
virtual transition & add_transition(transition_uptr _transition)
Add a transition to the state machine. The state machine takes ownership of the transition.
Definition: state_machine_base.cpp:85
std::vector< transition_uptr > transitions
Definition: transition_fwd.hpp:31
std::vector< event_sptr > events
Definition: event_fwd.hpp:27
sxe::SX_UNIQUE_PTR< behavior > behavior_uptr
Definition: behavior_fwd.hpp:25