diff --git a/CMakeHelpers/functionsRapidJSON.cmake b/CMakeHelpers/functionsRapidJSON.cmake index 5a73bcf..2188d55 100644 --- a/CMakeHelpers/functionsRapidJSON.cmake +++ b/CMakeHelpers/functionsRapidJSON.cmake @@ -10,9 +10,16 @@ if(SX_RAPIDJSON) else() message("SX_RAPIDJSON is not set by user. Setting default value.") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(SX_RAPIDJSON "/usr/include/rapidjson") + find_package(RapidJSON) + if(NOT ("${RAPIDJSON_INCLUDE_DIRS}" STREQUAL "")) + set(SX_RAPIDJSON ${RAPIDJSON_INCLUDE_DIRS}) + message(STATUS "Found rapidjson on: ${RAPIDJSON_INCLUDE_DIRS}") + else() + set(SX_RAPIDJSON /usr/include) + message(STATUS "Set default value for rapidjson") + endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(SX_RAPIDJSON "C:\\Program Files\\rapidjson") + set(SX_RAPIDJSON "C:\\Program Files") endif() endif() diff --git a/libyasmine/changelog.txt b/libyasmine/changelog.txt index 3596997..e745b7a 100644 --- a/libyasmine/changelog.txt +++ b/libyasmine/changelog.txt @@ -2,6 +2,15 @@ All notable changes to this project are documented in this file. +##[1.3.2] - 2017-10-26 + +### Changed +• CMake: changes of RapidJSON include path handling + +### Fixed +• bug: enqueuing of an event failed during the start of an async state machine + + ##[1.3.1] - 2017-10-16 ### Added diff --git a/libyasmine/include_impl/build_number.hpp b/libyasmine/include_impl/build_number.hpp index 9401703..3aef514 100644 --- a/libyasmine/include_impl/build_number.hpp +++ b/libyasmine/include_impl/build_number.hpp @@ -24,7 +24,7 @@ namespace version { -const sxe::uint16_t BUILD_NUMBER( 770 ); +const sxe::uint16_t BUILD_NUMBER( 790 ); } diff --git a/libyasmine/source/async_state_machine.cpp b/libyasmine/source/async_state_machine.cpp index cf1abeb..0f32aed 100644 --- a/libyasmine/source/async_state_machine.cpp +++ b/libyasmine/source/async_state_machine.cpp @@ -31,7 +31,7 @@ async_state_machine::async_state_machine( const std::string& _name, run_and_event_mutex_(), run_and_event_condition_(), terminated_condition_(), - worker_thread_(), + worker_thread_(), event_list_() { SX_LOG( hermes::log_level::LL_TRACE, "Creating async state_machine '%'.", _name ); @@ -66,6 +66,10 @@ bool async_state_machine::run() { SX_LOG( hermes::log_level::LL_INFO, "Starting async state machine '%'.", get_name() ); + SX_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), + "Status is neither 'NEW' nor 'STOPPED' on start!" ); + + status_ = state_machine_status::STARTED; const bool state_machine_started = state_machine_base::run( this ); if( state_machine_started ) { @@ -74,7 +78,7 @@ bool async_state_machine::run() else { SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate was reached in %.", get_name() ); - status_ = state_machine_status::STOPPED; + status_ = state_machine_status::STOPPED; } SX_LOG( hermes::log_level::LL_INFO, "Started async state machine '%'.", get_name() ); @@ -84,7 +88,7 @@ bool async_state_machine::run() void async_state_machine::halt_and_join() -{ +{ SX_LOG( hermes::log_level::LL_INFO, "Stopping and joining async state machine '%'.", get_name() ); halt(); @@ -168,10 +172,6 @@ bool async_state_machine::push( const event_sptr& _event ) void async_state_machine::start_state_machine() { - SX_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), - "Status is neither 'NEW' nor 'STOPPED' on start!" ); - - status_ = state_machine_status::STARTED; worker_thread_ = SX_MAKE_UNIQUE< sxe::thread >( &async_state_machine::work, this ); } @@ -206,7 +206,7 @@ void async_state_machine::insert_impl( const event_sptr& _event ) { if( event_list_.empty() ) { - event_list_.push_back( _event ); + event_list_.push_back( _event ); } else if( event_list_.back()->get_priority() >= _event->get_priority() ) @@ -217,7 +217,7 @@ void async_state_machine::insert_impl( const event_sptr& _event ) { std::list< event_sptr >::iterator position = event_list_.begin(); while( position != event_list_.end() ) - { + { if (_event->operator>(**position)) { break; @@ -232,7 +232,7 @@ void async_state_machine::insert_impl( const event_sptr& _event ) bool async_state_machine::wait_predicate() const { - return( !( status_ == state_machine_status::STARTED ) || !event_list_.empty() ); + return( !( status_ == state_machine_status::STARTED ) || !event_list_.empty() ); } @@ -251,7 +251,7 @@ void async_state_machine::work() event_sptr event; { sxe::unique_lock< sxe::mutex > lock( run_and_event_mutex_ ); - run_and_event_condition_.wait( lock, sxe::bind( &async_state_machine::wait_predicate, this ) ); + run_and_event_condition_.wait( lock, sxe::bind( &async_state_machine::wait_predicate, this ) ); if( !( status_ == state_machine_status::STARTED ) && ( event_list_.empty() || is_interrupted() ) ) { break; @@ -268,12 +268,12 @@ void async_state_machine::work() } catch ( const std::exception& exception ) { - SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); + SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); status_ = state_machine_status::STOPPED; } catch ( ... ) { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); status_ = state_machine_status::STOPPED; } diff --git a/libyasmine/source/behavior_impl.cpp b/libyasmine/source/behavior_impl.cpp index 4e7e0c1..5f08498 100644 --- a/libyasmine/source/behavior_impl.cpp +++ b/libyasmine/source/behavior_impl.cpp @@ -17,7 +17,7 @@ namespace sxy { - behavior_impl::behavior_impl( const behavior_function& _function ) + behavior_impl::behavior_impl( const behavior_function& _function ) : function_( _function ) { // Nothing to do... diff --git a/libyasmine/source/execution_state_do_step.cpp b/libyasmine/source/execution_state_do_step.cpp index 6c73451..d39bed8 100644 --- a/libyasmine/source/execution_state_do_step.cpp +++ b/libyasmine/source/execution_state_do_step.cpp @@ -39,7 +39,7 @@ execution_state_do_step::~execution_state_do_step() SX_NOEXCEPT bool execution_state_do_step::execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector ) const + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector ) const { SX_LOG( hermes::log_level::LL_TRACE, "Executing do behavior of state '%'.", state_.get_name() ); if( _event_processing_callback ) diff --git a/libyasmine/source/region_pseudostate_impl.cpp b/libyasmine/source/region_pseudostate_impl.cpp index 7cbc520..0e519f0 100644 --- a/libyasmine/source/region_pseudostate_impl.cpp +++ b/libyasmine/source/region_pseudostate_impl.cpp @@ -35,8 +35,8 @@ region_pseudostate_impl::region_pseudostate_impl( const std::string& _name ) { #ifdef Y_OPTIMIZE_4_SPEED ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); - ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); -#endif + ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); +#endif } @@ -44,7 +44,7 @@ region_pseudostate_impl::~region_pseudostate_impl() SX_NOEXCEPT { // Nothing to do... } - + const state_machine_element* region_pseudostate_impl::get_parent() const { @@ -84,9 +84,9 @@ raw_composite_states region_pseudostate_impl::get_ancestors( composite_state* co if( final_ancestor != ancestors_.end() ) { - raw_composite_states ancestors( ancestors_.begin(), final_ancestor + 1 ); + raw_composite_states ancestors( ancestors_.begin(), final_ancestor + 1 ); if( !_include_final_ancestor ) - { + { ancestors.erase( std::remove( ancestors.begin(), ancestors.end(), _final_ancestor ), ancestors.end() ); } return ( ancestors ); @@ -99,7 +99,7 @@ raw_composite_states region_pseudostate_impl::get_ancestors( composite_state* co } #else raw_composite_states ancestors; - collect_ancestors( ancestors, _final_ancestor ); + collect_ancestors( ancestors, _final_ancestor ); if( !_include_final_ancestor ) { ancestors.erase( std::remove( ancestors.begin(), ancestors.end(), _final_ancestor ), ancestors.end() ); @@ -116,7 +116,7 @@ raw_regions region_pseudostate_impl::get_ancestors_as_regions() const { collect_ancestors_as_regions( ancestors_as_regions_ ); } - return ( ancestors_as_regions_ ); + return ( ancestors_as_regions_ ); #else raw_regions ancestor_regions; collect_ancestors_as_regions( ancestor_regions ); diff --git a/libyasmine/source/simple_state_base.cpp b/libyasmine/source/simple_state_base.cpp index 79f4b25..9b4c666 100644 --- a/libyasmine/source/simple_state_base.cpp +++ b/libyasmine/source/simple_state_base.cpp @@ -98,7 +98,7 @@ bool simple_state_base::check( state_machine_defects& _defects ) const bool simple_state_base::has_error_event() const -{ +{ const bool state_has_error_event = !!error_event_; return( state_has_error_event ); } diff --git a/libyasmine/source/simple_state_impl.cpp b/libyasmine/source/simple_state_impl.cpp index 6e841da..0d9bca2 100644 --- a/libyasmine/source/simple_state_impl.cpp +++ b/libyasmine/source/simple_state_impl.cpp @@ -17,14 +17,14 @@ namespace sxy -{ +{ simple_state_impl::simple_state_impl( const std::string& _name, behavior_uptr _do_action, behavior_uptr _entry_action, behavior_uptr _exit_action, const event_ids& _deferred_events, event_sptr _error_event ) - : simple_state_base( _name, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events, + : simple_state_base( _name, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events, _error_event ), - do_( sxe::move( _do_action ) ) + do_( sxe::move( _do_action ) ) { // Nothing to do... } @@ -39,7 +39,7 @@ simple_state_impl::~simple_state_impl() SX_NOEXCEPT void simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, event_collector& _event_collector ) const { - SX_UNUSED_PARAMETER( _async_event_handler ); + SX_UNUSED_PARAMETER( _async_event_handler ); const behavior* const behavior = get_do(); if( behavior ) { diff --git a/libyasmine/source/state_machine_base.cpp b/libyasmine/source/state_machine_base.cpp index f9def39..2373902 100644 --- a/libyasmine/source/state_machine_base.cpp +++ b/libyasmine/source/state_machine_base.cpp @@ -74,7 +74,7 @@ namespace sxy } -#ifdef Y_PROFILER +#ifdef Y_PROFILER sxe::uint32_t state_machine_base::get_number_of_processed_events() const { return( processed_events_ ); @@ -295,6 +295,7 @@ namespace sxy return( state_machine_started ); } + bool state_machine_base::process_event( const event_sptr& _event, async_event_handler* const _async_event_handler ) { #ifdef Y_PROFILER @@ -341,7 +342,7 @@ namespace sxy } else { - if( !event_was_unhandled ) //event_was_unhandled + if( !event_was_unhandled ) { handle_unhandled_event( _event ); } diff --git a/libyasmine/source/transition_executor.cpp b/libyasmine/source/transition_executor.cpp index 1f6aa02..c8a4392 100644 --- a/libyasmine/source/transition_executor.cpp +++ b/libyasmine/source/transition_executor.cpp @@ -51,7 +51,7 @@ bool transition_executor::check_sort_and_execute_transitions( const compound_tra transition_executor_impl_->conflict_check( _compound_transitions ); SX_LOG( hermes::log_level::LL_TRACE, "Sorting compound transitions." ); const raw_compound_transitions& sorted_compound_transitions = - transition_executor_impl_->sort_compound_transitions( _compound_transitions ); + transition_executor_impl_->sort_compound_transitions( _compound_transitions ); SX_LOG( hermes::log_level::LL_TRACE, "Compound transitions sorted." ); SX_LOG( hermes::log_level::LL_TRACE, "Start calculating execution step(s) for all compound transitions." ); @@ -72,11 +72,11 @@ bool transition_executor::check_sort_and_execute_transitions( const compound_tra raw_const_region_set entered_regions; SX_LOG( hermes::log_level::LL_TRACE, "Calculate execution step(s) for one compound transition." ); transition_executor_impl_->find_states_to_enter_and_to_exit_and_calculate_execution_steps( *compound_transition, - execution_steps, entered_regions, _event, true, _event_collector ); + execution_steps, entered_regions, _event, true, _event_collector ); SX_LOG( hermes::log_level::LL_TRACE, "Found % execution step(s).", execution_steps.size() ); SX_LOG( hermes::log_level::LL_TRACE, "Start running execution step(s)." ); terminate_pseudostate_has_been_reached = transition_executor_impl_->run_execution_steps( execution_steps, - _event_processing_callback, _event, _exception_events, _async_event_handler, _event_collector ); + _event_processing_callback, _event, _exception_events, _async_event_handler, _event_collector ); SX_LOG( hermes::log_level::LL_TRACE, "Finished running execution step(s)." ); if( terminate_pseudostate_has_been_reached ) { diff --git a/libygen/include/libygen_build_number.hpp b/libygen/include/libygen_build_number.hpp index 9307981..79c8747 100644 --- a/libygen/include/libygen_build_number.hpp +++ b/libygen/include/libygen_build_number.hpp @@ -24,7 +24,7 @@ namespace version { - const sxe::uint16_t BUILD_NUMBER( 770 ); + const sxe::uint16_t BUILD_NUMBER( 790 ); } diff --git a/version.txt b/version.txt index 1e65d9b..bad0c62 100644 --- a/version.txt +++ b/version.txt @@ -1,5 +1,14 @@ Versions +• yasmine 1.4.2 released 2017-10-26 + • libyasmine 1.3.2 + • essentials 1.3.1 + • hermes 1.1.2 + • genesis 0.3.1 + • yasmine_model 0.1.4 + • libygen 0.1.2 + • ygen 0.1.4 + • yasmine 1.4.1 released 2017-10-16 • libyasmine 1.3.1 diff --git a/yasmine_model/changelog.txt b/yasmine_model/changelog.txt index 8dc92d6..7c6ba3d 100644 --- a/yasmine_model/changelog.txt +++ b/yasmine_model/changelog.txt @@ -2,6 +2,12 @@ All notable changes to this project are documented in this file. +##[0.1.4] - 2017-10-26 + +### Added +• rapidjson_document header as a wrapper for RapidJSON usage + + ##[0.1.3] - 2017-10-16 ### Fixed diff --git a/yasmine_model/include/algorithm_parameters.hpp b/yasmine_model/include/algorithm_parameters.hpp new file mode 100644 index 0000000..d32062c --- /dev/null +++ b/yasmine_model/include/algorithm_parameters.hpp @@ -0,0 +1,44 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD +#define ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD + + +namespace sxy +{ + + +extern const int TRANSITION_PRIORITIES_VECTOR_SIZE; +extern const int EXECUTION_STEPS_VECTOR_SIZE; +extern const int TRANSITION_STEPS_VECTOR_SIZE; +extern const int COMPOUND_TRANSITIONS_VECTOR_SIZE; +extern const int STATES_TO_EXIT_VECTOR_SIZE; +extern const int EXCEPTION_EVENTS_VECTOR_SIZE; +extern const int CHOICES_VECTOR_SIZE; +extern const int ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE; +extern const int DEFERRED_EVENTS_VECTOR_SIZE; +extern const int DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE; +extern const int ENTRY_POINTS_VECTOR_SIZE; +extern const int EXIT_POINTS_VECTOR_SIZE; +extern const int PSEUDOSTETS_IN_REGION_VECTOR_SIZE; +extern const int ANCESTORS_VECTOR_SIZE; +extern const int ASCENDING_PATH_ANCESTORS_VECTOR_SIZE; +extern const int REGIONS_OF_FINAL_STATE; +extern const int REGIONS_OF_SIMPLE_STATE; +extern const int ANCESTORS_REGION_VECTOR_SIZE; +extern const int ACTIVE_STATE_CONFIGRATION_VECTOR_SIZE; + + +} + + +#endif diff --git a/yasmine_model/include/assembly.hpp b/yasmine_model/include/assembly.hpp new file mode 100644 index 0000000..2d3f537 --- /dev/null +++ b/yasmine_model/include/assembly.hpp @@ -0,0 +1,427 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 +#define ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 + +#ifndef SX_CPP03_BOOST + #include +#endif + +#include "essentials/macro_helpers.hpp" + +#include "behavior_fwd.hpp" +#include "constraint_fwd.hpp" +#include "caller.hpp" +#include "guard_caller.hpp" + + +#ifndef SX_CPP03_BOOST + + +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_SELECT, __VA_ARGS__ ) ) + +//!\brief Macro for using any type of action as a behavior. +#define Y_BEHAVIOR_ACTION( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_ACTION_SELECT, __VA_ARGS__ ) ) + +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) + +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_SELECT, __VA_ARGS__ ) ) + +//!\brief Macro for using any type of action returning bool as a guard. +#define Y_GUARD_ACTION( ... ) EXPAND( VA_SELECT( Y_GUARD_ACTION_SELECT, __VA_ARGS__ ) ) + +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) + + +//!\brief Macro for using a class method as a behavior. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_SELECT_1( _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ); } ) + +//!\brief Macro for using a class method as a behavior. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ); } ) + +//!\brief Macro for using any type of action as a behavior. +#define Y_BEHAVIOR_ACTION_SELECT_1( _action ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using any type of action as a behavior. +#define Y_BEHAVIOR_ACTION_SELECT_2( _class_name, _action ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using a class method as a behavior without an event. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_1( _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); this->_method_name(); } ) + +//!\brief Macro for using a class method as a behavior without an event. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); this->_method_name(); } ) + +//!\brief Macro for using a class method as a guard. +//!\deprecated USE Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_SELECT_1( _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name( _event ) ); } ) + +//!\brief Macro for using a class method as a guard. +//!\deprecated USE Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name( _event ) ); } ) + +//!\brief Macro for using any type of action returning bool as a guard. +#define Y_GUARD_ACTION_SELECT_1( _action ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using any type of action returning bool as a guard. +#define Y_GUARD_ACTION_SELECT_2( _class_name, _action ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using a class method as a guard without an event. +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_1( _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name() ); } ) + +//!\brief Macro for using a class method as a guard without an event. +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name() ); } ) + +//!\brief Macro for using a free function as a guard. +//!\deprecated Use Y_GUARD_FUNCTION2 instead. +#define Y_GUARD_FUNCTION( _function_name ) \ + sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { SX_UNUSED_PARAMETER(_event_collector); return( _function_name( _event ) ); } ) + +//!\brief Macro for using a free function as a guard without an event. +//!\deprecated Use Y_GUARD_FUNCTION2 instead. +#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ + sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( _function_name() ); } ) + +//!\brief Macro for using a free function as a behavior. +//!\deprecated Use Y_BEHAVIOR_FUNCTION2 instead. +#define Y_BEHAVIOR_FUNCTION( _function_name ) \ + sxy::behavior_function( []( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); _function_name( _event ); } ) + +//!\brief Macro for using a free function as a behavior without an event. +//!\deprecated Use Y_BEHAVIOR_FUNCTION2 instead. +#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ + sxy::behavior_function( []( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); _function_name(); } )\ + + +#else + + +#define Y_BEHAVIOR_METHOD( _class_name, _method_name ) Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) +#define Y_BEHAVIOR_METHOD_NO_EVENT( _class_name, _method_name ) Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) +#define Y_GUARD_METHOD( _class_name, _method_name ) Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) +#define Y_GUARD_METHOD_NO_EVENT( _class_name, _method_name ) Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) + +//!\brief Macro for using a class method as a behavior. +#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) + +//!\brief Macro for using a class method as a behavior without an event. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( sxe::bind( &_class_name::_method_name, this ) ) + +#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) + +//!\brief Macro for using a class method as a guard without an event. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( sxe::bind (&_class_name::_method_name, this ) ) + +//!\brief Macro for using a free function as a guard. +#define Y_GUARD_FUNCTION( _function_name ) \ + sxy::constraint_function( sxe::bind( &_function_name, sxe::_1 ) ) + +//!\brief Macro for using a free function as a guard without an event. +#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ + sxy::constraint_function( sxe::bind( &_function_name ) ) + +//!\brief Macro for using a free function as a behavior. +#define Y_BEHAVIOR_FUNCTION( _function_name ) \ + sxy::behavior_function( sxe::bind( &_function_name, sxe::_1 ) ) + +//!\brief Macro for using a free function as a behavior without an event. +#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ + sxy::behavior_function( sxe::bind( &_function_name ) ) + + +#endif + + +//!\brief Macro for an empty behavior. +#define Y_EMPTY_BEHAVIOR sxy::behavior_function() + + +//!\brief Macro for an empty guard. +#define Y_EMPTY_GUARD sxy::constraint_function() + + +#ifndef SX_CPP03_BOOST // C++11 only + // Macros for passing handlers as behavior + + //!\brief The macro creates a behavior_function for the specified method(s). + //!\ The macro is variadic and can take up to 10 class methods pointers as parameters. + //#define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) + #define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( Y_BEHAVIOR_METHOD2( this, __VA_ARGS__ ) ) + + //!\brief The macro creates a behavior_function for the specified function(s). + //!\ The macro is variadic and can take up to 10 function pointers as parameters. + #define Y_BEHAVIOR_FUNCTION_EVENT( ... ) EXPAND( Y_BEHAVIOR_FUNCTION2( __VA_ARGS__ ) ) + + +#define VA_SELECT_WITH_CLASS_INSTANCE( NAME, CLASS_INSTANCE, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )(CLASS_INSTANCE, __VA_ARGS__) ) + +//!\brief The macro creates a behavior_function for the specified method(s). +//!\ The macro is variadic and can take up to 10 class methods pointers as parameters. +#define Y_BEHAVIOR_METHOD2(CLASS_INSTANCE, ...) EXPAND( VA_SELECT_WITH_CLASS_INSTANCE(Y_BEHAVIOR_METHOD2_SELECT, CLASS_INSTANCE, __VA_ARGS__)) + +//!\brief The macro creates a behavior_function for the specified function(s). +//!\ The macro is variadic and can take up to 10 function pointers as parameters. +#define Y_BEHAVIOR_FUNCTION2(...) EXPAND( VA_SELECT(Y_BEHAVIOR_FUNCTION2_SELECT, __VA_ARGS__) ) + +//!\brief The macro creates a behavior_function for the specified method(s). +//!\ The macro is variadic and can take up to 10 class methods pointers as parameters. +#define Y_GUARD_METHOD2(CLASS_INSTANCE, ...) EXPAND( VA_SELECT_WITH_CLASS_INSTANCE(Y_GUARD_METHOD2_SELECT, CLASS_INSTANCE, __VA_ARGS__)) + +//!\brief The macro creates a guard_function for the specified function(s). +//!\ The macro is variadic and can take up to 10 function pointers as parameters. +#define Y_GUARD_FUNCTION2(...) EXPAND( VA_SELECT(Y_GUARD_FUNCTION2_SELECT, __VA_ARGS__) ) + +//!\brief The macro creates a constraint_function for the specified method(s). +//!\ The macro is variadic and can take up to 10 method pointers as parameters. +//#define Y_GUARD_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_GUARDR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) +#define Y_GUARD_METHOD_EVENT(...) EXPAND( Y_GUARD_METHOD2( this, __VA_ARGS__ ) ) + +//!\brief The macro creates a constraint_function for the specified function(s). +//!\ The macro is variadic and can take up to 10 function pointers as parameters. +#define Y_GUARD_FUNCTION_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_FUNCTION_EVENT_SELECT, __VA_ARGS__ ) ) + + +#ifdef SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG + + +template< typename method1 > +sxy::behavior_function create_behavior_function( method1 _method1 ) +{ + return ( sxy::behavior_function( [_method1]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1 ); } ) ); +} + + +template< typename method1, typename method2 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2 ) +{ + return ( sxy::behavior_function( [_method1, _method2]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2 ); } ) ); +} + + +template< typename method1, typename method2, typename method3 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4, _method5]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4, _method5, _method6]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7, typename method8 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7, method8 _method8 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7, typename method8, typename method9 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7, method8 _method8, method9 _method9 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7, typename method8, typename method9, typename method10 > +sxy::behavior_function create_behavior_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7, method8 _method8, method9 _method9, method10 _method10 ) +{ + return ( sxy::behavior_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ); } ) ); +} + + +template< typename method1 > +sxy::constraint_function create_guard_function( method1 _method1 ) +{ + return ( sxy::constraint_function( [_method1]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1 ) ); } ) ); +} + + +template< typename method1, typename method2 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2 ) +{ + return ( sxy::constraint_function( [_method1, _method2]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4, _method5]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4, _method5, _method6]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7, typename method8 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7, method8 _method8 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7, typename method8, typename method9 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7, method8 _method8, method9 _method9 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) ); } ) ); +} + + +template< typename method1, typename method2, typename method3, typename method4, typename method5, typename method6, typename method7, typename method8, typename method9, typename method10 > +sxy::constraint_function create_guard_function( method1 _method1, method2 _method2, method3 _method3, method4 _method4, method5 _method5, method6 _method6, method7 _method7, method8 _method8, method9 _method9, method10 _method10 ) +{ + return ( sxy::constraint_function( [_method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) ); } ) ); +} + + +#else + + +template< typename ... Args > +sxy::behavior_function create_behavior_function( Args...args ) +{ + return ( sxy::behavior_function( [args...]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, args... ); } ) ); +} + + +template< typename ... Args > +sxy::constraint_function create_guard_function( Args...args ) +{ + return ( sxy::constraint_function( [args...]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, args... ) ); } ) ); +} + + +#endif + + #define Y_BEHAVIOR_METHOD2_SELECT_1( _class_instance, _method ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_2( _class_instance, _method1, _method2 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_3( _class_instance, _method1, _method2, _method3 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_4( _class_instance, _method1, _method2, _method3, _method4 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_5( _class_instance, _method1, _method2, _method3, _method4, _method5 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_6( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_7( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_8( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method8 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_9( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method8 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method9 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_10( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) create_behavior_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method8 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method9 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method10 ) ) + + #define Y_GUARD_METHOD2_SELECT_1( _class_instance, _method ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method ) ) + #define Y_GUARD_METHOD2_SELECT_2( _class_instance, _method1, _method2 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ) ) + #define Y_GUARD_METHOD2_SELECT_3( _class_instance, _method1, _method2, _method3 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ) ) + #define Y_GUARD_METHOD2_SELECT_4( _class_instance, _method1, _method2, _method3, _method4 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ) ) + #define Y_GUARD_METHOD2_SELECT_5( _class_instance, _method1, _method2, _method3, _method4, _method5 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ) ) + #define Y_GUARD_METHOD2_SELECT_6( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ) ) + #define Y_GUARD_METHOD2_SELECT_7( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ) ) + #define Y_GUARD_METHOD2_SELECT_8( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method8 ) ) + #define Y_GUARD_METHOD2_SELECT_9( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method8 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method9 ) ) + #define Y_GUARD_METHOD2_SELECT_10( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) create_guard_function( adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method1 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method2 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method3 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method4 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method5 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method6 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method7 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method8 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method9 ), adapt< typename std::remove_pointer< decltype(_class_instance)>::type >( _class_instance, _method10 ) ) + + #define Y_BEHAVIOR_FUNCTION2_SELECT_1( _function ) create_behavior_function( adapt_function( _function ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_2( _function1, _function2 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_3( _function1, _function2, _function3 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_4( _function1, _function2, _function3, _function4 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ), adapt_function( _function10 ) ) + + #define Y_GUARD_FUNCTION2_SELECT_1( _function ) create_guard_function( adapt_function( _function ) ) + #define Y_GUARD_FUNCTION2_SELECT_2( _function1, _function2 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ) ) + #define Y_GUARD_FUNCTION2_SELECT_3( _function1, _function2, _function3 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ) ) + #define Y_GUARD_FUNCTION2_SELECT_4( _function1, _function2, _function3, _function4 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ) ) + #define Y_GUARD_FUNCTION2_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ) ) + #define Y_GUARD_FUNCTION2_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ) ) + #define Y_GUARD_FUNCTION2_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ) ) + #define Y_GUARD_FUNCTION2_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ) ) + #define Y_GUARD_FUNCTION2_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ) ) + #define Y_GUARD_FUNCTION2_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ), adapt_function( _function10 ) ) + + +#endif + +#endif diff --git a/yasmine_model/include/async_behavior.hpp b/yasmine_model/include/async_behavior.hpp new file mode 100644 index 0000000..f71c8d8 --- /dev/null +++ b/yasmine_model/include/async_behavior.hpp @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB +#define ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB + + +#include "essentials/non_copyable.hpp" +#include "essentials/compatibility/thread.hpp" + +#include "async_behavior_fwd.hpp" + + +namespace sxy +{ + + +class event; +class simple_state_base; +class async_event_handler; +class event_collector; + + +class async_behavior +{ + + +public: + async_behavior(); + virtual ~async_behavior() SX_NOEXCEPT; + SX_NO_COPY(async_behavior) + void run( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); + void halt_and_join(); + +protected: + bool should_stop() const; + + +private: + void work( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, + async_event_handler& _async_event_handler ); + virtual void run_impl( const event& _event, event_collector& _event_collector, + async_event_handler& _async_event_handler ) = 0; + virtual void notify_should_stop(); + void join(); + + sxe::SX_UNIQUE_PTR worker_; + mutable sxe::mutex mutex_; + bool run_; + + +}; + + +} + + +#endif diff --git a/yasmine_model/include/async_behavior_fwd.hpp b/yasmine_model/include/async_behavior_fwd.hpp new file mode 100644 index 0000000..85c47a8 --- /dev/null +++ b/yasmine_model/include/async_behavior_fwd.hpp @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 +#define ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class async_behavior; +class event; +typedef sxe::SX_UNIQUE_PTR< async_behavior > async_behavior_uptr; + + +} + + +#endif diff --git a/yasmine_model/include/async_event_handler.hpp b/yasmine_model/include/async_event_handler.hpp new file mode 100644 index 0000000..0a91610 --- /dev/null +++ b/yasmine_model/include/async_event_handler.hpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E +#define ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E + +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class async_event_handler +{ + + +public: + async_event_handler() + { + // Nothing to do... + } + + + virtual ~async_event_handler() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(async_event_handler) + virtual void on_event( const event_sptr& _event ) = 0; + + +}; + + +} + + +#endif diff --git a/yasmine_model/include/async_simple_state_impl.hpp b/yasmine_model/include/async_simple_state_impl.hpp new file mode 100644 index 0000000..6383f9d --- /dev/null +++ b/yasmine_model/include/async_simple_state_impl.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD +#define ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD + + +#include "simple_state_base.hpp" +#include "async_behavior_fwd.hpp" + + +namespace sxy +{ + + +class async_simple_state_impl SX_FINAL: + public simple_state_base +{ +public: + explicit async_simple_state_impl( const std::string& _name, async_behavior_uptr _do_action, + behavior_uptr _entry_action = behavior_uptr(), behavior_uptr _exit_action = behavior_uptr(), + const event_ids& _deferred_events = event_ids(), event_sptr _error_event = event_sptr()); + virtual ~async_simple_state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(async_simple_state_impl) + void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + void stop_do_behavior() const; + + +private: + async_behavior_uptr do_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/async_state_machine.hpp b/yasmine_model/include/async_state_machine.hpp new file mode 100644 index 0000000..aa06975 --- /dev/null +++ b/yasmine_model/include/async_state_machine.hpp @@ -0,0 +1,134 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 +#define ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 + + +#include + +#include "essentials/compatibility/thread.hpp" +#include "essentials/compatibility/chrono.hpp" + +#include "state_machine_base.hpp" +#include "async_event_handler.hpp" +#include "state_machine_status.hpp" + + +namespace sxy +{ + + +//!\class async_state_machine +//!\brief Class for the "multi-threaded version" of the state machine. Provides methods to start and halt the state +//! machine and to fire events. +class async_state_machine SX_FINAL: + public state_machine_base, private async_event_handler +{ +public: + //!\brief Constructor. + //!\param _name Name of the state machine. + //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback + //!interface should be used. + explicit async_state_machine( const std::string& _name, + event_processing_callback* const _event_processing_callback = SX_NULLPTR ); + virtual ~async_state_machine() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(async_state_machine) + + //!\brief Enqueue the given event for firing. + //!\param _event Event to be fired. + //!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing + //!of the event is not possible because the state machine was stopped in the meantime (or was never started). + //!Firing the event enqueues the event for being processed. + virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; + + //!\brief Starts the state machine. When starting the state machine, the initial transitions are searched and + //!executed. Without running the state machine, it is not possible to fire events. + //!\return If the state machine reaches a terminate pseudostate after starting (on calling run), returns false. Else + //!if the state machine is started and running, returns true. + //!\sa halt_and_join, halt, join + virtual bool run() SX_OVERRIDE; + + //!\brief Stops and joins the state machine. When stopping the state machine, all the events remaining in the queue + //!of events will be processed and the event processing thread will be then stopped and joined. The state machine + //!will also check for active asynchronous simple states and will stop the do behavior for all of them. + //!\return void + //!\sa halt, join, run + void halt_and_join(); + + //!\brief Stops the state machine. When stopping the state machine, all the events remaining in the queue + //!of events will be processed and the event processing thread will be then stopped and joined. The state machine + //!will also check for active asynchronous simple states and will stop the do behavior for all of them. + //!\return void + //!\sa halt_and_join, join, run + virtual void halt() SX_OVERRIDE; + + //!\brief Joins the thread of the state machine. + //!\return void + //!\sa halt_and_join, halt, run + void join(); + + + //!\brief Waiting given amount of time for the state machine to terminate (or to stop). + //!\param _timeoutInMs Time in milliseconds to wait for the state machine to terminate. + //!\return bool true if the state machine is terminated or stopped, false otherwise. + //!\sa halt_and_join, halt, run, wait + bool wait( const sxe::milliseconds _timeoutInMs ) const; + + //!\brief Wait for the machine to terminate (or to stop). + //!\return void + //!\sa halt_and_join, halt, run, wait + void wait() const; + + //!\brief Check if the state machine is terminated or stopped. + //!\return bool true if the state machine is terminated or stopped, false otherwise. + //!\sa halt_and_join, halt, run, wait + bool terminated() const; + + + //!\brief Enqueue the given event for firing. + //!\param _event Event to be fired. + //!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing + //!of the event is not possible because the state machine was stopped in the meantime (or was never started). + //!Firing the event enqueues the event for being processed. + virtual bool push( const event_sptr& _event ) SX_OVERRIDE; + + +protected: + void start_state_machine(); + + +private: + bool insert( const event_sptr& _event ); + void insert_impl( const event_sptr& _event ); + bool wait_predicate() const; + bool wait_stop_condition() const; + void work(); + + //!\brief Sends a priority (internal) event and add it in the front of the event list, so it will be processed before other events. + //!\return void + virtual void on_event( const event_sptr& _event ) SX_OVERRIDE; + virtual void interrupt_impl() SX_OVERRIDE; + + + state_machine_status status_; + mutable sxe::mutex run_and_event_mutex_; + sxe::condition_variable run_and_event_condition_; + mutable sxe::condition_variable terminated_condition_; + sxe::SX_UNIQUE_PTR< sxe::thread > worker_thread_; + std::list event_list_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/backward_compatibility.hpp b/yasmine_model/include/backward_compatibility.hpp new file mode 100644 index 0000000..4fc4553 --- /dev/null +++ b/yasmine_model/include/backward_compatibility.hpp @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef BACKWARD_COMPATIBILITY_51D0150C_395A_4339_9F99_DFFD7274916D +#define BACKWARD_COMPATIBILITY_51D0150C_395A_4339_9F99_DFFD7274916D + + +#include "essentials/compatibility/compatibility.hpp" + + +#ifdef Y_NO_LOGGING +#define SX_NO_LOGGING +#endif + + +#ifdef Y_NO_STD_MAKE_UNIQUE +#define SX_NO_STD_MAKE_UNIQUE +#endif + + +#ifdef Y_CPP03_BOOST +#define SX_CPP03_BOOST +#endif + + +#ifdef Y_NO_WINDOWS_H +#define SX_NO_WINDOWS_H +#endif + + +#define Y_CONSTEXPR SX_CONSTEXPR +#define Y_FINAL SX_FINAL +#define Y_NOEXCEPT SX_NOEXCEPT +#define Y_OVERRIDE SX_OVERRIDE +#define Y_NO_COPY SX_NO_COPY +#define Y_NO_COPY_OPERATOR_EQUAL SX_NO_ASSIGNMENT_OPERATOR +#define Y_UNIQUE_PTR SX_UNIQUE_PTR +#define Y_MAKE_UNIQUE SX_MAKE_UNIQUE +#define Y_MAKE_SHARED SX_MAKE_SHARED +#define Y_UNUSED_PARAMETER SX_UNUSED_PARAMETER +#define Y_NO_LOGGING SX_NO_LOGGING +#define Y_LOG SX_LOG +#define Y_LOG_HEX SX_LOG_HEX +#define Y_ASSERT SX_ASSERT +#define Y_NULLPTR SX_NULLPTR +#define Y_FOR SX_FOR +#define Y_CPP03_BOOST SX_CPP03_BOOST +#define Y_NO_STD_MAKE_UNIQUE SX_NO_STD_MAKE_UNIQUE +#define Y_NO_WINDOWS_H SX_NO_WINDOWS_H +#define Y_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG + + +namespace sxy +{ + using sxe::shared_ptr; +} + + +#endif diff --git a/yasmine_model/include/behavior.hpp b/yasmine_model/include/behavior.hpp new file mode 100644 index 0000000..a04b4dc --- /dev/null +++ b/yasmine_model/include/behavior.hpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 +#define BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 + + +#include "essentials/non_copyable.hpp" + +#include "behavior_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class behavior +{ +public: + behavior() + { + // Nothing to do... + } + + + virtual ~behavior() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(behavior) + virtual void operator()( const event&, event_collector& ) const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/behavior_exception.hpp b/yasmine_model/include/behavior_exception.hpp new file mode 100644 index 0000000..e7db417 --- /dev/null +++ b/yasmine_model/include/behavior_exception.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C +#define BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C + + +#include "essentials/exception.hpp" +#include "essentials/non_copyable.hpp" + +#include "event_fwd.hpp" +#include "event_id.hpp" +#include "behavior_exception_fwd.hpp" + + +namespace sxy +{ + + +class behavior_exception SX_FINAL: + public sxe::exception +{ + + +public: + explicit behavior_exception( const event_sptr& _event ); + virtual ~behavior_exception() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_ASSIGNMENT_OPERATOR( behavior_exception ) + const event_sptr get_error_event() const; + + +private: + const event_sptr error_event_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/behavior_exception_fwd.hpp b/yasmine_model/include/behavior_exception_fwd.hpp new file mode 100644 index 0000000..c820200 --- /dev/null +++ b/yasmine_model/include/behavior_exception_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A +#define BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class behavior_exception; + + +typedef sxe::SX_UNIQUE_PTR< behavior_exception > behavior_exception_uptr; +typedef std::vector< behavior_exception_uptr > behavior_exceptions; + +} + + +#endif diff --git a/yasmine_model/include/behavior_fwd.hpp b/yasmine_model/include/behavior_fwd.hpp new file mode 100644 index 0000000..d9dd6dd --- /dev/null +++ b/yasmine_model/include/behavior_fwd.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 +#define BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class behavior; +class event; +class event_collector; + + +typedef sxe::SX_UNIQUE_PTR< behavior > behavior_uptr; +typedef sxe::function< void ( const event&, event_collector& ) > behavior_function; + + +} + + +#endif diff --git a/yasmine_model/include/build_number.hpp b/yasmine_model/include/build_number.hpp index 8c97408..5753557 100644 --- a/yasmine_model/include/build_number.hpp +++ b/yasmine_model/include/build_number.hpp @@ -24,7 +24,7 @@ namespace version { - const sxe::uint16_t BUILD_NUMBER( 770 ); + const sxe::uint16_t BUILD_NUMBER( 790 ); } diff --git a/yasmine_model/include/caller.hpp b/yasmine_model/include/caller.hpp new file mode 100644 index 0000000..4f75144 --- /dev/null +++ b/yasmine_model/include/caller.hpp @@ -0,0 +1,1297 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F +#define CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F + + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" + +#include "event.hpp" +#include "caller_adapter.hpp" +#include "caller_helper.hpp" +#include "event_adjuster.hpp" +#include "event_collector.hpp" + + +namespace sxy +{ + + +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +template< typename _event_type > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + _method( specialized_event ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + _method( specialized_event ); + + +#endif +} + + +template< typename _event_type > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + _method( specialized_event, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + _method( specialized_event, _event_collector ); + + +#endif +} + + +template< typename _event_type1, typename _event_type2 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2 ) +{ + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + const auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + _method8( specialized_event8, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type8>::value, + "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + _method8( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + _method9( specialized_event9, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type8>::value, + "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type9>::value, + "Event type 9 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + _method9( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, + typename _event_type10 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9, + sxe::function _method10 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + _method9( specialized_event9, _event_collector ); + } + else + { + const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); + if( specialized_event10 ) + { + _method10( specialized_event10, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + } + + +#else + + +static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type8>::value, + "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type9>::value, + "Event type 9 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type10>::value, + "Event type 10 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + _method9( specialized_event, _event_collector ); + break; + } + + case _event_type10::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); + _method10( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +} + +#endif diff --git a/yasmine_model/include/caller_adapter.hpp b/yasmine_model/include/caller_adapter.hpp new file mode 100644 index 0000000..e8fdad8 --- /dev/null +++ b/yasmine_model/include/caller_adapter.hpp @@ -0,0 +1,277 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26 +#define CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26 + +#ifndef SX_CPP03_BOOST + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class event_collector; + + +} + + +template +sxe::function adapt( T* _class, void ( T::*method )() ) +{ + return( [_class, method]() + { + ( _class->*method )(); + } + ); +} + + +template +sxe::function adapt( T* _class, void ( T::*method )( ) const ) +{ + return( [_class, method]() + { + ( _class->*method )( ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type& ) ) +{ + return( [_class, method]( const _event_type& _event) + { + ( _class->*method )( _event ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type& ) const ) +{ + return( [_class, method]( const _event_type& _event ) + { + ( _class->*method )( _event ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( sxy::event_collector& ) ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event_collector ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( sxy::event_collector& ) const ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event_collector ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type&, sxy::event_collector& ) ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event, _event_collector ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type&, sxy::event_collector& ) const ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event, _event_collector ); + } + ); +} + + +sxe::function adapt_function( void( *_function )() ); + + +template< typename _event_type > +sxe::function adapt_function( + void ( *_function )( const _event_type& ) ) +{ + return( [ _function ]( const _event_type& _event ) + { + ( *_function )( _event ); + } + ); +} + + +sxe::function adapt_function( void( *_function )( sxy::event_collector& ) ); + + +template< typename _event_type > +sxe::function adapt_function( + void( *_function )( const _event_type&, sxy::event_collector& ) ) +{ + return( [ _function ]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + ( *_function )( _event, _event_collector ); + } + ); +} + + + +template +sxe::function adapt( T* _class, bool ( T::*method )() ) +{ + return( [_class, method]() + { + return( ( _class->*method )( ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, bool ( T::*method )() const ) +{ + return( [_class, method]() + { + return( ( _class->*method )( ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, bool ( T::*method )( const _event_type& ) ) +{ + return( [_class, method]( const _event_type& _event ) + { + return( ( _class->*method )( _event ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, bool ( T::*method )( const _event_type& ) const ) +{ + return( [_class, method]( const _event_type& _event ) + { + return( ( _class->*method )( _event ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( sxy::event_collector& ) ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + return ( ( _class->*method )( _event_collector ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( sxy::event_collector& ) const ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + return( ( _class->*method )( _event_collector ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( const _event_type&, sxy::event_collector& ) ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + return( ( _class->*method )( _event, _event_collector ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( const _event_type&, sxy::event_collector& ) const ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + return( ( _class->*method )( _event, _event_collector ) ); + } + ); +} + + +sxe::function adapt_function( bool( *_function )() ); + + +template< typename _event_type > +sxe::function adapt_function( bool( *_function )( const _event_type& ) ) +{ + return( [_function]( const _event_type& _event ) + { + return( ( *_function )( _event ) ); + } + ); +} + + +sxe::function adapt_function( bool( *_function )( sxy::event_collector& ) ); + + +template< typename _event_type > +sxe::function adapt_function( + bool( *_function )( const _event_type&, sxy::event_collector& ) ) +{ + return( [_function]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + return( ( *_function )( _event, _event_collector ) ); + } + ); +} + + +#endif + +#endif diff --git a/yasmine_model/include/caller_helper.hpp b/yasmine_model/include/caller_helper.hpp new file mode 100644 index 0000000..e4cbf8f --- /dev/null +++ b/yasmine_model/include/caller_helper.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CALLER_HELPER_F7FFB6C9_339F_471F_B7A1_C77902353FBA +#define CALLER_HELPER_F7FFB6C9_339F_471F_B7A1_C77902353FBA + + +#include "event_id.hpp" + + +namespace sxy +{ + +#ifndef SX_CPP03_BOOST // C++11 only + + + template + struct has_get_event_id + { + private: + template + static constexpr auto check( T* ) -> typename + std::is_same< decltype( T::get_event_id() ), sxy::event_id >::type; + + template + static constexpr std::false_type check( ... ); + + typedef decltype( check( 0 ) ) type; + + public: + static constexpr bool value = type::value; + }; + + +#endif + +} + + +#endif diff --git a/yasmine_model/include/choice.hpp b/yasmine_model/include/choice.hpp new file mode 100644 index 0000000..6e28b13 --- /dev/null +++ b/yasmine_model/include/choice.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHOICE_31837C1D_B3FD_41D7_94FB_CD7B16FEBD73 +#define CHOICE_31837C1D_B3FD_41D7_94FB_CD7B16FEBD73 + + +#include "region_pseudostate.hpp" +#include "choice_fwd.hpp" + + +namespace sxy +{ + + +class choice: + public virtual region_pseudostate +{ +public: + choice() + { + // Nothing to do... + } + + + virtual ~choice() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(choice) +}; + + +} + + +#endif diff --git a/yasmine_model/include/choice_fwd.hpp b/yasmine_model/include/choice_fwd.hpp new file mode 100644 index 0000000..0071f98 --- /dev/null +++ b/yasmine_model/include/choice_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHOICE_FWD_CC41E744_8F28_465B_8CD6_4F3A437D121C +#define CHOICE_FWD_CC41E744_8F28_465B_8CD6_4F3A437D121C + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class choice; +typedef sxe::SX_UNIQUE_PTR< choice > choice_uptr; +typedef std::vector< choice_uptr > choices; +typedef std::vector< const choice* > raw_const_choices; + + +} + + +#endif diff --git a/yasmine_model/include/completion_event.hpp b/yasmine_model/include/completion_event.hpp new file mode 100644 index 0000000..a295db0 --- /dev/null +++ b/yasmine_model/include/completion_event.hpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 +#define COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 + + +#include "event_template.hpp" +#include "internal_completion_event_id.hpp" + + +namespace sxy +{ + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + extern const event_id Y_COMPLETION_EVENT_ID; + Y_EVENT_WITH_ID( completion_event, Y_INTERNAL_COMPLETION_EVENT_ID ) +#else + constexpr event_id Y_COMPLETION_EVENT_ID = std::numeric_limits::max(); + Y_EVENT_WITH_ID( completion_event, Y_COMPLETION_EVENT_ID ) +#endif + + +} + + +#endif diff --git a/yasmine_model/include/complex_state.hpp b/yasmine_model/include/complex_state.hpp new file mode 100644 index 0000000..a6019a7 --- /dev/null +++ b/yasmine_model/include/complex_state.hpp @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLEX_STATE_91053A02_65AF_40C3_B9F9_C283A743A85F +#define COMPLEX_STATE_91053A02_65AF_40C3_B9F9_C283A743A85F + + +#include "state.hpp" + + +namespace sxy +{ + + +class complex_state_visitor; + + +class complex_state: + public virtual state +{ +public: + complex_state() + { + // Nothing to do... + } + + + virtual ~complex_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(complex_state) + virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const = 0; + virtual void add_deferred_event( const event_id& _event_id ) = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/complex_state_impl.hpp b/yasmine_model/include/complex_state_impl.hpp new file mode 100644 index 0000000..b7424dd --- /dev/null +++ b/yasmine_model/include/complex_state_impl.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLEX_STATE_IMPL_38C23A75_BCF7_419A_BC41_CD8FB9F8C011 +#define COMPLEX_STATE_IMPL_38C23A75_BCF7_419A_BC41_CD8FB9F8C011 + + +#include "complex_state.hpp" +#include "state_impl.hpp" +#include "behavior.hpp" + + +namespace sxy +{ + + +class complex_state_impl: + public virtual complex_state, public state_impl +{ +public: + explicit complex_state_impl( const std::string& _name, behavior_uptr _entry_behavior, + behavior_uptr _exit_behavior, const event_ids& _deferred_events = event_ids() ); + virtual ~complex_state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(complex_state_impl) + virtual behavior * get_entry_behavior() const SX_OVERRIDE; + virtual behavior * get_exit_behavior() const SX_OVERRIDE; + virtual bool is_event_deferred( const event_id& _event_id ) const SX_OVERRIDE; + virtual void add_deferred_event( const event_id& _event_id ) SX_OVERRIDE; + + +protected: + bool check_if_one_of_the_deferred_events_triggers_a_transition() const; + + +private: + behavior_uptr entry_; + behavior_uptr exit_; + event_ids deferred_events_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/composite_state.hpp b/yasmine_model/include/composite_state.hpp new file mode 100644 index 0000000..db3df1e --- /dev/null +++ b/yasmine_model/include/composite_state.hpp @@ -0,0 +1,68 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOSITE_STATE_1AD1142C_AAD0_4161_B700_32D0C0441769 +#define COMPOSITE_STATE_1AD1142C_AAD0_4161_B700_32D0C0441769 + + +#include "composite_state_fwd.hpp" +#include "complex_state.hpp" +#include "shallow_history_fwd.hpp" +#include "deep_history_fwd.hpp" +#include "entry_point_fwd.hpp" +#include "exit_point_fwd.hpp" + + +namespace sxy +{ + + +class composite_state: + public virtual complex_state +{ +public: + composite_state() + { + // Nothing to do... + } + + + virtual ~composite_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(composite_state) + virtual region& add_region( region_uptr _region ) = 0; + virtual region& add_region( const std::string& _region_name ) = 0; + virtual const deep_history * get_deep_history() const = 0; + virtual deep_history& add_deep_history( deep_history_uptr _deep_history ) = 0; + virtual deep_history& add_deep_history( const std::string& _deep_history_name ) = 0; + virtual shallow_history * get_shallow_history() const = 0; + virtual shallow_history& add_shallow_history( shallow_history_uptr _shallow_history ) = 0; + virtual shallow_history& add_shallow_history( const std::string& _shallow_history_name ) = 0; + virtual const raw_const_entry_points get_entry_points() const = 0; + virtual entry_point& add_entry_point( entry_point_uptr _entry_point ) = 0; + virtual entry_point& add_entry_point( const std::string& _entry_point_name ) = 0; + virtual const raw_const_exit_points get_exit_points() const = 0; + virtual exit_point& add_exit_point( exit_point_uptr _exit_point ) = 0; + virtual exit_point& add_exit_point( const std::string& _exit_point ) = 0; + virtual size_t get_region_index( const region* const _region ) const = 0; + virtual bool check_if_regions_are_completed() const = 0; + virtual bool is_orthogonal() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/composite_state_fwd.hpp b/yasmine_model/include/composite_state_fwd.hpp new file mode 100644 index 0000000..8c13dfe --- /dev/null +++ b/yasmine_model/include/composite_state_fwd.hpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOSITE_STATE_FWD_4E6EFA7D_4400_4B33_A330_603146E114BD +#define COMPOSITE_STATE_FWD_4E6EFA7D_4400_4B33_A330_603146E114BD + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class composite_state; +typedef sxe::SX_UNIQUE_PTR< composite_state > composite_state_uptr; +typedef std::vector< composite_state* > raw_composite_states; + + +} + + +#endif diff --git a/yasmine_model/include/constraint.hpp b/yasmine_model/include/constraint.hpp new file mode 100644 index 0000000..98a92a6 --- /dev/null +++ b/yasmine_model/include/constraint.hpp @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONSTRAINT_DFC0FBD5_ACF7_4863_BB5F_129E8620FAB3 +#define CONSTRAINT_DFC0FBD5_ACF7_4863_BB5F_129E8620FAB3 + + +#include "essentials/non_copyable.hpp" + +#include "constraint_fwd.hpp" + + +namespace sxy +{ + + +class event; + + +class constraint +{ +public: + constraint() + { + // Nothing to do... + } + + + virtual ~constraint() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(constraint) + virtual bool operator()( const event& _event, event_collector& _event_collector ) const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/constraint_fwd.hpp b/yasmine_model/include/constraint_fwd.hpp new file mode 100644 index 0000000..9f5ff15 --- /dev/null +++ b/yasmine_model/include/constraint_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONSTRAINT_FWD_1FEE3CF1_5B7B_43EF_9E40_8CE0D3170E67 +#define CONSTRAINT_FWD_1FEE3CF1_5B7B_43EF_9E40_8CE0D3170E67 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class constraint; +class event; +class event_collector; + +typedef sxe::SX_UNIQUE_PTR< constraint > constraint_uptr; +typedef sxe::function< bool ( const event&, event_collector& ) > constraint_function; + + +} + + +#endif diff --git a/yasmine_model/include/deep_history.hpp b/yasmine_model/include/deep_history.hpp new file mode 100644 index 0000000..953cdcb --- /dev/null +++ b/yasmine_model/include/deep_history.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DEEP_HISTORY_4B2625A9_6406_4084_B3D3_7D67EDE09048 +#define DEEP_HISTORY_4B2625A9_6406_4084_B3D3_7D67EDE09048 + + +#include "history.hpp" +#include "deep_history_fwd.hpp" + + +namespace sxy +{ + + +class deep_history: + public virtual history +{ +public: + deep_history() + { + // Nothing to do... + } + + + virtual ~deep_history() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(deep_history) +}; + + +} + + +#endif diff --git a/yasmine_model/include/deep_history_fwd.hpp b/yasmine_model/include/deep_history_fwd.hpp new file mode 100644 index 0000000..d546242 --- /dev/null +++ b/yasmine_model/include/deep_history_fwd.hpp @@ -0,0 +1,32 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DEEP_HISTORY_FWD_DD821F91_9A4E_4520_988E_E457089412D0 +#define DEEP_HISTORY_FWD_DD821F91_9A4E_4520_988E_E457089412D0 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class deep_history; +typedef sxe::SX_UNIQUE_PTR< deep_history > deep_history_uptr; + + +} + + +#endif diff --git a/yasmine_model/include/entry_point.hpp b/yasmine_model/include/entry_point.hpp new file mode 100644 index 0000000..9167772 --- /dev/null +++ b/yasmine_model/include/entry_point.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F +#define ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F + + +#include "state_pseudostate.hpp" +#include "entry_point_fwd.hpp" + + +namespace sxy +{ + + +class entry_point: + public virtual state_pseudostate +{ +public: + entry_point() + { + // Nothing to do... + } + + + virtual ~entry_point() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(entry_point) +}; + + +} + + +#endif diff --git a/yasmine_model/include/entry_point_fwd.hpp b/yasmine_model/include/entry_point_fwd.hpp new file mode 100644 index 0000000..0a83392 --- /dev/null +++ b/yasmine_model/include/entry_point_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ENTRY_POINT_FWD_058240BC_C6BC_49D2_AEB5_CFF4935EC599 +#define ENTRY_POINT_FWD_058240BC_C6BC_49D2_AEB5_CFF4935EC599 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class entry_point; +typedef sxe::SX_UNIQUE_PTR< entry_point > entry_point_uptr; +typedef std::vector< entry_point_uptr > entry_points; +typedef std::vector< const entry_point* > raw_const_entry_points; + + +} + + +#endif diff --git a/yasmine_model/include/event.hpp b/yasmine_model/include/event.hpp new file mode 100644 index 0000000..53f33fd --- /dev/null +++ b/yasmine_model/include/event.hpp @@ -0,0 +1,67 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_990555DD_B4D7_49E4_AC39_7448568164F0 +#define EVENT_990555DD_B4D7_49E4_AC39_7448568164F0 + + +#include "essentials/non_copyable.hpp" + +#include "event_id.hpp" +#include "event_priority.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + +//!\interface event +//!\brief Interface of an event. An event has an ID, a name and a priority (for processing by the async state machine). +class event +{ +public: + event() + { + // Nothing to do... + } + + + virtual ~event() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(event) + + //!\brief Getter of event's ID. + //!\return ID of event. + virtual event_id get_id() const = 0; + + //!\brief Getter of event's name. + //!\return Name of event. + virtual std::string get_name() const = 0; + + //!\brief Getter of event's priority. + //!\return Priority of event. + virtual event_priority get_priority() const = 0; + + //!\brief Method for comparing the priorities between the current event and a given event. + //!\param _rhs Reference to an event whose priority is compared with the current event's priority. + //!\return True if the current event has a greater priority, else false. + virtual bool operator>(const event& _rhs) const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/event_adjuster.hpp b/yasmine_model/include/event_adjuster.hpp new file mode 100644 index 0000000..df63091 --- /dev/null +++ b/yasmine_model/include/event_adjuster.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5 +#define EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5 + + +#ifdef NDEBUG +#else +#include "essentials/base.hpp" +#include "hermes/log.hpp" +#endif + + +namespace sxy +{ + + +template +const _event_type& adjust_event_type( const event& _event ) +{ +#ifdef NDEBUG + return( static_cast< const _event_type& >( _event ) ); +#else + const _event_type* const specialized_event = dynamic_cast< const _event_type* const >( &_event ); + const std::string message = "Event " + _event.get_name() + " is not of given type."; + if( !specialized_event ) + { + SX_LOG( hermes::log_level::LL_ASSERT, message ); + SX_ASSERT( false, "Invalid event type!" ); + } + return( *specialized_event ); +#endif +} + + +} + + +#endif \ No newline at end of file diff --git a/yasmine_model/include/event_collector.hpp b/yasmine_model/include/event_collector.hpp new file mode 100644 index 0000000..b077d45 --- /dev/null +++ b/yasmine_model/include/event_collector.hpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_COLLECTOR_B423B8BB_DC7E_4957_95F5_2B5ECB9DD689 +#define EVENT_COLLECTOR_B423B8BB_DC7E_4957_95F5_2B5ECB9DD689 + + +#include "essentials/non_copyable.hpp" + +#include "event.hpp" + + +namespace sxy +{ + + +class event_collector +{ +public: + event_collector() + { + // Nothing to do... + } + + virtual ~event_collector() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( event_collector ) + virtual bool push( const event_sptr& _event ) = 0; + + +}; + + +} + + +#endif diff --git a/yasmine_model/include/event_creation_request.hpp b/yasmine_model/include/event_creation_request.hpp new file mode 100644 index 0000000..cc0af63 --- /dev/null +++ b/yasmine_model/include/event_creation_request.hpp @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_CREATION_REQUEST_05BAD27E_EBBD_405D_B23D_00670DF91241 +#define EVENT_CREATION_REQUEST_05BAD27E_EBBD_405D_B23D_00670DF91241 + + +#include "essentials/compatibility/chrono.hpp" +#include "essentials/non_copyable.hpp" + +#include "event_id.hpp" +#include "event_fwd.hpp" +#include "event_handle.hpp" + + +namespace sxy +{ + + +class event_creation_request SX_FINAL +{ +public: + + + event_creation_request( const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event, + const handle_type _handle ); + ~event_creation_request() SX_NOEXCEPT; +#ifndef SX_CPP03_BOOST + SX_NO_COPY(event_creation_request) + event_creation_request( event_creation_request&& ); + event_creation_request& operator=( event_creation_request&& ); +#endif + sxe::time_point< sxe::system_clock > get_time() const; + handle_type get_handle() const; + event_sptr get_event() const; + + +private: + sxe::time_point< sxe::system_clock > time_; + event_sptr event_; + handle_type handle_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/event_creation_request_time_comparer.hpp b/yasmine_model/include/event_creation_request_time_comparer.hpp new file mode 100644 index 0000000..14f46f4 --- /dev/null +++ b/yasmine_model/include/event_creation_request_time_comparer.hpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A +#define EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A + + +namespace sxy +{ + + +class event_creation_request; + + +struct event_creation_request_time_comparer +{ +public: + bool operator()( const event_creation_request& _lhs, const event_creation_request& _rhs ) const; +}; + + +} + + +#endif diff --git a/yasmine_model/include/event_fwd.hpp b/yasmine_model/include/event_fwd.hpp new file mode 100644 index 0000000..e5b6010 --- /dev/null +++ b/yasmine_model/include/event_fwd.hpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_FWD_622C6A23_5E15_4A6B_8278_460C74941A10 +#define EVENT_FWD_622C6A23_5E15_4A6B_8278_460C74941A10 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class event; +typedef sxe::shared_ptr< event > event_sptr; +typedef std::vector< event_sptr > events; + + +} + + +#endif diff --git a/yasmine_model/include/event_handle.hpp b/yasmine_model/include/event_handle.hpp new file mode 100644 index 0000000..3f2e0b2 --- /dev/null +++ b/yasmine_model/include/event_handle.hpp @@ -0,0 +1,40 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_HANDLE_57AE05A6_DA8B_4D0C_A50D_06AF8DFB46BF +#define EVENT_HANDLE_57AE05A6_DA8B_4D0C_A50D_06AF8DFB46BF + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + + //!\brief The type alias for yasmine's event handle. + typedef sxe::uint32_t handle_type; + +#ifndef SX_CPP03_BOOST + extern const handle_type Y_INVALID_EVENT_CREATION_REQUEST_HANDLE; +#else + #define Y_INVALID_EVENT_CREATION_REQUEST_HANDLE UINT_MAX +#endif + + extern const handle_type Y_DEFAULT_HANDLE; + + +} + + +#endif diff --git a/yasmine_model/include/event_id.hpp b/yasmine_model/include/event_id.hpp new file mode 100644 index 0000000..5e5e2b9 --- /dev/null +++ b/yasmine_model/include/event_id.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_ID_C05A5A39_AC17_467C_B975_8D744CC77D8B +#define EVENT_ID_C05A5A39_AC17_467C_B975_8D744CC77D8B + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +//!\brief The type alias for yasmine's event IDs. +typedef sxe::uint32_t event_id; + +//!\brief The type alias for yasmine's event ID list. +typedef std::vector< event_id > event_ids; + + +} + + +#endif diff --git a/yasmine_model/include/event_impl.hpp b/yasmine_model/include/event_impl.hpp new file mode 100644 index 0000000..a696754 --- /dev/null +++ b/yasmine_model/include/event_impl.hpp @@ -0,0 +1,67 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 +#define EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 + + +#include "event.hpp" + + +namespace sxy +{ + +//!\class event_impl +//!\brief Events that are processed by the state machine. +//!\An event can have an ID, a name and a priority (for processing by the async state machine). +class event_impl: + public event +{ +public: + explicit event_impl( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ); + virtual ~event_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(event_impl) + + //!\brief Getter of event's ID. + //!\return ID of event. + virtual event_id get_id() const SX_OVERRIDE; + + //!\brief Getter of event's name. + //!\return Name of event. + virtual std::string get_name() const SX_OVERRIDE; + + //!\brief Getter of event's priority. + //!\return Priority of event. + virtual event_priority get_priority() const SX_OVERRIDE; + + //!\brief Method for comparing the priorities between the current event and a given event. + //!\param _rhs Reference to an event whose priority is compared with the current event's priority. + //!\return True if the current event has a greater priority, else false. + virtual bool operator>(const event& _rhs) const SX_OVERRIDE; + + //!\brief Static method for creating an event with the given ID and a priority. + //!\Priority has DEFAULT_EVENT_PRIORITY as default value. + //!\param _event_id ID of the event that is created. + //!\param _event_priority Priority of the event that is created. DEFAULT_EVENT_PRIORITY is the default value. + //!\return The created event. + static event_sptr create( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ); + + +private: + event_id event_id_; + event_priority event_priority_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/event_priority.hpp b/yasmine_model/include/event_priority.hpp new file mode 100644 index 0000000..6556c7e --- /dev/null +++ b/yasmine_model/include/event_priority.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_PRIORITY_A7F92EA4_6076_48E4_B56A_E5BDDC99A655 +#define EVENT_PRIORITY_A7F92EA4_6076_48E4_B56A_E5BDDC99A655 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +//!\brief The type alias for yasmine's event priorities. +typedef sxe::int8_t event_priority; + +//!\brief The type alias for yasmine's event priority list. +typedef std::vector< event_priority > event_prioritys; + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + +#define STATE_MACHINE_INTERNAL_EVENT_PRIORITY 127u +#define DEFAULT_EVENT_PRIORITY 0u + +#else + +//!\brief yasmine's predefined event priority for the internal use. +constexpr event_priority STATE_MACHINE_INTERNAL_EVENT_PRIORITY = 127; +//!\brief yasmine's predefined default event priority. +constexpr event_priority DEFAULT_EVENT_PRIORITY = 0; + +#endif + + +} + + +#endif diff --git a/yasmine_model/include/event_template.hpp b/yasmine_model/include/event_template.hpp new file mode 100644 index 0000000..dcf70fc --- /dev/null +++ b/yasmine_model/include/event_template.hpp @@ -0,0 +1,1136 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 +#define EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 + + +#include "essentials/compatibility/compatibility.hpp" + +#include "specialized_event.hpp" + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + #define Y_AUX_DEFAULT_EVENT_PRIORITY DEFAULT_EVENT_PRIORITY +#else + #define Y_AUX_DEFAULT_EVENT_PRIORITY sxy::DEFAULT_EVENT_PRIORITY +#endif + + +#ifndef SX_NO_VARIADIC_MACRO + +#define Y_EVENT_EXPAND( x ) x + +#define Y_EVENT_CAT( A, B ) A ## B +#define Y_EVENT_SELECT( NAME, NUM ) Y_EVENT_CAT( NAME ## _, NUM ) + +#define Y_EVENT_GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, _SIXTEEN, _EIGHTEEN, _NINETEEN, _TWENTY, _TWENTY_ONE, _TWENTY_TWO, COUNT, ... ) COUNT +#define Y_EVENT_VA_SIZE( ... ) Y_EVENT_EXPAND( Y_EVENT_GET_COUNT( __VA_ARGS__, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 0, 0, -1, -1, -2, -2 ) ) + +#define Y_VA_SELECT( NAME, _level, ... ) Y_EVENT_EXPAND( Y_EVENT_SELECT( NAME, Y_EVENT_VA_SIZE(__VA_ARGS__) )( _level, __VA_ARGS__) ) +#define Y_VA_SELECT_PRIORITY( NAME, _level, _level_2, ... ) Y_EVENT_EXPAND( Y_EVENT_SELECT( NAME, Y_EVENT_VA_SIZE(__VA_ARGS__) )( _level, _level_2, __VA_ARGS__) ) + +//!\brief Macro for creating event class. It supports up to 10 event parameters. For each parameter, the type and the +//!\getter name must be specified. +#define Y_EVENT_CREATE( _class_name, ... ) Y_EVENT_EXPAND( Y_VA_SELECT( Y_EVENT_PARAM, _class_name, __VA_ARGS__ ) ) + +#define Y_EVENT_PARAM_0( _class_name, _event_id ) Y_EVENT_WITH_ID( _class_name, _event_id ) +#define Y_EVENT_PARAM_1( _class_name, _event_id, _parameter_type1, _getter_name1 ) Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id ) +#define Y_EVENT_PARAM_2( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2 ) Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id ) +#define Y_EVENT_PARAM_3( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3 ) Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id ) +#define Y_EVENT_PARAM_4( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4 ) Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id ) +#define Y_EVENT_PARAM_5( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5 ) Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id ) +#define Y_EVENT_PARAM_6( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6 ) Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id ) +#define Y_EVENT_PARAM_7( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7 ) Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id ) +#define Y_EVENT_PARAM_8( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8 ) Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id ) +#define Y_EVENT_PARAM_9( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9 ) Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id ) +#define Y_EVENT_PARAM_10( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10 ) Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id ) + + +//!\brief Macro for creating event class with event priority. It supports up to 10 event parameters. For each +//!\parameter, the type and the getter name must be specified. +#define Y_EVENT_WITH_PRIORITY_CREATE( _class_name, _event_id, ... ) Y_EVENT_EXPAND( Y_VA_SELECT_PRIORITY( Y_EVENT_PARAM_PRIORITY, _class_name, _event_id, __VA_ARGS__ ) ) + +#define Y_EVENT_PARAM_PRIORITY_0( _class_name, _event_id, _event_priority ) Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_1( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1 ) Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_2( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2 ) Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_3( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3 ) Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_4( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4 ) Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_5( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5 ) Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_6( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6 ) Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_7( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7 ) Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_8( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8 ) Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_9( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9 ) Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_10( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10 ) Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority ) + +#endif + + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID and a priority. +//!\param _class_name Name of the event class. +//!\param _event_id Event's ID. +//!\param _event_priority Event's priority. +#define Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + explicit _class_name() \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY( _class_name )\ +\ +\ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _event_id Event's id. +#define Y_EVENT_WITH_ID( _class_name, _event_id ) Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and a given type parameter. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the parameter. +//!\param _getter_name1 Name of the method that returns the value of the parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + explicit _class_name( const _param_type1& _p1 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ +SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has one parameter. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the parameter. +//!\param _getter_name1 Name of the method that returns the value of the parameter. +//!\param _event_id Event's id. +#define Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id ) Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and two given type parameter. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has two parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _event_id Event's id. +#define Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id ) Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and three given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has three parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _event_id Event's id. +#define Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id ) Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and four given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the fourth parameter. +//!\param _getter_name4 Name of the method that returns the value of the fourth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has four parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id ) Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and five given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has five parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id ) Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and six given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _parameter_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has six parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id ) Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and seven given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _event_id Event's id. +#define Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id ) Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and eight given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + typedef sxe::remove_reference::type>::type _param_type8;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ), \ + p8_( _p8 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ + const _param_type8& _getter_name8() const \ + { \ + return( p8_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ + const _param_type8 p8_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id ) Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and nine given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + typedef sxe::remove_reference::type>::type _param_type8;\ + typedef sxe::remove_reference::type>::type _param_type9;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8, const _param_type9& _p9 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ), \ + p8_( _p8 ), \ + p9_( _p9 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ +const _param_type8& _getter_name8() const \ + { \ + return( p8_ ); \ + } \ +\ +\ + const _param_type9& _getter_name9() const \ + { \ + return( p9_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ + const _param_type8 p8_; \ + const _param_type9 p9_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id ) Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and ten given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _parameter_type10 Type of the tenth parameter. +//!\param _getter_name10 Name of the method that returns the value of the tenth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + typedef sxe::remove_reference::type>::type _param_type8;\ + typedef sxe::remove_reference::type>::type _param_type9;\ + typedef sxe::remove_reference::type>::type _param_type10;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8, const _param_type9& _p9, const _param_type10& _p10 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ), \ + p8_( _p8 ), \ + p9_( _p9 ), \ + p10_( _p10 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ + const _param_type8& _getter_name8() const \ + { \ + return( p8_ ); \ + } \ +\ +\ + const _param_type9& _getter_name9() const \ + { \ + return( p9_ ); \ + } \ +\ +\ + const _param_type10& _getter_name10() const \ + { \ + return( p10_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ + const _param_type8 p8_; \ + const _param_type9 p9_; \ + const _param_type10 p10_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _parameter_type10 Type of the tenth parameter. +//!\param _getter_name10 Name of the method that returns the value of the tenth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id ) Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +#endif diff --git a/yasmine_model/include/exit_point.hpp b/yasmine_model/include/exit_point.hpp new file mode 100644 index 0000000..7d94bae --- /dev/null +++ b/yasmine_model/include/exit_point.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 +#define EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 + + +#include "state_pseudostate.hpp" +#include "exit_point_fwd.hpp" + + +namespace sxy +{ + + +class exit_point: + public virtual state_pseudostate +{ +public: + exit_point() + { + // Nothing to do... + } + + + virtual ~exit_point() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(exit_point) +}; + + +} + + +#endif diff --git a/yasmine_model/include/exit_point_fwd.hpp b/yasmine_model/include/exit_point_fwd.hpp new file mode 100644 index 0000000..49e9951 --- /dev/null +++ b/yasmine_model/include/exit_point_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXIT_POINT_FWD_7358F91A_C52C_47DC_9CF0_BB37E354B382 +#define EXIT_POINT_FWD_7358F91A_C52C_47DC_9CF0_BB37E354B382 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class exit_point; +typedef sxe::SX_UNIQUE_PTR< exit_point > exit_point_uptr; +typedef std::vector< exit_point_uptr > exit_points; +typedef std::vector< const exit_point* > raw_const_exit_points; + + +} + + +#endif diff --git a/yasmine_model/include/final_state.hpp b/yasmine_model/include/final_state.hpp new file mode 100644 index 0000000..a864ead --- /dev/null +++ b/yasmine_model/include/final_state.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FINAL_STATE_029A393C_1CDD_45AC_8FBD_860D1EC631D4 +#define FINAL_STATE_029A393C_1CDD_45AC_8FBD_860D1EC631D4 + + +#include "state.hpp" + + +namespace sxy +{ + + +class final_state: + public virtual state +{ +public: + final_state() + { + // Nothing to do... + } + + + virtual ~final_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(final_state) + +}; + + +} + + +#endif diff --git a/yasmine_model/include/fork.hpp b/yasmine_model/include/fork.hpp new file mode 100644 index 0000000..79c7ad5 --- /dev/null +++ b/yasmine_model/include/fork.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORK_AE64610F_E053_4011_9005_1CB9698FDE30 +#define FORK_AE64610F_E053_4011_9005_1CB9698FDE30 + + +#include "region_pseudostate.hpp" +#include "fork_fwd.hpp" + + +namespace sxy +{ + + +class fork: + public virtual region_pseudostate +{ +public: + fork() + { + // Nothing to do... + } + + + virtual ~fork() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(fork) +}; + + +} + + +#endif diff --git a/yasmine_model/include/fork_fwd.hpp b/yasmine_model/include/fork_fwd.hpp new file mode 100644 index 0000000..a921360 --- /dev/null +++ b/yasmine_model/include/fork_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORK_FWD_9E024994_76D1_4B32_AAA5_30630EC8F828 +#define FORK_FWD_9E024994_76D1_4B32_AAA5_30630EC8F828 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class fork; +typedef sxe::SX_UNIQUE_PTR< fork > fork_uptr; +typedef std::vector< fork_uptr > forks; +typedef std::vector< const fork* > raw_const_forks; + + +} + + +#endif diff --git a/yasmine_model/include/guard_caller.hpp b/yasmine_model/include/guard_caller.hpp new file mode 100644 index 0000000..fa42b33 --- /dev/null +++ b/yasmine_model/include/guard_caller.hpp @@ -0,0 +1,1221 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef GUARD_CALLER_739F1B72_B584_4F9E_AD3B_56149B96F7BE +#define GUARD_CALLER_739F1B72_B584_4F9E_AD3B_56149B96F7BE + + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" + +#include "event.hpp" +#include "caller_adapter.hpp" +#include "event_adjuster.hpp" +#include "event_collector.hpp" + + +namespace sxy +{ + +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +template< typename _event_type > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + enabled = _method( specialized_event ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + enabled = _method( specialized_event ); + + + +#endif + + return( enabled ); +} + + +template< typename _event_type > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + enabled = _method( specialized_event, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + enabled = _method( specialized_event, _event_collector ); + + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + const auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + enabled = _method8( specialized_event8, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + enabled = _method8( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + enabled = _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + enabled = _method9( specialized_event9, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + enabled = _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + enabled = _method9( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, + typename _event_type10 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9, + sxe::function _method10 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + enabled = _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + enabled = _method9( specialized_event9, _event_collector ); + } + else + { + const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); + if( specialized_event10 ) + { + enabled = _method10( specialized_event10, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + enabled = _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + enabled = _method9( specialized_event, _event_collector ); + break; + } + + case _event_type10::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); + enabled = _method10( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +} + +#endif diff --git a/yasmine_model/include/history.hpp b/yasmine_model/include/history.hpp new file mode 100644 index 0000000..8f0abf2 --- /dev/null +++ b/yasmine_model/include/history.hpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 +#define HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 + + +#include "state_pseudostate.hpp" + + +namespace sxy +{ + + +class history: + public virtual state_pseudostate +{ +public: + history() + { + // Nothing to do... + } + + + virtual ~history() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(history) + virtual raw_transitions get_default_transitions() const = 0; + virtual void add_default_transition( transition& _default_transition ) = 0; + virtual bool check_if_state_was_active_before() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/initial_pseudostate.hpp b/yasmine_model/include/initial_pseudostate.hpp new file mode 100644 index 0000000..dcbd696 --- /dev/null +++ b/yasmine_model/include/initial_pseudostate.hpp @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E +#define INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E + + +#include "region_pseudostate.hpp" +#include "initial_pseudostate_fwd.hpp" + + +namespace sxy +{ + + +class transition; + + +class initial_pseudostate: + public virtual region_pseudostate +{ +public: + initial_pseudostate() + { + // Nothing to do... + } + + + virtual ~initial_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(initial_pseudostate) + virtual transition * get_transition() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/initial_pseudostate_fwd.hpp b/yasmine_model/include/initial_pseudostate_fwd.hpp new file mode 100644 index 0000000..f9421f3 --- /dev/null +++ b/yasmine_model/include/initial_pseudostate_fwd.hpp @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INITIAL_PSEUDOSTATE_FWD_70DC64B4_80F9_4F69_9922_93DA7009BBF8 +#define INITIAL_PSEUDOSTATE_FWD_70DC64B4_80F9_4F69_9922_93DA7009BBF8 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class initial_pseudostate; +typedef sxe::SX_UNIQUE_PTR< initial_pseudostate > initial_pseudostate_uptr; + + +} + + +#endif diff --git a/yasmine_model/include/internal_completion_event_id.hpp b/yasmine_model/include/internal_completion_event_id.hpp new file mode 100644 index 0000000..e65d39c --- /dev/null +++ b/yasmine_model/include/internal_completion_event_id.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 +#define INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 + + +#include "event_template.hpp" + +#ifndef SX_CPP03_BOOST + +#include + +#endif + +#ifdef max + #undef max +#endif + + +//!\brief yasmine's predefined internal event ID for the completion event. +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + #define Y_INTERNAL_COMPLETION_EVENT_ID UINT_MAX +#endif + + +#endif diff --git a/yasmine_model/include/interruptible.hpp b/yasmine_model/include/interruptible.hpp new file mode 100644 index 0000000..545be17 --- /dev/null +++ b/yasmine_model/include/interruptible.hpp @@ -0,0 +1,44 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef INTERRUPTIBLE_32EC8385_109D_4338_BA8D_A82356BDBAF2 +#define INTERRUPTIBLE_32EC8385_109D_4338_BA8D_A82356BDBAF2 + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + + class interruptible + { + public: + interruptible() + { + // Nothing to do... + } + + virtual ~interruptible() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( interruptible ) + virtual bool is_interrupted() const = 0; + }; + + +} + + +#endif \ No newline at end of file diff --git a/yasmine_model/include/join.hpp b/yasmine_model/include/join.hpp new file mode 100644 index 0000000..694092d --- /dev/null +++ b/yasmine_model/include/join.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JOIN_712B59B9_F9E6_4E4B_9427_477A4782E70E +#define JOIN_712B59B9_F9E6_4E4B_9427_477A4782E70E + + +#include "region_pseudostate.hpp" +#include "join_fwd.hpp" + + +namespace sxy +{ + + +class join: + public virtual region_pseudostate +{ +public: + join() + { + // Nothing to do... + } + + + virtual ~join() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(join) + virtual bool check_if_all_source_states_of_incoming_transitions_are_active() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/join_fwd.hpp b/yasmine_model/include/join_fwd.hpp new file mode 100644 index 0000000..ffff59e --- /dev/null +++ b/yasmine_model/include/join_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JOIN_FWD_62FA1B0B_2997_4645_A325_BD9ED4C1EC7D +#define JOIN_FWD_62FA1B0B_2997_4645_A325_BD9ED4C1EC7D + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class join; +typedef sxe::SX_UNIQUE_PTR< join > join_uptr; +typedef std::vector< join_uptr > joins; +typedef std::vector< const join* > raw_const_joins; + + +} + + +#endif diff --git a/yasmine_model/include/json_parser_helper.hpp b/yasmine_model/include/json_parser_helper.hpp index 4475db4..c53b4f9 100644 --- a/yasmine_model/include/json_parser_helper.hpp +++ b/yasmine_model/include/json_parser_helper.hpp @@ -14,10 +14,10 @@ #include -#include - #include "essentials/compatibility/compatibility.hpp" +#include "rapidjson_document.hpp" + namespace sxy { diff --git a/yasmine_model/include/json_reader.hpp b/yasmine_model/include/json_reader.hpp index a0f02ec..81b79c2 100644 --- a/yasmine_model/include/json_reader.hpp +++ b/yasmine_model/include/json_reader.hpp @@ -11,12 +11,10 @@ #ifndef JSON_READER_B84EDCFB_85B6_4060_971F_96D6FB6D87B7 #define JSON_READER_B84EDCFB_85B6_4060_971F_96D6FB6D87B7 - -#include - #include "essentials/non_copyable.hpp" #include "essentials/uri.hpp" +#include "rapidjson_document.hpp" #include "transition_model_kind.hpp" #include "region_model_fwd.hpp" #include "pseudostate_model_fwd.hpp" diff --git a/yasmine_model/include/json_writer.hpp b/yasmine_model/include/json_writer.hpp index 3a9ef3b..41ab84e 100644 --- a/yasmine_model/include/json_writer.hpp +++ b/yasmine_model/include/json_writer.hpp @@ -26,10 +26,11 @@ typedef std::size_t SizeType; } -#include #include "state_machine_model.hpp" +#include "rapidjson_document.hpp" + namespace sxy { diff --git a/yasmine_model/include/junction.hpp b/yasmine_model/include/junction.hpp new file mode 100644 index 0000000..a6ba46a --- /dev/null +++ b/yasmine_model/include/junction.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JUNCTION_C9792E4F_85DB_4377_AFE4_E1A1B9F101E0 +#define JUNCTION_C9792E4F_85DB_4377_AFE4_E1A1B9F101E0 + + +#include "region_pseudostate.hpp" +#include "join_fwd.hpp" + + +namespace sxy +{ + + +class junction: + public virtual region_pseudostate +{ +public: + junction() + { + // Nothing to do... + } + + + virtual ~junction() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(junction) +}; + + +} + + +#endif diff --git a/yasmine_model/include/junction_fwd.hpp b/yasmine_model/include/junction_fwd.hpp new file mode 100644 index 0000000..661a88c --- /dev/null +++ b/yasmine_model/include/junction_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JUNCTION_FWD_7B62488D_9661_42DD_BC43_8E9737158029 +#define JUNCTION_FWD_7B62488D_9661_42DD_BC43_8E9737158029 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class junction; +typedef sxe::SX_UNIQUE_PTR< junction > junction_uptr; +typedef std::vector< junction_uptr > junctions; +typedef std::vector< const junction* > raw_const_junctions; + + +} + + +#endif diff --git a/yasmine_model/include/libyasmine_backward_compatibility.hpp b/yasmine_model/include/libyasmine_backward_compatibility.hpp new file mode 100644 index 0000000..8a0f291 --- /dev/null +++ b/yasmine_model/include/libyasmine_backward_compatibility.hpp @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LIBYASMINE_BACKWARD_COMPATIBILITY_25EFEF99_3357_4F3D_843D_AEB2C56E19DD +#define LIBYASMINE_BACKWARD_COMPATIBILITY_25EFEF99_3357_4F3D_843D_AEB2C56E19DD + + +#include "essentials/compatibility/compatibility.hpp" + + +#ifdef Y_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG +#define SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG +#endif + + +namespace sxy +{ + using sxe::shared_ptr; +} + + +#endif diff --git a/yasmine_model/include/logging.hpp b/yasmine_model/include/logging.hpp new file mode 100644 index 0000000..af17df4 --- /dev/null +++ b/yasmine_model/include/logging.hpp @@ -0,0 +1,20 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef LOGGING_BD013464_0F4C_4276_ADB7_312BF2A33912 +#define LOGGING_BD013464_0F4C_4276_ADB7_312BF2A33912 + + +#include "hermes/log.hpp" +#include "hermes/cout_logger.hpp" +#include "hermes/file_logger.hpp" + + +#endif diff --git a/yasmine_model/include/optimization.hpp b/yasmine_model/include/optimization.hpp new file mode 100644 index 0000000..26469ef --- /dev/null +++ b/yasmine_model/include/optimization.hpp @@ -0,0 +1,44 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef OPTIMIZATION_3A290AFB_D672_4E4A_98AD_94841A01D76D +#define OPTIMIZATION_3A290AFB_D672_4E4A_98AD_94841A01D76D + + +#ifdef Y_OPTIMIZE_4_SPEED + + + #ifdef Y_OPTIMIZE_4_SIZE + + + #error "Y_OPTIMIZE_4_SPEED and Y_OPTIMIZE_4_SIZE are both defined!" + + + + #endif + + +#else + + + #ifndef Y_OPTIMIZE_4_SIZE + + + #define Y_OPTIMIZE_4_SIZE + + + #endif + + +#endif + + +#endif diff --git a/yasmine_model/include/pseudostate.hpp b/yasmine_model/include/pseudostate.hpp new file mode 100644 index 0000000..2d31691 --- /dev/null +++ b/yasmine_model/include/pseudostate.hpp @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PSEUDOSTATE_595E5B94_1CE0_41B8_AD35_F0DB43C647B2 +#define PSEUDOSTATE_595E5B94_1CE0_41B8_AD35_F0DB43C647B2 + + +#include "vertex.hpp" +#include "pseudostate_fwd.hpp" + + +namespace sxy +{ + + +class pseudostate_visitor; + + +class pseudostate: + public virtual vertex +{ +public: + pseudostate() + { + // Nothing to do... + } + + + virtual ~pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(pseudostate) + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/pseudostate_fwd.hpp b/yasmine_model/include/pseudostate_fwd.hpp new file mode 100644 index 0000000..0b8ef98 --- /dev/null +++ b/yasmine_model/include/pseudostate_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PSEUDOSTATE_FWD_64C5B45A_A614_4CE6_8634_E96D6DF41F04 +#define PSEUDOSTATE_FWD_64C5B45A_A614_4CE6_8634_E96D6DF41F04 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class pseudostate; +typedef sxe::SX_UNIQUE_PTR< pseudostate > pseudostate_uptr; +typedef std::vector< pseudostate_uptr > pseudostates; +typedef std::vector< const pseudostate* > raw_const_pseudostates; + + +} + + +#endif diff --git a/yasmine_model/include/rapidjson_document.hpp b/yasmine_model/include/rapidjson_document.hpp new file mode 100644 index 0000000..2e9a65e --- /dev/null +++ b/yasmine_model/include/rapidjson_document.hpp @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef RAPIDJSON_DOCUMENT_ED907436_BE54_4D3D_9FDA_5C83FCBCBDF2 +#define RAPIDJSON_DOCUMENT_ED907436_BE54_4D3D_9FDA_5C83FCBCBDF2 + + +#define RAPIDJSON_NO_SIZETYPEDEFINE + + +namespace rapidjson +{ + + +typedef std::size_t SizeType; + + +} + + +#include + + +#endif diff --git a/yasmine_model/include/region.hpp b/yasmine_model/include/region.hpp new file mode 100644 index 0000000..6f8b9d5 --- /dev/null +++ b/yasmine_model/include/region.hpp @@ -0,0 +1,117 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_06648EA9_E80A_49B8_9814_1723273908D2 +#define REGION_06648EA9_E80A_49B8_9814_1723273908D2 + + +#include "state_machine_element.hpp" +#include "state_fwd.hpp" +#include "region_fwd.hpp" +#include "pseudostate_fwd.hpp" +#include "initial_pseudostate_fwd.hpp" +#include "choice_fwd.hpp" +#include "fork_fwd.hpp" +#include "join_fwd.hpp" +#include "junction_fwd.hpp" +#include "terminate_pseudostate_fwd.hpp" +#include "behavior_fwd.hpp" +#include "async_behavior.hpp" +#include "event_fwd.hpp" +#include "event_id.hpp" + + +namespace sxy +{ + + +class vertex; +class composite_state; +class simple_state; +class final_state; + + +class region: public virtual state_machine_element +{ +public: + region() + { + // Nothing to do... + } + + + virtual ~region () SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(region) + virtual void set_parent_state( composite_state* const _composite_state ) = 0; + virtual const composite_state& get_parent_state() const = 0; + virtual composite_state& get_parent_state() = 0; + virtual raw_const_states get_states() const = 0; + virtual size_t get_pseudostate_count() const = 0; + virtual vertex* get_pseudostate( const std::string& _name ) const = 0; + virtual vertex* get_vertex( const std::string& _vertex_name ) const = 0; + virtual raw_const_pseudostates get_pseudostates() const = 0; + virtual initial_pseudostate* get_initial_pseudostate() const = 0; + virtual initial_pseudostate& add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) = 0; + virtual initial_pseudostate& add_initial_pseudostate( const std::string& _initial_state_name ) = 0; + virtual state& add_state( state_uptr _state ) = 0; + virtual choice& add_choice( choice_uptr _choice ) = 0; + virtual choice& add_choice( const std::string& _choice_name ) = 0; + virtual fork& add_fork( fork_uptr _fork ) = 0; + virtual fork& add_fork( const std::string& _fork_name ) = 0; + virtual join& add_join( join_uptr _join ) = 0; + virtual join& add_join( const std::string& _join_name ) = 0; + virtual junction& add_junction( junction_uptr _junction ) = 0; + virtual junction& add_junction( const std::string& _junction_name ) = 0; + virtual terminate_pseudostate& add_terminate_pseudostate( + terminate_pseudostate_uptr _terminate_pseudostate ) = 0; + virtual terminate_pseudostate& add_terminate_pseudostate( const std::string& _terminate_pseudostate_name ) = 0; + virtual simple_state& add_simple_state( const std::string& _name, + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function() ) = 0; + virtual simple_state& add_simple_state( const std::string& _name, const event_ids& _deferred_events, + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function(), + event_sptr _error_event = event_sptr() ) = 0; + virtual simple_state& add_async_simple_state( const std::string& _name, const event_ids& _deferred_events, + async_behavior_uptr _do_action = async_behavior_uptr(), const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function(), + event_sptr _error_event = event_sptr() ) = 0; + virtual composite_state& add_composite_state( const std::string& _name, + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) = 0; + virtual composite_state& add_composite_state( const std::string& _name, const event_ids& _deferred_events, + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) = 0; + virtual final_state& add_final_state( const std::string& _name ) = 0; + virtual size_t get_state_count() const = 0; + virtual state* get_state( const std::string& _name ) const = 0; + virtual const state* get_active_state() const = 0; + virtual state* get_active_state() = 0; + virtual void set_active_state( state* const _active_state ) = 0; + virtual void set_state_was_active( state* const _active_state ) = 0; + virtual const state* get_last_active_state() const = 0; + virtual state* get_last_active_state() = 0; + virtual bool is_active_state_final() const = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/region_fwd.hpp b/yasmine_model/include/region_fwd.hpp new file mode 100644 index 0000000..bc9db74 --- /dev/null +++ b/yasmine_model/include/region_fwd.hpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_FWD_DFB0F2A6_B441_4314_BB3D_18DCDE9ADF7B +#define REGION_FWD_DFB0F2A6_B441_4314_BB3D_18DCDE9ADF7B + + +#include +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class region; +typedef sxe::SX_UNIQUE_PTR< region > region_uptr; +typedef std::vector< region_uptr > regions; +typedef std::vector< region* > raw_regions; +typedef std::set< const region* > raw_const_region_set; + + +} + + +#endif diff --git a/yasmine_model/include/region_pseudostate.hpp b/yasmine_model/include/region_pseudostate.hpp new file mode 100644 index 0000000..da502cc --- /dev/null +++ b/yasmine_model/include/region_pseudostate.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_PSEUDOSTATE_B33005D7_D302_495D_9118_F45EA4443736 +#define REGION_PSEUDOSTATE_B33005D7_D302_495D_9118_F45EA4443736 + + +#include "pseudostate.hpp" + + +namespace sxy +{ + + +class region_pseudostate: + public virtual pseudostate +{ +public: + region_pseudostate() + { + // Nothing to do... + } + + + virtual ~region_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(region_pseudostate) + virtual region* get_parent_region() const = 0; + virtual void set_parent_region( region* const _parent_region ) = 0; +}; + + +} + +#endif diff --git a/yasmine_model/include/region_pseudostates.hpp b/yasmine_model/include/region_pseudostates.hpp new file mode 100644 index 0000000..f40cacc --- /dev/null +++ b/yasmine_model/include/region_pseudostates.hpp @@ -0,0 +1,24 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_PSEUDOSTATES_96ABC260_2695_4935_9AFD_A76CA61987E0 +#define REGION_PSEUDOSTATES_96ABC260_2695_4935_9AFD_A76CA61987E0 + + +#include "initial_pseudostate.hpp" +#include "terminate_pseudostate.hpp" +#include "choice.hpp" +#include "junction.hpp" +#include "join.hpp" +#include "fork.hpp" + + +#endif diff --git a/yasmine_model/include/shallow_history.hpp b/yasmine_model/include/shallow_history.hpp new file mode 100644 index 0000000..8f1fa77 --- /dev/null +++ b/yasmine_model/include/shallow_history.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SHALLOW_HISTORY_2F18336E_AEBD_4040_B40D_E96E0738B83E +#define SHALLOW_HISTORY_2F18336E_AEBD_4040_B40D_E96E0738B83E + + +#include "history.hpp" +#include "shallow_history_fwd.hpp" + + +namespace sxy +{ + + +class shallow_history: + public virtual history +{ +public: + shallow_history() + { + // Nothing to do... + } + + + virtual ~shallow_history() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(shallow_history) +}; + + +} + + +#endif diff --git a/yasmine_model/include/shallow_history_fwd.hpp b/yasmine_model/include/shallow_history_fwd.hpp new file mode 100644 index 0000000..7125a93 --- /dev/null +++ b/yasmine_model/include/shallow_history_fwd.hpp @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SHALLOW_HISTORY_FWD_42B01401_8D1E_4108_B4C2_7EED7CAE9DFB +#define SHALLOW_HISTORY_FWD_42B01401_8D1E_4108_B4C2_7EED7CAE9DFB + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class shallow_history; +typedef sxe::SX_UNIQUE_PTR< shallow_history > shallow_history_uptr; + + +} + + +#endif diff --git a/yasmine_model/include/simple_state.hpp b/yasmine_model/include/simple_state.hpp new file mode 100644 index 0000000..8efda24 --- /dev/null +++ b/yasmine_model/include/simple_state.hpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SIMPLE_STATE_FE75D8CB_F61A_4291_94EC_206E43F291AA +#define SIMPLE_STATE_FE75D8CB_F61A_4291_94EC_206E43F291AA + + +#include "complex_state.hpp" + + +namespace sxy +{ + + +class simple_state: + public virtual complex_state +{ +public: + simple_state() + { + // Nothing to do... + } + + + virtual ~simple_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(simple_state) +}; + + +} + + +#endif diff --git a/yasmine_model/include/simple_state_base.hpp b/yasmine_model/include/simple_state_base.hpp new file mode 100644 index 0000000..46b77f8 --- /dev/null +++ b/yasmine_model/include/simple_state_base.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SIMPLE_STATE_BASE_804FA805_18CB_4778_8C90_9B7AB2023D3B +#define SIMPLE_STATE_BASE_804FA805_18CB_4778_8C90_9B7AB2023D3B + + +#include "simple_state.hpp" +#include "complex_state_impl.hpp" + + +namespace sxy +{ + + +class simple_state_base: + public virtual simple_state, public complex_state_impl +{ + + +public: + simple_state_base( const std::string& _name, behavior_uptr _entry_action, behavior_uptr _exit_action, + const event_ids& _deferred_events, event_sptr _error_event ); + virtual ~simple_state_base() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(simple_state_base) + virtual const regions& get_regions() const SX_OVERRIDE; + virtual regions& get_regions() SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual bool has_error_event() const SX_OVERRIDE; + virtual event_sptr get_error_event() const SX_OVERRIDE; + + +private: + event_sptr error_event_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/specialized_event.hpp b/yasmine_model/include/specialized_event.hpp new file mode 100644 index 0000000..e5f5d62 --- /dev/null +++ b/yasmine_model/include/specialized_event.hpp @@ -0,0 +1,211 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SPECIALIZED_EVENT_CA823D7C_65A6_4094_8641_FA9496F11C1F +#define SPECIALIZED_EVENT_CA823D7C_65A6_4094_8641_FA9496F11C1F + + +#include "event_impl.hpp" + + +namespace sxy +{ + +//!\class specialized_event +//!\brief Class that inherits event_impl and provides a fixed event ID and priority as well as create methods +//!for creating instances of the event. +template +class specialized_event: public event_impl +{ +public: + //!\brief Constructor. + explicit specialized_event(const std::string _name = std::string()) + : event_impl( _event_id, _event_priority ), + name_( _name ) + { + // Nothing to do. + } + + + virtual ~specialized_event() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do. + } + + + SX_NO_COPY(specialized_event) + + //!\brief Getter for event's name. + //!\return Name of the event. + virtual std::string get_name() const SX_OVERRIDE + { + const std::string name = name_.empty() ? event_impl::get_name() : name_; + return(name); + } + + + //!\brief Getter for event's ID. + //!\return ID of the event. + virtual sxy::event_id get_id() const SX_OVERRIDE + { + return( _event_id ); + } + + + //!\brief Static getter for event's ID. + //!\return ID of the event.Static method for creating an event + static SX_CONSTEXPR sxy::event_id get_event_id() + { + return( _event_id ); + } + + +#ifdef SX_CPP03_BOOST + + + //!\brief Method for creating an event with no parameters. + //!\return The created event. + static sxe::shared_ptr< _concrete_event > create() + { + return( SX_MAKE_SHARED< _concrete_event >() ); + } + + + //!\brief Method for creating an event with 1 parameter. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1 ) ); + } + + + //!\brief Method for creating an event with 2 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2 ) ); + } + + + //!\brief Method for creating an event with 3 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3 ) ); + } + + + //!\brief Method for creating an event with 4 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4 ) ); + } + + + //!\brief Method for creating an event with 5 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5 ) ); + } + + + //!\brief Method for creating an event with 6 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6 ) ); + } + + + //!\brief Method for creating an event with 7 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) ); + } + + + //!\brief Method for creating an event with 8 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, + const _param_type8& _p8 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) ); + } + + + //!\brief Method for creating an event with 9 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, + const _param_type8& _p8, const _param_type9& _p9 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9 ) ); + } + + + //!\brief Method for creating an event with 10 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, + const _param_type8& _p8, const _param_type9& _p9, const _param_type10& _p10 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10 ) ); + } + + +#else + //!\brief Method for creating an event with its parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( _param_types... args ) + { + return( SX_MAKE_SHARED< _concrete_event >( args... ) ); + } + + +#endif + + + +private: + std::string name_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/state.hpp b/yasmine_model/include/state.hpp new file mode 100644 index 0000000..93a5b71 --- /dev/null +++ b/yasmine_model/include/state.hpp @@ -0,0 +1,82 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_A72D37CD_D9B1_430D_BBCA_13371745FC80 +#define STATE_A72D37CD_D9B1_430D_BBCA_13371745FC80 + + +#include "vertex.hpp" +#include "state_fwd.hpp" +#include "region_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class state_visitor; +class behavior; +class event; +class async_event_handler; +class event_collector; + + +class state: + public virtual vertex +{ +public: + state() + { + // Nothing to do... + } + + + virtual ~state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(state) + virtual void set_parent_region( region* const _parent_region ) = 0; + virtual region * get_parent_region() const = 0; + virtual size_t get_parent_region_index() const = 0; + virtual region * get_region( const std::string& _region_name ) const = 0; + virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const = 0; + virtual behavior * get_entry_behavior() const = 0; + virtual behavior * get_exit_behavior() const = 0; + virtual std::size_t get_nesting_level() const = 0; + virtual void set_active() = 0; + virtual void set_inactive() = 0; + virtual bool is_active() const = 0; + virtual bool is_complete() const = 0; + virtual bool is_event_deferred( const event_id& _event_id ) const = 0; + virtual bool was_active() const = 0; + virtual void set_was_active() = 0; + virtual const regions& get_regions() const = 0; + virtual regions& get_regions() = 0; + virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const = 0; + virtual void execute_enter_behavior( const event& _event, event_collector& _event_collector ) const = 0; + virtual void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const = 0; + virtual void accept_state_visitor( state_visitor& _visitor ) const = 0; + virtual void enter_state( const event& _event, event_collector& _event_collector ) = 0; + virtual void exit_state( const event& _event, event_collector& _event_collector ) = 0; + virtual bool has_error_event() const = 0; + virtual event_sptr get_error_event() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/state_fwd.hpp b/yasmine_model/include/state_fwd.hpp new file mode 100644 index 0000000..1793b20 --- /dev/null +++ b/yasmine_model/include/state_fwd.hpp @@ -0,0 +1,40 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_FWD_B1FE7EC2_9444_4D6B_AD05_C59EA6F7FF8A +#define STATE_FWD_B1FE7EC2_9444_4D6B_AD05_C59EA6F7FF8A + + +#include +#include + +#include "states_nesting_comparer.hpp" +#include "states_nesting_comparer_ascending.hpp" + + +namespace sxy +{ + + +class state; +typedef sxe::SX_UNIQUE_PTR< state > state_uptr; +typedef std::vector< const state* > raw_const_states; +typedef std::vector< state_uptr > states; +typedef std::set< const state* > raw_const_state_set; +typedef std::set< const state*, states_nesting_comparer > raw_const_states_by_nesting_level; +typedef std::set< state*, states_nesting_comparer > raw_states_by_nesting_level; +typedef std::set< state*, states_nesting_comparer_ascending > raw_states_by_nesting_level_ascending; + + +} + + +#endif diff --git a/yasmine_model/include/state_impl.hpp b/yasmine_model/include/state_impl.hpp new file mode 100644 index 0000000..dc03b3b --- /dev/null +++ b/yasmine_model/include/state_impl.hpp @@ -0,0 +1,78 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_IMPL_3DE89F57_84D8_41A8_98D2_67E95A9D1C27 +#define STATE_IMPL_3DE89F57_84D8_41A8_98D2_67E95A9D1C27 + + +#include "state.hpp" +#include "vertex_impl.hpp" +#include "behavior_fwd.hpp" +#include "event_fwd.hpp" +#include "optimization.hpp" + + +namespace sxy +{ + + +class state_impl: + public virtual state, public vertex_impl +{ +public: + explicit state_impl( const std::string& _name ); + virtual ~state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(state_impl) + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + virtual void set_parent_region( region* const _parent_region ) SX_OVERRIDE; + virtual region * get_parent_region() const SX_OVERRIDE; + virtual size_t get_parent_region_index() const SX_OVERRIDE; + virtual region * get_region( const std::string& _region_name ) const SX_OVERRIDE; + virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const SX_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const SX_OVERRIDE; + virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; + virtual std::size_t get_nesting_level() const SX_OVERRIDE; + virtual void set_was_active() SX_OVERRIDE; + virtual bool was_active() const SX_OVERRIDE; + virtual void set_active() SX_OVERRIDE; + virtual void set_inactive() SX_OVERRIDE; + virtual bool is_active() const SX_OVERRIDE; + virtual bool is_complete() const SX_OVERRIDE; + virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + virtual void execute_enter_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual void enter_state( const event& _event, event_collector& _event_collector ) SX_OVERRIDE; + virtual void exit_state( const event& _event, event_collector& _event_collector ) SX_OVERRIDE; + virtual bool has_error_event() const SX_OVERRIDE; + virtual event_sptr get_error_event() const SX_OVERRIDE; + + +private: + void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const; + void collect_ancestors_as_regions( raw_regions& _ancestors_as_regions ) const; + + bool was_active_; + bool is_active_; + region* parent_; + +#ifdef Y_OPTIMIZE_4_SPEED + mutable raw_composite_states ancestors_; + mutable raw_regions ancestors_as_regions_; +#endif +}; + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_base.hpp b/yasmine_model/include/state_machine_base.hpp new file mode 100644 index 0000000..d6c47f1 --- /dev/null +++ b/yasmine_model/include/state_machine_base.hpp @@ -0,0 +1,240 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 +#define STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 + + +#include "essentials/compatibility/thread.hpp" + +#include "state_machine_introspection.hpp" +#include "event_collector.hpp" +#include "interruptible.hpp" +#include "transition_kind.hpp" +#include "constraint_fwd.hpp" +#include "behavior_fwd.hpp" +#include "transition_fwd.hpp" +#include "composite_state_fwd.hpp" +#include "region_fwd.hpp" +#include "event_id.hpp" +#include "state_machine_defect_fwd.hpp" + + +namespace sxy +{ + + + class vertex; + class async_event_handler; + class event_processing_callback; + class uri; + class region; + + + //!\class state_machine + //!\brief Base class for the state machines. It provides methods to start the state machine, to fire events, + //!to add transitions, to check the state machine for possible defects and to get the root state reference. + class state_machine_base : + private state_machine_introspection, public event_collector, private interruptible + { + public: + //!\brief Constructor + //!\param _name Name of the state machine. + //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback + //!interface should be used. + explicit state_machine_base( const std::string& _name, + event_processing_callback* const _event_processing_callback = SX_NULLPTR ); + virtual ~state_machine_base() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( state_machine_base ) + + //!\brief Returns the root state of the state machine. Commonly used to add regions to the root state and to create transitions + //!from and to the root state. + //!\return Reference to the root state of the state machine. + composite_state& get_root_state() const; + +#ifdef Y_PROFILER + sxe::uint32_t get_number_of_processed_events() const; +#endif + + //!\brief Add a transition to the state machine. The state machine takes ownership of the transition. + //!\param _transition A transition. + //!\return transition Reference to the added transition. + virtual transition& add_transition( transition_uptr _transition ); + + //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\param _guard The guard of the transition. Default is an empty function. + //!\param _behavior The behavior of the transition. Default is an empty function. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + const constraint_function& _guard = constraint_function(), + const behavior_function& _behavior = behavior_function() ); + + //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param event_ids List of IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\param _guard The guard of the transition. Default is an empty function. + //!\param _behavior The behavior of the transition. Default is an empty function. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + const constraint_function& _guard = constraint_function(), + const behavior_function& _behavior = behavior_function() ); + + //!\brief Creates a transition with the given name, kind, event, guard between the given source and + //! target and adds it to the state machine. No behavior is provided. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const constraint_function& _guard, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, events, guard between the given source and + //! target and adds it to the state machine. No behavior is provided. + //!\param _event_ids IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const constraint_function& _guard, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const constraint_function& _guard, const behavior_function& _behavior, + const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, events, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param _event_ids IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const constraint_function& _guard, const behavior_function& _behavior, + const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, event and behavior between the given source and + //! target and adds it to the state machine. No guard is provided. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, events and behavior between the given source and + //! target and adds it to the state machine. No guard is provided. + //!\param _event_ids IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + virtual bool fire_event( const event_sptr& _event ) = 0; + + //!\brief Check the state machine for defects by checking the constraints of each component. + //!\param _defects Collected for all found defects. + //!\return bool true if there are no defects, else false. + bool check( state_machine_defects& _defects ) const; + + virtual bool run() = 0; + + //!\brief Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors. + virtual void halt(); + + //!\brief Set the internal flag of the state machine, to interrupt all processes inside the state machine and + //!to stop the state machine. + virtual void interrupt(); + + //!\brief Get the internal flag of the state machine that specify if the run of state machine is interrupted. + //!\return true if the internal flag is set to interrupt the state machine, false otherwise. + //!\sa interrupt + virtual bool is_interrupted() const SX_OVERRIDE; + + //!\brief Sets the behavior for handler of unhandled events. + //!\param _behavior + virtual void set_behavior_of_unhandled_event_handler( const behavior_function& _behavior ); + + //!\brief Get the name of the state machine. + //!\return name of the state machine + virtual std::string get_name() const; + + + protected: + //!\brief Starts the state machine. + //!\param _async_event_handler Pointer to an asynchronous event handler. It's used by + //!the asynchronous state machine if it has to process asynchronous errors that occur in the + //!asynchronous behavior of asynchronous simple states. + //!\return bool true if state machine can be started, else false what means that a terminate pseudostate has been + //!reached and the state machine is stopped. + bool run( async_event_handler* const _async_event_handler ); + bool process_event( const event_sptr& _event, async_event_handler* const _async_event_handler ); + static void stop_all_async_states( state& _state ); + + + private: + virtual const events& get_deferred_events() const SX_OVERRIDE; + virtual raw_const_states get_active_state_configuration() const SX_OVERRIDE; + void get_active_states_from_region( raw_const_states& _active_state_configuration, const region& _region ) const; + void check_regions_for_active_states( raw_const_states& _active_state_configuration, const state& _state ) const; + void add_deferred_event( const event_sptr& _event_id ); + bool process_deferred_events( async_event_handler* const _async_event_handler ); + static void stop_all_async_states_from_region( region_uptr& _region ); + virtual void interrupt_impl(); + void handle_unhandled_event( const event_sptr& _event ); + + const std::string name_; + event_processing_callback* event_processing_callback_; + composite_state_uptr root_state_; + transitions transitions_; + events deferred_events_; + sxe::atomic state_machine_is_running_; + sxe::atomic interrupt_; +#ifdef Y_PROFILER + sxe::uint32_t processed_events_; +#endif + behavior_uptr event_handler_behavior_; + + }; + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_defect.hpp b/yasmine_model/include/state_machine_defect.hpp new file mode 100644 index 0000000..1d40639 --- /dev/null +++ b/yasmine_model/include/state_machine_defect.hpp @@ -0,0 +1,80 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC +#define STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC + + +#include "essentials/sxprintf.hpp" +#include "essentials/compatibility/compatibility.hpp" + +#include "state_machine_defect_fwd.hpp" + + +namespace sxy +{ + + +class state_machine_element; + + +class state_machine_defect SX_FINAL +{ + +public: + + +#ifndef SX_CPP03_BOOST + + + template< typename ... args > + state_machine_defect( const state_machine_element &_element, const std::string & _message, args ... _args ): + element_( &_element ), message_( sxe::sxprintf( _message.c_str(), _args ... ) ) + { + // Nothing to do. + } + + +#else + + state_machine_defect( const state_machine_element&_element, const std::string & _message ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2 ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2, const sxe::value_type&_value3 ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2, const sxe::value_type &_value3, const sxe::value_type &_value4 ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2, const sxe::value_type &_value3, const sxe::value_type &_value4, + const sxe::value_type &_value5 ); + +#endif + + + ~state_machine_defect() SX_NOEXCEPT; + + + const state_machine_element& get_element() const; + const std::string& get_message() const; + + +private: + const state_machine_element* element_; + std::string message_; +}; + + +void write_defects_to_log( const state_machine_defects& _defects ); +} + + +#endif diff --git a/yasmine_model/include/state_machine_defect_fwd.hpp b/yasmine_model/include/state_machine_defect_fwd.hpp new file mode 100644 index 0000000..d5c445a --- /dev/null +++ b/yasmine_model/include/state_machine_defect_fwd.hpp @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_DEFECT_FWD_1B447269_4868_47C6_AE95_566BF658EAE3 +#define STATE_MACHINE_DEFECT_FWD_1B447269_4868_47C6_AE95_566BF658EAE3 + + +#include + + +namespace sxy +{ + + +class state_machine_defect; + +typedef std::vector< state_machine_defect > state_machine_defects; + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_element.hpp b/yasmine_model/include/state_machine_element.hpp new file mode 100644 index 0000000..dae5bf1 --- /dev/null +++ b/yasmine_model/include/state_machine_element.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_ELEMENT_122BB9E6_0CA4_4EEC_A341_EAD756AC89E9 +#define STATE_MACHINE_ELEMENT_122BB9E6_0CA4_4EEC_A341_EAD756AC89E9 + + +#include "essentials/non_copyable.hpp" +#include "essentials/uri.hpp" + +#include "state_machine_defect_fwd.hpp" + + +namespace sxy +{ + + +class state_machine_element +{ +public: + state_machine_element() + { + // Nothing to do... + } + + + virtual ~state_machine_element() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(state_machine_element) + virtual const std::string& get_name() const = 0; + virtual sxe::uri get_uri() const = 0; + virtual void add_ancestor_uri( sxe::uri& _uri ) const = 0; + virtual bool check( state_machine_defects& _defects ) const = 0; + virtual const state_machine_element * get_parent() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_element_impl.hpp b/yasmine_model/include/state_machine_element_impl.hpp new file mode 100644 index 0000000..3b7bfa1 --- /dev/null +++ b/yasmine_model/include/state_machine_element_impl.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_ELEMENT_IMPL_EC5B279B_E7A2_40CF_8D97_F0581F89B36C +#define STATE_MACHINE_ELEMENT_IMPL_EC5B279B_E7A2_40CF_8D97_F0581F89B36C + + +#include + +#include "state_machine_element.hpp" + + +namespace sxy +{ + + +class state_machine_element_impl: + public virtual state_machine_element +{ +public: + explicit state_machine_element_impl( const std::string& _name ); + virtual ~state_machine_element_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(state_machine_element_impl) + virtual const std::string& get_name() const SX_OVERRIDE; + + +private: + const std::string name_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_introspection.hpp b/yasmine_model/include/state_machine_introspection.hpp new file mode 100644 index 0000000..357ae20 --- /dev/null +++ b/yasmine_model/include/state_machine_introspection.hpp @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_INTROSPECTION_45E0820B_4D2F_4EF7_AF0D_EA840DA9F7C0 +#define STATE_MACHINE_INTROSPECTION_45E0820B_4D2F_4EF7_AF0D_EA840DA9F7C0 + + +#include "essentials/non_copyable.hpp" + +#include "state_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +//!\interface state_machine_introspection +//!\brief The interface for state machine introspection. It is inherited by the state machine class state_machine. +class state_machine_introspection +{ +public: + //!\brief Constructor. + state_machine_introspection() + { + // Nothing to do... + } + + + virtual ~state_machine_introspection() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(state_machine_introspection) + + //!\brief Get the active state configuration of the state machine. + //!\return A list of active states of the state machine at the moment when the function is called. + virtual raw_const_states get_active_state_configuration() const = 0; + virtual const events& get_deferred_events() const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_status.hpp b/yasmine_model/include/state_machine_status.hpp new file mode 100644 index 0000000..3b57a60 --- /dev/null +++ b/yasmine_model/include/state_machine_status.hpp @@ -0,0 +1,68 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 +#define STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 + + +namespace sxy +{ + + +#ifndef SX_CPP03_BOOST + enum class state_machine_status + { + NEW, STARTED, STOP_REQUESTED, TERMINATED, STOPPED + }; +#else + struct state_machine_status + { + enum inner + { + NEW, STARTED, STOP_REQUESTED, TERMINATED, STOPPED + }; + + + state_machine_status() : value_( NEW ) + { + // Nothing to do... + } + + + // cppcheck-suppress noExplicitConstructor + state_machine_status( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + // cppcheck-suppress functionConst + operator inner() + { + return ( value_ ); + } + + + inner value_; + + }; + + + bool operator==( const state_machine_status& _lhs, const state_machine_status::inner _rhs ); + bool operator==( const state_machine_status::inner _lhs, const state_machine_status& _rhs ); + + +#endif + + +} + +#endif diff --git a/yasmine_model/include/state_pseudostate.hpp b/yasmine_model/include/state_pseudostate.hpp new file mode 100644 index 0000000..75fbd37 --- /dev/null +++ b/yasmine_model/include/state_pseudostate.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_PSEUDOSTATE_73003664_F128_436A_8412_B1453D067026 +#define STATE_PSEUDOSTATE_73003664_F128_436A_8412_B1453D067026 + + +#include "pseudostate.hpp" +#include "composite_state.hpp" + + +namespace sxy +{ + + +class state_pseudostate: + public virtual pseudostate +{ +public: + state_pseudostate() + { + // Nothing to do... + } + + + virtual ~state_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(state_pseudostate) + virtual composite_state& get_parent_state() const = 0; + virtual void set_parent_state( composite_state* const _parent_state ) = 0; +}; + + +} + +#endif diff --git a/yasmine_model/include/state_pseudostates.hpp b/yasmine_model/include/state_pseudostates.hpp new file mode 100644 index 0000000..88ff247 --- /dev/null +++ b/yasmine_model/include/state_pseudostates.hpp @@ -0,0 +1,22 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INCLUDE_STATE_PSEUDOSTATES_16AAE994_A9EF_4E66_A5EE_A0900700796C +#define INCLUDE_STATE_PSEUDOSTATES_16AAE994_A9EF_4E66_A5EE_A0900700796C + + +#include "entry_point.hpp" +#include "exit_point.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" + + +#endif diff --git a/yasmine_model/include/states.hpp b/yasmine_model/include/states.hpp new file mode 100644 index 0000000..f8d415e --- /dev/null +++ b/yasmine_model/include/states.hpp @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_6E221415_EBDC_407C_B71B_99E822319A77 +#define STATES_6E221415_EBDC_407C_B71B_99E822319A77 + + +#include "simple_state.hpp" +#include "composite_state.hpp" +#include "final_state.hpp" + + +#ifndef Y_LEAN_AND_MEAN + + +#include "async_simple_state_impl.hpp" + + +#endif + + +#endif diff --git a/yasmine_model/include/states_nesting_comparer.hpp b/yasmine_model/include/states_nesting_comparer.hpp new file mode 100644 index 0000000..7fffadd --- /dev/null +++ b/yasmine_model/include/states_nesting_comparer.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_NESTING_COMPARER_B8C0C256_3761_47DC_A60A_DB2BF706EEB0 +#define STATES_NESTING_COMPARER_B8C0C256_3761_47DC_A60A_DB2BF706EEB0 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class state; + + +struct states_nesting_comparer SX_FINAL +{ +public: + states_nesting_comparer(); + ~states_nesting_comparer() SX_NOEXCEPT; + bool operator()( const state& _lhs, const state& _rhs ) const; + bool operator()( const state* const _lhs, const state* const _rhs ) const; +}; + +} + + +#endif diff --git a/yasmine_model/include/states_nesting_comparer_ascending.hpp b/yasmine_model/include/states_nesting_comparer_ascending.hpp new file mode 100644 index 0000000..d88372f --- /dev/null +++ b/yasmine_model/include/states_nesting_comparer_ascending.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_NESTING_COMPARER_ASCENDING_D08136C5_FE07_48F1_8D77_5C460EC2EFF4 +#define STATES_NESTING_COMPARER_ASCENDING_D08136C5_FE07_48F1_8D77_5C460EC2EFF4 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class state; + + +struct states_nesting_comparer_ascending SX_FINAL +{ +public: + states_nesting_comparer_ascending(); + ~states_nesting_comparer_ascending() SX_NOEXCEPT; + bool operator()( const state& _lhs, const state& _rhs ) const; + bool operator()( const state* const _lhs, const state* const _rhs ) const; +}; + +} + + +#endif diff --git a/yasmine_model/include/sync_state_machine.hpp b/yasmine_model/include/sync_state_machine.hpp new file mode 100644 index 0000000..443ed34 --- /dev/null +++ b/yasmine_model/include/sync_state_machine.hpp @@ -0,0 +1,68 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SYNC_STATE_MACHINE_5352FE73_987B_4ECB_9320_685740A30EAA +#define SYNC_STATE_MACHINE_5352FE73_987B_4ECB_9320_685740A30EAA + + +#include +#include "state_machine_base.hpp" + + +namespace sxy +{ + + +//!\class sync_state_machine +//!\brief Class for the "single-threaded version" of the state machine. It provides the methods to start the state +//!machine, to fire events, to check the state machine for possible defects and to get the root state reference. +class sync_state_machine: + public state_machine_base +{ +public: + //!\brief Constructor. + //!\param _name Name of the state machine. + //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback + //!interface should be used. + explicit sync_state_machine( const std::string& _name, + event_processing_callback* const _event_processing_callback = SX_NULLPTR ); + virtual ~sync_state_machine() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( sync_state_machine ) + + virtual bool push( const event_sptr& _event ) SX_OVERRIDE; + + //!\brief Fire the given event. + //!\param _event Event to be fired. + //!\return true if event was successfully fired, else false what means that a terminate pseudostate has been reached, + //!the state machine was stopped and no further events can be fired. + virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; + + //!\brief Starts the state machine. + //!\return bool true if state machine can be started, else false what means that a terminate pseudostate has been + //!reached and the state machine is stopped. + virtual bool run() SX_OVERRIDE; + + +private: + bool process_events_from_queue(); + + std::list event_list_; +}; + + +//!\deprecated use sync_state_machine instead +typedef sync_state_machine state_machine; + + +} + + +#endif diff --git a/yasmine_model/include/terminate_pseudostate.hpp b/yasmine_model/include/terminate_pseudostate.hpp new file mode 100644 index 0000000..d21635a --- /dev/null +++ b/yasmine_model/include/terminate_pseudostate.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TERMINATE_PSEUDOSTATE_86477850_30F8_412F_B194_45E54964DF7B +#define TERMINATE_PSEUDOSTATE_86477850_30F8_412F_B194_45E54964DF7B + + +#include "region_pseudostate.hpp" +#include "terminate_pseudostate_fwd.hpp" + + +namespace sxy +{ + + +class terminate_pseudostate: + public virtual region_pseudostate +{ +public: + terminate_pseudostate() + { + // Nothing to do... + } + + + virtual ~terminate_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(terminate_pseudostate) +}; + + +} + + +#endif diff --git a/yasmine_model/include/terminate_pseudostate_fwd.hpp b/yasmine_model/include/terminate_pseudostate_fwd.hpp new file mode 100644 index 0000000..86bd1e8 --- /dev/null +++ b/yasmine_model/include/terminate_pseudostate_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TERMINATE_PSEUDOSTATE_FWD_C63AEEFF_DBF1_44D5_961A_A2E4D0BB745B +#define TERMINATE_PSEUDOSTATE_FWD_C63AEEFF_DBF1_44D5_961A_A2E4D0BB745B + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class terminate_pseudostate; +typedef sxe::SX_UNIQUE_PTR< terminate_pseudostate > terminate_pseudostate_uptr; +typedef std::vector< terminate_pseudostate_uptr > terminate_pseudostates; +typedef std::vector< const terminate_pseudostate* > raw_const_terminate_pseudostates; + + +} + + +#endif diff --git a/yasmine_model/include/timed_event_creator.hpp b/yasmine_model/include/timed_event_creator.hpp new file mode 100644 index 0000000..5b77fd3 --- /dev/null +++ b/yasmine_model/include/timed_event_creator.hpp @@ -0,0 +1,115 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TIMED_EVENT_CREATOR_14DCF0FF_0E5B_41DE_B213_C7CC1610A406 +#define TIMED_EVENT_CREATOR_14DCF0FF_0E5B_41DE_B213_C7CC1610A406 + + +#include + +#include "essentials/compatibility/thread.hpp" + +#include "event_creation_request_time_comparer.hpp" +#include "event_creation_request.hpp" + + +namespace sxy +{ + + +class async_state_machine; + + +typedef std::set< event_creation_request, event_creation_request_time_comparer > event_queue; + +//!\class timed_event_creator +//!\brief Provides the possibility to create timed events. It uses the state machine passed into the constructor as +//!target for the events. +class timed_event_creator SX_FINAL +{ +public: + //!\brief Constructor. + //!\param _async_state_machine - state_machine the created events are sent to. + explicit timed_event_creator( async_state_machine& _async_state_machine ); + ~timed_event_creator() SX_NOEXCEPT; + SX_NO_COPY(timed_event_creator) + + //!\brief Creates an event creation request. + //!\param _time_till_event_is_fired The time point when the event should be fired. + //!\param _event The event that will be fired. + //!\return Handle of the new event creation request. The handle can be used for canceling the request. + //!\sa cancel() + handle_type create_event_creation_request( const sxe::time_point< sxe::system_clock >& _time_till_event_is_fired, + const event_sptr _event ); + + //!\brief Creates an event creation request. + //!\param _time The time duration after that the event should be fired. + //!\param _event The event that will be fired. + //!\return Handle of the new event creation request. The handle can be used for canceling the request. + //!\sa cancel() + handle_type create_event_creation_request( const sxe::milliseconds& _time, const event_sptr& _event ); + + //!\brief Cancels the event creation request with the given handle if the event is still in the queue of the event + //!creator. + //!\param _handle const handle_type Handle of the event creation request that should be canceled. + //!\return true if the event was canceled or false if the event could not be canceled. + //!\sa create() + bool cancel( const handle_type _handle ); + + //!\brief Starts the event creator. This has to be called before creating timed events. + //!\return void + //!\sa halt(), join(), halt_and_join() + void run(); + + //!\brief Stops the event creator. The event creator needs to be stopped before it is destroyed (if it was started). + //!Else the internal thread is not cleaned-up correctly. + //!\return void + //!\sa run(), join(), halt_and_join() + void halt(); + + //!\brief Joins the event creator thread. + //!\return void + //!\sa run(), stop(), halt_and_join() + void join(); + + //!\brief Stops and joins the event creator thread. The event creator needs to be stopped before it is destroyed (if it was started). + //!Else the internal thread is not cleaned-up correctly. + //!\return void + //!\sa run(), join(), halt() + void halt_and_join(); + + +private: + // cppcheck-suppress unusedPrivateFunction + handle_type generate_handle(); + bool check_if_handle_exists( const handle_type _handle ) const; + void generate_event(); + event_queue::const_iterator find_element_by_handle( const handle_type _handle ) const; + static bool compare_handles( const handle_type _handle, const event_creation_request& _event_creation_request ); + bool check_wait_condition() const; + + async_state_machine& state_machine_; + event_queue event_creation_requests_; + sxe::SX_UNIQUE_PTR< sxe::thread > worker_; + sxe::mutex mutex_; + sxe::condition_variable condition_variable_; + bool run_; + + handle_type maximum_handle_; + + +}; + + +} + + +#endif diff --git a/yasmine_model/include/transition.hpp b/yasmine_model/include/transition.hpp new file mode 100644 index 0000000..08689c3 --- /dev/null +++ b/yasmine_model/include/transition.hpp @@ -0,0 +1,67 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_9D568568_F100_40E3_B02C_1141C218D7D8 +#define TRANSITION_9D568568_F100_40E3_B02C_1141C218D7D8 + + +#include "state_machine_element.hpp" + +#include "transition_kind.hpp" +#include "event_id.hpp" +#include "transition_fwd.hpp" + + +namespace sxy +{ + + +class vertex; +class constraint; +class behavior; +class event; +class event_collector; + + +class transition: + public virtual state_machine_element +{ +public: + transition() + { + // Nothing to do... + } + + + virtual ~transition() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(transition) + virtual const vertex& get_source() const = 0; + virtual const vertex& get_target() const = 0; + virtual vertex& get_target() = 0; + virtual const constraint * get_guard() const = 0; + virtual const behavior * get_behavior() const = 0; + virtual sxy::transition_kind get_kind() const = 0; + virtual void on_transition_behavior( const event& _event, event_collector& _event_collector ) const = 0; + virtual bool check_guard( const event& _event, event_collector& _event_collector ) const = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; + virtual bool can_accept_event( const event_id _event ) const = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/transition_fwd.hpp b/yasmine_model/include/transition_fwd.hpp new file mode 100644 index 0000000..ebe00e3 --- /dev/null +++ b/yasmine_model/include/transition_fwd.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_FWD_394BD21E_9C09_454E_8C58_19F984D09497 +#define TRANSITION_FWD_394BD21E_9C09_454E_8C58_19F984D09497 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class transition; + + +typedef sxe::SX_UNIQUE_PTR< transition > transition_uptr; +typedef std::vector< const transition* > raw_const_transitions; +typedef std::vector< transition* > raw_transitions; +typedef std::vector< transition_uptr > transitions; + + +} + + +#endif diff --git a/yasmine_model/include/transition_impl.hpp b/yasmine_model/include/transition_impl.hpp new file mode 100644 index 0000000..2c721f5 --- /dev/null +++ b/yasmine_model/include/transition_impl.hpp @@ -0,0 +1,78 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_IMPL_9F6CF536_11D2_4F11_B5FB_AB930B935720 +#define TRANSITION_IMPL_9F6CF536_11D2_4F11_B5FB_AB930B935720 + + +#include "transition.hpp" +#include "state_machine_element_impl.hpp" +#include "constraint.hpp" +#include "behavior.hpp" + + +namespace sxy +{ + + +class composite_state; + + +class transition_impl SX_FINAL: + public virtual transition, public state_machine_element_impl +{ +public: + transition_impl( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); + transition_impl( const event_ids _event_ids, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); + virtual ~transition_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(transition_impl) + virtual const vertex& get_source() const SX_OVERRIDE; + virtual const vertex& get_target() const SX_OVERRIDE; + virtual vertex& get_target() SX_OVERRIDE; + virtual const constraint * get_guard() const SX_OVERRIDE; + virtual const behavior * get_behavior() const SX_OVERRIDE; + virtual sxe::uri get_uri() const SX_OVERRIDE; + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + virtual sxy::transition_kind get_kind() const SX_OVERRIDE; + virtual void add_ancestor_uri( sxe::uri& _uri ) const SX_OVERRIDE; + virtual void on_transition_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual bool check_guard( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual bool can_accept_event( const event_id _event ) const SX_OVERRIDE; + + +private: + static bool check_if_source_and_target_are_in_ancestor_relationship( const vertex& _source, + const vertex& _target ); + static bool check_relationship( const vertex& _lhs, const composite_state* _rhs ); + static std::string get_transition_name( vertex& _source, vertex& _target, const event_ids& _event_ids ); + bool check_for_cross_region_transition( state_machine_defects& _defects ) const; + bool check_child_parent_relationship_of_source_target_of_transition( state_machine_defects& _defects ) const; + bool check_initial_pseudostate( state_machine_defects& _defects ) const; + bool check_exit_point( state_machine_defects& _defects ) const; + + event_ids event_ids_; + vertex& source_; + vertex& target_; + constraint_uptr guard_; + behavior_uptr behavior_; + transition_kind kind_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/transition_kind.hpp b/yasmine_model/include/transition_kind.hpp new file mode 100644 index 0000000..1c45db4 --- /dev/null +++ b/yasmine_model/include/transition_kind.hpp @@ -0,0 +1,88 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_KIND_BA4883BC_C6FF_4F55_BA40_3FF8C973631D +#define TRANSITION_KIND_BA4883BC_C6FF_4F55_BA40_3FF8C973631D + + +#include + + +namespace sxy +{ + +#ifndef SX_CPP03_BOOST + + + enum class transition_kind + { + EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 + }; + + +#else + + + struct transition_kind + { + + enum inner + { + EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 + }; + + + // cppcheck-suppress noExplicitConstructor + transition_kind() : value_( EXTERNAL ) + { + // Nothing to do... + } + + + // cppcheck-suppress noExplicitConstructor + transition_kind( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + // cppcheck-suppress functionConst + operator inner() + { + return ( value_ ); + } + + + inner value_; + + }; + +#endif + + +std::string to_string( const transition_kind _kind ); + + +#ifdef SX_CPP03_BOOST + + +bool operator==( const sxy::transition_kind& _lhs, const sxy::transition_kind::inner _rhs ); +bool operator==( const sxy::transition_kind::inner _lhs, const sxy::transition_kind& _rhs ); +bool operator<( const sxy::transition_kind _lhs, const sxy::transition_kind _rhs ); + + + +#endif + +} + + +#endif diff --git a/yasmine_model/include/utils.hpp b/yasmine_model/include/utils.hpp new file mode 100644 index 0000000..cf7cdba --- /dev/null +++ b/yasmine_model/include/utils.hpp @@ -0,0 +1,65 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B +#define UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B + + +#include "hermes/hermes_backward_compatibility.hpp" + + +#ifdef WIN32 + + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#ifndef SX_NO_WINDOWS_H + #include +#endif + + +#endif + + +namespace sxy +{ + + +namespace utils +{ + + +#ifdef WIN32 + + +//!\brief Set the size of the console. +//!\param _width Number of columns in Windows console. +//!\param _height Number of lines in Windows console. +//!\return void +void set_window_size( const SHORT _width, const SHORT _height ); + +//!\brief Maximize the Windows console. +//!\return void +void maximize_window(); + + +#endif + + +} + + +} + + +#endif diff --git a/yasmine_model/include/version.hpp b/yasmine_model/include/version.hpp new file mode 100644 index 0000000..b24934a --- /dev/null +++ b/yasmine_model/include/version.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERSION_53B7B4DC_2A8B_4736_B190_6348C9D8F8F2 +#define VERSION_53B7B4DC_2A8B_4736_B190_6348C9D8F8F2 + + +#include "essentials/base.hpp" +#include "essentials/compatibility/compatibility.hpp" +#include "hermes/hermes_backward_compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + +#ifndef SX_NO_LOGGING + +void log_version(); + +#endif + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +#endif diff --git a/yasmine_model/include/vertex.hpp b/yasmine_model/include/vertex.hpp new file mode 100644 index 0000000..bcda9b2 --- /dev/null +++ b/yasmine_model/include/vertex.hpp @@ -0,0 +1,76 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_126F87F3_2278_4867_B69F_ABEE5AB88A61 +#define VERTEX_126F87F3_2278_4867_B69F_ABEE5AB88A61 + + +#include "state_machine_element.hpp" +#include "vertex_fwd.hpp" +#include "transition_fwd.hpp" +#include "region_fwd.hpp" +#include "composite_state_fwd.hpp" +#include "event_id.hpp" +#include "event_priority.hpp" + + +namespace sxy +{ + + +class const_vertex_visitor; +class vertex_visitor; +class uri; +class event; +class event_collector; + + +class vertex: + public virtual state_machine_element +{ +public: + vertex() + { + // Nothing to do... + } + + + virtual ~vertex() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( vertex ) + virtual composite_state* get_root_state() = 0; + virtual const composite_state* get_root_state() const = 0; + virtual void add_outgoing_transition( transition& _outgoing_transition ) = 0; + virtual void add_incoming_transition( transition& _incoming_transition ) = 0; + virtual void remove_outgoing_transition( const transition& _outgoing_transition ) = 0; + virtual void remove_incoming_transition( const transition& _incoming_transition ) = 0; + virtual const raw_transitions& get_outgoing_transitions() const = 0; + virtual const raw_transitions& get_incoming_transitions() const = 0; + virtual raw_regions get_ancestors_as_regions() const = 0; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const = 0; + virtual transition * search_transition( const event& _event, event_collector& _event_collector ) const = 0; + virtual region * LCA_region( const vertex& _target_vertex ) const = 0; + virtual composite_state * LCA_composite_state( const vertex& _rhs ) const = 0; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const = 0; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; +}; + + +} + + +#endif diff --git a/yasmine_model/include/vertex_fwd.hpp b/yasmine_model/include/vertex_fwd.hpp new file mode 100644 index 0000000..51fa4d1 --- /dev/null +++ b/yasmine_model/include/vertex_fwd.hpp @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_FWD_9F913860_C5C3_4773_BB31_D98183BE0565 +#define VERTEX_FWD_9F913860_C5C3_4773_BB31_D98183BE0565 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class vertex; +typedef sxe::SX_UNIQUE_PTR< vertex > vertex_uptr; +typedef std::vector< const vertex* > raw_const_vertices; +typedef std::vector< vertex_uptr > vertices; + + +} + + +#endif diff --git a/yasmine_model/include/vertex_impl.hpp b/yasmine_model/include/vertex_impl.hpp new file mode 100644 index 0000000..31ab82f --- /dev/null +++ b/yasmine_model/include/vertex_impl.hpp @@ -0,0 +1,61 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_IMPL_B16E40A6_719B_4DFD_91DB_D4790C6EC14D +#define VERTEX_IMPL_B16E40A6_719B_4DFD_91DB_D4790C6EC14D + + +#include + +#include "vertex.hpp" +#include "state_machine_element_impl.hpp" + + +namespace sxy +{ + + +class vertex_impl: + public virtual vertex, public state_machine_element_impl +{ +public: + explicit vertex_impl( const std::string& _name ); + virtual ~vertex_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( vertex_impl ) + virtual composite_state* get_root_state() SX_OVERRIDE; + virtual const composite_state* get_root_state() const SX_OVERRIDE; + virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; + virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; + virtual void remove_outgoing_transition( const transition& _outgoing_transition ) SX_OVERRIDE; + virtual void remove_incoming_transition( const transition& _incoming_transition ) SX_OVERRIDE; + virtual const raw_transitions& get_outgoing_transitions() const SX_OVERRIDE; + virtual const raw_transitions& get_incoming_transitions() const SX_OVERRIDE; + virtual sxe::uri get_uri() const SX_OVERRIDE; + transition* search_transition( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual region* LCA_region( const vertex& _target_vertex ) const SX_OVERRIDE; + virtual composite_state* LCA_composite_state( const vertex& _rhs ) const SX_OVERRIDE; + + +private: + void add_ancestor_uri( sxe::uri& _uri ) const SX_OVERRIDE; + raw_transitions::iterator find_first_transition_without_guard( raw_transitions& _vector_of_transitions ); + static bool has_no_guard( const transition* const _transition ); + + + raw_transitions outgoing_transitions_; + raw_transitions incoming_transitions_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/y_assert.hpp b/yasmine_model/include/y_assert.hpp new file mode 100644 index 0000000..ff633dc --- /dev/null +++ b/yasmine_model/include/y_assert.hpp @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef Y_ASSERT_99E5ACCD_95C4_419D_A257_7294D6692569 +#define Y_ASSERT_99E5ACCD_95C4_419D_A257_7294D6692569 + + +#define Y_ASSERT( _condition, _message ) \ + do \ + { \ + if( !( _condition ) ) \ + { \ + SX_LOG_AND_WAIT( hermes::log_level::LL_ASSERT, "Assert failed! Message: '%', Condition '%'", _message, #_condition ); \ + assert( ( _condition ) && _message ); \ + } \ + } \ + while( 0 ) + +#include "hermes/log.hpp" + + +#endif diff --git a/yasmine_model/include/yasmine.hpp b/yasmine_model/include/yasmine.hpp new file mode 100644 index 0000000..689d85c --- /dev/null +++ b/yasmine_model/include/yasmine.hpp @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 +#define YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 + + +#include "libyasmine_backward_compatibility.hpp" + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/compatibility/chrono.hpp" +#include "essentials/compatibility/thread.hpp" +#include "essentials/non_copyable.hpp" + +#include "sync_state_machine.hpp" +#include "async_state_machine.hpp" +#include "timed_event_creator.hpp" + +#include "state_machine_defect.hpp" +#include "state_machine_introspection.hpp" + +#include "states.hpp" +#include "region.hpp" +#include "region_pseudostates.hpp" + +#include "transition.hpp" +#include "transition_impl.hpp" +#include "behavior.hpp" +#include "behavior_exception.hpp" +#include "event_impl.hpp" + +#include "event_template.hpp" +#include "constraint.hpp" +#include "completion_event.hpp" + +#include "logging.hpp" +#include "utils.hpp" +#include "assembly.hpp" +#include "version.hpp" + + +#ifndef Y_LEAN_AND_MEAN + + +#include "state_pseudostates.hpp" +#include "async_behavior.hpp" + + +#endif + + +#endif diff --git a/yasmine_model/source/json_writer.cpp b/yasmine_model/source/json_writer.cpp index 4f21630..865b808 100644 --- a/yasmine_model/source/json_writer.cpp +++ b/yasmine_model/source/json_writer.cpp @@ -12,7 +12,7 @@ #include -#include "prettywriter.h" +#include #include "essentials/exception.hpp" #include "essentials/base.hpp" diff --git a/yasmine_model/yasmine_model.vcxproj b/yasmine_model/yasmine_model.vcxproj index 3bdae37..73c8ea6 100644 --- a/yasmine_model/yasmine_model.vcxproj +++ b/yasmine_model/yasmine_model.vcxproj @@ -179,6 +179,7 @@ + diff --git a/yasmine_model/yasmine_model.vcxproj.filters b/yasmine_model/yasmine_model.vcxproj.filters index 96699d8..c797543 100644 --- a/yasmine_model/yasmine_model.vcxproj.filters +++ b/yasmine_model/yasmine_model.vcxproj.filters @@ -422,6 +422,9 @@ Headerdateien\externals\essentials\compatibility + + Headerdateien\json + diff --git a/ygen/include/ygen_build_number.hpp b/ygen/include/ygen_build_number.hpp index 07fe407..7789475 100644 --- a/ygen/include/ygen_build_number.hpp +++ b/ygen/include/ygen_build_number.hpp @@ -20,7 +20,7 @@ namespace version { - const sxe::uint16_t BUILD_NUMBER( 770 ); + const sxe::uint16_t BUILD_NUMBER( 790 ); }