From 4c04c7106f30863cf64c5c703bb25dc0ac1a54a6 Mon Sep 17 00:00:00 2001 From: Tibor Molnar Date: Fri, 20 Jan 2017 15:49:45 +0100 Subject: [PATCH] yasmine 1.0.0 yasmine 1.0.0 build - first stable release Changelog: http://yasmine.seadex.de/Changelog.html Documentation: http://yasmine.seadex.de/Documentation.html --- CMakeLists.txt | 6 + {yasmine/build => build}/c++03.props | 4 +- {yasmine/build => build}/debug_info.props | 2 +- build/use_c++03.props | 17 + build/use_yasmine.props | 18 + .../use_yasmine_base.props | 4 +- {yasmine/build => build}/vs2013.props | 26 +- {yasmine/build => build}/yasmine.props | 2 + {yasmine => examples}/CMakeLists.txt | 3 - examples/classic_farmroad/CMakeLists.txt | 185 ++ .../classic_farmroad/classic_farmroad.vcxproj | 78 +- .../classic_farmroad.vcxproj.filters | 8 +- .../classic_farmroad/detector.cpp | 23 +- .../classic_farmroad/detector.hpp | 4 +- .../classic_farmroad/detector_callback.hpp | 2 +- examples/classic_farmroad/intersection.cpp | 418 +++++ .../classic_farmroad/intersection.hpp | 12 +- .../classic_farmroad/main.cpp | 11 +- .../classic_farmroad/random_generator.cpp | 55 + .../classic_farmroad/random_generator.hpp | 42 + .../classic_farmroad/traffic_light.cpp | 52 +- .../classic_farmroad/traffic_light.hpp | 6 +- .../events_with_parameters/CMakeLists.txt | 18 +- .../class_method_downcast.cpp | 77 +- .../class_method_downcast.hpp | 12 +- .../events_with_parameters/downcast_event.cpp | 43 +- .../events_with_parameters/downcast_event.hpp | 2 +- .../events_with_parameters/events.hpp | 23 +- .../events_with_parameters.cpp | 6 +- .../events_with_parameters.vcxproj | 72 +- .../events_with_parameters.vcxproj.filters | 0 .../function_downcast.cpp | 67 +- .../function_downcast.hpp | 2 +- .../forty_two/CMakeLists.txt | 18 +- examples/forty_two/forty_two.cpp | 394 +++++ {yasmine => examples}/forty_two/forty_two.hpp | 4 +- .../forty_two/forty_two.vcxproj | 73 +- .../forty_two/forty_two.vcxproj.filters | 0 {yasmine => examples}/forty_two/main.cpp | 2 +- .../hello_yasmine/CMakeLists.txt | 18 +- .../hello_yasmine/hello_yasmine.cpp | 32 +- .../hello_yasmine/hello_yasmine.vcxproj | 74 +- .../hello_yasmine.vcxproj.filters | 0 .../CMakeLists.txt | 18 +- .../substatemachines_and_variables/events.hpp | 41 +- .../substatemachines_and_variables/main.cpp | 2 +- .../state_machine_with_submachines.cpp | 8 +- .../state_machine_with_submachines.hpp | 6 +- .../submachine.cpp | 34 +- .../submachine.hpp | 20 +- .../substatemachines_and_variables.vcxproj | 75 +- ...tatemachines_and_variables.vcxproj.filters | 0 .../yasmine => libyasmine}/CMakeLists.txt | 28 +- {yasmine/yasmine => libyasmine}/changelog.txt | 64 +- .../include}/algorithm_parameters.hpp | 0 libyasmine/include/assembly.hpp | 175 ++ .../include/async_behavior.hpp | 24 +- .../include/async_behavior_fwd.hpp | 8 +- .../include}/async_event_handler.hpp | 0 .../include}/async_simple_state_impl.hpp | 14 +- .../include}/async_state_machine.hpp | 87 +- .../yasmine => libyasmine/include}/base.hpp | 3 +- .../include/behavior.hpp | 14 +- .../include/behavior_exception.hpp | 14 +- libyasmine/include/behavior_exception_fwd.hpp | 34 + .../include/behavior_fwd.hpp | 10 +- libyasmine/include/caller.hpp | 1484 +++++++++++++++++ .../yasmine => libyasmine/include}/choice.hpp | 0 .../include}/choice_fwd.hpp | 0 .../yasmine => libyasmine/include}/chrono.hpp | 4 +- .../yasmine => libyasmine/include}/color.hpp | 0 .../include}/color_mapping.hpp | 0 .../include}/compatibility.hpp | 39 +- libyasmine/include/completion_event.hpp | 47 + .../include}/complex_state.hpp | 0 .../include}/complex_state_impl.hpp | 14 +- .../include}/composite_state.hpp | 0 .../include}/composite_state_fwd.hpp | 0 .../include}/constraint.hpp | 0 .../include}/constraint_fwd.hpp | 0 .../include}/cout_logger.hpp | 0 .../include}/deep_history.hpp | 0 .../include}/deep_history_fwd.hpp | 0 .../include}/entry_point.hpp | 1 - .../include}/entry_point_fwd.hpp | 0 .../yasmine => libyasmine/include}/event.hpp | 0 .../include}/event_creation_request.hpp | 3 +- .../event_creation_request_time_comparer.hpp | 8 +- .../include}/event_fwd.hpp | 0 .../include}/event_handle.hpp | 0 .../include}/event_id.hpp | 1 + .../include}/event_impl.hpp | 4 - .../include}/event_priority.hpp | 10 +- libyasmine/include/event_template.hpp | 1324 +++++++++++++++ .../include}/exception.hpp | 0 .../include}/exception_template.hpp | 39 +- .../include}/exit_point.hpp | 1 - .../include}/exit_point_fwd.hpp | 0 .../include}/file_logger.hpp | 2 - .../include}/final_state.hpp | 0 .../yasmine => libyasmine/include}/fork.hpp | 0 .../include}/fork_fwd.hpp | 0 .../include}/format_settings.hpp | 0 .../include}/history.hpp | 1 - .../include}/initial_pseudostate.hpp | 1 - .../include}/initial_pseudostate_fwd.hpp | 0 .../include/internal_completion_event_id.hpp | 26 +- .../yasmine => libyasmine/include}/join.hpp | 0 .../include}/join_fwd.hpp | 1 + .../include}/junction.hpp | 0 .../include}/junction_fwd.hpp | 1 + .../yasmine => libyasmine/include}/log.hpp | 17 + libyasmine/include/log_callback.hpp | 51 + .../include}/log_helper.hpp | 145 +- .../include}/log_level.hpp | 6 +- libyasmine/include/log_manager_template.hpp | 592 +++++++ .../include}/log_message.hpp | 10 +- .../yasmine => libyasmine/include}/logger.hpp | 4 +- .../include}/logger_fwd.hpp | 0 .../include}/logging.hpp | 0 .../include}/macro_helpers.hpp | 10 +- .../include}/non_copyable.hpp | 0 .../include}/optimization.hpp | 0 .../include}/pseudostate.hpp | 0 .../include}/pseudostate_fwd.hpp | 1 + .../yasmine => libyasmine/include}/region.hpp | 36 +- .../include}/region_fwd.hpp | 0 .../include}/region_pseudostate.hpp | 0 .../include}/region_pseudostates.hpp | 0 .../include}/shallow_history.hpp | 0 .../include}/shallow_history_fwd.hpp | 0 .../include}/simple_state.hpp | 0 .../include}/simple_state_base.hpp | 2 +- .../include}/specialized_event.hpp | 2 +- .../yasmine => libyasmine/include}/state.hpp | 12 +- .../include}/state_fwd.hpp | 0 .../include}/state_impl.hpp | 11 +- .../include}/state_machine.hpp | 59 +- .../include}/state_machine_defect.hpp | 4 - .../include}/state_machine_defect_fwd.hpp | 0 .../include}/state_machine_element.hpp | 0 .../include}/state_machine_element_impl.hpp | 0 .../include}/state_machine_introspection.hpp | 0 libyasmine/include/state_machine_status.hpp | 68 + .../include}/state_pseudostate.hpp | 0 .../include}/state_pseudostates.hpp | 0 .../yasmine => libyasmine/include}/states.hpp | 0 .../include}/states_nesting_comparer.hpp | 0 .../states_nesting_comparer_ascending.hpp | 0 .../include}/std_timestamp_policy.hpp | 0 .../include}/terminate_pseudostate.hpp | 0 .../include}/terminate_pseudostate_fwd.hpp | 0 .../yasmine => libyasmine/include}/thread.hpp | 8 +- .../include}/timed_event_creator.hpp | 24 +- .../include}/transition.hpp | 6 +- .../include}/transition_fwd.hpp | 0 .../include}/transition_impl.hpp | 17 +- .../include}/transition_kind.hpp | 0 .../yasmine => libyasmine/include}/uri.hpp | 1 - .../yasmine => libyasmine/include}/utils.hpp | 0 .../include}/version.hpp | 2 +- .../yasmine => libyasmine/include}/vertex.hpp | 7 +- .../include}/vertex_fwd.hpp | 0 .../include}/vertex_impl.hpp | 6 +- libyasmine/include/waiter.hpp | 48 + .../include}/yasmine.hpp | 8 +- .../include}/yprintf.hpp | 3 +- .../include_impl/behavior_impl.hpp | 26 +- .../include_impl}/build_number.hpp | 4 +- .../build_transition_steps_visitor.hpp | 0 ...transitions_sources_are_active_visitor.hpp | 0 .../include_impl}/choice_impl.hpp | 0 .../include_impl}/complex_state_visitor.hpp | 0 .../include_impl}/composite_state_impl.hpp | 4 +- .../include_impl}/compound_transition.hpp | 0 .../compound_transition_builder.hpp | 0 .../compound_transition_consumer.hpp | 0 .../include_impl}/compound_transition_fwd.hpp | 9 - .../compound_transition_impl.hpp | 0 .../compound_transition_step.hpp | 2 +- .../include_impl}/const_vertex_visitor.hpp | 0 .../include_impl}/constraint_impl.hpp | 0 .../include_impl}/conversion.hpp | 0 .../include_impl}/deep_history_impl.hpp | 0 .../include_impl}/entry_point_impl.hpp | 0 .../event_processing_callback.hpp | 16 +- .../include_impl}/execution_state_do_step.hpp | 2 +- .../execution_state_enter_step.hpp | 2 +- .../execution_state_exit_step.hpp | 2 +- .../include_impl}/execution_step.hpp | 4 +- .../include_impl}/execution_step_fwd.hpp | 0 .../include_impl}/execution_step_visitor.hpp | 0 .../execution_transition_step.hpp | 2 +- .../include_impl}/exit_point_impl.hpp | 0 .../include_impl}/file_system.hpp | 0 .../include_impl}/final_state_impl.hpp | 4 +- .../include_impl}/fork_impl.hpp | 0 .../include_impl}/globals.hpp | 0 .../include_impl}/history_impl.hpp | 0 .../initial_pseudostate_impl.hpp | 0 .../include_impl}/join_impl.hpp | 0 .../include_impl}/junction_impl.hpp | 0 .../include_impl}/log_and_throw.hpp | 29 +- .../include_impl}/log_and_throw_helper.hpp | 0 .../include_impl}/pseudostate_impl.hpp | 0 .../include_impl}/pseudostate_visitor.hpp | 0 .../include_impl}/region_impl.hpp | 24 +- .../include_impl}/region_pseudostate_impl.hpp | 3 +- .../include_impl}/shallow_history_impl.hpp | 0 .../include_impl}/simple_state_impl.hpp | 10 +- .../include_impl}/simple_transition_step.hpp | 2 +- .../include_impl}/state_pseudostate_impl.hpp | 6 +- .../include_impl}/state_visitor.hpp | 0 .../states_to_enter_visitor_impl.hpp | 10 +- .../terminate_pseudostate_impl.hpp | 0 .../include_impl}/transition_controller.hpp | 7 +- .../include_impl}/transition_executor.hpp | 2 +- .../transition_executor_impl.hpp | 18 +- .../include_impl}/transition_finder.hpp | 0 .../include_impl}/transition_priority.hpp | 0 .../include_impl}/transition_step.hpp | 2 +- .../include_impl}/transition_step_fwd.hpp | 0 ...y_to_build_compound_transition_visitor.hpp | 0 .../include_impl}/vertex_visitor.hpp | 0 .../libyasmine.vcxproj | 492 +++--- .../libyasmine.vcxproj.filters | 505 +++--- .../source}/algorithm_parameters.cpp | 0 .../source/async_behavior.cpp | 37 +- .../source}/async_simple_state_impl.cpp | 29 +- .../source}/async_state_machine.cpp | 161 +- .../source/behavior_exception.cpp | 8 +- .../source/behavior_impl.cpp | 16 +- .../build_transition_steps_visitor.cpp | 0 ...transitions_sources_are_active_visitor.cpp | 0 .../source}/choice_impl.cpp | 2 +- .../source}/color_mapping.cpp | 10 +- libyasmine/source/completion_event.cpp | 37 + .../source}/complex_state_impl.cpp | 12 +- .../source}/composite_state_impl.cpp | 17 +- .../source}/compound_transition_builder.cpp | 16 - .../source}/compound_transition_impl.cpp | 1 - .../source}/compound_transition_step.cpp | 6 +- .../source}/constraint_impl.cpp | 0 .../source}/conversion.cpp | 0 .../source}/cout_logger.cpp | 1 + .../source}/deep_history_impl.cpp | 0 .../source}/entry_point_impl.cpp | 0 .../source}/event_creation_request.cpp | 1 + .../event_creation_request_time_comparer.cpp | 2 + .../source}/event_handle.cpp | 0 .../source}/event_impl.cpp | 0 .../source}/execution_state_do_step.cpp | 15 +- .../source}/execution_state_enter_step.cpp | 2 +- .../source}/execution_state_exit_step.cpp | 2 +- .../source}/execution_transition_step.cpp | 5 +- .../source}/exit_point_impl.cpp | 0 .../source}/file_logger.cpp | 1 + .../source}/file_system.cpp | 0 .../source}/final_state_impl.cpp | 19 +- .../source}/fork_impl.cpp | 1 + .../source}/format_settings.cpp | 0 .../yasmine => libyasmine/source}/globals.cpp | 0 .../source}/history_impl.cpp | 1 - .../source}/initial_pseudostate_impl.cpp | 3 +- .../source}/join_impl.cpp | 0 .../source}/junction_impl.cpp | 1 + .../source}/log_and_throw_helper.cpp | 0 .../source}/log_helper.cpp | 0 .../source}/log_level.cpp | 10 +- .../source}/log_message.cpp | 18 +- .../source}/pseudostate_impl.cpp | 2 +- .../source}/region_impl.cpp | 57 +- .../source}/region_pseudostate_impl.cpp | 15 +- .../source}/shallow_history_impl.cpp | 0 .../source}/simple_state_base.cpp | 4 +- .../source}/simple_state_impl.cpp | 18 +- .../source}/simple_transition_step.cpp | 4 +- .../source}/state_impl.cpp | 66 +- .../source}/state_machine.cpp | 57 +- .../source}/state_machine_defect.cpp | 15 +- .../source}/state_machine_element_impl.cpp | 0 libyasmine/source/state_machine_status.cpp | 38 + .../source}/state_pseudostate_impl.cpp | 13 +- .../source}/states_nesting_comparer.cpp | 0 .../states_nesting_comparer_ascending.cpp | 0 .../source}/states_to_enter_visitor_impl.cpp | 21 +- .../source}/std_timestamp_policy.cpp | 0 .../source}/terminate_pseudostate_impl.cpp | 0 .../source}/timed_event_creator.cpp | 27 +- .../source}/transition_controller.cpp | 57 +- .../source}/transition_executor.cpp | 2 +- .../source}/transition_executor_impl.cpp | 222 +-- .../source}/transition_finder.cpp | 19 +- .../source}/transition_impl.cpp | 262 ++- .../source}/transition_kind.cpp | 0 .../source}/transition_priority.cpp | 10 +- ...y_to_build_compound_transition_visitor.cpp | 2 +- .../yasmine => libyasmine/source}/uri.cpp | 3 - .../yasmine => libyasmine/source}/utils.cpp | 0 .../yasmine => libyasmine/source}/version.cpp | 6 +- .../source}/vertex_impl.cpp | 108 +- libyasmine/source/waiter.cpp | 60 + .../yasmine => libyasmine/source}/yprintf.cpp | 47 +- ...eschaeftliche_Nutzung_Fassung_20160804.pdf | Bin ...haeftliche_Nutzung_Fassung_20160804_en.pdf | Bin ...enschaftliche_Nutzung_Fassung_20160804.pdf | Bin ...chaftliche_Nutzung_Fassung_20160804_en.pdf | Bin {yasmine/license => license}/license.txt | 0 yasmine/yasmine.sln => yasmine.sln | 430 ++--- yasmine/classic_farmroad/CMakeLists.txt | 171 -- yasmine/classic_farmroad/intersection.cpp | 413 ----- yasmine/forty_two/forty_two.cpp | 395 ----- yasmine/yasmine/assembly.hpp | 130 -- yasmine/yasmine/behaviour_exception_fwd.hpp | 23 - yasmine/yasmine/caller.hpp | 742 --------- yasmine/yasmine/event_template.hpp | 492 ------ yasmine/yasmine/log_manager_template.hpp | 377 ----- 317 files changed, 7882 insertions(+), 4812 deletions(-) create mode 100644 CMakeLists.txt rename {yasmine/build => build}/c++03.props (92%) rename {yasmine/build => build}/debug_info.props (89%) create mode 100644 build/use_c++03.props create mode 100644 build/use_yasmine.props rename yasmine/build/use_yasmine.props => build/use_yasmine_base.props (70%) rename {yasmine/build => build}/vs2013.props (64%) rename {yasmine/build => build}/yasmine.props (85%) rename {yasmine => examples}/CMakeLists.txt (83%) create mode 100644 examples/classic_farmroad/CMakeLists.txt rename {yasmine => examples}/classic_farmroad/classic_farmroad.vcxproj (88%) rename {yasmine => examples}/classic_farmroad/classic_farmroad.vcxproj.filters (88%) rename {yasmine => examples}/classic_farmroad/detector.cpp (82%) rename {yasmine => examples}/classic_farmroad/detector.hpp (94%) rename {yasmine => examples}/classic_farmroad/detector_callback.hpp (98%) create mode 100644 examples/classic_farmroad/intersection.cpp rename {yasmine => examples}/classic_farmroad/intersection.hpp (90%) rename {yasmine => examples}/classic_farmroad/main.cpp (92%) create mode 100644 examples/classic_farmroad/random_generator.cpp create mode 100644 examples/classic_farmroad/random_generator.hpp rename {yasmine => examples}/classic_farmroad/traffic_light.cpp (65%) rename {yasmine => examples}/classic_farmroad/traffic_light.hpp (94%) rename {yasmine => examples}/events_with_parameters/CMakeLists.txt (90%) rename {yasmine => examples}/events_with_parameters/class_method_downcast.cpp (57%) rename {yasmine => examples}/events_with_parameters/class_method_downcast.hpp (80%) rename {yasmine => examples}/events_with_parameters/downcast_event.cpp (65%) rename {yasmine => examples}/events_with_parameters/downcast_event.hpp (98%) rename {yasmine => examples}/events_with_parameters/events.hpp (77%) rename {yasmine => examples}/events_with_parameters/events_with_parameters.cpp (92%) rename {yasmine => examples}/events_with_parameters/events_with_parameters.vcxproj (89%) rename {yasmine => examples}/events_with_parameters/events_with_parameters.vcxproj.filters (100%) rename {yasmine => examples}/events_with_parameters/function_downcast.cpp (62%) rename {yasmine => examples}/events_with_parameters/function_downcast.hpp (98%) rename {yasmine => examples}/forty_two/CMakeLists.txt (91%) create mode 100644 examples/forty_two/forty_two.cpp rename {yasmine => examples}/forty_two/forty_two.hpp (94%) rename {yasmine => examples}/forty_two/forty_two.vcxproj (88%) rename {yasmine => examples}/forty_two/forty_two.vcxproj.filters (100%) rename {yasmine => examples}/forty_two/main.cpp (96%) rename {yasmine => examples}/hello_yasmine/CMakeLists.txt (91%) rename {yasmine => examples}/hello_yasmine/hello_yasmine.cpp (79%) rename {yasmine => examples}/hello_yasmine/hello_yasmine.vcxproj (88%) rename {yasmine => examples}/hello_yasmine/hello_yasmine.vcxproj.filters (100%) rename {yasmine => examples}/substatemachines_and_variables/CMakeLists.txt (93%) rename {yasmine => examples}/substatemachines_and_variables/events.hpp (70%) rename {yasmine => examples}/substatemachines_and_variables/main.cpp (93%) rename {yasmine => examples}/substatemachines_and_variables/state_machine_with_submachines.cpp (94%) rename {yasmine => examples}/substatemachines_and_variables/state_machine_with_submachines.hpp (91%) rename {yasmine => examples}/substatemachines_and_variables/submachine.cpp (59%) rename {yasmine => examples}/substatemachines_and_variables/submachine.hpp (88%) rename {yasmine => examples}/substatemachines_and_variables/substatemachines_and_variables.vcxproj (88%) rename {yasmine => examples}/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters (100%) rename {yasmine/yasmine => libyasmine}/CMakeLists.txt (90%) rename {yasmine/yasmine => libyasmine}/changelog.txt (57%) rename {yasmine/yasmine => libyasmine/include}/algorithm_parameters.hpp (100%) create mode 100644 libyasmine/include/assembly.hpp rename yasmine/yasmine/async_behaviour.hpp => libyasmine/include/async_behavior.hpp (77%) rename yasmine/yasmine/async_behaviour_fwd.hpp => libyasmine/include/async_behavior_fwd.hpp (82%) rename {yasmine/yasmine => libyasmine/include}/async_event_handler.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/async_simple_state_impl.hpp (78%) rename {yasmine/yasmine => libyasmine/include}/async_state_machine.hpp (62%) rename {yasmine/yasmine => libyasmine/include}/base.hpp (90%) rename yasmine/yasmine/behaviour.hpp => libyasmine/include/behavior.hpp (83%) rename yasmine/yasmine/behaviour_exception.hpp => libyasmine/include/behavior_exception.hpp (76%) create mode 100644 libyasmine/include/behavior_exception_fwd.hpp rename yasmine/yasmine/behaviour_fwd.hpp => libyasmine/include/behavior_fwd.hpp (80%) create mode 100644 libyasmine/include/caller.hpp rename {yasmine/yasmine => libyasmine/include}/choice.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/choice_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/chrono.hpp (95%) rename {yasmine/yasmine => libyasmine/include}/color.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/color_mapping.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/compatibility.hpp (82%) create mode 100644 libyasmine/include/completion_event.hpp rename {yasmine/yasmine => libyasmine/include}/complex_state.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/complex_state_impl.hpp (80%) rename {yasmine/yasmine => libyasmine/include}/composite_state.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/composite_state_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/constraint.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/constraint_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/cout_logger.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/deep_history.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/deep_history_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/entry_point.hpp (97%) rename {yasmine/yasmine => libyasmine/include}/entry_point_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/event.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/event_creation_request.hpp (97%) rename {yasmine/yasmine => libyasmine/include}/event_creation_request_time_comparer.hpp (95%) rename {yasmine/yasmine => libyasmine/include}/event_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/event_handle.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/event_id.hpp (99%) rename {yasmine/yasmine => libyasmine/include}/event_impl.hpp (96%) rename {yasmine/yasmine => libyasmine/include}/event_priority.hpp (85%) create mode 100644 libyasmine/include/event_template.hpp rename {yasmine/yasmine => libyasmine/include}/exception.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/exception_template.hpp (61%) rename {yasmine/yasmine => libyasmine/include}/exit_point.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/exit_point_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/file_logger.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/final_state.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/fork.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/fork_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/format_settings.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/history.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/initial_pseudostate.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/initial_pseudostate_fwd.hpp (100%) rename yasmine/yasmine/completion_event.hpp => libyasmine/include/internal_completion_event_id.hpp (73%) rename {yasmine/yasmine => libyasmine/include}/join.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/join_fwd.hpp (99%) rename {yasmine/yasmine => libyasmine/include}/junction.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/junction_fwd.hpp (99%) rename {yasmine/yasmine => libyasmine/include}/log.hpp (84%) create mode 100644 libyasmine/include/log_callback.hpp rename {yasmine/yasmine => libyasmine/include}/log_helper.hpp (53%) rename {yasmine/yasmine => libyasmine/include}/log_level.hpp (94%) create mode 100644 libyasmine/include/log_manager_template.hpp rename {yasmine/yasmine => libyasmine/include}/log_message.hpp (87%) rename {yasmine/yasmine => libyasmine/include}/logger.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/logger_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/logging.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/macro_helpers.hpp (83%) rename {yasmine/yasmine => libyasmine/include}/non_copyable.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/optimization.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/pseudostate.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/pseudostate_fwd.hpp (99%) rename {yasmine/yasmine => libyasmine/include}/region.hpp (81%) rename {yasmine/yasmine => libyasmine/include}/region_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/region_pseudostate.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/region_pseudostates.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/shallow_history.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/shallow_history_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/simple_state.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/simple_state_base.hpp (95%) rename {yasmine/yasmine => libyasmine/include}/specialized_event.hpp (97%) rename {yasmine/yasmine => libyasmine/include}/state.hpp (86%) rename {yasmine/yasmine => libyasmine/include}/state_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/state_impl.hpp (88%) rename {yasmine/yasmine => libyasmine/include}/state_machine.hpp (83%) rename {yasmine/yasmine => libyasmine/include}/state_machine_defect.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/state_machine_defect_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/state_machine_element.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/state_machine_element_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/state_machine_introspection.hpp (100%) create mode 100644 libyasmine/include/state_machine_status.hpp rename {yasmine/yasmine => libyasmine/include}/state_pseudostate.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/state_pseudostates.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/states.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/states_nesting_comparer.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/states_nesting_comparer_ascending.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/std_timestamp_policy.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/terminate_pseudostate.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/terminate_pseudostate_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/thread.hpp (90%) rename {yasmine/yasmine => libyasmine/include}/timed_event_creator.hpp (89%) rename {yasmine/yasmine => libyasmine/include}/transition.hpp (92%) rename {yasmine/yasmine => libyasmine/include}/transition_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/transition_impl.hpp (79%) rename {yasmine/yasmine => libyasmine/include}/transition_kind.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/uri.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/utils.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/version.hpp (98%) rename {yasmine/yasmine => libyasmine/include}/vertex.hpp (92%) rename {yasmine/yasmine => libyasmine/include}/vertex_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include}/vertex_impl.hpp (87%) create mode 100644 libyasmine/include/waiter.hpp rename {yasmine/yasmine => libyasmine/include}/yasmine.hpp (92%) rename {yasmine/yasmine => libyasmine/include}/yprintf.hpp (98%) rename yasmine/yasmine/behaviour_impl.hpp => libyasmine/include_impl/behavior_impl.hpp (61%) rename {yasmine/yasmine => libyasmine/include_impl}/build_number.hpp (95%) rename {yasmine/yasmine => libyasmine/include_impl}/build_transition_steps_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/check_if_all_incoming_transitions_sources_are_active_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/choice_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/complex_state_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/composite_state_impl.hpp (97%) rename {yasmine/yasmine => libyasmine/include_impl}/compound_transition.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/compound_transition_builder.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/compound_transition_consumer.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/compound_transition_fwd.hpp (86%) rename {yasmine/yasmine => libyasmine/include_impl}/compound_transition_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/compound_transition_step.hpp (95%) rename {yasmine/yasmine => libyasmine/include_impl}/const_vertex_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/constraint_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/conversion.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/deep_history_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/entry_point_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/event_processing_callback.hpp (88%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_state_do_step.hpp (94%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_state_enter_step.hpp (94%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_state_exit_step.hpp (94%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_step.hpp (92%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_step_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_step_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/execution_transition_step.hpp (94%) rename {yasmine/yasmine => libyasmine/include_impl}/exit_point_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/file_system.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/final_state_impl.hpp (93%) rename {yasmine/yasmine => libyasmine/include_impl}/fork_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/globals.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/history_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/initial_pseudostate_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/join_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/junction_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/log_and_throw.hpp (60%) rename {yasmine/yasmine => libyasmine/include_impl}/log_and_throw_helper.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/pseudostate_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/pseudostate_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/region_impl.hpp (86%) rename {yasmine/yasmine => libyasmine/include_impl}/region_pseudostate_impl.hpp (96%) rename {yasmine/yasmine => libyasmine/include_impl}/shallow_history_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/simple_state_impl.hpp (78%) rename {yasmine/yasmine => libyasmine/include_impl}/simple_transition_step.hpp (96%) rename {yasmine/yasmine => libyasmine/include_impl}/state_pseudostate_impl.hpp (92%) rename {yasmine/yasmine => libyasmine/include_impl}/state_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/states_to_enter_visitor_impl.hpp (89%) rename {yasmine/yasmine => libyasmine/include_impl}/terminate_pseudostate_impl.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_controller.hpp (87%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_executor.hpp (97%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_executor_impl.hpp (89%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_finder.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_priority.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_step.hpp (95%) rename {yasmine/yasmine => libyasmine/include_impl}/transition_step_fwd.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/try_to_build_compound_transition_visitor.hpp (100%) rename {yasmine/yasmine => libyasmine/include_impl}/vertex_visitor.hpp (100%) rename yasmine/yasmine/yasmine.vcxproj => libyasmine/libyasmine.vcxproj (64%) rename yasmine/yasmine/yasmine.vcxproj.filters => libyasmine/libyasmine.vcxproj.filters (65%) rename {yasmine/yasmine => libyasmine/source}/algorithm_parameters.cpp (100%) rename yasmine/yasmine/async_behaviour.cpp => libyasmine/source/async_behavior.cpp (70%) rename {yasmine/yasmine => libyasmine/source}/async_simple_state_impl.cpp (67%) rename {yasmine/yasmine => libyasmine/source}/async_state_machine.cpp (56%) rename yasmine/yasmine/behaviour_exception.cpp => libyasmine/source/behavior_exception.cpp (83%) rename yasmine/yasmine/behaviour_impl.cpp => libyasmine/source/behavior_impl.cpp (73%) rename {yasmine/yasmine => libyasmine/source}/build_transition_steps_visitor.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/check_if_all_incoming_transitions_sources_are_active_visitor.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/choice_impl.cpp (99%) rename {yasmine/yasmine => libyasmine/source}/color_mapping.cpp (91%) create mode 100644 libyasmine/source/completion_event.cpp rename {yasmine/yasmine => libyasmine/source}/complex_state_impl.cpp (87%) rename {yasmine/yasmine => libyasmine/source}/composite_state_impl.cpp (95%) rename {yasmine/yasmine => libyasmine/source}/compound_transition_builder.cpp (86%) rename {yasmine/yasmine => libyasmine/source}/compound_transition_impl.cpp (99%) rename {yasmine/yasmine => libyasmine/source}/compound_transition_step.cpp (92%) rename {yasmine/yasmine => libyasmine/source}/constraint_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/conversion.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/cout_logger.cpp (98%) rename {yasmine/yasmine => libyasmine/source}/deep_history_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/entry_point_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/event_creation_request.cpp (99%) rename {yasmine/yasmine => libyasmine/source}/event_creation_request_time_comparer.cpp (96%) rename {yasmine/yasmine => libyasmine/source}/event_handle.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/event_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/execution_state_do_step.cpp (81%) rename {yasmine/yasmine => libyasmine/source}/execution_state_enter_step.cpp (94%) rename {yasmine/yasmine => libyasmine/source}/execution_state_exit_step.cpp (94%) rename {yasmine/yasmine => libyasmine/source}/execution_transition_step.cpp (92%) rename {yasmine/yasmine => libyasmine/source}/exit_point_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/file_logger.cpp (99%) rename {yasmine/yasmine => libyasmine/source}/file_system.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/final_state_impl.cpp (91%) rename {yasmine/yasmine => libyasmine/source}/fork_impl.cpp (99%) rename {yasmine/yasmine => libyasmine/source}/format_settings.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/globals.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/history_impl.cpp (97%) rename {yasmine/yasmine => libyasmine/source}/initial_pseudostate_impl.cpp (98%) rename {yasmine/yasmine => libyasmine/source}/join_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/junction_impl.cpp (99%) rename {yasmine/yasmine => libyasmine/source}/log_and_throw_helper.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/log_helper.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/log_level.cpp (95%) rename {yasmine/yasmine => libyasmine/source}/log_message.cpp (80%) rename {yasmine/yasmine => libyasmine/source}/pseudostate_impl.cpp (95%) rename {yasmine/yasmine => libyasmine/source}/region_impl.cpp (84%) rename {yasmine/yasmine => libyasmine/source}/region_pseudostate_impl.cpp (91%) rename {yasmine/yasmine => libyasmine/source}/shallow_history_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/simple_state_base.cpp (96%) rename {yasmine/yasmine => libyasmine/source}/simple_state_impl.cpp (76%) rename {yasmine/yasmine => libyasmine/source}/simple_transition_step.cpp (94%) rename {yasmine/yasmine => libyasmine/source}/state_impl.cpp (81%) rename {yasmine/yasmine => libyasmine/source}/state_machine.cpp (89%) rename {yasmine/yasmine => libyasmine/source}/state_machine_defect.cpp (95%) rename {yasmine/yasmine => libyasmine/source}/state_machine_element_impl.cpp (100%) create mode 100644 libyasmine/source/state_machine_status.cpp rename {yasmine/yasmine => libyasmine/source}/state_pseudostate_impl.cpp (87%) rename {yasmine/yasmine => libyasmine/source}/states_nesting_comparer.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/states_nesting_comparer_ascending.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/states_to_enter_visitor_impl.cpp (89%) rename {yasmine/yasmine => libyasmine/source}/std_timestamp_policy.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/terminate_pseudostate_impl.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/timed_event_creator.cpp (93%) rename {yasmine/yasmine => libyasmine/source}/transition_controller.cpp (84%) rename {yasmine/yasmine => libyasmine/source}/transition_executor.cpp (98%) rename {yasmine/yasmine => libyasmine/source}/transition_executor_impl.cpp (82%) rename {yasmine/yasmine => libyasmine/source}/transition_finder.cpp (92%) rename {yasmine/yasmine => libyasmine/source}/transition_impl.cpp (53%) rename {yasmine/yasmine => libyasmine/source}/transition_kind.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/transition_priority.cpp (89%) rename {yasmine/yasmine => libyasmine/source}/try_to_build_compound_transition_visitor.cpp (98%) rename {yasmine/yasmine => libyasmine/source}/uri.cpp (96%) rename {yasmine/yasmine => libyasmine/source}/utils.cpp (100%) rename {yasmine/yasmine => libyasmine/source}/version.cpp (94%) rename {yasmine/yasmine => libyasmine/source}/vertex_impl.cpp (65%) create mode 100644 libyasmine/source/waiter.cpp rename {yasmine/yasmine => libyasmine/source}/yprintf.cpp (95%) rename {yasmine/license => license}/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf (100%) rename {yasmine/license => license}/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf (100%) rename {yasmine/license => license}/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf (100%) rename {yasmine/license => license}/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf (100%) rename {yasmine/license => license}/license.txt (100%) rename yasmine/yasmine.sln => yasmine.sln (95%) delete mode 100644 yasmine/classic_farmroad/CMakeLists.txt delete mode 100644 yasmine/classic_farmroad/intersection.cpp delete mode 100644 yasmine/forty_two/forty_two.cpp delete mode 100644 yasmine/yasmine/assembly.hpp delete mode 100644 yasmine/yasmine/behaviour_exception_fwd.hpp delete mode 100644 yasmine/yasmine/caller.hpp delete mode 100644 yasmine/yasmine/event_template.hpp delete mode 100644 yasmine/yasmine/log_manager_template.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5d508fe --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.5) + +project(yasmine) +add_subdirectory(libyasmine) + +add_subdirectory(examples) diff --git a/yasmine/build/c++03.props b/build/c++03.props similarity index 92% rename from yasmine/build/c++03.props rename to build/c++03.props index a0c9440..c65e485 100644 --- a/yasmine/build/c++03.props +++ b/build/c++03.props @@ -5,7 +5,9 @@ ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0 ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0\stage\VS2015\$(Platform)\lib - + + <_PropertySheetDisplayName>c++03 + Y_NO_VARIADIC_MACRO;Y_CPP03_BOOST;BOOST_SP_USE_STD_ATOMIC;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/yasmine/build/debug_info.props b/build/debug_info.props similarity index 89% rename from yasmine/build/debug_info.props rename to build/debug_info.props index b42570a..5dc702b 100644 --- a/yasmine/build/debug_info.props +++ b/build/debug_info.props @@ -7,7 +7,7 @@ NotSet - DebugFastLink + true EditAndContinue diff --git a/build/use_c++03.props b/build/use_c++03.props new file mode 100644 index 0000000..dbee839 --- /dev/null +++ b/build/use_c++03.props @@ -0,0 +1,17 @@ + + + + + + + + Y_NO_VARIADIC_MACRO;Y_CPP03_BOOST;BOOST_SP_USE_STD_ATOMIC;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + + $(BOOST_LIB_PATH);$(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/build/use_yasmine.props b/build/use_yasmine.props new file mode 100644 index 0000000..b9a7423 --- /dev/null +++ b/build/use_yasmine.props @@ -0,0 +1,18 @@ + + + + + + + + ..\..\libyasmine\include;..\..\libyasmine\include_impl;%(AdditionalIncludeDirectories) + None + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + libyasmine.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/yasmine/build/use_yasmine.props b/build/use_yasmine_base.props similarity index 70% rename from yasmine/build/use_yasmine.props rename to build/use_yasmine_base.props index f73d5a4..f779770 100644 --- a/yasmine/build/use_yasmine.props +++ b/build/use_yasmine_base.props @@ -5,13 +5,13 @@ - ..\yasmine;%(AdditionalIncludeDirectories) + ..\libyasmine\include;..\libyasmine\include_impl;%(AdditionalIncludeDirectories) None $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) - yasmine.lib;%(AdditionalDependencies) + libyasmine.lib;%(AdditionalDependencies) diff --git a/yasmine/build/vs2013.props b/build/vs2013.props similarity index 64% rename from yasmine/build/vs2013.props rename to build/vs2013.props index 69351d3..b02ec73 100644 --- a/yasmine/build/vs2013.props +++ b/build/vs2013.props @@ -1,12 +1,16 @@ - - - - - - - - false - - - + + + + + + + + false + Y_CPP03_BOOST;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + + \ No newline at end of file diff --git a/yasmine/build/yasmine.props b/build/yasmine.props similarity index 85% rename from yasmine/build/yasmine.props rename to build/yasmine.props index d782892..600f7ae 100644 --- a/yasmine/build/yasmine.props +++ b/build/yasmine.props @@ -12,6 +12,8 @@ Y_OPTIMIZE_4_SPEED;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) None false + true + include;include_impl;%(AdditionalIncludeDirectories) diff --git a/yasmine/CMakeLists.txt b/examples/CMakeLists.txt similarity index 83% rename from yasmine/CMakeLists.txt rename to examples/CMakeLists.txt index b33233a..39cd67e 100644 --- a/yasmine/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(yasmine) -add_subdirectory(yasmine) - add_subdirectory(hello_yasmine) add_subdirectory(classic_farmroad) add_subdirectory(forty_two) diff --git a/examples/classic_farmroad/CMakeLists.txt b/examples/classic_farmroad/CMakeLists.txt new file mode 100644 index 0000000..063f46d --- /dev/null +++ b/examples/classic_farmroad/CMakeLists.txt @@ -0,0 +1,185 @@ +cmake_minimum_required(VERSION 3.5) + +project(classic_farmroad) + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +set(HEADER_FILES "./../../libyasmine/include/*.hpp") +file(GLOB classic_farmroad_SRC "./*.cpp" ${HEADER_FILES}) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) + set(extra_flags "${extra_flags} -m64") + message(STATUS "setting platform x64") + else() + set(extra_flags "${extra_flags} -m32") + message(STATUS "setting platform x86") + endif() + + if("${CPP_VERSION}" STREQUAL "03") + set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\" -D \"Y_NO_VARIADIC_MACRO\"") + else() + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") + endif() + + # yasmine's preprocessor definitions + set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") + if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) + set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") + else() + set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") + endif() + + option("Y_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") + if( "${Y_NO_LOGGING}" ) + set(extra_flags "${extra_flags} -D \"Y_NO_LOGGING\"") + endif() + + option("Y_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") + if( "${Y_NO_STD_MAKE_UNIQUE}" ) + set(extra_flags "${extra_flags} -D \"Y_NO_STD_MAKE_UNIQUE\"") + endif() + + option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") + if( "${Y_LEAN_AND_MEAN}" ) + set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") + endif() + + option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") + if( "${Y_PROFILER}" ) + set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") + endif() + +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # Checks buffer security. + set(extra_flags "${extra_flags} /GS") + + #Sets output warning level. + set(extra_flags "${extra_flags} /W4") + + #Disable specific Warnings. + set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") + + #Defines constants and macros. + set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") + + #Enables function-level linking. + set(extra_flags "${extra_flags} /Gy") + + #Specifies standard behavior under /Ze. + set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") + + #Disable minimal rebuild. + set(extra_flags "${extra_flags} /Gm-") + + #Enables additional security features and warnings. + set(extra_flags "${extra_flags} /sdl") + + #Specifies floating-point behavior. + set(extra_flags "${extra_flags} /fp:precise") + + #Multibyte character sets macro. + set(extra_flags "${extra_flags} /D \"_MBCS\"") + + #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. + set(extra_flags "${extra_flags} /errorReport:prompt") + + #Treats warnings as errors. + set(extra_flags "${extra_flags} /WX") + + #Generates intrinsic functions. + set(extra_flags "${extra_flags} /Oi") + + #Specifies the model of exception handling. + set(extra_flags "${extra_flags} /EHsc") + + #Creates an object file. + set(extra_flags "${extra_flags} /Fo") + + #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. + #set(extra_flags "${extra_flags} /NXCOMPAT") + +# yasmine's preprocessor definitions + set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") + if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") + endif() + + option("Y_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") + if( "${Y_NO_LOGGING}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_NO_LOGGING\"") + endif() + + option("Y_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") + if( "${Y_NO_STD_MAKE_UNIQUE}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_NO_STD_MAKE_UNIQUE\"") + endif() + + option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") + if( "${Y_LEAN_AND_MEAN}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") + endif() + + option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") + if( "${Y_PROFILER}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") + endif() + +endif() + +# for release +if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) + #Creates fast code. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") + + #Controls LINK optimizations. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") + +# for debug +elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) + #Creates a program database (PDB) file. + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") +endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") + +add_executable(classic_farmroad ${classic_farmroad_SRC}) +include_directories("./../../libyasmine/include") + +#using boost +if("${CPP_VERSION}" STREQUAL "03") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + link_directories("${Y_BOOST_LIB_PATH}") + endif() +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if("${CPP_VERSION}" STREQUAL "03") + target_link_libraries (classic_farmroad LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono boost_random) + else() + target_link_libraries (classic_farmroad LINK_PUBLIC libyasmine pthread) + endif() +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_link_libraries (classic_farmroad LINK_PUBLIC libyasmine) +endif() + + +if("${CPP_VERSION}" STREQUAL "03") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET(Boost_USE_STATIC_LIBS ON) + SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") + SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") + include_directories(${Boost_INCLUDE_DIRS}) + target_link_libraries(classic_farmroad LINK_PUBLIC ${Boost_LIBRARIES}) + endif() +endif() + +install(TARGETS classic_farmroad DESTINATION bin) diff --git a/yasmine/classic_farmroad/classic_farmroad.vcxproj b/examples/classic_farmroad/classic_farmroad.vcxproj similarity index 88% rename from yasmine/classic_farmroad/classic_farmroad.vcxproj rename to examples/classic_farmroad/classic_farmroad.vcxproj index b3a8f90..0ad8c62 100644 --- a/yasmine/classic_farmroad/classic_farmroad.vcxproj +++ b/examples/classic_farmroad/classic_farmroad.vcxproj @@ -141,79 +141,82 @@ - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - Level3 Disabled true @@ -358,6 +361,7 @@ + @@ -373,6 +377,10 @@ + + + + diff --git a/yasmine/classic_farmroad/classic_farmroad.vcxproj.filters b/examples/classic_farmroad/classic_farmroad.vcxproj.filters similarity index 88% rename from yasmine/classic_farmroad/classic_farmroad.vcxproj.filters rename to examples/classic_farmroad/classic_farmroad.vcxproj.filters index b0cdf9d..89cecd0 100644 --- a/yasmine/classic_farmroad/classic_farmroad.vcxproj.filters +++ b/examples/classic_farmroad/classic_farmroad.vcxproj.filters @@ -27,6 +27,9 @@ Header Files + + Header Files + @@ -41,5 +44,8 @@ Source Files + + Source Files + - + \ No newline at end of file diff --git a/yasmine/classic_farmroad/detector.cpp b/examples/classic_farmroad/detector.cpp similarity index 82% rename from yasmine/classic_farmroad/detector.cpp rename to examples/classic_farmroad/detector.cpp index 512764d..293e42e 100644 --- a/yasmine/classic_farmroad/detector.cpp +++ b/examples/classic_farmroad/detector.cpp @@ -11,12 +11,10 @@ #include "detector.hpp" -#include -#include - #include "base.hpp" #include "detector_callback.hpp" #include "chrono.hpp" +#include "random_generator.hpp" namespace @@ -32,7 +30,7 @@ namespace } -namespace sxy +namespace examples { @@ -87,23 +85,20 @@ void detector::generate_detector_events() sxy::unique_lock< sxy::mutex > lock( mutex_ ); while( run_ ) { - std::random_device r; - std::default_random_engine e( r() ); + random_generator generator; is_on_ = false; - { - std::uniform_int_distribution< int > uniform_dist( DETECTOR_OFF_LOWER_EXTREMITY, - DETECTOR_OFF_UPPER_EXTREMITY ); - sxy::milliseconds time_to_wait = sxy::milliseconds( uniform_dist( e ) ); + { + sxy::milliseconds time_to_wait = + sxy::milliseconds( generator.generate( DETECTOR_OFF_LOWER_EXTREMITY, DETECTOR_OFF_UPPER_EXTREMITY ) ); condition_variable_.wait_for( lock, time_to_wait ); detector_callback_.detector_off(); } if( run_ ) { is_on_ = true; - { - std::uniform_int_distribution< int > uniform_dist( DETECTOR_ON_UPPER_EXTREMITY, - DETECTOR_ON_UPPER_EXTREMITY ); - sxy::milliseconds time_to_wait = sxy::milliseconds( uniform_dist( e ) ); + { + sxy::milliseconds time_to_wait = + sxy::milliseconds( generator.generate( DETECTOR_ON_UPPER_EXTREMITY, DETECTOR_ON_UPPER_EXTREMITY ) ); condition_variable_.wait_for( lock, time_to_wait ); detector_callback_.detector_on(); diff --git a/yasmine/classic_farmroad/detector.hpp b/examples/classic_farmroad/detector.hpp similarity index 94% rename from yasmine/classic_farmroad/detector.hpp rename to examples/classic_farmroad/detector.hpp index 4976000..98e6064 100644 --- a/yasmine/classic_farmroad/detector.hpp +++ b/examples/classic_farmroad/detector.hpp @@ -18,7 +18,7 @@ #include "non_copyable.hpp" -namespace sxy +namespace examples { @@ -42,7 +42,7 @@ class detector Y_FINAL detector_callback& detector_callback_; bool is_on_; - Y_UNIQUE_PTR< sxy::thread > generate_random_detector_events_; + sxy::Y_UNIQUE_PTR< sxy::thread > generate_random_detector_events_; bool run_; sxy::mutex mutex_; sxy::condition_variable condition_variable_; diff --git a/yasmine/classic_farmroad/detector_callback.hpp b/examples/classic_farmroad/detector_callback.hpp similarity index 98% rename from yasmine/classic_farmroad/detector_callback.hpp rename to examples/classic_farmroad/detector_callback.hpp index f31ea09..4f0ef36 100644 --- a/yasmine/classic_farmroad/detector_callback.hpp +++ b/examples/classic_farmroad/detector_callback.hpp @@ -17,7 +17,7 @@ #include "compatibility.hpp" -namespace sxy +namespace examples { diff --git a/examples/classic_farmroad/intersection.cpp b/examples/classic_farmroad/intersection.cpp new file mode 100644 index 0000000..911ab7a --- /dev/null +++ b/examples/classic_farmroad/intersection.cpp @@ -0,0 +1,418 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "intersection.hpp" + +#include + +#include "yasmine.hpp" + + +namespace examples +{ + + +namespace +{ + + +const sxy::event_id DETECTOR_ON = 1; +Y_EVENT_WITH_ID( detector_on_event, DETECTOR_ON ) + +const sxy::event_id DETECTOR_OFF = 2; +Y_EVENT_WITH_ID( detector_off_event, DETECTOR_OFF ) + +const sxy::event_id TIMER_HIGHWAY_MINIMUM_TIME = 3; +Y_EVENT_WITH_ID( timer_highway_minimum_time_event, TIMER_HIGHWAY_MINIMUM_TIME ) + +const sxy::event_id TIMER_PHASE_1 = 4; +Y_EVENT_WITH_ID( timer_phase_1_event, TIMER_PHASE_1 ) + +const sxy::event_id TIMER_PHASE_2 = 5; +Y_EVENT_WITH_ID( timer_phase_2_event, TIMER_PHASE_2 ) + +const sxy::event_id TIMER_FARMROAD_MAXIMUM_TIME = 6; +Y_EVENT_WITH_ID( timer_farmroad_maximum_time_event, TIMER_FARMROAD_MAXIMUM_TIME ) + +const sxy::event_id EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED = 7; +Y_EVENT_WITH_ID( event_farmroad_maximum_time_elapsed_event, EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED ) + +#ifndef Y_CPP03_BOOST +const sxy::event_ids EVENTS_EXIT_FARMROAD_OPEN = +{ detector_on_event::get_event_id(), event_farmroad_maximum_time_elapsed_event::get_event_id() }; +#endif + +const sxy::milliseconds TIMER_HIGHWAY_MINIMUM_TIME_DURATION( 5 ); +const sxy::milliseconds TIMER_PHASE_1_DURATION( 1 ); +const sxy::milliseconds TIMER_PHASE_2_DURATION( 1 ); +const sxy::milliseconds TIMER_FARMROAD_MAXIMUM_TIME_DURATION( 3 ); +const std::string FARMROAD_ASCII_ART = "--- "; +const std::string HIGHWAY_ASCII_ART = "==== "; + +} + + +intersection::intersection() + : detector_callback(), + intersection_state_machine_( "intersection state machine" ), + highway_traffic_light_( "highway traffic light", HIGHWAY_ASCII_ART ), + farmroad_traffic_light_( "farmroad traffic light", FARMROAD_ASCII_ART ), + timed_event_creator_( intersection_state_machine_ ), + detector_( *this ), + farmroad_maximum_time_event_handle_() +{ + build_intersection_state_machine(); +} + + +intersection::~intersection() Y_NOEXCEPT +{ + // Nothing to do... +} + + +bool intersection::start() +{ + bool started = false; + sxy::state_machine_defects defects; + intersection_state_machine_.check( defects ); + if( defects.empty() ) + { + farmroad_traffic_light_.start(); + highway_traffic_light_.start(); + timed_event_creator_.run(); + intersection_state_machine_.run(); + detector_.start(); + started = true; + } + else + { + std::cout << "The state machine is defect." << std::endl; + write_defects_to_log( defects ); + } + + return( started ); +} + + +void intersection::stop() +{ + detector_.stop(); + intersection_state_machine_.halt_and_join(); + timed_event_creator_.halt_and_join(); + highway_traffic_light_.stop(); + farmroad_traffic_light_.stop(); +} + + +void intersection::detector_on() +{ + std::cout << "Detector is on." << std::endl; + intersection_state_machine_.fire_event( detector_on_event::create() ); +} + + +void intersection::detector_off() +{ + std::cout << "Detector is off." << std::endl; + intersection_state_machine_.fire_event( detector_off_event::create() ); +} + + +int intersection::fire_timed_event( const sxy::milliseconds _milliseconds, const sxy::event_sptr _event ) +{ + sxy::handle_type event_handle = + timed_event_creator_.create_event_creation_request( sxy::milliseconds( _milliseconds ), _event ); + return( event_handle ); +} + + +void intersection::highway_open_entry() +{ + Y_LOG( sxy::log_level::LL_INFO, "Highway open." ); + highway_traffic_light_.switch_to_green(); + fire_timed_event( TIMER_HIGHWAY_MINIMUM_TIME_DURATION, timer_highway_minimum_time_event::create() ); +} + + +void intersection::highway_open_exit() const +{ + Y_LOG( sxy::log_level::LL_INFO, "Highway closed." ); +} + + +void intersection::switching_to_farmroad_phase_1() +{ + Y_LOG( sxy::log_level::LL_INFO, "Switching highway to farmroad. Phase 1." ); + highway_traffic_light_.switch_to_yellow(); + farmroad_traffic_light_.switch_to_red_yellow(); + fire_timed_event( TIMER_PHASE_1_DURATION, timer_phase_1_event::create() ); +} + + +void intersection::switching_to_farmroad_phase_2() +{ + Y_LOG( sxy::log_level::LL_INFO, "Switching highway to farmroad. Phase 2." ); + highway_traffic_light_.switch_to_red(); + fire_timed_event( TIMER_PHASE_2_DURATION, timer_phase_2_event::create() ); +} + + +void intersection::farmroad_open_entry() +{ + Y_LOG( sxy::log_level::LL_INFO, "Farmroad open." ); + farmroad_traffic_light_.switch_to_green(); + farmroad_maximum_time_event_handle_ = fire_timed_event( TIMER_FARMROAD_MAXIMUM_TIME_DURATION, + timer_farmroad_maximum_time_event::create() ); +} + + +void intersection::farmroad_open_exit() const +{ + Y_LOG( sxy::log_level::LL_INFO, "Farmroad closed." ); +} + + +void intersection::minimum_time_not_elapsed() const +{ + Y_LOG( sxy::log_level::LL_INFO, "Minimum time not elapsed." ); +} + + +void intersection::minimum_time_elapsed() const +{ + Y_LOG( sxy::log_level::LL_INFO, "Minimum time elapsed." ); +} + + +void intersection::minimum_time_not_elapsed_farmroad_waiting() const +{ + Y_LOG( sxy::log_level::LL_INFO, "Minimum time not elapsed. Farmroad waiting." ); +} + + +void intersection::switching_to_highway_phase_1() +{ + Y_LOG( sxy::log_level::LL_INFO, "Switching farmroad to highway. Phase 1." ); + highway_traffic_light_.switch_to_red_yellow(); + farmroad_traffic_light_.switch_to_yellow(); + fire_timed_event( TIMER_PHASE_1_DURATION, timer_phase_1_event::create() ); +} + + +void intersection::switching_to_highway_phase_2() +{ + Y_LOG( sxy::log_level::LL_INFO, "Switching farmroad to highway. Phase 2." ); + farmroad_traffic_light_.switch_to_red(); + fire_timed_event( TIMER_PHASE_2_DURATION, timer_phase_2_event::create() ); +} + + +bool intersection::check_detector_is_on() +{ + return( detector_.is_on() ); +} + + +bool intersection::check_detector_is_off() +{ + return( !detector_.is_on() ); +} + + +void intersection::cancel_timer_event_on_detector_off( const sxy::event& _event ) +{ + if( _event.get_id() == detector_off_event::get_event_id() ) + { + if( farmroad_maximum_time_event_handle_ > 0 ) + { + Y_LOG( sxy::log_level::LL_INFO, "Try to cancel event with handle %.", farmroad_maximum_time_event_handle_ ); + if( timed_event_creator_.cancel( farmroad_maximum_time_event_handle_ ) ) + { + Y_LOG( sxy::log_level::LL_INFO, "Event with handle % was cancelled.", farmroad_maximum_time_event_handle_ ); + } + else + { + Y_LOG( sxy::log_level::LL_INFO, "Event with handle % could not be canceled.", farmroad_maximum_time_event_handle_ ); + } + + farmroad_maximum_time_event_handle_ = 0; + } + else + { + Y_LOG( sxy::log_level::LL_INFO, "There is no event to be cancelled on detector off." ); + } + } +} + + +void intersection::build_intersection_state_machine() +{ +#ifdef Y_CPP03_BOOST + sxy::event_ids EVENTS_EXIT_FARMROAD_OPEN; + EVENTS_EXIT_FARMROAD_OPEN.push_back( detector_on_event::get_event_id() ); + EVENTS_EXIT_FARMROAD_OPEN.push_back( event_farmroad_maximum_time_elapsed_event::get_event_id() ); +#endif + + sxy::composite_state& root = intersection_state_machine_.get_root_state(); + sxy::region& main_region = root.add_region( "main_region" ); + sxy::initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); + + // highway open +#ifdef Y_CPP03_BOOST + sxy::composite_state& l_highway_open = + main_region.add_composite_state( "highway open", + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, highway_open_entry ), + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, highway_open_exit ) ); +#else + sxy::composite_state& l_highway_open = main_region.add_composite_state( "highway open", + Y_BEHAVIOR_METHOD_NO_EVENT( highway_open_entry ), Y_BEHAVIOR_METHOD_NO_EVENT( highway_open_exit ) ); +#endif + + sxy::region& highway_open_region = l_highway_open.add_region( "highway region" ); + sxy::initial_pseudostate& initial_highway = highway_open_region.add_initial_pseudostate( "initial highway" ); + sxy::simple_state& initialize_dummy = highway_open_region.add_simple_state( "initialize dummy" ); + sxy::junction& detector_junction = highway_open_region.add_junction( "detector junction" ); + +#ifdef Y_CPP03_BOOST + sxy::simple_state& l_minimum_time_not_elapsed = highway_open_region.add_simple_state( "minimum time not elapsed", + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, minimum_time_not_elapsed ) ); + sxy::simple_state& l_minimum_time_elapsed = highway_open_region.add_simple_state( "minimum time elapsed", + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, minimum_time_elapsed ) ); + sxy::simple_state& l_minimum_time_not_elapsed_farmroad_waiting = highway_open_region.add_simple_state( + "Minimum time not elapsed and farmroad waiting", + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, minimum_time_not_elapsed_farmroad_waiting ) ); +#else + sxy::simple_state& l_minimum_time_not_elapsed = highway_open_region.add_simple_state( "minimum time not elapsed", + Y_BEHAVIOR_METHOD_NO_EVENT( minimum_time_not_elapsed ) ); + sxy::simple_state& l_minimum_time_elapsed = highway_open_region.add_simple_state( "minimum time elapsed", + Y_BEHAVIOR_METHOD_NO_EVENT( minimum_time_elapsed ) ); + sxy::simple_state& l_minimum_time_not_elapsed_farmroad_waiting = highway_open_region.add_simple_state( + "Minimum time not elapsed and farmroad waiting", + Y_BEHAVIOR_METHOD_NO_EVENT( minimum_time_not_elapsed_farmroad_waiting ) ); +#endif + + + sxy::final_state& highway_finished = highway_open_region.add_final_state( "highway finished" ); + + // switching highway to farmroad + sxy::composite_state& switching_to_farmroad = main_region.add_composite_state( "switching highway to farmroad" ); + sxy::region& switching_to_farmroad_region = switching_to_farmroad.add_region( "region switching to farmroad" ); + sxy::initial_pseudostate& initial_switching_to_farmroad = + switching_to_farmroad_region.add_initial_pseudostate( "initial switching highway to farmroad" ); + +#ifdef Y_CPP03_BOOST + sxy::simple_state& l_switching_to_farmroad_phase_1 = switching_to_farmroad_region.add_simple_state( + "switching to farmroad phase 1", Y_BEHAVIOR_METHOD_NO_EVENT( intersection, switching_to_farmroad_phase_1 ) ); + sxy::simple_state& state_switching_to_farmroad_phase_2 = switching_to_farmroad_region.add_simple_state( + "switching to farmroad phase 2", Y_EMPTY_BEHAVIOR, + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, switching_to_farmroad_phase_2 ) ); + sxy::simple_state& farmroad_open = main_region.add_simple_state( "farmroad open", Y_EMPTY_BEHAVIOR, + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, farmroad_open_entry ), + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, farmroad_open_exit ) ); +#else + sxy::simple_state& l_switching_to_farmroad_phase_1 = switching_to_farmroad_region.add_simple_state( + "switching to farmroad phase 1", Y_BEHAVIOR_METHOD_NO_EVENT( switching_to_farmroad_phase_1 ) ); + sxy::simple_state& state_switching_to_farmroad_phase_2 = switching_to_farmroad_region.add_simple_state( + "switching to farmroad phase 2", Y_NULLPTR, Y_BEHAVIOR_METHOD_NO_EVENT( switching_to_farmroad_phase_2 ) ); + sxy::simple_state& farmroad_open = + main_region.add_simple_state( "farmroad open", Y_NULLPTR, + Y_BEHAVIOR_METHOD_NO_EVENT( farmroad_open_entry ), Y_BEHAVIOR_METHOD_NO_EVENT( farmroad_open_exit ) ); +#endif + + sxy::final_state& switching_to_farmroad_finished = + switching_to_farmroad_region.add_final_state( "switching to farmroad finished" ); + + // switching farmroad to highway + sxy::composite_state& switching_to_highway = main_region.add_composite_state( "switching farmroad to highway" ); + sxy::region& switching_to_highway_region = switching_to_highway.add_region( "region switching to highway" ); + sxy::initial_pseudostate& initial_switching_to_highway = + switching_to_highway_region.add_initial_pseudostate( "initial switching to highway" ); + +#ifdef Y_CPP03_BOOST + sxy::simple_state& l_switching_to_highway_phase_1 = switching_to_highway_region.add_simple_state( + "switching to highway phase 1", Y_EMPTY_BEHAVIOR, + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, switching_to_highway_phase_1 ) ); + sxy::simple_state& l_switching_to_highway_phase_2 = switching_to_highway_region.add_simple_state( + "switching to highway phase 2", Y_EMPTY_BEHAVIOR, + Y_BEHAVIOR_METHOD_NO_EVENT( intersection, switching_to_highway_phase_2 ) ); +#else + sxy::simple_state& l_switching_to_highway_phase_1 = switching_to_highway_region.add_simple_state( + "switching to highway phase 1", Y_NULLPTR, Y_BEHAVIOR_METHOD_NO_EVENT( switching_to_highway_phase_1 ) ); + sxy::simple_state& l_switching_to_highway_phase_2 = switching_to_highway_region.add_simple_state( + "switching to highway phase 2", Y_NULLPTR, Y_BEHAVIOR_METHOD_NO_EVENT( switching_to_highway_phase_2 ) ); +#endif + + + sxy::final_state& switching_to_highway_finished = + switching_to_highway_region.add_final_state( "switching to highway finished" ); + + // transitions + // in main region + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, l_highway_open ); + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, l_highway_open, switching_to_farmroad ); + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, switching_to_farmroad, farmroad_open ); +#ifdef Y_CPP03_BOOST + intersection_state_machine_.add_transition( EVENTS_EXIT_FARMROAD_OPEN, farmroad_open, switching_to_highway, + sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, + Y_BEHAVIOR_METHOD( intersection, cancel_timer_event_on_detector_off ) ); +#else + intersection_state_machine_.add_transition( EVENTS_EXIT_FARMROAD_OPEN, farmroad_open, switching_to_highway, + sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_BEHAVIOR_METHOD( cancel_timer_event_on_detector_off ) ); +#endif + + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, switching_to_highway, l_highway_open ); + + // inside highway open + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_highway, initialize_dummy ); + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, initialize_dummy, detector_junction ); +#ifdef Y_CPP03_BOOST + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, detector_junction, + l_minimum_time_not_elapsed_farmroad_waiting, sxy::transition_kind::EXTERNAL, + Y_GUARD_METHOD_NO_EVENT( intersection, check_detector_is_on ) ); + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, detector_junction, l_minimum_time_not_elapsed, + sxy::transition_kind::EXTERNAL, Y_GUARD_METHOD_NO_EVENT( intersection, check_detector_is_off ) ); +#else + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, detector_junction, + l_minimum_time_not_elapsed_farmroad_waiting, sxy::transition_kind::EXTERNAL, + Y_GUARD_METHOD_NO_EVENT( check_detector_is_on ) ); + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, detector_junction, l_minimum_time_not_elapsed, + sxy::transition_kind::EXTERNAL, Y_GUARD_METHOD_NO_EVENT( check_detector_is_off ) ); +#endif + + intersection_state_machine_.add_transition( + detector_on_event::get_event_id(), l_minimum_time_not_elapsed, l_minimum_time_not_elapsed_farmroad_waiting ); + intersection_state_machine_.add_transition( + timer_highway_minimum_time_event::get_event_id(), l_minimum_time_not_elapsed, l_minimum_time_elapsed ); + intersection_state_machine_.add_transition( + timer_highway_minimum_time_event::get_event_id(), l_minimum_time_not_elapsed_farmroad_waiting, highway_finished ); + intersection_state_machine_.add_transition( + detector_on_event::get_event_id(), l_minimum_time_elapsed, highway_finished ); + + // inside switching highway to farmroad + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_switching_to_farmroad, + l_switching_to_farmroad_phase_1 ); + intersection_state_machine_.add_transition( + timer_phase_1_event::get_event_id(), l_switching_to_farmroad_phase_1, state_switching_to_farmroad_phase_2 ); + intersection_state_machine_.add_transition( + timer_phase_2_event::get_event_id(), state_switching_to_farmroad_phase_2, switching_to_farmroad_finished ); + + // inside switching farmroad to highway + intersection_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_switching_to_highway, + l_switching_to_highway_phase_1 ); + intersection_state_machine_.add_transition( + timer_phase_1_event::get_event_id(), l_switching_to_highway_phase_1, l_switching_to_highway_phase_2 ); + intersection_state_machine_.add_transition( + timer_phase_2_event::get_event_id(), l_switching_to_highway_phase_2, switching_to_highway_finished ); +} + + +} diff --git a/yasmine/classic_farmroad/intersection.hpp b/examples/classic_farmroad/intersection.hpp similarity index 90% rename from yasmine/classic_farmroad/intersection.hpp rename to examples/classic_farmroad/intersection.hpp index db61d12..6839f33 100644 --- a/yasmine/classic_farmroad/intersection.hpp +++ b/examples/classic_farmroad/intersection.hpp @@ -20,7 +20,7 @@ #include "async_state_machine.hpp" -namespace sxy +namespace examples { @@ -35,9 +35,9 @@ class intersection Y_FINAL: private detector_callback private: - virtual void detector_on() override; - virtual void detector_off() override; - int fire_timed_event( const sxy::milliseconds _milliseconds, const event_sptr _event ); + virtual void detector_on() Y_OVERRIDE; + virtual void detector_off() Y_OVERRIDE; + int fire_timed_event( const sxy::milliseconds _milliseconds, const sxy::event_sptr _event ); void highway_open_entry(); void highway_open_exit() const; void switching_to_farmroad_phase_1(); @@ -55,10 +55,10 @@ class intersection Y_FINAL: private detector_callback void cancel_timer_event_on_detector_off( const sxy::event& _event ); - async_state_machine intersection_state_machine_; + sxy::async_state_machine intersection_state_machine_; traffic_light highway_traffic_light_; traffic_light farmroad_traffic_light_; - timed_event_creator timed_event_creator_; + sxy::timed_event_creator timed_event_creator_; detector detector_; unsigned int farmroad_maximum_time_event_handle_; }; diff --git a/yasmine/classic_farmroad/main.cpp b/examples/classic_farmroad/main.cpp similarity index 92% rename from yasmine/classic_farmroad/main.cpp rename to examples/classic_farmroad/main.cpp index 2814328..e8b9486 100644 --- a/yasmine/classic_farmroad/main.cpp +++ b/examples/classic_farmroad/main.cpp @@ -76,13 +76,13 @@ int main() #endif sxy::log_manager_template& log_manager = sxy::log_manager::get_instance(); log_manager.set_log_level( sxy::log_level::LL_DEBUG ); - log_manager.add_logger( std::make_unique< sxy::cout_logger >() ); - log_manager.start(); - yasmine::version::log_version(); + log_manager.add_logger( Y_MAKE_UNIQUE< sxy::cout_logger >() ); + log_manager.run(); + sxy::version::log_version(); try { - sxy::intersection intersection_of_roads; + examples::intersection intersection_of_roads; if( intersection_of_roads.start() ) { std::cout << "To quit press 'q'." << std::endl; @@ -106,8 +106,7 @@ catch ( ... ) error_code = 3; } -log_manager.stop(); -log_manager.join(); +log_manager.halt_and_join(); return( error_code ); } diff --git a/examples/classic_farmroad/random_generator.cpp b/examples/classic_farmroad/random_generator.cpp new file mode 100644 index 0000000..2a759b2 --- /dev/null +++ b/examples/classic_farmroad/random_generator.cpp @@ -0,0 +1,55 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "random_generator.hpp" + + +#ifdef Y_CPP03_BOOST +#include +#include +#endif + + +namespace examples +{ + + +random_generator::random_generator() + : random_device_() +{ + // Nothing to do... +} + + +random_generator::~random_generator() +{ + // Nothing to do... +} + + +const unsigned int random_generator::generate( const unsigned int _lower_extremity, const unsigned int _upper_extremity ) +{ + unsigned int number = 0; + +#ifndef Y_CPP03_BOOST + std::default_random_engine engine( random_device_() ); + std::uniform_int_distribution< int > uniform_distribution( _lower_extremity, _upper_extremity ); + number = uniform_distribution( engine ); +#else + boost::random::mt19937 engine( random_device_() ); + boost::random::uniform_int_distribution<> uniform_distribution( _lower_extremity, _upper_extremity ); + number = uniform_distribution( engine ); +#endif + + return( number ); +} + + +} diff --git a/examples/classic_farmroad/random_generator.hpp b/examples/classic_farmroad/random_generator.hpp new file mode 100644 index 0000000..67acdbe --- /dev/null +++ b/examples/classic_farmroad/random_generator.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef RANDOM_GENERATOR_63744576_1DBE_44C8_B2EE_3A3A1EE0B66F +#define RANDOM_GENERATOR_63744576_1DBE_44C8_B2EE_3A3A1EE0B66F + + +#include "non_copyable.hpp" + + +namespace examples +{ + + +class random_generator Y_FINAL +{ +public: + random_generator(); + ~random_generator(); + Y_NO_COPY( random_generator ) + + const unsigned int generate(const unsigned int _lower_extremity, const unsigned int _upper_extremity); + +private: + sxy::random_device random_device_; + + +}; + + +} + + +#endif diff --git a/yasmine/classic_farmroad/traffic_light.cpp b/examples/classic_farmroad/traffic_light.cpp similarity index 65% rename from yasmine/classic_farmroad/traffic_light.cpp rename to examples/classic_farmroad/traffic_light.cpp index 2e8b4b7..b81b457 100644 --- a/yasmine/classic_farmroad/traffic_light.cpp +++ b/examples/classic_farmroad/traffic_light.cpp @@ -16,7 +16,7 @@ #include "yasmine.hpp" -namespace sxy +namespace examples { @@ -24,10 +24,10 @@ namespace { -Y_EVENT_WITH_ID( EVENT_SWITCH_TO_RED_YELLOW, 1 ); -Y_EVENT_WITH_ID( EVENT_SWITCH_TO_GREEN, 2 ); -Y_EVENT_WITH_ID( EVENT_SWITCH_TO_YELLOW, 3 ); -Y_EVENT_WITH_ID( EVENT_SWITCH_TO_RED, 4 ); +Y_EVENT_WITH_ID( EVENT_SWITCH_TO_RED_YELLOW, 1 ) +Y_EVENT_WITH_ID( EVENT_SWITCH_TO_GREEN, 2 ) +Y_EVENT_WITH_ID( EVENT_SWITCH_TO_YELLOW, 3 ) +Y_EVENT_WITH_ID( EVENT_SWITCH_TO_RED, 4 ) } @@ -50,13 +50,13 @@ traffic_light::~traffic_light() Y_NOEXCEPT void traffic_light::start() { - traffic_light_state_machine_.start_state_machine(); + traffic_light_state_machine_.run(); } void traffic_light::stop() { - traffic_light_state_machine_.stop_state_machine(); + traffic_light_state_machine_.halt_and_join(); } @@ -110,33 +110,33 @@ void traffic_light::on_traffic_light_yellow() const void traffic_light::build_traffic_light_state_machine() { - composite_state& root = traffic_light_state_machine_.get_root_state(); - region& main_region = root.add_region( "main_region" ); - initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); + sxy::composite_state& root = traffic_light_state_machine_.get_root_state(); + sxy::region& main_region = root.add_region( "main_region" ); + sxy::initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); // states #ifdef Y_CPP03_BOOST - simple_state& red_state = - main_region.add_simple_state( "Red", Y_BEHAVIOUR_METHOD_NO_EVENT( traffic_light, on_traffic_light_red ) ); - simple_state& red_yellow_state = + sxy::simple_state& red_state = + main_region.add_simple_state( "Red", Y_BEHAVIOR_METHOD_NO_EVENT( traffic_light, on_traffic_light_red ) ); + sxy::simple_state& red_yellow_state = main_region.add_simple_state( "Red-Yellow", - Y_BEHAVIOUR_METHOD_NO_EVENT( traffic_light, on_traffic_light_red_yellow ) ); - simple_state& green_state = - main_region.add_simple_state( "Green", Y_BEHAVIOUR_METHOD_NO_EVENT( traffic_light, on_traffic_light_green ) ); - simple_state& yellow_state = - main_region.add_simple_state( "Yellow", Y_BEHAVIOUR_METHOD_NO_EVENT( traffic_light, on_traffic_light_yellow ) ); + Y_BEHAVIOR_METHOD_NO_EVENT( traffic_light, on_traffic_light_red_yellow ) ); + sxy::simple_state& green_state = + main_region.add_simple_state( "Green", Y_BEHAVIOR_METHOD_NO_EVENT( traffic_light, on_traffic_light_green ) ); + sxy::simple_state& yellow_state = + main_region.add_simple_state( "Yellow", Y_BEHAVIOR_METHOD_NO_EVENT( traffic_light, on_traffic_light_yellow ) ); #else - simple_state& red_state = main_region.add_simple_state( "Red", Y_BEHAVIOUR_METHOD_NO_EVENT( on_traffic_light_red ) ); - simple_state& red_yellow_state = - main_region.add_simple_state( "Red-Yellow", Y_BEHAVIOUR_METHOD_NO_EVENT( on_traffic_light_red_yellow ) ); - simple_state& green_state = main_region.add_simple_state( "Green", - Y_BEHAVIOUR_METHOD_NO_EVENT( on_traffic_light_green ) ); - simple_state& yellow_state = - main_region.add_simple_state( "Yellow", Y_BEHAVIOUR_METHOD_NO_EVENT( on_traffic_light_yellow ) ); + sxy::simple_state& red_state = main_region.add_simple_state( "Red", Y_BEHAVIOR_METHOD_NO_EVENT( on_traffic_light_red ) ); + sxy::simple_state& red_yellow_state = + main_region.add_simple_state( "Red-Yellow", Y_BEHAVIOR_METHOD_NO_EVENT( on_traffic_light_red_yellow ) ); + sxy::simple_state& green_state = main_region.add_simple_state( "Green", + Y_BEHAVIOR_METHOD_NO_EVENT( on_traffic_light_green ) ); + sxy::simple_state& yellow_state = + main_region.add_simple_state( "Yellow", Y_BEHAVIOR_METHOD_NO_EVENT( on_traffic_light_yellow ) ); #endif // transitions - traffic_light_state_machine_.add_transition( COMPLETION_EVENT_ID, initial_pseudostate, red_state ); + traffic_light_state_machine_.add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, red_state ); traffic_light_state_machine_.add_transition( EVENT_SWITCH_TO_RED_YELLOW::get_event_id(), red_state, red_yellow_state ); traffic_light_state_machine_.add_transition( EVENT_SWITCH_TO_GREEN::get_event_id(), red_yellow_state, green_state ); diff --git a/yasmine/classic_farmroad/traffic_light.hpp b/examples/classic_farmroad/traffic_light.hpp similarity index 94% rename from yasmine/classic_farmroad/traffic_light.hpp rename to examples/classic_farmroad/traffic_light.hpp index 2e12168..34c876d 100644 --- a/yasmine/classic_farmroad/traffic_light.hpp +++ b/examples/classic_farmroad/traffic_light.hpp @@ -18,11 +18,11 @@ #include "async_state_machine.hpp" -namespace sxy +namespace examples { -class traffic_light final +class traffic_light Y_FINAL { public: traffic_light( const std::string& _name, const std::string& _ascii_prefix ); @@ -45,7 +45,7 @@ class traffic_light final std::string display_road_name_with_ascii_prefix() const; - async_state_machine traffic_light_state_machine_; + sxy::async_state_machine traffic_light_state_machine_; const std::string name_; const std::string ascii_prefix_; }; diff --git a/yasmine/events_with_parameters/CMakeLists.txt b/examples/events_with_parameters/CMakeLists.txt similarity index 90% rename from yasmine/events_with_parameters/CMakeLists.txt rename to examples/events_with_parameters/CMakeLists.txt index d08f6aa..44f6c79 100644 --- a/yasmine/events_with_parameters/CMakeLists.txt +++ b/examples/events_with_parameters/CMakeLists.txt @@ -4,8 +4,8 @@ project(events_with_parameters) set(CMAKE_VERBOSE_MAKEFILE, 1) -set(HEADER_FILES "./../yasmine/*.hpp") -file(GLOB events_with_parameters_SRC "./../events_with_parameters/*.cpp" ${HEADER_FILES}) +set(HEADER_FILES "./../../libyasmine/include/*.hpp") +file(GLOB events_with_parameters_SRC "./*.cpp" ${HEADER_FILES}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -22,9 +22,9 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQ endif() if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\"") + set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\" -D \"Y_NO_VARIADIC_MACRO\"") else() - set(extra_flags "${extra_flags} -std=c++14 -Wall -g") + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") endif() # yasmine's preprocessor definitions @@ -102,7 +102,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(extra_flags "${extra_flags} /Fo") #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") + #set(extra_flags "${extra_flags} /NXCOMPAT") # yasmine's preprocessor definitions set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") @@ -151,7 +151,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(events_with_parameters ${events_with_parameters_SRC}) -include_directories("./../yasmine") +include_directories("./../../libyasmine/include") #using boost if("${CPP_VERSION}" STREQUAL "03") @@ -163,12 +163,12 @@ endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (events_with_parameters LINK_PUBLIC yasmine pthread boost_system boost_thread boost_chrono) + target_link_libraries (events_with_parameters LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) else() - target_link_libraries (events_with_parameters LINK_PUBLIC yasmine pthread) + target_link_libraries (events_with_parameters LINK_PUBLIC libyasmine pthread) endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (events_with_parameters LINK_PUBLIC yasmine) + target_link_libraries (events_with_parameters LINK_PUBLIC libyasmine) endif() diff --git a/yasmine/events_with_parameters/class_method_downcast.cpp b/examples/events_with_parameters/class_method_downcast.cpp similarity index 57% rename from yasmine/events_with_parameters/class_method_downcast.cpp rename to examples/events_with_parameters/class_method_downcast.cpp index dc0c950..eca41da 100644 --- a/yasmine/events_with_parameters/class_method_downcast.cpp +++ b/examples/events_with_parameters/class_method_downcast.cpp @@ -14,17 +14,17 @@ #include -namespace sxy +namespace examples { class_method_downcast::class_method_downcast() { state_machine_uptr state_machine = setup_state_machine( "downcast_event_state_machine" ); - state_machine->start_state_machine(); + state_machine->run(); state_machine->fire_event( event_1::create( "parameter 1 test" ) ); state_machine->fire_event( event_2::create( 2, 3.4 ) ); - state_machine->stop_state_machine(); + state_machine->halt(); } @@ -41,7 +41,7 @@ void class_method_downcast::do_something_event_2_parameters( const event_2& _eve _event.get_param_2() << std::endl; } #else -void class_method_downcast::do_something_event_2_parameters( const event& _event ) +void class_method_downcast::do_something_event_2_parameters( const sxy::event& _event ) { const event_2* specialized_event = dynamic_cast< const event_2* >( &_event ); if( specialized_event ) @@ -51,7 +51,7 @@ void class_method_downcast::do_something_event_2_parameters( const event& _event } else { - const completion_event* specialized_event2 = dynamic_cast< const completion_event* >( &_event ); + const sxy::completion_event* specialized_event2 = dynamic_cast< const sxy::completion_event* >( &_event ); if( specialized_event2 ) { do_something_event_0_parameters( _event ); @@ -71,7 +71,7 @@ void class_method_downcast::do_something_event_1_parameter( const event_1& _even std::cout << "Parameter of event " << _event.get_name() << " is: " << _event.get_param() << std::endl; } #else -void class_method_downcast::do_something_event_1_parameter( const event& _event ) +void class_method_downcast::do_something_event_1_parameter( const sxy::event& _event ) { const event_1* specialized_event = dynamic_cast< const event_1* >( &_event ); if( specialized_event ) @@ -87,14 +87,15 @@ void class_method_downcast::do_something_event_1_parameter( const event& _event #ifndef Y_CPP03_BOOST -void class_method_downcast::do_something_event_0_parameters( const completion_event& _event ) +void class_method_downcast::do_something_event_0_parameters( const sxy::completion_event& _event ) { + Y_UNUSED_PARAMETER( _event ); std::cout << "Completion event has no parameters." << std::endl; } #else -void class_method_downcast::do_something_event_0_parameters( const event& _event ) +void class_method_downcast::do_something_event_0_parameters( const sxy::event& _event ) { - const completion_event* specialized_event = dynamic_cast< const completion_event* >( &_event ); + const sxy::completion_event* specialized_event = dynamic_cast< const sxy::completion_event* >( &_event ); if( specialized_event ) { std::cout << "Completion event has no parameters." << std::endl; @@ -110,45 +111,45 @@ void class_method_downcast::do_something_event_0_parameters( const event& _event state_machine_uptr class_method_downcast::setup_state_machine( const std::string& _name ) { state_machine_uptr state_machine = Y_MAKE_UNIQUE< sxy::state_machine >( _name ); - composite_state& root_state = state_machine->get_root_state(); - region& main_region = root_state.add_region( "main region" ); - initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); + sxy::composite_state& root_state = state_machine->get_root_state(); + sxy::region& main_region = root_state.add_region( "main region" ); + sxy::initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); #ifndef Y_CPP03_BOOST - simple_state& simple_state_1 = main_region.add_simple_state( "1", - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters, + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters, &class_method_downcast::do_something_event_0_parameters ), - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters, + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters, &class_method_downcast::do_something_event_0_parameters), - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ) ); + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ) ); - simple_state& simple_state_2 = main_region.add_simple_state( "2", - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ), - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ), - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters ) ); + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ), + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ), + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters ) ); - state_machine->add_transition( COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_0_parameters ) ); + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_0_parameters ) ); state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ) ); + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_1_parameter ) ); state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOUR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters ) ); + Y_BEHAVIOR_METHOD_EVENT( &class_method_downcast::do_something_event_2_parameters ) ); #else - simple_state& simple_state_1 = main_region.add_simple_state( "1", - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ) ); - - simple_state& simple_state_2 = main_region.add_simple_state( "2", - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ) ); - - state_machine->add_transition( COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_0_parameters, this, sxy::_1 ) ) ); + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ) ); + + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_0_parameters, this, sxy::_1 ) ) ); state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ) ); + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_1_parameter, this, sxy::_1 ) ) ); state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - sxy::behaviour_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ) ); + sxy::behavior_function( sxy::bind( &class_method_downcast::do_something_event_2_parameters, this, sxy::_1 ) ) ); #endif diff --git a/yasmine/events_with_parameters/class_method_downcast.hpp b/examples/events_with_parameters/class_method_downcast.hpp similarity index 80% rename from yasmine/events_with_parameters/class_method_downcast.hpp rename to examples/events_with_parameters/class_method_downcast.hpp index 526ca79..f7f6b53 100644 --- a/yasmine/events_with_parameters/class_method_downcast.hpp +++ b/examples/events_with_parameters/class_method_downcast.hpp @@ -16,11 +16,11 @@ #include "events.hpp" -namespace sxy +namespace examples { -typedef Y_UNIQUE_PTR< sxy::state_machine > state_machine_uptr; +typedef sxy::Y_UNIQUE_PTR< sxy::state_machine > state_machine_uptr; class class_method_downcast Y_FINAL @@ -34,11 +34,11 @@ class class_method_downcast Y_FINAL #ifndef Y_CPP03_BOOST void do_something_event_2_parameters( const event_2& _event ); void do_something_event_1_parameter( const event_1& _event ); - void do_something_event_0_parameters( const completion_event& _event ); + void do_something_event_0_parameters( const sxy::completion_event& _event ); #else - void do_something_event_2_parameters( const event& _event ); - void do_something_event_1_parameter( const event& _event ); - void do_something_event_0_parameters( const event& _event ); + void do_something_event_2_parameters( const sxy::event& _event ); + void do_something_event_1_parameter( const sxy::event& _event ); + void do_something_event_0_parameters( const sxy::event& _event ); #endif state_machine_uptr setup_state_machine( const std::string& _name ); }; diff --git a/yasmine/events_with_parameters/downcast_event.cpp b/examples/events_with_parameters/downcast_event.cpp similarity index 65% rename from yasmine/events_with_parameters/downcast_event.cpp rename to examples/events_with_parameters/downcast_event.cpp index 53b02b4..c15670e 100644 --- a/yasmine/events_with_parameters/downcast_event.cpp +++ b/examples/events_with_parameters/downcast_event.cpp @@ -24,7 +24,7 @@ typedef sxy::Y_UNIQUE_PTR< sxy::state_machine > state_machine_uptr; void do_something_event_2_parameters( const sxy::event& _event ) { - const sxy::event_2* event_with_param = dynamic_cast< const sxy::event_2* >( &_event ); + const examples::event_2* event_with_param = dynamic_cast< const examples::event_2* >( &_event ); if( event_with_param ) { @@ -40,7 +40,7 @@ void do_something_event_2_parameters( const sxy::event& _event ) void do_something_event_1_parameter( const sxy::event& _event ) { - const sxy::event_1* event_with_param = dynamic_cast< const sxy::event_1* >( &_event ); + const examples::event_1* event_with_param = dynamic_cast< const examples::event_1* >( &_event ); if( event_with_param ) { @@ -56,6 +56,7 @@ void do_something_event_1_parameter( const sxy::event& _event ) void do_something_event_0_parameters( const sxy::event& _event ) { + Y_UNUSED_PARAMETER( _event ); std::cout << "Event with no parameters." << std::endl; } @@ -63,31 +64,31 @@ void do_something_event_0_parameters( const sxy::event& _event ) } -namespace sxy +namespace examples { state_machine_uptr setup_state_machine( const std::string& _name ) { state_machine_uptr state_machine = Y_MAKE_UNIQUE< sxy::state_machine >( _name ); - composite_state& root_state = state_machine->get_root_state(); - region& main_region = root_state.add_region( "main region" ); - initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); - simple_state& simple_state_1 = main_region.add_simple_state( "1", - Y_BEHAVIOUR_FUNCTION( do_something_event_2_parameters ), - Y_BEHAVIOUR_FUNCTION( do_something_event_2_parameters ), - Y_BEHAVIOUR_FUNCTION( do_something_event_1_parameter ) ); - simple_state& simple_state_2 = main_region.add_simple_state( "2", - Y_BEHAVIOUR_FUNCTION( do_something_event_1_parameter ), - Y_BEHAVIOUR_FUNCTION( do_something_event_1_parameter ), - Y_BEHAVIOUR_FUNCTION( do_something_event_2_parameters ) ); - - state_machine->add_transition( COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - Y_BEHAVIOUR_FUNCTION( do_something_event_0_parameters ) ); + sxy::composite_state& root_state = state_machine->get_root_state(); + sxy::region& main_region = root_state.add_region( "main region" ); + sxy::initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + Y_BEHAVIOR_FUNCTION( do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION( do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION( do_something_event_1_parameter ) ); + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + Y_BEHAVIOR_FUNCTION( do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION( do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION( do_something_event_2_parameters ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + Y_BEHAVIOR_FUNCTION( do_something_event_0_parameters ) ); state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - Y_BEHAVIOUR_FUNCTION( do_something_event_1_parameter ) ); + Y_BEHAVIOR_FUNCTION( do_something_event_1_parameter ) ); state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOUR_FUNCTION( do_something_event_2_parameters ) ); + Y_BEHAVIOR_FUNCTION( do_something_event_2_parameters ) ); return( sxy::move( state_machine ) ); } @@ -95,10 +96,10 @@ state_machine_uptr setup_state_machine( const std::string& _name ) void downcast_event() { state_machine_uptr state_machine = setup_state_machine( "downcast_event_state_machine" ); - state_machine->start_state_machine(); + state_machine->run(); state_machine->fire_event( event_1::create( "parameter 1 test" ) ); state_machine->fire_event( event_2::create( 2, 3.4 ) ); - state_machine->stop_state_machine(); + state_machine->halt(); } diff --git a/yasmine/events_with_parameters/downcast_event.hpp b/examples/events_with_parameters/downcast_event.hpp similarity index 98% rename from yasmine/events_with_parameters/downcast_event.hpp rename to examples/events_with_parameters/downcast_event.hpp index dfc454b..32bebc9 100644 --- a/yasmine/events_with_parameters/downcast_event.hpp +++ b/examples/events_with_parameters/downcast_event.hpp @@ -13,7 +13,7 @@ #define DOWNCAST_EVENT_59195EF3_F9F0_47C4_BF1F_67C3AC807C0B -namespace sxy +namespace examples { void downcast_event(); diff --git a/yasmine/events_with_parameters/events.hpp b/examples/events_with_parameters/events.hpp similarity index 77% rename from yasmine/events_with_parameters/events.hpp rename to examples/events_with_parameters/events.hpp index d2a013e..e3869e5 100644 --- a/yasmine/events_with_parameters/events.hpp +++ b/examples/events_with_parameters/events.hpp @@ -16,26 +16,21 @@ #include "yasmine.hpp" -namespace sxy -{ - - namespace - { - - -#ifndef Y_CPP03_BOOST - constexpr event_id EVENT_1 = 1; - constexpr event_id EVENT_2 = 2; -#else +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) #define EVENT_1 1 #define EVENT_2 2 +#else +constexpr sxy::event_id EVENT_1 = 1; +constexpr sxy::event_id EVENT_2 = 2; #endif -} +namespace examples +{ + - Y_EVENT_1PARAM_WITH_ID(event_1, std::string, get_param, EVENT_1); - Y_EVENT_2PARAM_WITH_ID(event_2, int, get_param_1, double, get_param_2, EVENT_2); + Y_EVENT_1PARAM_WITH_ID( event_1, std::string, get_param, EVENT_1 ) + Y_EVENT_2PARAM_WITH_ID( event_2, int, get_param_1, double, get_param_2, EVENT_2 ) } diff --git a/yasmine/events_with_parameters/events_with_parameters.cpp b/examples/events_with_parameters/events_with_parameters.cpp similarity index 92% rename from yasmine/events_with_parameters/events_with_parameters.cpp rename to examples/events_with_parameters/events_with_parameters.cpp index d5229d9..b51adb6 100644 --- a/yasmine/events_with_parameters/events_with_parameters.cpp +++ b/examples/events_with_parameters/events_with_parameters.cpp @@ -18,12 +18,12 @@ int main() { std::cout << "#1 Downcast event scenario:" << std::endl; - sxy::downcast_event(); + examples::downcast_event(); std::cout << "#2 Use function downcast scenario:" << std::endl; - sxy::use_function_downcast(); + examples::use_function_downcast(); std::cout << "#3 Use class method downcast scenario:" << std::endl; - sxy::use_method_downcast(); + examples::use_method_downcast(); } diff --git a/yasmine/events_with_parameters/events_with_parameters.vcxproj b/examples/events_with_parameters/events_with_parameters.vcxproj similarity index 89% rename from yasmine/events_with_parameters/events_with_parameters.vcxproj rename to examples/events_with_parameters/events_with_parameters.vcxproj index 82e2d98..5c81038 100644 --- a/yasmine/events_with_parameters/events_with_parameters.vcxproj +++ b/examples/events_with_parameters/events_with_parameters.vcxproj @@ -165,76 +165,82 @@ - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - - + + + - - + + + - - - + + + + + - - + + - - + + - - - + + + + - Level3 Disabled true @@ -297,7 +303,6 @@ - Level3 MaxSpeed true true @@ -349,6 +354,7 @@ true true true + MachineX64 diff --git a/yasmine/events_with_parameters/events_with_parameters.vcxproj.filters b/examples/events_with_parameters/events_with_parameters.vcxproj.filters similarity index 100% rename from yasmine/events_with_parameters/events_with_parameters.vcxproj.filters rename to examples/events_with_parameters/events_with_parameters.vcxproj.filters diff --git a/yasmine/events_with_parameters/function_downcast.cpp b/examples/events_with_parameters/function_downcast.cpp similarity index 62% rename from yasmine/events_with_parameters/function_downcast.cpp rename to examples/events_with_parameters/function_downcast.cpp index 5b65280..caf2e7f 100644 --- a/yasmine/events_with_parameters/function_downcast.cpp +++ b/examples/events_with_parameters/function_downcast.cpp @@ -25,7 +25,8 @@ typedef sxy::Y_UNIQUE_PTR< sxy::state_machine > state_machine_uptr; #ifndef Y_CPP03_BOOST void do_something_event_0_parameters( const sxy::completion_event& _event ) -{ +{ + Y_UNUSED_PARAMETER( _event ); std::cout << "Completion event has no parameters." << std::endl; } #else @@ -45,14 +46,14 @@ void do_something_event_0_parameters( const sxy::event& _event ) #ifndef Y_CPP03_BOOST -void do_something_event_1_parameter( const sxy::event_1& _event ) +void do_something_event_1_parameter( const examples::event_1& _event ) { std::cout << "Parameter of event " << _event.get_name() << " is: " << _event.get_param() << std::endl; } #else void do_something_event_1_parameter( const sxy::event& _event ) { - const sxy::event_1* specialized_event = dynamic_cast< const sxy::event_1* >( &_event ); + const examples::event_1* specialized_event = dynamic_cast< const examples::event_1* >( &_event ); if( specialized_event ) { std::cout << "Parameter of event " << specialized_event->get_name() << " is: " << specialized_event->get_param() << std::endl; @@ -66,7 +67,7 @@ void do_something_event_1_parameter( const sxy::event& _event ) #ifndef Y_CPP03_BOOST -void do_something_event_2_parameters( const sxy::event_2& _event ) +void do_something_event_2_parameters( const examples::event_2& _event ) { std::cout << "Parameters of event " << _event.get_name() << " are:\n" << _event.get_param_1() << "\n" << _event.get_param_2() << std::endl; @@ -74,11 +75,11 @@ void do_something_event_2_parameters( const sxy::event_2& _event ) #else void do_something_event_2_parameters( const sxy::event& _event ) { - const sxy::event_2* specialized_event = dynamic_cast< const sxy::event_2* >( &_event ); + const examples::event_2* specialized_event = dynamic_cast< const examples::event_2* >( &_event ); if( specialized_event ) { - std::cout << "Parameters of event " << specialized_event->get_name() << " are:\n" << specialized_event->get_param_1() << "\n" << - specialized_event->get_param_2() << std::endl; + std::cout << "Parameters of event " << specialized_event->get_name() << " are:\n" + << specialized_event->get_param_1() << "\n" << specialized_event->get_param_2() << std::endl; } else { @@ -104,36 +105,36 @@ state_machine_uptr setup_state_machine2( const std::string& _name ) sxy::initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); #ifndef Y_CPP03_BOOST sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_0_parameters, &do_something_event_2_parameters ), - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_0_parameters, &do_something_event_2_parameters ), - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_1_parameter ) ); + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_0_parameters, &do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_0_parameters, &do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_1_parameter ) ); sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_1_parameter ), - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_1_parameter ), - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_2_parameters ) ); - - state_machine->add_transition( sxy::COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_0_parameters ) ); - state_machine->add_transition( sxy::EVENT_1, simple_state_1, simple_state_2, - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_1_parameter ) ); - state_machine->add_transition( sxy::EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOUR_FUNCTION_EVENT( &do_something_event_2_parameters ) ); + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_2_parameters ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_0_parameters ) ); + state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_1_parameter ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + Y_BEHAVIOR_FUNCTION_EVENT( &do_something_event_2_parameters ) ); #else sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - sxy::behaviour_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ) ); + sxy::behavior_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ) ); sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - sxy::behaviour_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ), - sxy::behaviour_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ) ); + sxy::behavior_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ), + sxy::behavior_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ) ); - state_machine->add_transition( COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - sxy::behaviour_function( sxy::bind( &do_something_event_0_parameters, sxy::_1 ) ) ); + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + sxy::behavior_function( sxy::bind( &do_something_event_0_parameters, sxy::_1 ) ) ); state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - sxy::behaviour_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ) ); + sxy::behavior_function( sxy::bind( &do_something_event_1_parameter, sxy::_1 ) ) ); state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - sxy::behaviour_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ) ); + sxy::behavior_function( sxy::bind( &do_something_event_2_parameters, sxy::_1 ) ) ); #endif @@ -144,17 +145,17 @@ state_machine_uptr setup_state_machine2( const std::string& _name ) } -namespace sxy +namespace examples { void use_function_downcast() { state_machine_uptr state_machine = setup_state_machine2( "downcast_event_state_machine" ); - state_machine->start_state_machine(); + state_machine->run(); state_machine->fire_event( event_1::create( "parameter 1 test" ) ); state_machine->fire_event( event_2::create( 2, 3.4 ) ); - state_machine->stop_state_machine(); + state_machine->halt(); } diff --git a/yasmine/events_with_parameters/function_downcast.hpp b/examples/events_with_parameters/function_downcast.hpp similarity index 98% rename from yasmine/events_with_parameters/function_downcast.hpp rename to examples/events_with_parameters/function_downcast.hpp index 0e31d69..f6ea63e 100644 --- a/yasmine/events_with_parameters/function_downcast.hpp +++ b/examples/events_with_parameters/function_downcast.hpp @@ -13,7 +13,7 @@ #define FUNCTION_DOWNCAST_F8097BC3_DB64_4220_B2F7_7113B069EB7D -namespace sxy +namespace examples { void use_function_downcast(); diff --git a/yasmine/forty_two/CMakeLists.txt b/examples/forty_two/CMakeLists.txt similarity index 91% rename from yasmine/forty_two/CMakeLists.txt rename to examples/forty_two/CMakeLists.txt index 39a16ac..eeb2cbe 100644 --- a/yasmine/forty_two/CMakeLists.txt +++ b/examples/forty_two/CMakeLists.txt @@ -4,8 +4,8 @@ project(forty_two) set(CMAKE_VERBOSE_MAKEFILE, 1) -set(HEADER_FILES "./../yasmine/*.hpp") -file(GLOB forty_two_SRC "./../forty_two/*.cpp" ${HEADER_FILES}) +set(HEADER_FILES "./../../libyasmine/include/*.hpp") +file(GLOB forty_two_SRC "./*.cpp" ${HEADER_FILES}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -22,9 +22,9 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQ endif() if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\"") + set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\" -D \"Y_NO_VARIADIC_MACRO\"") else() - set(extra_flags "${extra_flags} -std=c++14 -Wall -g") + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") endif() # yasmine's preprocessor definitions @@ -102,7 +102,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(extra_flags "${extra_flags} /Fo") #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") + #set(extra_flags "${extra_flags} /NXCOMPAT") # yasmine's preprocessor definitions set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") @@ -151,7 +151,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(forty_two ${forty_two_SRC}) -include_directories("./../yasmine") +include_directories("./../../libyasmine/include") #using boost if("${CPP_VERSION}" STREQUAL "03") @@ -163,12 +163,12 @@ endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (forty_two LINK_PUBLIC yasmine pthread boost_system boost_thread boost_chrono) + target_link_libraries (forty_two LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) else() - target_link_libraries (forty_two LINK_PUBLIC yasmine pthread) + target_link_libraries (forty_two LINK_PUBLIC libyasmine pthread) endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (forty_two LINK_PUBLIC yasmine) + target_link_libraries (forty_two LINK_PUBLIC libyasmine) endif() diff --git a/examples/forty_two/forty_two.cpp b/examples/forty_two/forty_two.cpp new file mode 100644 index 0000000..9dea122 --- /dev/null +++ b/examples/forty_two/forty_two.cpp @@ -0,0 +1,394 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "forty_two.hpp" + +#include +#include +#include + +#ifdef Y_PROFILER + #include "conversion.hpp" +#endif + +namespace examples +{ + +Y_EVENT_WITH_ID( event_A, 1 ) +Y_EVENT_WITH_ID( event_B, 2 ) +Y_EVENT_WITH_ID( event_C, 3 ) +Y_EVENT_WITH_ID( event_D, 4 ) +Y_EVENT_WITH_ID( event_E, 5 ) +Y_EVENT_WITH_ID( event_F, 6 ) +Y_EVENT_WITH_ID( event_G, 7 ) +Y_EVENT_WITH_ID( event_H, 8 ) +Y_EVENT_WITH_ID( event_I, 9 ) +Y_EVENT_WITH_ID( event_J, 10 ) +Y_EVENT_WITH_ID( event_K, 11 ) +Y_EVENT_WITH_ID( event_L, 12 ) +Y_EVENT_WITH_ID( event_M, 13 ) +Y_EVENT_WITH_ID( event_N, 14 ) +Y_EVENT_WITH_ID( event_O, 15 ) +Y_EVENT_WITH_ID( event_P, 16 ) +Y_EVENT_WITH_ID( event_Q, 17 ) +Y_EVENT_WITH_ID( event_R, 18 ) +Y_EVENT_WITH_ID( event_S, 19 ) +Y_EVENT_WITH_ID( event_T, 20 ) + + +forty_two::forty_two( const sxy::uint32_t _max_iterations ) + : state_machine_( build_state_machine() ), + iterations_( 0 ), + max_iterations_( _max_iterations ) +{ + Y_ASSERT( check_state_machine(), "State machine has defects!" ); + run(); +} + + +forty_two::~forty_two() Y_NOEXCEPT +{ + // Nothing to do... +} + + +forty_two::state_machine_uptr forty_two::build_state_machine() +{ + sxy::Y_UNIQUE_PTR< sxy::state_machine > l_state_machine = + Y_MAKE_UNIQUE< sxy::state_machine >( "forty two state machine" ); + sxy::composite_state& root_state = l_state_machine->get_root_state(); + sxy::region& main_region = root_state.add_region( "main region" ); + sxy::initial_pseudostate& i1 = main_region.add_initial_pseudostate( "initial pseudostate 1" ); +#ifdef Y_CPP03_BOOST + sxy::simple_state& s1 = + main_region.add_simple_state( "s1", Y_BEHAVIOR_METHOD_NO_EVENT( forty_two, increment_iterations ) ); +#else + sxy::simple_state& s1 = main_region.add_simple_state( "s1", Y_BEHAVIOR_METHOD_NO_EVENT( increment_iterations ) ); +#endif + sxy::simple_state& s2 = main_region.add_simple_state( "s2" ); + sxy::composite_state& s3 = main_region.add_composite_state( "s3" ); + sxy::region& r3_1 = s3.add_region( "s3_r1" ); + sxy::region& r3_2 = s3.add_region( "s3_r2" ); + sxy::region& r3_3 = s3.add_region( "s3_r3" ); + sxy::initial_pseudostate& i2 = r3_1.add_initial_pseudostate( "initial pseudostate 2" ); + sxy::simple_state& s3_1_1 = r3_1.add_simple_state( "s3_r1_s1" ); + sxy::final_state& final1 = r3_1.add_final_state( "final state 1" ); + sxy::initial_pseudostate& i3 = r3_2.add_initial_pseudostate( "initial pseudostate 3" ); + sxy::composite_state& s3_2_1 = r3_2.add_composite_state( "s3_r2_s1" ); + sxy::region& r3_2_1_1 = s3_2_1.add_region( "s3_r2_s1_r1" ); + sxy::initial_pseudostate& i4 = r3_2_1_1.add_initial_pseudostate( "initial pseudostate 4" ); + sxy::composite_state& s3_2_1_1_1 = r3_2_1_1.add_composite_state( "s3_r2_s1_r1_s1" ); + sxy::region& r3_2_1_1_1_1 = s3_2_1_1_1.add_region( "s3_r2_s1_r1_s1_r1" ); + sxy::initial_pseudostate& i5 = r3_2_1_1_1_1.add_initial_pseudostate( "initial pseudostate 5" ); + sxy::simple_state& s3_2_1_1_1_1_1 = r3_2_1_1_1_1.add_simple_state( "s3_r2_s1_r1_s1_r1_s1" ); + sxy::final_state& final2 = r3_2.add_final_state( "final state 2" ); + sxy::initial_pseudostate& i6 = r3_3.add_initial_pseudostate( "initial pseudostate 6" ); + sxy::simple_state& s3_3_1 = r3_3.add_simple_state( "s3_r3_s1" ); + sxy::final_state& final3 = r3_3.add_final_state( "final state 3" ); + sxy::simple_state& s4 = main_region.add_simple_state( "s4" ); + sxy::composite_state& s5 = main_region.add_composite_state( "s5" ); + sxy::region& r5_1 = s5.add_region( "s5_r1" ); + sxy::composite_state& s5_1_1 = r5_1.add_composite_state( "s5_r1_s1" ); + sxy::region& r5_1_1_1 = s5_1_1.add_region( "s5_r1_s1_r1" ); + sxy::composite_state& s5_1_1_1_1 = r5_1_1_1.add_composite_state( "s5_r1_s1_r1_s1" ); + sxy::region& r5_1_1_1_1_1 = s5_1_1_1_1.add_region( "s5_r1_s1_r1_s1_r1" ); + sxy::simple_state& s5_1_1_1_1_1_1 = r5_1_1_1_1_1.add_simple_state( "s5_r1_s1_r1_s1_r1_s1" ); + sxy::simple_state& s5_1_1_1_1_1_2 = r5_1_1_1_1_1.add_simple_state( "s5_r1_s1_r1_s1_r1_s2" ); + sxy::exit_point& exit1 = s5_1_1_1_1.add_exit_point( "exit1" ); + sxy::exit_point& exit2 = s5.add_exit_point( "exit2" ); + sxy::simple_state& s6 = main_region.add_simple_state( "s6" ); + sxy::composite_state& s7 = main_region.add_composite_state( "s7" ); + sxy::region& r7_1 = s7.add_region( "s7_r1" ); + sxy::composite_state& s7_1_1 = r7_1.add_composite_state( "s7_r1_s1" ); + sxy::region& r7_1_1_1 = s7_1_1.add_region( "s7_r1_s1_r1" ); + sxy::composite_state& s7_1_1_1_1 = r7_1_1_1.add_composite_state( "s7_r1_s1_r1_s1" ); + sxy::region& r7_1_1_1_1_1 = s7_1_1_1_1.add_region( "s7_r1_s1_r1_s1_r1" ); + sxy::composite_state& s7_1_1_1_1_1_1 = r7_1_1_1_1_1.add_composite_state( "s7_r1_s1_r1_s1_r1_s1" ); + sxy::region& r7_1_1_1_1_1_1_1 = s7_1_1_1_1_1_1.add_region( "s7_r1_s1_r1_s1_r1_s1_r1" ); + sxy::simple_state& s7_1_1_1_1_1_1_1_1 = r7_1_1_1_1_1_1_1.add_simple_state( "s7_r1_s1_r1_s1_r1_s1_r1_s1" ); + sxy::entry_point& entry1 = s7_1_1_1_1.add_entry_point( "entry1" ); + sxy::entry_point& entry2 = s7.add_entry_point( "entry2" ); + sxy::simple_state& s8 = main_region.add_simple_state( "s8" ); + sxy::simple_state& s9 = main_region.add_simple_state( "s9" ); + sxy::composite_state& s10 = main_region.add_composite_state( "s10" ); + sxy::region& r10_1 = s10.add_region( "s10_r1" ); + sxy::initial_pseudostate& i7 = r10_1.add_initial_pseudostate( "initial pseudostate 7" ); + sxy::composite_state& s10_1_1 = r10_1.add_composite_state( "s10_r1_s1" ); + sxy::region& r10_1_1_1 = s10_1_1.add_region( "s10_r1_s1_r1" ); + sxy::initial_pseudostate& i8 = r10_1_1_1.add_initial_pseudostate( "initial pseudostate 8" ); + sxy::simple_state& s10_1_1_1_1 = r10_1_1_1.add_simple_state( "s10_r1_s1_r1_s1" ); + sxy::composite_state& s10_1_1_1_2 = r10_1_1_1.add_composite_state( "s10_r1_s1_r1_s2" ); + sxy::region& r10_1_1_1_2_1 = s10_1_1_1_2.add_region( "s10_r1_s1_r1_s2_r1" ); + sxy::initial_pseudostate& i9 = r10_1_1_1_2_1.add_initial_pseudostate( "initial pseudostate 9" ); + sxy::simple_state& s10_1_1_1_2_1_1 = r10_1_1_1_2_1.add_simple_state( "r10_r1_s1_r1_s2_r1_s1" ); + sxy::simple_state& s10_1_2 = r10_1.add_simple_state( "s10_r1_s2" ); + sxy::simple_state& s10_1_3 = r10_1.add_simple_state( "s10_r1_s3" ); + sxy::shallow_history& shallow_history1 = s10.add_shallow_history( "shallow history 1" ); + sxy::simple_state& s11 = main_region.add_simple_state( "s11" ); + sxy::simple_state& s12 = main_region.add_simple_state( "s12" ); + sxy::composite_state& s13 = main_region.add_composite_state( "s13" ); + sxy::region& r13_1 = s13.add_region( "s13_r1" ); + sxy::initial_pseudostate& i10 = r13_1.add_initial_pseudostate( "initial pseudostate 10" ); + sxy::composite_state& s13_1_1 = r13_1.add_composite_state( "s13_r1_s1" ); + sxy::region& r13_1_1_1 = s13_1_1.add_region( "s13_r1_s1_r1" ); + sxy::initial_pseudostate& i11 = r13_1_1_1.add_initial_pseudostate( "initial pseudostate 11" ); + sxy::simple_state& s13_1_1_1_1 = r13_1_1_1.add_simple_state( "s13_r1_s1_r1_s1" ); + sxy::composite_state& s13_1_1_1_2 = r13_1_1_1.add_composite_state( "s13_r1_s1_r1_s2" ); + sxy::region& r13_1_1_1_2_1 = s13_1_1_1_2.add_region( "s13_r1_s1_r1_s2_r1" ); + sxy::initial_pseudostate& i12 = r13_1_1_1_2_1.add_initial_pseudostate( "initial pseudostate 12" ); + sxy::simple_state& s13_1_1_1_2_1_1 = r13_1_1_1_2_1.add_simple_state( "r13_r1_s1_r1_s2_r1_s1" ); + sxy::simple_state& s13_1_2 = r13_1.add_simple_state( "s13_r1_s2" ); + sxy::simple_state& s13_1_3 = r13_1.add_simple_state( "s13_r1_s3" ); + sxy::shallow_history& deep_history1 = s13.add_shallow_history( "deep history 1" ); + sxy::simple_state& s14 = main_region.add_simple_state( "s14" ); + sxy::simple_state& s15 = main_region.add_simple_state( "s15" ); + sxy::fork& fork1 = main_region.add_fork( "fork 1" ); + sxy::composite_state& s16 = main_region.add_composite_state( "s16" ); + sxy::region& r16_1 = s16.add_region( "s16_r1" ); + sxy::region& r16_2 = s16.add_region( "s16_r2" ); + sxy::region& r16_3 = s16.add_region( "s16_r3" ); + sxy::region& r16_4 = s16.add_region( "s16_r4" ); + sxy::initial_pseudostate& i13 = r16_1.add_initial_pseudostate( "initial pseudostate 13" ); + sxy::simple_state& s16_1_1 = r16_1.add_simple_state( "s16_r1_s1" ); + sxy::simple_state& s16_1_2 = r16_1.add_simple_state( "s16_r1_s2" ); + sxy::simple_state& s16_1_3 = r16_1.add_simple_state( "s16_r1_s3" ); + sxy::simple_state& s16_2_1 = r16_2.add_simple_state( "s16_r2_s1" ); + sxy::simple_state& s16_2_2 = r16_2.add_simple_state( "s16_r2_s2" ); + sxy::simple_state& s16_2_3 = r16_2.add_simple_state( "s16_r2_s3" ); + sxy::simple_state& s16_3_1 = r16_3.add_simple_state( "s16_r3_s1" ); + sxy::simple_state& s16_3_2 = r16_3.add_simple_state( "s16_r3_s2" ); + sxy::simple_state& s16_4_1 = r16_4.add_simple_state( "s16_r4_s1" ); + sxy::simple_state& s16_4_2 = r16_4.add_simple_state( "s16_r4_s2" ); + sxy::simple_state& s16_4_3 = r16_4.add_simple_state( "s16_r4_s3" ); + sxy::simple_state& s17 = main_region.add_simple_state( "s17" ); + sxy::join& join1 = main_region.add_join( "join 1" ); + sxy::simple_state& s18 = main_region.add_simple_state( "s18" ); + sxy::choice& choice1 = main_region.add_choice( "choice 1" ); + sxy::simple_state& s19 = main_region.add_simple_state( "s19" ); + sxy::junction& junction1 = main_region.add_junction( "junction 1" ); + sxy::simple_state& s20 = main_region.add_simple_state( "s20" ); + sxy::simple_state& s21 = main_region.add_simple_state( "s21" ); + sxy::simple_state& s22 = main_region.add_simple_state( "s22" ); + sxy::event_ids deferred_events_ids; + deferred_events_ids.push_back( event_S::get_event_id() ); + sxy::simple_state& s23 = main_region.add_simple_state( "s23", deferred_events_ids ); + sxy::simple_state& s24 = main_region.add_simple_state( "s24" ); + sxy::junction& junction2 = main_region.add_junction( "junction 2" ); + sxy::terminate_pseudostate& terminate_pseudostate_1 = main_region.add_terminate_pseudostate( "terminate pseudostate 1" ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i1, s1 ); + l_state_machine->add_transition( event_B::get_event_id(), s1, s2 ); + l_state_machine->add_transition( event_A::get_event_id(), s1, s3 ); + l_state_machine->add_transition( event_C::get_event_id(), s3, s2 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i2, s3_1_1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s3_1_1, final1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i3, s3_2_1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i4, s3_2_1_1_1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i5, s3_2_1_1_1_1_1 ); + l_state_machine->add_transition( event_D::get_event_id(), s3_2_1_1_1_1_1, final2 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i6, s3_3_1 ); + l_state_machine->add_transition( event_C::get_event_id(), s3_3_1, final3 ); + l_state_machine->add_transition( event_A::get_event_id(), s3, s4 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s3, s5_1_1_1_1_1_1 ); + l_state_machine->add_transition( event_A::get_event_id(), s5_1_1_1_1_1_1, s5_1_1_1_1_1_2 ); + l_state_machine->add_transition( event_E::get_event_id(), s5_1_1_1_1_1_1, exit1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, exit1, exit2 ); + l_state_machine->add_transition( event_E::get_event_id(), s5, s6 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, exit2, entry2 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, entry2, entry1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, entry1, s7_1_1_1_1_1_1_1_1 ); + l_state_machine->add_transition( event_F::get_event_id(), s7, s8 ); + l_state_machine->add_transition( event_A::get_event_id(), s7, s9 ); + l_state_machine->add_transition( event_F::get_event_id(), s7_1_1_1_1_1_1_1_1, s10 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i7, s10_1_2 ); + l_state_machine->add_transition( event_A::get_event_id(), s10_1_2, s10_1_3 ); + l_state_machine->add_transition( event_G::get_event_id(), s10_1_2, s10_1_1 ); + l_state_machine->add_transition( event_A::get_event_id(), s10_1_1, s10_1_3 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i8, s10_1_1_1_1 ); + l_state_machine->add_transition( event_H::get_event_id(), s10_1_1_1_1, s10_1_1_1_2 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i9, s10_1_1_1_2_1_1 ); + l_state_machine->add_transition( event_I::get_event_id(), s10_1_1, s11 ); + l_state_machine->add_transition( event_A::get_event_id(), s11, s12 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s11, shallow_history1 ); + l_state_machine->add_transition( event_K::get_event_id(), s10, s13 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i10, s13_1_2 ); + l_state_machine->add_transition( event_A::get_event_id(), s13_1_2, s13_1_3 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s13_1_2, s13_1_1 ); + l_state_machine->add_transition( event_A::get_event_id(), s13_1_1, s13_1_3 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i11, s13_1_1_1_1 ); + l_state_machine->add_transition( event_L::get_event_id(), s13_1_1_1_1, s13_1_1_1_2 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i12, s13_1_1_1_2_1_1 ); + l_state_machine->add_transition( event_M::get_event_id(), s13_1_1, s14 ); + l_state_machine->add_transition( event_A::get_event_id(), s14, s15 ); + l_state_machine->add_transition( event_N::get_event_id(), s14, deep_history1 ); + l_state_machine->add_transition( event_O::get_event_id(), s13, fork1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, fork1, s16_2_1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, fork1, s16_3_1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, fork1, s16_4_1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, i13, s16_1_1 ); + l_state_machine->add_transition( event_A::get_event_id(), s16_1_1, s16_1_2 ); + l_state_machine->add_transition( event_Q::get_event_id(), s16_1_1, s16_1_3 ); + l_state_machine->add_transition( event_A::get_event_id(), s16_2_1, s16_2_2 ); + l_state_machine->add_transition( event_Q::get_event_id(), s16_2_1, s16_2_3 ); + l_state_machine->add_transition( event_Q::get_event_id(), s16_3_1, s16_3_2 ); + l_state_machine->add_transition( event_A::get_event_id(), s16_4_1, s16_4_2 ); + l_state_machine->add_transition( event_Q::get_event_id(), s16_4_1, s16_4_3 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s16_1_3, join1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s16_2_3, join1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s16_3_2, join1 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s16_4_3, join1 ); + l_state_machine->add_transition( event_B::get_event_id(), s16, s17 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, join1, s18 ); + l_state_machine->add_transition( event_R::get_event_id(), s18, choice1 ); + +#ifdef Y_CPP03_BOOST + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, choice1, s19, + Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_divided_by_2 ) ); +#else + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, choice1, s19, + Y_GUARD_METHOD_NO_EVENT( check_iterations_divided_by_2 ) ); +#endif + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, choice1, junction1 ); + +#ifdef Y_CPP03_BOOST + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s20, + Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_divided_by_3 ) ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s21, + Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_divided_by_5 ) ); +#else + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s20, + Y_GUARD_METHOD_NO_EVENT( check_iterations_divided_by_3 ) ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s21, + Y_GUARD_METHOD_NO_EVENT( check_iterations_divided_by_5 ) ); +#endif + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s22 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s19, s23 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s20, s23 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s21, s23 ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s22, s23 ); + l_state_machine->add_transition( event_T::get_event_id(), s23, s24 ); + l_state_machine->add_transition( event_S::get_event_id(), s24, junction2 ); + +#ifdef Y_CPP03_BOOST + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction2, terminate_pseudostate_1, + Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_exceded ) ); +#else + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction2, terminate_pseudostate_1, + Y_GUARD_METHOD_NO_EVENT( check_iterations_exceded ) ); +#endif + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction2, s1 ); + return( sxy::move( l_state_machine ) ); +} + + +bool forty_two::check_state_machine() const +{ + bool state_machine_is_ok = true; + sxy::state_machine_defects defects; + state_machine_->check( defects ); + if( !defects.empty() ) + { + state_machine_is_ok = false; + } + + return( state_machine_is_ok ); +} + + +void forty_two::increment_iterations() +{ + ++iterations_; + Y_LOG( sxy::log_level::LL_DEBUG, "iterator incremented to %", iterations_ ); +} + + +bool forty_two::check_iterations_divided_by_2() const +{ + return( iterations_ % 2 == 0 ); +} + + +bool forty_two::check_iterations_divided_by_3() const +{ + return( iterations_ % 3 == 0 ); +} + + +bool forty_two::check_iterations_divided_by_5() const +{ + return( iterations_ % 5 == 0 ); +} + + +bool forty_two::check_iterations_exceded() const +{ + return( iterations_ > max_iterations_ ); +} + + +void forty_two::run() +{ +#ifndef Y_NO_LOGGING + sxy::log_manager_template& log_manager = sxy::log_manager::get_instance(); + log_manager.set_log_level( sxy::log_level::LL_DEBUG ); + log_manager.add_logger( Y_MAKE_UNIQUE< sxy::cout_logger >() ); + log_manager.run(); +#endif + + sxy::system_clock::time_point start = sxy::system_clock::now(); + + bool starting_success = state_machine_->run(); + Y_ASSERT( starting_success, "State machine was not started!" ); + + for( uint32_t iteration = 0; iteration < max_iterations_; ++iteration ) + { + state_machine_->fire_event( event_A::create() ); + state_machine_->fire_event( event_B::create() ); + state_machine_->fire_event( event_C::create() ); + state_machine_->fire_event( event_D::create() ); + state_machine_->fire_event( event_E::create() ); + state_machine_->fire_event( event_F::create() ); + state_machine_->fire_event( event_G::create() ); + state_machine_->fire_event( event_H::create() ); + state_machine_->fire_event( event_I::create() ); + state_machine_->fire_event( event_J::create() ); + state_machine_->fire_event( event_K::create() ); + state_machine_->fire_event( event_L::create() ); + state_machine_->fire_event( event_M::create() ); + state_machine_->fire_event( event_N::create() ); + state_machine_->fire_event( event_O::create() ); + state_machine_->fire_event( event_P::create() ); + state_machine_->fire_event( event_Q::create() ); + state_machine_->fire_event( event_R::create() ); + state_machine_->fire_event( event_S::create() ); + state_machine_->fire_event( event_T::create() ); + } + + const sxy::system_clock::time_point stop = sxy::system_clock::now(); + +#ifdef Y_PROFILER + Y_LOG( log_level::LL_INFO, "% events were fired.", + sxy::to_string( state_machine_->get_number_of_processed_events() ) ); +#endif + + state_machine_->halt(); + + Y_LOG( sxy::log_level::LL_INFO, "Run time: % seconds", + sxy::duration_cast< sxy::seconds >( stop - start ).count() ); + +#ifndef Y_NO_LOGGING + log_manager.halt_and_join(); +#endif + + std::cin.get(); +} + + +} diff --git a/yasmine/forty_two/forty_two.hpp b/examples/forty_two/forty_two.hpp similarity index 94% rename from yasmine/forty_two/forty_two.hpp rename to examples/forty_two/forty_two.hpp index 7ab9aeb..f28f548 100644 --- a/yasmine/forty_two/forty_two.hpp +++ b/examples/forty_two/forty_two.hpp @@ -18,7 +18,7 @@ #include "yasmine.hpp" -namespace sxy +namespace examples { @@ -26,7 +26,7 @@ class forty_two Y_FINAL { public: - typedef Y_UNIQUE_PTR state_machine_uptr; + typedef sxy::Y_UNIQUE_PTR state_machine_uptr; explicit forty_two( const sxy::uint32_t _max_iterations ); diff --git a/yasmine/forty_two/forty_two.vcxproj b/examples/forty_two/forty_two.vcxproj similarity index 88% rename from yasmine/forty_two/forty_two.vcxproj rename to examples/forty_two/forty_two.vcxproj index 29580b7..466964f 100644 --- a/yasmine/forty_two/forty_two.vcxproj +++ b/examples/forty_two/forty_two.vcxproj @@ -141,73 +141,77 @@ - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + @@ -270,7 +274,6 @@ - Level3 MaxSpeed true true diff --git a/yasmine/forty_two/forty_two.vcxproj.filters b/examples/forty_two/forty_two.vcxproj.filters similarity index 100% rename from yasmine/forty_two/forty_two.vcxproj.filters rename to examples/forty_two/forty_two.vcxproj.filters diff --git a/yasmine/forty_two/main.cpp b/examples/forty_two/main.cpp similarity index 96% rename from yasmine/forty_two/main.cpp rename to examples/forty_two/main.cpp index b839c32..91a3d68 100644 --- a/yasmine/forty_two/main.cpp +++ b/examples/forty_two/main.cpp @@ -14,5 +14,5 @@ int main() { - sxy::forty_two _42( 100000 ); + examples::forty_two _42( 100000 ); } \ No newline at end of file diff --git a/yasmine/hello_yasmine/CMakeLists.txt b/examples/hello_yasmine/CMakeLists.txt similarity index 91% rename from yasmine/hello_yasmine/CMakeLists.txt rename to examples/hello_yasmine/CMakeLists.txt index 0b8d2e6..eba08c6 100644 --- a/yasmine/hello_yasmine/CMakeLists.txt +++ b/examples/hello_yasmine/CMakeLists.txt @@ -4,8 +4,8 @@ project(hello_yasmine) set(CMAKE_VERBOSE_MAKEFILE, 1) -set(HEADER_FILES "./../yasmine/*.hpp") -file(GLOB hello_yasmine_SRC "./../hello_yasmine/*.cpp" ${HEADER_FILES}) +set(HEADER_FILES "./../../libyasmine/include/*.hpp") +file(GLOB hello_yasmine_SRC "./*.cpp" ${HEADER_FILES}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -22,9 +22,9 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQ endif() if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\"") + set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\" -D \"Y_NO_VARIADIC_MACRO\"") else() - set(extra_flags "${extra_flags} -std=c++14 -Wall -g") + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") endif() # yasmine's preprocessor definitions @@ -102,7 +102,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(extra_flags "${extra_flags} /Fo") #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") + #set(extra_flags "${extra_flags} /NXCOMPAT") # yasmine's preprocessor definitions set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") @@ -151,7 +151,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(hello_yasmine ${hello_yasmine_SRC}) -include_directories("./../yasmine") +include_directories("./../../libyasmine/include") #using boost if("${CPP_VERSION}" STREQUAL "03") @@ -163,12 +163,12 @@ endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (hello_yasmine LINK_PUBLIC yasmine pthread boost_system boost_thread boost_chrono) + target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) else() - target_link_libraries (hello_yasmine LINK_PUBLIC yasmine pthread) + target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine pthread) endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (hello_yasmine LINK_PUBLIC yasmine) + target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine) endif() diff --git a/yasmine/hello_yasmine/hello_yasmine.cpp b/examples/hello_yasmine/hello_yasmine.cpp similarity index 79% rename from yasmine/hello_yasmine/hello_yasmine.cpp rename to examples/hello_yasmine/hello_yasmine.cpp index fcb4e00..882594e 100644 --- a/yasmine/hello_yasmine/hello_yasmine.cpp +++ b/examples/hello_yasmine/hello_yasmine.cpp @@ -12,7 +12,6 @@ #include #include "yasmine.hpp" -#include "version.hpp" const sxy::event_id HELLO_EVENT = 1; @@ -34,23 +33,17 @@ void wait() state_machine_uptr setup_state_machine( const std::string& _name ) { - state_machine_uptr state_machine = Y_MAKE_UNIQUE< sxy::state_machine >(_name); + state_machine_uptr state_machine = Y_MAKE_UNIQUE< sxy::state_machine >( _name ); sxy::composite_state& root_state = state_machine->get_root_state(); sxy::region& main_region = root_state.add_region( "main region" ); sxy::initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); - sxy::simple_state& simple_state_waiting = main_region.add_simple_state( "waiting", Y_BEHAVIOUR_FUNCTION_NO_EVENT( wait ) ); - sxy::simple_state& simple_state_replying = main_region.add_simple_state( "replying", Y_BEHAVIOUR_FUNCTION_NO_EVENT( reply ) ); + sxy::simple_state& simple_state_waiting = main_region.add_simple_state( "waiting", Y_BEHAVIOR_FUNCTION_NO_EVENT( wait ) ); + sxy::simple_state& simple_state_replying = main_region.add_simple_state( "replying", Y_BEHAVIOR_FUNCTION_NO_EVENT( reply ) ); state_machine->add_transition( HELLO_EVENT, simple_state_waiting, simple_state_replying ); + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_waiting ); + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, simple_state_replying, simple_state_waiting ); -#ifdef Y_CPP03_BOOST - state_machine->add_transition( COMPLETION_EVENT_ID, initial_pseudostate, simple_state_waiting ); - state_machine->add_transition( COMPLETION_EVENT_ID, simple_state_replying, simple_state_waiting ); -#else - state_machine->add_transition( sxy::COMPLETION_EVENT_ID, initial_pseudostate, simple_state_waiting ); - state_machine->add_transition( sxy::COMPLETION_EVENT_ID, simple_state_replying, simple_state_waiting ); -#endif - return( sxy::move( state_machine ) ); } @@ -75,19 +68,19 @@ int main() sxy::log_manager_template& log_manager = sxy::log_manager::get_instance(); log_manager.set_log_level( sxy::log_level::LL_FATAL ); log_manager.add_logger( Y_MAKE_UNIQUE< sxy::cout_logger >() ); - log_manager.start(); - yasmine::version::log_version(); + log_manager.run(); + sxy::version::log_version(); const state_machine_uptr hello_yasmine_state_machine = setup_state_machine( "hello yasmine state machine" ); if( check_state_machine_for_defects( *hello_yasmine_state_machine ) ) { - hello_yasmine_state_machine->start_state_machine(); + hello_yasmine_state_machine->run(); try { hello_yasmine_state_machine->fire_event( sxy::event_impl::create( HELLO_EVENT ) ); hello_yasmine_state_machine->fire_event( sxy::event_impl::create( HELLO_EVENT ) ); - hello_yasmine_state_machine->fire_event( sxy::event_impl::create( HELLO_EVENT ) ); - hello_yasmine_state_machine->stop_state_machine(); + hello_yasmine_state_machine->fire_event( sxy::event_impl::create( HELLO_EVENT ) ); + hello_yasmine_state_machine->halt(); } catch( const std::exception& exception ) { @@ -105,8 +98,7 @@ int main() error_code = 3; } - log_manager.stop(); - log_manager.join(); - + log_manager.halt_and_join(); + return( error_code ); } diff --git a/yasmine/hello_yasmine/hello_yasmine.vcxproj b/examples/hello_yasmine/hello_yasmine.vcxproj similarity index 88% rename from yasmine/hello_yasmine/hello_yasmine.vcxproj rename to examples/hello_yasmine/hello_yasmine.vcxproj index eed2999..55bf8ae 100644 --- a/yasmine/hello_yasmine/hello_yasmine.vcxproj +++ b/examples/hello_yasmine/hello_yasmine.vcxproj @@ -141,78 +141,81 @@ - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - Level3 Disabled true @@ -268,7 +271,6 @@ - Level3 MaxSpeed true true diff --git a/yasmine/hello_yasmine/hello_yasmine.vcxproj.filters b/examples/hello_yasmine/hello_yasmine.vcxproj.filters similarity index 100% rename from yasmine/hello_yasmine/hello_yasmine.vcxproj.filters rename to examples/hello_yasmine/hello_yasmine.vcxproj.filters diff --git a/yasmine/substatemachines_and_variables/CMakeLists.txt b/examples/substatemachines_and_variables/CMakeLists.txt similarity index 93% rename from yasmine/substatemachines_and_variables/CMakeLists.txt rename to examples/substatemachines_and_variables/CMakeLists.txt index c6298c9..7050c8f 100644 --- a/yasmine/substatemachines_and_variables/CMakeLists.txt +++ b/examples/substatemachines_and_variables/CMakeLists.txt @@ -4,8 +4,8 @@ project(substatemachines_and_variables) set(CMAKE_VERBOSE_MAKEFILE, 1) -set(HEADER_FILES "./../yasmine/*.hpp") -file(GLOB substatemachines_and_variables_SRC "./../substatemachines_and_variables/*.cpp" ${HEADER_FILES}) +set(HEADER_FILES "./../../libyasmine/include/*.hpp") +file(GLOB substatemachines_and_variables_SRC "./*.cpp" ${HEADER_FILES}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -22,9 +22,9 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQ endif() if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\"") + set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\" -D \"Y_NO_VARIADIC_MACRO\"") else() - set(extra_flags "${extra_flags} -std=c++14 -Wall -g") + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") endif() # yasmine's preprocessor definitions @@ -102,7 +102,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(extra_flags "${extra_flags} /Fo") #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") + #set(extra_flags "${extra_flags} /NXCOMPAT") # yasmine's preprocessor definitions set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") @@ -151,7 +151,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(substatemachines_and_variables ${substatemachines_and_variables_SRC}) -include_directories("./../yasmine") +include_directories("./../../libyasmine/include") #using boost if("${CPP_VERSION}" STREQUAL "03") @@ -163,12 +163,12 @@ endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (substatemachines_and_variables LINK_PUBLIC yasmine pthread boost_system boost_thread boost_chrono) + target_link_libraries (substatemachines_and_variables LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) else() - target_link_libraries (substatemachines_and_variables LINK_PUBLIC yasmine pthread) + target_link_libraries (substatemachines_and_variables LINK_PUBLIC libyasmine pthread) endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (substatemachines_and_variables LINK_PUBLIC yasmine) + target_link_libraries (substatemachines_and_variables LINK_PUBLIC libyasmine) endif() diff --git a/yasmine/substatemachines_and_variables/events.hpp b/examples/substatemachines_and_variables/events.hpp similarity index 70% rename from yasmine/substatemachines_and_variables/events.hpp rename to examples/substatemachines_and_variables/events.hpp index fee455e..a4ef87c 100644 --- a/yasmine/substatemachines_and_variables/events.hpp +++ b/examples/substatemachines_and_variables/events.hpp @@ -14,42 +14,41 @@ #include "yasmine.hpp" - - -namespace sxy -{ - - + + namespace { - // DONE we need defines for C++03! -#ifndef Y_CPP03_BOOST - constexpr event_id EVENT_1 = 1; - constexpr event_id EVENT_2 = 2; - constexpr event_id EVENT_3 = 3; - constexpr event_id EVENT_4 = 4; - constexpr event_id EVENT_5 = 5; -#else +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) #define EVENT_1 1 #define EVENT_2 2 #define EVENT_3 3 #define EVENT_4 4 #define EVENT_5 5 +#else + constexpr sxy::event_id EVENT_1 = 1; + constexpr sxy::event_id EVENT_2 = 2; + constexpr sxy::event_id EVENT_3 = 3; + constexpr sxy::event_id EVENT_4 = 4; + constexpr sxy::event_id EVENT_5 = 5; #endif - + + } - Y_EVENT_WITH_ID( event_1, EVENT_1 ); - Y_EVENT_WITH_ID( event_2, EVENT_2 ); - Y_EVENT_WITH_ID( event_3, EVENT_3 ); - Y_EVENT_WITH_ID( event_4, EVENT_4 ); - Y_EVENT_1PARAM_WITH_ID( event_5, std::string, get_param, EVENT_5 ); +namespace examples +{ + +Y_EVENT_WITH_ID( event_1, EVENT_1 ) +Y_EVENT_WITH_ID( event_2, EVENT_2 ) +Y_EVENT_WITH_ID( event_3, EVENT_3 ) +Y_EVENT_WITH_ID( event_4, EVENT_4 ) +Y_EVENT_1PARAM_WITH_ID( event_5, std::string, get_param, EVENT_5 ) -} +} #endif diff --git a/yasmine/substatemachines_and_variables/main.cpp b/examples/substatemachines_and_variables/main.cpp similarity index 93% rename from yasmine/substatemachines_and_variables/main.cpp rename to examples/substatemachines_and_variables/main.cpp index 08c8f99..3f1e432 100644 --- a/yasmine/substatemachines_and_variables/main.cpp +++ b/examples/substatemachines_and_variables/main.cpp @@ -14,7 +14,7 @@ int main() { - sxy::state_machine_with_submachines state_machine_with_submachines; + examples::state_machine_with_submachines state_machine_with_submachines; state_machine_with_submachines.create(); state_machine_with_submachines.run(); } diff --git a/yasmine/substatemachines_and_variables/state_machine_with_submachines.cpp b/examples/substatemachines_and_variables/state_machine_with_submachines.cpp similarity index 94% rename from yasmine/substatemachines_and_variables/state_machine_with_submachines.cpp rename to examples/substatemachines_and_variables/state_machine_with_submachines.cpp index 0a68c2f..6386931 100644 --- a/yasmine/substatemachines_and_variables/state_machine_with_submachines.cpp +++ b/examples/substatemachines_and_variables/state_machine_with_submachines.cpp @@ -12,7 +12,7 @@ #include "state_machine_with_submachines.hpp" -namespace sxy +namespace examples { @@ -44,7 +44,7 @@ void state_machine_with_submachines::create() sxy::final_state& final_state = main_region.add_final_state( "final state" ); - state_machine_->add_transition( COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1 ); + state_machine_->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1 ); state_machine_->add_transition( EVENT_1, simple_state_1, submachine1_->get_submachine_root_state() ); state_machine_->add_transition( EVENT_2, submachine1_->get_submachine_root_state(), simple_state_1 ); state_machine_->add_transition( EVENT_3, simple_state_1, submachine2_->get_submachine_root_state() ); @@ -54,7 +54,7 @@ void state_machine_with_submachines::create() void state_machine_with_submachines::run() { - state_machine_->start_state_machine(); + state_machine_->run(); state_machine_->fire_event( event_1::create() ); state_machine_->fire_event( event_5::create( "Hello!" ) ); state_machine_->fire_event( event_5::create( "yasmine" ) ); @@ -64,7 +64,7 @@ void state_machine_with_submachines::run() state_machine_->fire_event( event_5::create( "xyz" ) ); state_machine_->fire_event( event_5::create( "123" ) ); state_machine_->fire_event( event_4::create() ); - state_machine_->stop_state_machine(); + state_machine_->halt(); } diff --git a/yasmine/substatemachines_and_variables/state_machine_with_submachines.hpp b/examples/substatemachines_and_variables/state_machine_with_submachines.hpp similarity index 91% rename from yasmine/substatemachines_and_variables/state_machine_with_submachines.hpp rename to examples/substatemachines_and_variables/state_machine_with_submachines.hpp index 3a21538..a6d8e2b 100644 --- a/yasmine/substatemachines_and_variables/state_machine_with_submachines.hpp +++ b/examples/substatemachines_and_variables/state_machine_with_submachines.hpp @@ -17,7 +17,7 @@ #include "events.hpp" -namespace sxy +namespace examples { @@ -25,8 +25,8 @@ class state_machine_with_submachines Y_FINAL { -typedef Y_UNIQUE_PTR state_machine_uptr; -typedef Y_UNIQUE_PTR submachine_uptr; +typedef sxy::Y_UNIQUE_PTR state_machine_uptr; +typedef sxy::Y_UNIQUE_PTR submachine_uptr; public: diff --git a/yasmine/substatemachines_and_variables/submachine.cpp b/examples/substatemachines_and_variables/submachine.cpp similarity index 59% rename from yasmine/substatemachines_and_variables/submachine.cpp rename to examples/substatemachines_and_variables/submachine.cpp index f70e5fc..9045674 100644 --- a/yasmine/substatemachines_and_variables/submachine.cpp +++ b/examples/substatemachines_and_variables/submachine.cpp @@ -19,38 +19,38 @@ #include "events.hpp" -namespace sxy +namespace examples { submachine::submachine( sxy::state_machine& _parent_state_machine, sxy::region& _parent_region ) : #ifndef Y_CPP03_BOOST - submachine_( _parent_region.add_composite_state( "submachine", Y_BEHAVIOUR_METHOD_NO_EVENT( reset_members ) ) ), + submachine_( _parent_region.add_composite_state( "submachine", Y_BEHAVIOR_METHOD_NO_EVENT( reset_members ) ) ), #else - submachine_( _parent_region.add_composite_state( "submachine", Y_BEHAVIOUR_METHOD_NO_EVENT( submachine, reset_members ) ) ), + submachine_( _parent_region.add_composite_state( "submachine", Y_BEHAVIOR_METHOD_NO_EVENT( submachine, reset_members ) ) ), #endif i_(), s_() { - region& submachine_region = submachine_.add_region( "submachine region" ); - initial_pseudostate& submachine_initial_pseudostate = submachine_region.add_initial_pseudostate( + sxy::region& submachine_region = submachine_.add_region( "submachine region" ); + sxy::initial_pseudostate& submachine_initial_pseudostate = submachine_region.add_initial_pseudostate( "submachine_initial_pseudostate" ); #ifndef Y_CPP03_BOOST - simple_state& submachine_simple_state_1 = submachine_region.add_simple_state( "submachine simple_state_1", - Y_BEHAVIOUR_METHOD_NO_EVENT( print_members ) ); - simple_state& submachine_simple_state_2 = submachine_region.add_simple_state( "submachine simple_state_2", - Y_BEHAVIOUR_METHOD_EVENT( &submachine::change_members ) ); + sxy::simple_state& submachine_simple_state_1 = submachine_region.add_simple_state( "submachine simple_state_1", + Y_BEHAVIOR_METHOD_NO_EVENT( print_members ) ); + sxy::simple_state& submachine_simple_state_2 = submachine_region.add_simple_state( "submachine simple_state_2", + Y_BEHAVIOR_METHOD_EVENT( &submachine::change_members ) ); #else - simple_state& submachine_simple_state_1 = submachine_region.add_simple_state( "submachine simple_state_1", - Y_BEHAVIOUR_METHOD_NO_EVENT( submachine, print_members ) ); - simple_state& submachine_simple_state_2 = submachine_region.add_simple_state( "submachine simple_state_2", - sxy::behaviour_function( sxy::bind( &submachine::change_members, this, sxy::_1 ) ) ); + sxy::simple_state& submachine_simple_state_1 = submachine_region.add_simple_state( "submachine simple_state_1", + Y_BEHAVIOR_METHOD_NO_EVENT( submachine, print_members ) ); + sxy::simple_state& submachine_simple_state_2 = submachine_region.add_simple_state( "submachine simple_state_2", + sxy::behavior_function( sxy::bind( &submachine::change_members, this, sxy::_1 ) ) ); #endif - _parent_state_machine.add_transition( COMPLETION_EVENT_ID, submachine_initial_pseudostate, submachine_simple_state_1 ); + _parent_state_machine.add_transition( sxy::Y_COMPLETION_EVENT_ID, submachine_initial_pseudostate, submachine_simple_state_1 ); _parent_state_machine.add_transition( EVENT_5, submachine_simple_state_1, submachine_simple_state_2 ); - _parent_state_machine.add_transition( COMPLETION_EVENT_ID, submachine_simple_state_2, submachine_simple_state_1 ); + _parent_state_machine.add_transition( sxy::Y_COMPLETION_EVENT_ID, submachine_simple_state_2, submachine_simple_state_1 ); } @@ -82,14 +82,14 @@ void submachine::print_members() const #ifndef Y_CPP03_BOOST void submachine::change_members( const event_5& _event ) #else -void submachine::change_members( const event& _event ) +void submachine::change_members( const sxy::event& _event ) #endif { ++i_; #ifndef Y_CPP03_BOOST s_ = _event.get_param(); #else - const sxy::event_5* event_with_param = dynamic_cast< const sxy::event_5* >( &_event ); + const event_5* event_with_param = dynamic_cast< const event_5* >( &_event ); if( event_with_param ) { diff --git a/yasmine/substatemachines_and_variables/submachine.hpp b/examples/substatemachines_and_variables/submachine.hpp similarity index 88% rename from yasmine/substatemachines_and_variables/submachine.hpp rename to examples/substatemachines_and_variables/submachine.hpp index 9f3b97c..97d0a70 100644 --- a/yasmine/substatemachines_and_variables/submachine.hpp +++ b/examples/substatemachines_and_variables/submachine.hpp @@ -21,17 +21,25 @@ namespace sxy { -class state_machine; -class region; -class composite_state; + class state_machine; + class region; + class composite_state; + + +} + #ifndef Y_CPP03_BOOST - class event_5; +namespace examples{ class event_5; } #else - class event; +namespace sxy { class event; } #endif +namespace examples +{ + + class submachine Y_FINAL { public: @@ -47,7 +55,7 @@ class submachine Y_FINAL #ifndef Y_CPP03_BOOST void change_members( const event_5& _event ); #else - void change_members( const event& _event ); + void change_members( const sxy::event& _event ); #endif sxy::composite_state& submachine_; diff --git a/yasmine/substatemachines_and_variables/substatemachines_and_variables.vcxproj b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj similarity index 88% rename from yasmine/substatemachines_and_variables/substatemachines_and_variables.vcxproj rename to examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj index fe822a4..a36e1ea 100644 --- a/yasmine/substatemachines_and_variables/substatemachines_and_variables.vcxproj +++ b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj @@ -141,79 +141,82 @@ - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - - - + + + - - - + + + - - - - + + + + + - - + + - - + + - - - + + + + - Level3 Disabled true @@ -273,7 +276,6 @@ - Level3 MaxSpeed true true @@ -325,6 +327,7 @@ true true true + MachineX64 diff --git a/yasmine/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters similarity index 100% rename from yasmine/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters rename to examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters diff --git a/yasmine/yasmine/CMakeLists.txt b/libyasmine/CMakeLists.txt similarity index 90% rename from yasmine/yasmine/CMakeLists.txt rename to libyasmine/CMakeLists.txt index 48cb677..87925f4 100644 --- a/yasmine/yasmine/CMakeLists.txt +++ b/libyasmine/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.5) -project(yasmine) +project(libyasmine) -set(MAJOR_VERSION 0) -set(MINOR_VERSION 5) +set(MAJOR_VERSION 1) +set(MINOR_VERSION 0) set(PATH_VERSION 0) set(CMAKE_VERBOSE_MAKEFILE, 1) -file(GLOB yasmine_SRC "*.hpp" "*.cpp") +file(GLOB yasmine_SRC "include/*.hpp" "include_impl/*.hpp" "source/*.cpp") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -23,10 +23,10 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQ message(STATUS "setting platform x86") endif() - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\"") + if("${CPP_VERSION}" STREQUAL "03") + set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\" -D \"Y_NO_VARIADIC_MACRO\"") else() - set(extra_flags "${extra_flags} -std=c++14 -Wall -g") + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") endif() # yasmine's preprocessor definitions @@ -119,7 +119,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(extra_flags "${extra_flags} /Fo") #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") + #set(extra_flags "${extra_flags} /NXCOMPAT") # yasmine's preprocessor definitions set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") @@ -159,6 +159,8 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") endif() +include_directories("./include" "./include_impl") + # for release if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) #Creates fast code. @@ -179,12 +181,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_library(yasmine SHARED ${yasmine_SRC}) + add_library(libyasmine SHARED ${yasmine_SRC}) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_library(yasmine STATIC ${yasmine_SRC}) + add_library(libyasmine STATIC ${yasmine_SRC}) endif() -install(TARGETS yasmine DESTINATION lib) -install(FILES *.h DESTINATION include) -set_target_properties(yasmine PROPERTIES PREFIX "") \ No newline at end of file +install(TARGETS libyasmine DESTINATION lib) +install(FILES *.hpp DESTINATION include) +set_target_properties(libyasmine PROPERTIES PREFIX "") \ No newline at end of file diff --git a/yasmine/yasmine/changelog.txt b/libyasmine/changelog.txt similarity index 57% rename from yasmine/yasmine/changelog.txt rename to libyasmine/changelog.txt index 6474986..a18722f 100644 --- a/yasmine/yasmine/changelog.txt +++ b/libyasmine/changelog.txt @@ -1,24 +1,76 @@ # Change log All notable changes to this project will be documented in this file. +##[1.0.0] - 2017-01-19 + +### Added +• The logger now has got a halt_and_join method. +• Logging: A message that can be waited for. Needed for Y_ASSERT in order to guarantee that the log message from the assert gets +written before the application terminates. +• New check: The target of a transition emanating from an initial pseudostate: It has to be a state. +• New check for local transitions: The target has to be a child of the source or the source itself. +• New check: A transition's source is a child of the target's parent state or the parent state itself, when the target is an exit point. +• wait methods in async state machine +• terminated method in async state machine for checking if the state machine is terminated or stopped +• (C++03) macros for creating event classes now support up to 10 parameters (from Y_EVENT_1PARAM_WITH_ID to Y_EVENT_10PARAM_WITH_ID +and Y_EVENT_1PARAM_WITH_ID_PRIORITY to Y_EVENT_10PARAM_WITH_ID_PRIORITY) +• Y_EVENT_CREATE overloaded macro for creating event classes with up to 10 parameters +• overloaded macros Y_BEHAVIOR_METHOD_EVENT and Y_BEHAVIOR_FUNCTION_EVENT support up to 10 parameters +• Y_EMPTY_GUARD for creating an empty guard + +### Changed +• replaced platform/compiler specific code with a single solution, removed dead code, minor refactoring +• renamed 'start_state_machine' method to 'run' for state_machine and async_state_machine +• renamed 'stop_state_machine' method to 'halt' for state_machine +• renamed 'stop_state_machine' method to 'halt_and_join' for async_state_machine +• renamed 'start' method to 'run' for logger and async_behavior +• renamed 'stop' method to 'halt' for logger and async_behavior +• examples are no more using the sxy namespace +• yasmine file structure refactoring. All source files are now located in the 'source' folder, the header files that compose yasmine's + external API are located in the 'include' folder, and internally used headers are in the 'include_impl' folder. +• removed LL_PROTOCOL from log levels +• version.hpp is now under sxy namespace instead of yasmine namespace +• version.hpp is now included in the collection header yasmine.hpp +• The event ID of the completion event, COMPLETION_EVENT_ID, was changed to Y_COMPLETION_EVENT_ID and resides inside the sxy namespace. +• Transitions with guards are checked if they are active before transitions without guards. + +### Fixed +• bug fix: invalid state exit on external transition returning into source state +• bug fix: transition emanating from or targeting the root state caused crash +• bug fix: when a composite state is entered via a choice, the parent state of the choice was not entered +• usage of macros for creation of event classes outside of sxy namespace +• log message from 'Searching for initial state in region' to 'Searching for initial pseudostate in region' +• wrong unused parameter on transition check + + +##[0.6.1] - 2016-12-12 + +### Changed +• 'behaviour' to 'behavior' in code and documentation +• replaced platform/compiler specific code with a single solution, removed dead code, minor refactoring + +### Fixed +• bug fix: invalid state exit on external transition returning into source state + + ##[0.6.0] - 2016-12-09 ### Added • C++03 compatibility -• macros for creating events classes for a easy usecase. • A new example: Events with parameters. It explains the use case of events with parameters macros. • a new example of using sub-machine and variables into a state machine: Sub state machine with variables -• Macros for passing handlers as behaviour (states and transitions) and transition guards. +• Macros for setting handlers (that expect a certain event type) as behaviors of states (do, enter, exit) or transitions. ### Changed • 'behavior' to 'behaviour' in code and documentation • Y_ASSERT instead of Y_LOG_AND_THROW when checking if the transition of an initial pseudostate was build in a compound transition +• event ID of completion event, COMPLETION_EVENT, becomes COMPLETION_EVENT_ID ##[0.5.0] - 2016-11-07 ### Added -• Y_EMPTY_BEHAVIOR for creating a behaviour that does nothing +• Y_EMPTY_BEHAVIOR for creating a behavior that does nothing • CMake files for generators under Windows (Visual Studio) and Linux (gcc, clang) @@ -49,8 +101,8 @@ All notable changes to this project will be documented in this file. ### Added • changelog.txt. It contains the changelog for the yasmine library -• assembly.h. It contains macros used for different tasks like creating the lambda wrappers for behaviours and guards (constraints) -• overloaded methods for adding transitions into state machine: different combinations of parameters for kind, guard and behaviour +• assembly.h. It contains macros used for different tasks like creating the lambda wrappers for behaviors and guards (constraints) +• overloaded methods for adding transitions into state machine: different combinations of parameters for kind, guard and behavior • priority for events and event priority processing in the state machine • yasmine's interpretation of the choice pseudostate. The choice allows only one default outgoing transition (a transition with no guard). • 'Y_NOEXCEPT' for all destructors @@ -63,7 +115,7 @@ All notable changes to this project will be documented in this file. • Both the synchronous and asynchronous state machines use "start_state_machine" and "stop_state_machine" methods to start and stop the state machines. • "start_state_machine" will return now true if the state machine was started and is running and false if a terminate pseudostate was reached or the state machine encountered a problem and is shutting down. Before the opposite was true. • COMPLETION_EVENT will now have the maximum value of event_id (std::uint32_t -> 4.294.967.295 or 0xFFFFFFFF) instead of 0 -• simple state and asynchronous simple state store an error event instead of a behaviour exception +• simple state and asynchronous simple state store an error event instead of a behavior exception • Defects of the state machine will not be stored in the free store anymore. A copy of the object is stored instead. • event's 'create_event' is now called 'create' • constraint's (guard's) 'create_constraint' is now called 'create' diff --git a/yasmine/yasmine/algorithm_parameters.hpp b/libyasmine/include/algorithm_parameters.hpp similarity index 100% rename from yasmine/yasmine/algorithm_parameters.hpp rename to libyasmine/include/algorithm_parameters.hpp diff --git a/libyasmine/include/assembly.hpp b/libyasmine/include/assembly.hpp new file mode 100644 index 0000000..b87b065 --- /dev/null +++ b/libyasmine/include/assembly.hpp @@ -0,0 +1,175 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 +#define ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 + + +#include "macro_helpers.hpp" +#include "behavior_fwd.hpp" +#include "constraint_fwd.hpp" +#include "caller.hpp" + + +#ifndef Y_CPP03_BOOST + + +#define Y_BEHAVIOR_METHOD( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_SELECT, __VA_ARGS__ ) ) +#define Y_BEHAVIOR_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) +#define Y_GUARD_METHOD( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_SELECT, __VA_ARGS__ ) ) +#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. +#define Y_BEHAVIOR_METHOD_SELECT_1( _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ this->_method_name( _event ); } ) + +//!\brief Macro for using a class method as a behavior. +#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ this->_method_name( _event ); } ) + + +//!\brief Macro for using a class method as a behavior without an event. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_1( _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); this->_method_name(); } ) + +//!\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( [ this ]( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); this->_method_name(); } ) + + +//!\brief Macro for using a class method as a guard. +#define Y_GUARD_METHOD_SELECT_1( _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ return( this->_method_name( _event ) ); } ) + +#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ return( this->_method_name( _event ) ); } ) + + +//!\brief Macro for using a class method as a guard without an event. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_1( _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); return( this->_method_name() ); } ) + +//!\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( [ this ]( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); return( this->_method_name() ); } ) + + +//!\brief Macro for using a free function as a guard. +#define Y_GUARD_FUNCTION( _function_name ) \ + sxy::constraint_function( []( const sxy::event& _event )->bool { return( _function_name( _event ) ); } ) + +//!\brief Macro for using a free function as a guard without an event. +#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ + sxy::constraint_function( []( const sxy::event& _event )->bool { Y_UNUSED_PARAMETER(_event); return( _function_name() ); } ) + + +//!\brief Macro for using a free function as a behavior. +#define Y_BEHAVIOR_FUNCTION( _function_name ) \ + sxy::behavior_function( []( const sxy::event& _event ){ _function_name( _event ); } ) + + +//!\brief Macro for using a free function as a behavior without an event. +#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ + sxy::behavior_function( []( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); _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( sxy::bind( &_class_name::_method_name, this, sxy::_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( sxy::bind( &_class_name::_method_name, this ) ) + +#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( sxy::bind( &_class_name::_method_name, this, sxy::_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( sxy::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( sxy::bind( &_function_name, sxy::_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( sxy::bind( &_function_name ) ) + + +//!\brief Macro for using a free function as a behavior. +#define Y_BEHAVIOR_FUNCTION( _function_name ) \ + sxy::behavior_function( sxy::bind( &_function_name, sxy::_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( sxy::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 Y_CPP03_BOOST // C++11 only + // Macros for passing handlers as behavior + + //!\brief The macro adds the specified class method(s) as behavior(s) to states or transitions. + //!\ 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__ ) ) + + //!\brief The macro adds the specified function(s) as behavior(s) to states or transitions. + //!\ The macro is variadic and can take up to 10 function pointers as parameters. + #define Y_BEHAVIOR_FUNCTION_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_FUNCTION_EVENT_SELECT, __VA_ARGS__ ) ) + + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_1( _method ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_2( _method1, _method2 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_3( _method1, _method2, _method3 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_4( _method1, _method2, _method3, _method4 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( event, this, _method1, _method2, _method3, _method4 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_5( _method1, _method2, _method3, _method4, _method5 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_6( _method1, _method2, _method3, _method4, _method5, _method6 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5, _method6 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_7( _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_8( _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_9( _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ); } ) + #define Y_BEHAVIOR_METHOD_EVENT_SELECT_10( _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) sxy::behavior_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ); } ) + + + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_1( _function) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function ); }) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_2( _function1, _function2 ) sxy::behavior_function( [](const sxy::event& _event ) { function_caller( _event, _function1, _function2 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_3( _function1, _function2, _function3 ) sxy::behavior_function( [](const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_4( _function1, _function2, _function3, _function4 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5, _function6 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5, _function6, _function7 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ); } ) + #define Y_BEHAVIOR_FUNCTION_EVENT_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) sxy::behavior_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ); } ) + +#endif + +#endif diff --git a/yasmine/yasmine/async_behaviour.hpp b/libyasmine/include/async_behavior.hpp similarity index 77% rename from yasmine/yasmine/async_behaviour.hpp rename to libyasmine/include/async_behavior.hpp index a279a2a..03e1040 100644 --- a/yasmine/yasmine/async_behaviour.hpp +++ b/libyasmine/include/async_behavior.hpp @@ -9,12 +9,12 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef ASYNC_BEHAVIOUR_IMPL_2B8FEEBB_B698_4333_A90E_5686B143B1C1 -#define ASYNC_BEHAVIOUR_IMPL_2B8FEEBB_B698_4333_A90E_5686B143B1C1 +#ifndef ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB +#define ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB #include "non_copyable.hpp" -#include "async_behaviour_fwd.hpp" +#include "async_behavior_fwd.hpp" #include "thread.hpp" @@ -27,23 +27,23 @@ class simple_state_base; class async_event_handler; -class async_behaviour +class async_behavior { public: - async_behaviour(); - virtual ~async_behaviour() Y_NOEXCEPT; - Y_NO_COPY(async_behaviour) - void start( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); - void stop(); - + async_behavior(); + virtual ~async_behavior() Y_NOEXCEPT; + Y_NO_COPY(async_behavior) + void run( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); + void halt(); + protected: bool should_stop() const; -private: - void run( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); +private: + void work( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); virtual void run_impl( const event& _event, async_event_handler& _async_event_handler ) = 0; virtual void notify_should_stop(); void join(); diff --git a/yasmine/yasmine/async_behaviour_fwd.hpp b/libyasmine/include/async_behavior_fwd.hpp similarity index 82% rename from yasmine/yasmine/async_behaviour_fwd.hpp rename to libyasmine/include/async_behavior_fwd.hpp index 71b14ca..80dd5b5 100644 --- a/yasmine/yasmine/async_behaviour_fwd.hpp +++ b/libyasmine/include/async_behavior_fwd.hpp @@ -9,8 +9,8 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef ASYNC_BEHAVIOUR_FWD_58B37F86_A51C_435F_8182_354B2D8960F4 -#define ASYNC_BEHAVIOUR_FWD_58B37F86_A51C_435F_8182_354B2D8960F4 +#ifndef ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 +#define ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 #include "compatibility.hpp" @@ -20,9 +20,9 @@ namespace sxy { -class async_behaviour; +class async_behavior; class event; -typedef Y_UNIQUE_PTR< async_behaviour > async_behaviour_uptr; +typedef Y_UNIQUE_PTR< async_behavior > async_behavior_uptr; } diff --git a/yasmine/yasmine/async_event_handler.hpp b/libyasmine/include/async_event_handler.hpp similarity index 100% rename from yasmine/yasmine/async_event_handler.hpp rename to libyasmine/include/async_event_handler.hpp diff --git a/yasmine/yasmine/async_simple_state_impl.hpp b/libyasmine/include/async_simple_state_impl.hpp similarity index 78% rename from yasmine/yasmine/async_simple_state_impl.hpp rename to libyasmine/include/async_simple_state_impl.hpp index a55b9d6..b9420ea 100644 --- a/yasmine/yasmine/async_simple_state_impl.hpp +++ b/libyasmine/include/async_simple_state_impl.hpp @@ -14,7 +14,7 @@ #include "simple_state_base.hpp" -#include "async_behaviour.hpp" +#include "async_behavior_fwd.hpp" namespace sxy @@ -25,18 +25,18 @@ class async_simple_state_impl Y_FINAL: public simple_state_base { public: - explicit async_simple_state_impl( const std::string& _name, async_behaviour_uptr _do_action, - behaviour_uptr _entry_action = behaviour_uptr(), behaviour_uptr _exit_action = behaviour_uptr(), + 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() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(async_simple_state_impl) - void execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; - void execute_exit_behaviour( const event& _event ) const Y_OVERRIDE; - void stop_do_behaviour() const; + void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; + void execute_exit_behavior( const event& _event ) const Y_OVERRIDE; + void stop_do_behavior() const; private: - async_behaviour_uptr do_; + async_behavior_uptr do_; }; diff --git a/yasmine/yasmine/async_state_machine.hpp b/libyasmine/include/async_state_machine.hpp similarity index 62% rename from yasmine/yasmine/async_state_machine.hpp rename to libyasmine/include/async_state_machine.hpp index 09dcd39..428fbe8 100644 --- a/yasmine/yasmine/async_state_machine.hpp +++ b/libyasmine/include/async_state_machine.hpp @@ -18,6 +18,8 @@ #include "thread.hpp" #include "state_machine.hpp" #include "async_event_handler.hpp" +#include "state_machine_status.hpp" +#include "chrono.hpp" namespace sxy @@ -26,7 +28,7 @@ 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. +//! machine and to fire events. class async_state_machine Y_FINAL: public state_machine, private async_event_handler { @@ -51,60 +53,55 @@ class async_state_machine Y_FINAL: //!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. - virtual bool start_state_machine() Y_OVERRIDE; - - //!\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 behaviour for all of them. + //!\sa halt_and_join, halt, join + virtual bool run() Y_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 - virtual void stop_state_machine() Y_OVERRIDE; - + //!\sa halt_and_join, join, run + virtual void halt() Y_OVERRIDE; -protected: - void start(); - void stop(); + //!\brief Joins the thread of the state machine. + //!\return void + //!\sa halt_and_join, halt, run void join(); -private: - typedef Y_UNIQUE_PTR< sxy::thread > thread_uptr; - typedef sxy::function queue_inserter; -#ifndef Y_CPP03_BOOST - enum class status - { - NEW, STARTED, STOP_REQUESTED, STOPPED - }; -#else - struct status - { - enum inner - { - NEW, STARTED, STOP_REQUESTED, STOPPED - }; - - - // cppcheck-suppress noExplicitConstructor - status( const inner _value ) : value_( _value ) - { - // Nothing to do... - } + //!\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 sxy::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; - // cppcheck-suppress functionConst - operator inner() - { - return ( value_ ); - } + //!\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; - inner value_; +protected: + void start_state_machine(); - }; -#endif +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. @@ -112,11 +109,11 @@ class async_state_machine Y_FINAL: virtual void on_event( const event_sptr& _event ) Y_OVERRIDE; - status status_; - sxy::mutex run_and_event_mutex_; + state_machine_status status_; + mutable sxy::mutex run_and_event_mutex_; sxy::condition_variable run_and_event_condition_; - thread_uptr worker_thread_; - bool run_; + mutable sxy::condition_variable terminated_condition_; + Y_UNIQUE_PTR< sxy::thread > worker_thread_; std::list event_list_; }; diff --git a/yasmine/yasmine/base.hpp b/libyasmine/include/base.hpp similarity index 90% rename from yasmine/yasmine/base.hpp rename to libyasmine/include/base.hpp index afbae69..239889f 100644 --- a/yasmine/yasmine/base.hpp +++ b/libyasmine/include/base.hpp @@ -18,7 +18,7 @@ { \ if( !( _condition ) ) \ { \ - Y_LOG( sxy::log_level::LL_ASSERT, "Assert failed! Message: '%', Condition '%'", _message, #_condition ); \ + Y_LOG_AND_WAIT( sxy::log_level::LL_ASSERT, "Assert failed! Message: '%', Condition '%'", _message, #_condition ); \ assert( ( _condition ) && _message ); \ } \ } \ @@ -39,7 +39,6 @@ #define Y_ASSERTED( _x ) static_cast< void >( _x ); -//#define Y_UNUSED_PARAMETER( _x ) [ &_x ] {} () #define Y_UNUSED_PARAMETER( _x ) static_cast( _x ) diff --git a/yasmine/yasmine/behaviour.hpp b/libyasmine/include/behavior.hpp similarity index 83% rename from yasmine/yasmine/behaviour.hpp rename to libyasmine/include/behavior.hpp index 5d586b5..6985150 100644 --- a/yasmine/yasmine/behaviour.hpp +++ b/libyasmine/include/behavior.hpp @@ -9,12 +9,12 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef BEHAVIOUR_86504172_8E66_4DF4_945F_A76FC04D3BEF -#define BEHAVIOUR_86504172_8E66_4DF4_945F_A76FC04D3BEF +#ifndef BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 +#define BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 #include "non_copyable.hpp" -#include "behaviour_fwd.hpp" +#include "behavior_fwd.hpp" #include "event_fwd.hpp" @@ -22,22 +22,22 @@ namespace sxy { -class behaviour +class behavior { public: - behaviour() + behavior() { // Nothing to do... } - virtual ~behaviour() Y_NOEXCEPT + virtual ~behavior() Y_NOEXCEPT { // Nothing to do... } - Y_NO_COPY(behaviour) + Y_NO_COPY(behavior) virtual void operator()( const event& ) const = 0; }; diff --git a/yasmine/yasmine/behaviour_exception.hpp b/libyasmine/include/behavior_exception.hpp similarity index 76% rename from yasmine/yasmine/behaviour_exception.hpp rename to libyasmine/include/behavior_exception.hpp index 41ffb1f..f32d5eb 100644 --- a/yasmine/yasmine/behaviour_exception.hpp +++ b/libyasmine/include/behavior_exception.hpp @@ -9,14 +9,14 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef BEHAVIOUR_EXCEPTION_2D8556FD_222C_4ABD_B11B_1AC356D1A0BB -#define BEHAVIOUR_EXCEPTION_2D8556FD_222C_4ABD_B11B_1AC356D1A0BB +#ifndef BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C +#define BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C #include "event_fwd.hpp" #include "event_id.hpp" #include "exception.hpp" -#include "behaviour_exception_fwd.hpp" +#include "behavior_exception_fwd.hpp" #include "non_copyable.hpp" @@ -24,15 +24,15 @@ namespace sxy { -class behaviour_exception Y_FINAL: +class behavior_exception Y_FINAL: public exception { public: - explicit behaviour_exception( const event_sptr& _event ); - virtual ~behaviour_exception() Y_NOEXCEPT Y_OVERRIDE; - Y_NO_COPY_OPERATOR_EQUAL(behaviour_exception) + explicit behavior_exception( const event_sptr& _event ); + virtual ~behavior_exception() Y_NOEXCEPT Y_OVERRIDE; + Y_NO_COPY_OPERATOR_EQUAL( behavior_exception ) const event_sptr get_error_event() const; diff --git a/libyasmine/include/behavior_exception_fwd.hpp b/libyasmine/include/behavior_exception_fwd.hpp new file mode 100644 index 0000000..7c86d5e --- /dev/null +++ b/libyasmine/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 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A +#define BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A + + +#include + +#include "compatibility.hpp" + + +namespace sxy +{ + + +class behavior_exception; + + +typedef Y_UNIQUE_PTR< behavior_exception > behavior_exception_uptr; +typedef std::vector< behavior_exception_uptr > behavior_exceptions; + +} + + +#endif diff --git a/yasmine/yasmine/behaviour_fwd.hpp b/libyasmine/include/behavior_fwd.hpp similarity index 80% rename from yasmine/yasmine/behaviour_fwd.hpp rename to libyasmine/include/behavior_fwd.hpp index 01e3e5c..622ba67 100644 --- a/yasmine/yasmine/behaviour_fwd.hpp +++ b/libyasmine/include/behavior_fwd.hpp @@ -9,8 +9,8 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef BEHAVIOUR_FWD_56B32B7A_BC57_467C_84D8_A79626B0DD0D -#define BEHAVIOUR_FWD_56B32B7A_BC57_467C_84D8_A79626B0DD0D +#ifndef BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 +#define BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 #include "compatibility.hpp" @@ -20,12 +20,12 @@ namespace sxy { -class behaviour; +class behavior; class event; -typedef Y_UNIQUE_PTR< behaviour > behaviour_uptr; -typedef sxy::function< void ( const event& ) > behaviour_function; +typedef Y_UNIQUE_PTR< behavior > behavior_uptr; +typedef sxy::function< void ( const event& ) > behavior_function; } diff --git a/libyasmine/include/caller.hpp b/libyasmine/include/caller.hpp new file mode 100644 index 0000000..ea7c0c5 --- /dev/null +++ b/libyasmine/include/caller.hpp @@ -0,0 +1,1484 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F +#define CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F + + +#include "event.hpp" +#include "base.hpp" + + +namespace sxy +{ + + +template +const _event_type& adjust_event_type(const event& _event) +{ +#ifdef NDEBUG + return( static_cast( _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) + { + Y_LOG( sxy::log_level::LL_ASSERT, message ); + Y_ASSERT_NO_LOG( false, "Invalid event type!" ); + } + return( *specialized_event ); +#endif +} + + +template< typename _class, typename _event_type > +void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method )( const _event_type& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + if( _event.get_id() == specialized_event->get_id() ) + { + ( _this->*_method )( *specialized_event ); + } + } + else + { + throw sxy::exception( "Invalid event type!" ); + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + ( _this->*_method )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _class, typename _event_type1, typename _event_type2 > +void method_caller( const sxy::event& _event, _class* _this, + void ( _class::* _method1 )( const _event_type1& ), void ( _class::* _method2 )( const _event_type2& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( _this->*_method1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( _this->*_method2 )( *specialized_event2 ); + } + else + { + throw sxy::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); + ( _this->*_method1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >(_event); + ( _this->*_method2 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _class, typename _event_type1, typename _event_type2, typename _event_type3 > +void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method1 )( const _event_type1& ), + void ( _class::* _method2 )( const _event_type2& ), void ( _class::* _method3 )( const _event_type3& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( _this->*_method1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( _this->*_method2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( _this->*_method3 )( *specialized_event3 ); + } + else + { + throw sxy::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 ); + ( _this->*_method1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( _this->*_method2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( _this->*_method3 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _class, typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > +void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method1 )( const _event_type1& ), + void ( _class::* _method2 )( const _event_type2& ), void ( _class::* _method3 )( const _event_type3& ), + void ( _class::* _method4 )( const _event_type4& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( _this->*_method1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( _this->*_method2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( _this->*_method3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( _this->*_method4 )( *specialized_event4 ); + } + else + { + throw sxy::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 ); + ( _this->*_method1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( _this->*_method2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( _this->*_method3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( _this->*_method4 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _class, typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5 > +void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method1 )( const _event_type1& ), + void ( _class::* _method2 )( const _event_type2& ), void ( _class::* _method3 )( const _event_type3& ), + void ( _class::* _method4 )( const _event_type4& ), void ( _class::* _method5 )( const _event_type5& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( _this->*_method1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( _this->*_method2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( _this->*_method3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( _this->*_method4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( _this->*_method5 )( *specialized_event5 ); + } + else + { + throw sxy::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 ); + ( _this->*_method1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( _this->*_method2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( _this->*_method3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( _this->*_method4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( _this->*_method5 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type > +void function_caller( const sxy::event& _event, void ( *_function )( const _event_type& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + ( *_function )( *specialized_event ); + } + else + { + throw sxy::exception( "Invalid event type!" ); + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type >(_event); + ( *_function )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2 > +void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), + void ( *_function_2 )( const _event_type2& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + throw sxy::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); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >(_event); + ( *_function_2 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3 > +void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), + void ( * _function_2 )( const _event_type2& ), void ( *_function_3 )( const _event_type3& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > +void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), + void ( * _function_2 )( const _event_type2& ), void ( *_function_3 )( const _event_type3& ), + void ( * _function_4 )( const _event_type4& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5 > +void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), + void ( *_function_2 )( const _event_type2& ), void ( *_function_3 )( const _event_type3& ), + void ( *_function_4 )( const _event_type4& ), void ( *_function_5 )( const _event_type5& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( *_function_5 )( *specialized_event5 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( *_function_5 )( specialized_event ); + break; + } + + default: + Y_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 function_caller( const sxy::event& _event, void( *_function_1 )( const _event_type1& ), + void( *_function_2 )( const _event_type2& ), void( *_function_3 )( const _event_type3& ), + void( *_function_4 )( const _event_type4& ), void( *_function_5 )( const _event_type5& ), + void( *_function_6 )( const _event_type6& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( *_function_5 )( *specialized_event5 ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + ( *_function_6 )( *specialized_event6 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( *_function_5 )( specialized_event ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + ( *_function_6 )( specialized_event ); + break; + } + + default: + Y_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 function_caller( const sxy::event& _event, void( *_function_1 )( const _event_type1& ), + void( *_function_2 )( const _event_type2& ), void( *_function_3 )( const _event_type3& ), + void( *_function_4 )( const _event_type4& ), void( *_function_5 )( const _event_type5& ), + void( *_function_6 )( const _event_type6& ), void( *_function_7 )( const _event_type7& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( *_function_5 )( *specialized_event5 ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + ( *_function_6 )( *specialized_event6 ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + ( *_function_7 )( *specialized_event7 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( *_function_5 )( specialized_event ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + ( *_function_6 )( specialized_event ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + ( *_function_7 )( specialized_event ); + break; + } + + default: + Y_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 function_caller( const sxy::event& _event, void( *_function_1 )( const _event_type1& ), + void( *_function_2 )( const _event_type2& ), void( *_function_3 )( const _event_type3& ), + void( *_function_4 )( const _event_type4& ), void( *_function_5 )( const _event_type5& ), + void( *_function_6 )( const _event_type6& ), void( *_function_7 )( const _event_type7& ), + void( *_function_8 )( const _event_type8& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( *_function_5 )( *specialized_event5 ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + ( *_function_6 )( *specialized_event6 ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + ( *_function_7 )( *specialized_event7 ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + ( *_function_8 )( *specialized_event8 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( *_function_5 )( specialized_event ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + ( *_function_6 )( specialized_event ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + ( *_function_7 )( specialized_event ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + ( *_function_8 )( specialized_event ); + break; + } + + default: + Y_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 function_caller( const sxy::event& _event, void( *_function_1 )( const _event_type1& ), + void( *_function_2 )( const _event_type2& ), void( *_function_3 )( const _event_type3& ), + void( *_function_4 )( const _event_type4& ), void( *_function_5 )( const _event_type5& ), + void( *_function_6 )( const _event_type6& ), void( *_function_7 )( const _event_type7& ), + void( *_function_8 )( const _event_type8& ), void( *_function_9 )( const _event_type9& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( *_function_5 )( *specialized_event5 ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + ( *_function_6 )( *specialized_event6 ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + ( *_function_7 )( *specialized_event7 ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + ( *_function_8 )( *specialized_event8 ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + ( *_function_9 )( *specialized_event9 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( *_function_5 )( specialized_event ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + ( *_function_6 )( specialized_event ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + ( *_function_7 )( specialized_event ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + ( *_function_8 )( specialized_event ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + ( *_function_9 )( specialized_event ); + break; + } + + default: + Y_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 function_caller( const sxy::event& _event, void( *_function_1 )( const _event_type1& ), + void( *_function_2 )( const _event_type2& ), void( *_function_3 )( const _event_type3& ), + void( *_function_4 )( const _event_type4& ), void( *_function_5 )( const _event_type5& ), + void( *_function_6 )( const _event_type6& ), void( *_function_7 )( const _event_type7& ), + void( *_function_8 )( const _event_type8& ), void( *_function_9 )( const _event_type9& ), + void( *_function_10 )( const _event_type10& ) ) +{ +#if defined( Y_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + ( *_function_1 )( *specialized_event ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + ( *_function_2 )( *specialized_event2 ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + ( *_function_3 )( *specialized_event3 ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + ( *_function_4 )( *specialized_event4 ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + ( *_function_5 )( *specialized_event5 ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + ( *_function_6 )( *specialized_event6 ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + ( *_function_7 )( *specialized_event7 ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + ( *_function_8 )( *specialized_event8 ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + ( *_function_9 )( *specialized_event9 ); + } + else + { + const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); + if( specialized_event10 ) + { + ( *_function_10 )( *specialized_event10 ); + } + else + { + throw sxy::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 ); + ( *_function_1 )( specialized_event ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + ( *_function_2 )( specialized_event ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + ( *_function_3 )( specialized_event ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + ( *_function_4 )( specialized_event ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + ( *_function_5 )( specialized_event ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + ( *_function_6 )( specialized_event ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + ( *_function_7 )( specialized_event ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + ( *_function_8 )( specialized_event ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + ( *_function_9 )( specialized_event ); + break; + } + + case _event_type10::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); + ( *_function_10 )( specialized_event ); + break; + } + + default: + Y_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +} + + +#endif diff --git a/yasmine/yasmine/choice.hpp b/libyasmine/include/choice.hpp similarity index 100% rename from yasmine/yasmine/choice.hpp rename to libyasmine/include/choice.hpp diff --git a/yasmine/yasmine/choice_fwd.hpp b/libyasmine/include/choice_fwd.hpp similarity index 100% rename from yasmine/yasmine/choice_fwd.hpp rename to libyasmine/include/choice_fwd.hpp diff --git a/yasmine/yasmine/chrono.hpp b/libyasmine/include/chrono.hpp similarity index 95% rename from yasmine/yasmine/chrono.hpp rename to libyasmine/include/chrono.hpp index 076c7d0..53d34dc 100644 --- a/yasmine/yasmine/chrono.hpp +++ b/libyasmine/include/chrono.hpp @@ -28,7 +28,7 @@ namespace sxy { -#ifdef Y_CPP03_BOOST // c++03 compatibility +#ifdef Y_CPP03_BOOST // C++03 compatibility using boost::chrono::time_point; using boost::chrono::system_clock; @@ -39,7 +39,7 @@ namespace sxy using boost::chrono::time_point; -#else // c++11 compatibility +#else // C++11 compatibility using std::chrono::time_point; diff --git a/yasmine/yasmine/color.hpp b/libyasmine/include/color.hpp similarity index 100% rename from yasmine/yasmine/color.hpp rename to libyasmine/include/color.hpp diff --git a/yasmine/yasmine/color_mapping.hpp b/libyasmine/include/color_mapping.hpp similarity index 100% rename from yasmine/yasmine/color_mapping.hpp rename to libyasmine/include/color_mapping.hpp diff --git a/yasmine/yasmine/compatibility.hpp b/libyasmine/include/compatibility.hpp similarity index 82% rename from yasmine/yasmine/compatibility.hpp rename to libyasmine/include/compatibility.hpp index 5b334ff..460d61d 100644 --- a/yasmine/yasmine/compatibility.hpp +++ b/libyasmine/include/compatibility.hpp @@ -14,7 +14,12 @@ #ifdef Y_CPP03_BOOST +#ifdef _MSC_VER +#pragma warning( push ) #pragma warning( disable : 4456 ) +#pragma warning( disable : 4996 ) +#endif + #include #include @@ -23,10 +28,19 @@ #include #include #include +#include +#include + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + #else #include #include #include +#include +#include #endif @@ -34,7 +48,7 @@ namespace sxy { -#ifdef Y_CPP03_BOOST // c++03 compatibility +#ifdef Y_CPP03_BOOST // C++03 compatibility #define Y_OVERRIDE #define Y_FINAL @@ -73,8 +87,13 @@ namespace sxy using boost::function; + using boost::remove_reference; + using boost::remove_const; -#else // c++11 compatibility + using boost::random_device; + + +#else // C++11 compatibility #ifdef Y_NO_STD_MAKE_UNIQUE @@ -96,7 +115,15 @@ namespace sxy #define Y_FOR(_variable, _container) for( _variable : _container ) - #define Y_CONSTEXPR constexpr + #ifdef _MSC_VER + #if _MSC_VER <= 1800 + #define Y_CONSTEXPR const + #endif + #endif + + #ifndef Y_CONSTEXPR + #define Y_CONSTEXPR constexpr + #endif #ifdef _MSC_VER #if _MSC_VER <= 1800 @@ -131,6 +158,12 @@ namespace sxy using std::function; + using std::remove_reference; + using std::remove_const; + + using std::random_device; + + #endif diff --git a/libyasmine/include/completion_event.hpp b/libyasmine/include/completion_event.hpp new file mode 100644 index 0000000..9fd1734 --- /dev/null +++ b/libyasmine/include/completion_event.hpp @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.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 +{ + + + +#ifdef Y_CPP03_BOOST + extern const event_id Y_COMPLETION_EVENT_ID; + Y_EVENT_WITH_ID( completion_event, Y_INTERNAL_COMPLETION_EVENT_ID ) +#else + #ifdef _MSC_VER + #if _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 + #else + constexpr event_id Y_COMPLETION_EVENT_ID = std::numeric_limits::max(); + Y_EVENT_WITH_ID( completion_event, Y_COMPLETION_EVENT_ID ) + #endif +#endif + + +} + + +#endif diff --git a/yasmine/yasmine/complex_state.hpp b/libyasmine/include/complex_state.hpp similarity index 100% rename from yasmine/yasmine/complex_state.hpp rename to libyasmine/include/complex_state.hpp diff --git a/yasmine/yasmine/complex_state_impl.hpp b/libyasmine/include/complex_state_impl.hpp similarity index 80% rename from yasmine/yasmine/complex_state_impl.hpp rename to libyasmine/include/complex_state_impl.hpp index 172efad..1c47ba3 100644 --- a/yasmine/yasmine/complex_state_impl.hpp +++ b/libyasmine/include/complex_state_impl.hpp @@ -15,7 +15,7 @@ #include "complex_state.hpp" #include "state_impl.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" namespace sxy @@ -26,12 +26,12 @@ class complex_state_impl: public virtual complex_state, public state_impl { public: - explicit complex_state_impl( const std::string& _name, behaviour_uptr _entry_behaviour, - behaviour_uptr _exit_behaviour, const event_ids& _deferred_events = event_ids() ); + 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() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(complex_state_impl) - virtual behaviour * get_entry_behaviour() const Y_OVERRIDE; - virtual behaviour * get_exit_behaviour() const Y_OVERRIDE; + virtual behavior * get_entry_behavior() const Y_OVERRIDE; + virtual behavior * get_exit_behavior() const Y_OVERRIDE; virtual bool is_event_deferred( const event_id& _event_id ) const Y_OVERRIDE; @@ -40,8 +40,8 @@ class complex_state_impl: private: - behaviour_uptr entry_; - behaviour_uptr exit_; + behavior_uptr entry_; + behavior_uptr exit_; event_ids deferred_events_; }; diff --git a/yasmine/yasmine/composite_state.hpp b/libyasmine/include/composite_state.hpp similarity index 100% rename from yasmine/yasmine/composite_state.hpp rename to libyasmine/include/composite_state.hpp diff --git a/yasmine/yasmine/composite_state_fwd.hpp b/libyasmine/include/composite_state_fwd.hpp similarity index 100% rename from yasmine/yasmine/composite_state_fwd.hpp rename to libyasmine/include/composite_state_fwd.hpp diff --git a/yasmine/yasmine/constraint.hpp b/libyasmine/include/constraint.hpp similarity index 100% rename from yasmine/yasmine/constraint.hpp rename to libyasmine/include/constraint.hpp diff --git a/yasmine/yasmine/constraint_fwd.hpp b/libyasmine/include/constraint_fwd.hpp similarity index 100% rename from yasmine/yasmine/constraint_fwd.hpp rename to libyasmine/include/constraint_fwd.hpp diff --git a/yasmine/yasmine/cout_logger.hpp b/libyasmine/include/cout_logger.hpp similarity index 100% rename from yasmine/yasmine/cout_logger.hpp rename to libyasmine/include/cout_logger.hpp diff --git a/yasmine/yasmine/deep_history.hpp b/libyasmine/include/deep_history.hpp similarity index 100% rename from yasmine/yasmine/deep_history.hpp rename to libyasmine/include/deep_history.hpp diff --git a/yasmine/yasmine/deep_history_fwd.hpp b/libyasmine/include/deep_history_fwd.hpp similarity index 100% rename from yasmine/yasmine/deep_history_fwd.hpp rename to libyasmine/include/deep_history_fwd.hpp diff --git a/yasmine/yasmine/entry_point.hpp b/libyasmine/include/entry_point.hpp similarity index 97% rename from yasmine/yasmine/entry_point.hpp rename to libyasmine/include/entry_point.hpp index 138c52c..b324e9e 100644 --- a/yasmine/yasmine/entry_point.hpp +++ b/libyasmine/include/entry_point.hpp @@ -13,7 +13,6 @@ #define ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F -//#include "pseudostate.hpp" #include "state_pseudostate.hpp" #include "entry_point_fwd.hpp" diff --git a/yasmine/yasmine/entry_point_fwd.hpp b/libyasmine/include/entry_point_fwd.hpp similarity index 100% rename from yasmine/yasmine/entry_point_fwd.hpp rename to libyasmine/include/entry_point_fwd.hpp diff --git a/yasmine/yasmine/event.hpp b/libyasmine/include/event.hpp similarity index 100% rename from yasmine/yasmine/event.hpp rename to libyasmine/include/event.hpp diff --git a/yasmine/yasmine/event_creation_request.hpp b/libyasmine/include/event_creation_request.hpp similarity index 97% rename from yasmine/yasmine/event_creation_request.hpp rename to libyasmine/include/event_creation_request.hpp index 8a7e9ca..ff9f6fe 100644 --- a/yasmine/yasmine/event_creation_request.hpp +++ b/libyasmine/include/event_creation_request.hpp @@ -15,9 +15,8 @@ #include "chrono.hpp" #include "event_id.hpp" -#include "log.hpp" +#include "non_copyable.hpp" #include "event_fwd.hpp" -#include "compatibility.hpp" #include "event_handle.hpp" diff --git a/yasmine/yasmine/event_creation_request_time_comparer.hpp b/libyasmine/include/event_creation_request_time_comparer.hpp similarity index 95% rename from yasmine/yasmine/event_creation_request_time_comparer.hpp rename to libyasmine/include/event_creation_request_time_comparer.hpp index 82ca2c5..f5ec9ae 100644 --- a/yasmine/yasmine/event_creation_request_time_comparer.hpp +++ b/libyasmine/include/event_creation_request_time_comparer.hpp @@ -13,15 +13,13 @@ #define EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A -#include - -#include "event_creation_request.hpp" - - namespace sxy { +class event_creation_request; + + struct event_creation_request_time_comparer { public: diff --git a/yasmine/yasmine/event_fwd.hpp b/libyasmine/include/event_fwd.hpp similarity index 100% rename from yasmine/yasmine/event_fwd.hpp rename to libyasmine/include/event_fwd.hpp diff --git a/yasmine/yasmine/event_handle.hpp b/libyasmine/include/event_handle.hpp similarity index 100% rename from yasmine/yasmine/event_handle.hpp rename to libyasmine/include/event_handle.hpp diff --git a/yasmine/yasmine/event_id.hpp b/libyasmine/include/event_id.hpp similarity index 99% rename from yasmine/yasmine/event_id.hpp rename to libyasmine/include/event_id.hpp index ebcca66..c52159f 100644 --- a/yasmine/yasmine/event_id.hpp +++ b/libyasmine/include/event_id.hpp @@ -14,6 +14,7 @@ #include + #include "compatibility.hpp" diff --git a/yasmine/yasmine/event_impl.hpp b/libyasmine/include/event_impl.hpp similarity index 96% rename from yasmine/yasmine/event_impl.hpp rename to libyasmine/include/event_impl.hpp index 587ee71..9078b43 100644 --- a/yasmine/yasmine/event_impl.hpp +++ b/libyasmine/include/event_impl.hpp @@ -13,10 +13,6 @@ #define EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 -#include -#include - -#include "compatibility.hpp" #include "event.hpp" diff --git a/yasmine/yasmine/event_priority.hpp b/libyasmine/include/event_priority.hpp similarity index 85% rename from yasmine/yasmine/event_priority.hpp rename to libyasmine/include/event_priority.hpp index 1e63a0a..117ee9e 100644 --- a/yasmine/yasmine/event_priority.hpp +++ b/libyasmine/include/event_priority.hpp @@ -39,16 +39,10 @@ typedef std::vector< event_priority > event_prioritys; //!\brief yasmine's predefined default event priority. constexpr event_priority DEFAULT_EVENT_PRIORITY = 0; #endif -#else - #if defined( Y_CPP03_BOOST ) +#else #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/libyasmine/include/event_template.hpp b/libyasmine/include/event_template.hpp new file mode 100644 index 0000000..2589f24 --- /dev/null +++ b/libyasmine/include/event_template.hpp @@ -0,0 +1,1324 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 +#define EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 + + +#include "specialized_event.hpp" +#include "compatibility.hpp" + + +#ifdef Y_CPP03_BOOST + #define Y_AUX_DEFAULT_EVENT_PRIORITY DEFAULT_EVENT_PRIORITY +#else + #ifdef _MSC_VER + #if _MSC_VER <= 1800 + #define Y_AUX_DEFAULT_EVENT_PRIORITY DEFAULT_EVENT_PRIORITY + #else + #define Y_AUX_DEFAULT_EVENT_PRIORITY sxy::DEFAULT_EVENT_PRIORITY + #endif + #else + #define Y_AUX_DEFAULT_EVENT_PRIORITY DEFAULT_EVENT_PRIORITY + #endif + +#endif + + +#ifndef Y_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__) ) + +//!\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, _event_id, ... ) Y_EVENT_EXPAND( Y_VA_SELECT( Y_EVENT_PARAM, _class_name, _event_id, __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 ) + + +#endif + + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + explicit _class_name() \ + : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_NO_COPY(_class_name)\ +\ +\ + static sxy::shared_ptr< _class_name > create() { \ + return( Y_MAKE_SHARED< _class_name >() ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + explicit _class_name( const _param_type1& _p1 ) \ + : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ +Y_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > create( const _param_type1& _p1 ) \ + { \ + return( Y_MAKE_SHARED< _class_name >( _p1 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event will have one parameter. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2 ) \ + : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > create( const _param_type1& _p1, const _param_type2& _p2 ) \ + { \ + return( Y_MAKE_SHARED< _class_name >( _p1, _p2 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event will have two parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) \ + : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) \ + { \ + return( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have three parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::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< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4 ) \ + { \ + return( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have four parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::remove_reference::type>::type _param_type4;\ + typedef sxy::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< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5 ) \ + { \ + return( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have five parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::remove_reference::type>::type _param_type4;\ + typedef sxy::remove_reference::type>::type _param_type5;\ + typedef sxy::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< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > 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( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5, _p6 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have six parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::remove_reference::type>::type _param_type4;\ + typedef sxy::remove_reference::type>::type _param_type5;\ + typedef sxy::remove_reference::type>::type _param_type6;\ + typedef sxy::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< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ + } \ +\ +\ + static sxy::shared_ptr< _class_name > 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( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) ); \ + } \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have seven parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::remove_reference::type>::type _param_type4;\ + typedef sxy::remove_reference::type>::type _param_type5;\ + typedef sxy::remove_reference::type>::type _param_type6;\ + typedef sxy::remove_reference::type>::type _param_type7;\ + typedef sxy::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< struct _class_name##_tag, _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() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ + } \ +\ +\ +static sxy::shared_ptr< _class_name > 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( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) ); \ +} \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have seven parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::remove_reference::type>::type _param_type4;\ + typedef sxy::remove_reference::type>::type _param_type5;\ + typedef sxy::remove_reference::type>::type _param_type6;\ + typedef sxy::remove_reference::type>::type _param_type7;\ + typedef sxy::remove_reference::type>::type _param_type8;\ + typedef sxy::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< struct _class_name##_tag, _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() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ +} \ +\ +\ +static sxy::shared_ptr< _class_name > 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( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9 ) ); \ +} \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have seven parameters. The event priority will be 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 will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ +public: \ + typedef sxy::remove_reference::type>::type _param_type1;\ + typedef sxy::remove_reference::type>::type _param_type2;\ + typedef sxy::remove_reference::type>::type _param_type3;\ + typedef sxy::remove_reference::type>::type _param_type4;\ + typedef sxy::remove_reference::type>::type _param_type5;\ + typedef sxy::remove_reference::type>::type _param_type6;\ + typedef sxy::remove_reference::type>::type _param_type7;\ + typedef sxy::remove_reference::type>::type _param_type8;\ + typedef sxy::remove_reference::type>::type _param_type9;\ + typedef sxy::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< struct _class_name##_tag, _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() Y_NOEXCEPT Y_OVERRIDE \ + { \ + } \ +\ +\ + Y_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_ ); \ +} \ +\ +\ +static sxy::shared_ptr< _class_name > 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( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10 ) ); \ +} \ +\ +\ + virtual sxy::event_id get_id() const Y_OVERRIDE\ + { \ + return( _event_id ); \ + } \ +\ +\ + static Y_CONSTEXPR sxy::event_id get_event_id() \ + { \ + return( _event_id ); \ + } \ +\ +\ +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 will have seven parameters. The event priority will be 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/yasmine/exception.hpp b/libyasmine/include/exception.hpp similarity index 100% rename from yasmine/yasmine/exception.hpp rename to libyasmine/include/exception.hpp diff --git a/yasmine/yasmine/exception_template.hpp b/libyasmine/include/exception_template.hpp similarity index 61% rename from yasmine/yasmine/exception_template.hpp rename to libyasmine/include/exception_template.hpp index 8b90ac9..c792d6d 100644 --- a/yasmine/yasmine/exception_template.hpp +++ b/libyasmine/include/exception_template.hpp @@ -14,7 +14,6 @@ #include -#include #include "compatibility.hpp" #include "yprintf.hpp" @@ -25,7 +24,7 @@ //!\def Y_EXCEPTION( _name ) //!\brief The macro creates an exception class inheriting the std::exception with the given name. It also supports -// creating messages with placeholders by calling yprintf. +//! creating messages with placeholders by calling yprintf. //!\sa yprintf #define Y_EXCEPTION( _name ) \ class _name: public std::exception \ @@ -103,6 +102,42 @@ public: \ { \ } \ \ +\ + explicit _name(const std::string & _what, const log_value& _value1, const log_value& _value2, const log_value& _value3, const log_value& _value4, const log_value& _value5, const log_value& _value6 )\ + : std::exception(), \ + what_( yprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6 ) ) \ + { \ + } \ +\ +\ +\ + explicit _name(const std::string & _what, const log_value& _value1, const log_value& _value2, const log_value& _value3, const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7 )\ + : std::exception(), \ + what_( yprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const log_value& _value1, const log_value& _value2, const log_value& _value3, const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, const log_value& _value8 )\ + : std::exception(), \ + what_( yprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const log_value& _value1, const log_value& _value2, const log_value& _value3, const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, const log_value& _value8, const log_value& _value9 )\ + : std::exception(), \ + what_( yprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const log_value& _value1, const log_value& _value2, const log_value& _value3, const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, const log_value& _value8, const log_value& _value9, const log_value& _value10 )\ + : std::exception(), \ + what_( yprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ) \ + { \ + } \ +\ \ virtual ~_name () Y_NOEXCEPT Y_OVERRIDE {}\ \ diff --git a/yasmine/yasmine/exit_point.hpp b/libyasmine/include/exit_point.hpp similarity index 98% rename from yasmine/yasmine/exit_point.hpp rename to libyasmine/include/exit_point.hpp index f5d8600..083f682 100644 --- a/yasmine/yasmine/exit_point.hpp +++ b/libyasmine/include/exit_point.hpp @@ -13,7 +13,6 @@ #define EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 -#include "pseudostate.hpp" #include "state_pseudostate.hpp" #include "exit_point_fwd.hpp" diff --git a/yasmine/yasmine/exit_point_fwd.hpp b/libyasmine/include/exit_point_fwd.hpp similarity index 100% rename from yasmine/yasmine/exit_point_fwd.hpp rename to libyasmine/include/exit_point_fwd.hpp diff --git a/yasmine/yasmine/file_logger.hpp b/libyasmine/include/file_logger.hpp similarity index 98% rename from yasmine/yasmine/file_logger.hpp rename to libyasmine/include/file_logger.hpp index 16d628b..d7bc8ba 100644 --- a/yasmine/yasmine/file_logger.hpp +++ b/libyasmine/include/file_logger.hpp @@ -13,8 +13,6 @@ #ifndef FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 #define FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 -#include -#include #include "logger.hpp" #include "exception_template.hpp" diff --git a/yasmine/yasmine/final_state.hpp b/libyasmine/include/final_state.hpp similarity index 100% rename from yasmine/yasmine/final_state.hpp rename to libyasmine/include/final_state.hpp diff --git a/yasmine/yasmine/fork.hpp b/libyasmine/include/fork.hpp similarity index 100% rename from yasmine/yasmine/fork.hpp rename to libyasmine/include/fork.hpp diff --git a/yasmine/yasmine/fork_fwd.hpp b/libyasmine/include/fork_fwd.hpp similarity index 100% rename from yasmine/yasmine/fork_fwd.hpp rename to libyasmine/include/fork_fwd.hpp diff --git a/yasmine/yasmine/format_settings.hpp b/libyasmine/include/format_settings.hpp similarity index 100% rename from yasmine/yasmine/format_settings.hpp rename to libyasmine/include/format_settings.hpp diff --git a/yasmine/yasmine/history.hpp b/libyasmine/include/history.hpp similarity index 98% rename from yasmine/yasmine/history.hpp rename to libyasmine/include/history.hpp index f6f00af..f0d8a09 100644 --- a/yasmine/yasmine/history.hpp +++ b/libyasmine/include/history.hpp @@ -13,7 +13,6 @@ #define HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 -#include "pseudostate.hpp" #include "state_pseudostate.hpp" diff --git a/yasmine/yasmine/initial_pseudostate.hpp b/libyasmine/include/initial_pseudostate.hpp similarity index 98% rename from yasmine/yasmine/initial_pseudostate.hpp rename to libyasmine/include/initial_pseudostate.hpp index a6bba22..c203a6a 100644 --- a/yasmine/yasmine/initial_pseudostate.hpp +++ b/libyasmine/include/initial_pseudostate.hpp @@ -13,7 +13,6 @@ #define INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E -#include "pseudostate.hpp" #include "region_pseudostate.hpp" #include "initial_pseudostate_fwd.hpp" diff --git a/yasmine/yasmine/initial_pseudostate_fwd.hpp b/libyasmine/include/initial_pseudostate_fwd.hpp similarity index 100% rename from yasmine/yasmine/initial_pseudostate_fwd.hpp rename to libyasmine/include/initial_pseudostate_fwd.hpp diff --git a/yasmine/yasmine/completion_event.hpp b/libyasmine/include/internal_completion_event_id.hpp similarity index 73% rename from yasmine/yasmine/completion_event.hpp rename to libyasmine/include/internal_completion_event_id.hpp index 556d746..6804e75 100644 --- a/yasmine/yasmine/completion_event.hpp +++ b/libyasmine/include/internal_completion_event_id.hpp @@ -9,8 +9,8 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 -#define COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 +#ifndef INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 +#define INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 #include "event_template.hpp" @@ -26,22 +26,16 @@ #endif -namespace sxy -{ - - -//!\brief yasmine's predefined event ID for the completion event. +//!\brief yasmine's predefined internal event ID for the completion event. #ifdef Y_CPP03_BOOST -#define COMPLETION_EVENT_ID UINT_MAX + #define Y_INTERNAL_COMPLETION_EVENT_ID UINT_MAX #else - constexpr event_id COMPLETION_EVENT_ID = std::numeric_limits::max(); + #ifdef _MSC_VER + #if _MSC_VER <= 1800 + #define Y_INTERNAL_COMPLETION_EVENT_ID UINT_MAX + #endif + #endif #endif - - - Y_EVENT_WITH_ID(completion_event, COMPLETION_EVENT_ID); - - -} - + #endif diff --git a/yasmine/yasmine/join.hpp b/libyasmine/include/join.hpp similarity index 100% rename from yasmine/yasmine/join.hpp rename to libyasmine/include/join.hpp diff --git a/yasmine/yasmine/join_fwd.hpp b/libyasmine/include/join_fwd.hpp similarity index 99% rename from yasmine/yasmine/join_fwd.hpp rename to libyasmine/include/join_fwd.hpp index 85000e8..a4bec12 100644 --- a/yasmine/yasmine/join_fwd.hpp +++ b/libyasmine/include/join_fwd.hpp @@ -14,6 +14,7 @@ #include + #include "compatibility.hpp" diff --git a/yasmine/yasmine/junction.hpp b/libyasmine/include/junction.hpp similarity index 100% rename from yasmine/yasmine/junction.hpp rename to libyasmine/include/junction.hpp diff --git a/yasmine/yasmine/junction_fwd.hpp b/libyasmine/include/junction_fwd.hpp similarity index 99% rename from yasmine/yasmine/junction_fwd.hpp rename to libyasmine/include/junction_fwd.hpp index 99dd1f2..785ab68 100644 --- a/yasmine/yasmine/junction_fwd.hpp +++ b/libyasmine/include/junction_fwd.hpp @@ -14,6 +14,7 @@ #include + #include "compatibility.hpp" diff --git a/yasmine/yasmine/log.hpp b/libyasmine/include/log.hpp similarity index 84% rename from yasmine/yasmine/log.hpp rename to libyasmine/include/log.hpp index 848ede9..73eccf1 100644 --- a/yasmine/yasmine/log.hpp +++ b/libyasmine/include/log.hpp @@ -93,10 +93,27 @@ void parameter_muncher( T, args ... _args ) while( false ) +//!\brief Macro to create a log message and wait for the message to be written by the logger. +//!\param _level The log level of the message. +//!\param ... Parameters that are inserted into the message. +//!\sa yprintf +#define Y_LOG_AND_WAIT( _level, ... ) \ + do \ + { \ + sxy::log_manager_template& l_log_manager = sxy::log_manager::get_instance(); \ + if( _level <= l_log_manager.get_log_level() ) \ + { \ + l_log_manager.log_and_wait( _level, sxy::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, __VA_ARGS__ ); \ + } \ + } \ + while( false ) + + #else #define Y_LOG sxy::log_helper( __FILE__, __LINE__).log +#define Y_LOG_AND_WAIT sxy::log_helper( __FILE__, __LINE__).log_and_wait #endif diff --git a/libyasmine/include/log_callback.hpp b/libyasmine/include/log_callback.hpp new file mode 100644 index 0000000..ff7d832 --- /dev/null +++ b/libyasmine/include/log_callback.hpp @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef Y_NO_LOGGING + + +#ifndef LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 +#define LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 + + +#include "compatibility.hpp" + + +namespace sxy +{ + + +class log_callback +{ +public: + log_callback() + { + // Nothing to do... + } + + + virtual ~log_callback() Y_NOEXCEPT + { + // Nothing to do... + } + + + virtual void wait() = 0; + virtual void done() = 0; + virtual bool is_done() = 0; +}; + +} + + +#endif + + +#endif diff --git a/yasmine/yasmine/log_helper.hpp b/libyasmine/include/log_helper.hpp similarity index 53% rename from yasmine/yasmine/log_helper.hpp rename to libyasmine/include/log_helper.hpp index 81bbf45..658a863 100644 --- a/yasmine/yasmine/log_helper.hpp +++ b/libyasmine/include/log_helper.hpp @@ -46,7 +46,7 @@ class log_helper Y_FINAL log_manager_template& l_log_manager = log_manager::get_instance(); if( _level <= l_log_manager.get_log_level() ) { - log_manager::get_instance().log( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + l_log_manager.log( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1 ); } } @@ -183,6 +183,149 @@ class log_helper Y_FINAL } + template< typename _parameter_type1 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, + _value2, _value3, _value4 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4, + typename _parameter_type5 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4, _parameter_type5 _value5 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4, + typename _parameter_type5, typename _parameter_type6 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4, _parameter_type5 _value5, + _parameter_type6 _value6 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4, + typename _parameter_type5, typename _parameter_type6, typename _parameter_type7 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4, _parameter_type5 _value5, + _parameter_type6 _value6, _parameter_type7 _value7 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4, + typename _parameter_type5, typename _parameter_type6, typename _parameter_type7, typename _parameter_type8 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4, _parameter_type5 _value5, + _parameter_type6 _value6, _parameter_type7 _value7, _parameter_type8 _value8 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4, + typename _parameter_type5, typename _parameter_type6, typename _parameter_type7, typename _parameter_type8, + typename _parameter_type9 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4, _parameter_type5 _value5, + _parameter_type6 _value6, _parameter_type7 _value7, _parameter_type8 _value8, _parameter_type9 _value9 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, typename _parameter_type4, + typename _parameter_type5, typename _parameter_type6, typename _parameter_type7, typename _parameter_type8, + typename _parameter_type9, typename _parameter_type10 > + void log_and_wait( const log_level& _level, const std::string& _message, _parameter_type1 _value1, + _parameter_type2 _value2, _parameter_type3 _value3, _parameter_type4 _value4, _parameter_type5 _value5, + _parameter_type6 _value6, _parameter_type7 _value7, _parameter_type8 _value8, _parameter_type9 _value9, + _parameter_type10 _value10 ) const + { + log_manager_template& l_log_manager = log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log_and_wait( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); + } + } + + private: const std::string& file_name_; const int line_; diff --git a/yasmine/yasmine/log_level.hpp b/libyasmine/include/log_level.hpp similarity index 94% rename from yasmine/yasmine/log_level.hpp rename to libyasmine/include/log_level.hpp index a8e1817..a4be0d2 100644 --- a/yasmine/yasmine/log_level.hpp +++ b/libyasmine/include/log_level.hpp @@ -28,8 +28,7 @@ namespace sxy //!\brief Enum class for log levels. enum class log_level { - LL_OFF = -1, LL_ASSERT = 0, LL_FATAL = 1, LL_ERROR = 2, LL_WARN = 3, LL_INFO = 4, LL_DEBUG = 5, LL_TRACE = 6, LL_SPAM = 7, - LL_PROTOCOL = 8 + LL_OFF = -1, LL_ASSERT = 0, LL_FATAL = 1, LL_ERROR = 2, LL_WARN = 3, LL_INFO = 4, LL_DEBUG = 5, LL_TRACE = 6, LL_SPAM = 7 }; @@ -39,8 +38,7 @@ struct log_level { enum inner { - LL_OFF = -1, LL_ASSERT = 0, LL_FATAL = 1, LL_ERROR = 2, LL_WARN = 3, LL_INFO = 4, LL_DEBUG = 5, LL_TRACE = 6, LL_SPAM = 7, - LL_PROTOCOL = 8 + LL_OFF = -1, LL_ASSERT = 0, LL_FATAL = 1, LL_ERROR = 2, LL_WARN = 3, LL_INFO = 4, LL_DEBUG = 5, LL_TRACE = 6, LL_SPAM = 7 }; diff --git a/libyasmine/include/log_manager_template.hpp b/libyasmine/include/log_manager_template.hpp new file mode 100644 index 0000000..b78cc66 --- /dev/null +++ b/libyasmine/include/log_manager_template.hpp @@ -0,0 +1,592 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef Y_NO_LOGGING + + +#ifndef LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B +#define LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B + + +#include + +#include "base.hpp" +#include "logger.hpp" +#include "log_message.hpp" +#include "yprintf.hpp" +#include "waiter.hpp" + + +namespace sxy +{ + + +namespace +{ + + +bool LOG_MANAGER_EXISTS = false; + + +} + +//!\class t_log_manager_template +//!\brief The log manager (a singleton) controls the different loggers, manages the current log level, and takes care +//!of dispatching log messages. +template< typename time_stamp_policy > +class log_manager_template Y_FINAL +{ +public: + //!\brief Get a reference to the single instance of the log manager template. + static log_manager_template& get_instance( void ) + { + static log_manager_template instance; + return( instance ); + } + + + Y_NO_COPY(log_manager_template) + + //!\brief Gets the currently set log level. + //!\return Current log level. + log_level get_log_level() const + { + return( log_level_ ); + } + + + //!\brief Sets a new log level. + //!\param _log_level Log level to be set. + //!\return void + void set_log_level( const log_level _log_level ) + { + log_level_ = _log_level; + } + + +#ifndef Y_CPP03_BOOST + + + //!\brief Add a message to the queue of messages that will be processed. + //!\param _log_level Log level of the message. + //!\param _time_stamp Date and time when the log message was created. + //!\param _file The file from where the log was called. + //!\param _line The line from where the log was called. + //!\param _message The message text for the log. + //!\param _args Parameters that are inserted in the message. + //!\return void + //!\sa log_and_wait, Y_LOG(), yprintf + template< typename ... args > + void log( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, args ... _args ) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _args ... ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + } + + + //!\brief Add a message to the queue of messages and waits the message to be processed. + //!\param _log_level Log level of the message. + //!\param _time_stamp Date and time when the log message was created. + //!\param _file The file from where the log was called. + //!\param _line The line from where the log was called. + //!\param _message The message text for the log. + //!\param _args Parameters that are inserted in the message. + //!\return void + //!\sa log, Y_LOG(), yprintf + template< typename ... args > + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, args ... _args ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _args ... ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + +#else + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str() ) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, + _value2) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3)); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4)); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5 ) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5)); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6)); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, + const log_value& _value8) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, + const log_value& _value8, const log_value& _value9) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, + const log_value& _value8, const log_value& _value9, const log_value& _value10) + { + { + log_message message( Y_NULLPTR, _log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10) ); + sxy::lock_guard< sxy::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + +//**************************************************log_and_wait**************************************************// + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str() ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, + const log_value& _value8 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, + const log_value& _value8, const log_value& _value9 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, + const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, + const log_value& _value8, const log_value& _value9, const log_value& _value10 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + messages_.push( message ); + } + condition_.notify_one(); + waiter.wait(); + } + + + +#endif + + + //!\brief Adds a logger to which the log will be written. + //!\param _logger - The logger to be added. + //!\return void + void add_logger( logger_uptr _logger ) + { + Y_ASSERT_NO_LOG( stop_, "Logger cannot be added while running!" ); + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + loggers_.push_back( sxy::move( _logger ) ); + } + + + //!\brief Starts the logging. On starting, a new thread is created which processes the enqueued log message by + //!sending them to each logger. The thread has to be stopped and joined before the log manager is destroyed! + //!\return void + //!\sa halt, join + void run() + { + stop_ = false; + thread_ = sxy::thread( sxy::bind( &log_manager_template::work, this ) ); + } + + + //!\brief Stops the logging. The thread that processes the log messages is notified that it should stop. It still has + //!to be joined later. + //!\return void + //!\sa run, join, halt_and_join + void halt() + { + { + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + stop_ = true; + } + condition_.notify_one(); + } + + + //!\brief Joins the thread that processed the log messages. Join has to be called after the halt function. + //!\return void + //!\sa halt, run, halt_and_join + void join() + { + thread_.join(); + } + + + //!\brief Stops the logging and joins the thread that processed the log messages. + //!\return void + //!\sa halt, run, join + void halt_and_join() + { + halt(); + join(); + } + + + //!\brief Gets the current date and time as a string. + //!\return String containing the date and time. + static std::string get_timestamp() + { + return( time_stamp_policy::get_timestamp() ); + } + + +private: + log_manager_template() + : thread_(), + mutex_(), + condition_(), + stop_( true ), + loggers_(), + messages_(), + log_level_( log_level::LL_OFF ) + { + Y_ASSERT_NO_LOG( !LOG_MANAGER_EXISTS, "Log manager already exists!" ); + LOG_MANAGER_EXISTS = true; + } + + + ~log_manager_template() + { + Y_ASSERT_NO_LOG( stop_, "Thread is still running! It was not stopped." ); + } + + + bool should_be_running() const + { + return( stop_ || !messages_.empty() ); + } + + + bool finished() const + { + return( stop_ && messages_.empty() ); + } + + + void work() + { + while( true ) + { + log_message message; + { + sxy::unique_lock< sxy::mutex > lock( mutex_ ); + condition_.wait( lock, sxy::bind( &log_manager_template::should_be_running, this ) ); + + if( finished() ) + { + break; + } + + message = messages_.front(); + messages_.pop(); + } + + Y_FOR(const logger_uptr& logger, loggers_) + { + logger->log( message ); + message.done(); + } + } + } + + + sxy::thread thread_; + sxy::mutex mutex_; + sxy::condition_variable condition_; + bool stop_; + loggers loggers_; + std::queue< log_message > messages_; + log_level log_level_; +}; + + +} + + +#endif + +#endif diff --git a/yasmine/yasmine/log_message.hpp b/libyasmine/include/log_message.hpp similarity index 87% rename from yasmine/yasmine/log_message.hpp rename to libyasmine/include/log_message.hpp index df65650..96959d3 100644 --- a/yasmine/yasmine/log_message.hpp +++ b/libyasmine/include/log_message.hpp @@ -15,8 +15,6 @@ #define LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 -#include - #include "log_level.hpp" #include "compatibility.hpp" @@ -25,18 +23,22 @@ namespace sxy { +class log_callback; + + struct log_message Y_FINAL { log_message(); - log_message( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, + log_message( log_callback* _log_callback, const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, const std::string& _message ); - + void done(); log_level log_level_; std::string time_stamp_; std::string file_; int line_; std::string message_; + log_callback* log_callback_; }; diff --git a/yasmine/yasmine/logger.hpp b/libyasmine/include/logger.hpp similarity index 98% rename from yasmine/yasmine/logger.hpp rename to libyasmine/include/logger.hpp index ed32682..349ce5e 100644 --- a/yasmine/yasmine/logger.hpp +++ b/libyasmine/include/logger.hpp @@ -15,7 +15,6 @@ #include "logger_fwd.hpp" -#include "log_message.hpp" #include "non_copyable.hpp" @@ -23,6 +22,9 @@ namespace sxy { +struct log_message; + + //!\interface logger //!\brief Interface of the general logger. The specialized loggers derive from this interface. class logger diff --git a/yasmine/yasmine/logger_fwd.hpp b/libyasmine/include/logger_fwd.hpp similarity index 100% rename from yasmine/yasmine/logger_fwd.hpp rename to libyasmine/include/logger_fwd.hpp diff --git a/yasmine/yasmine/logging.hpp b/libyasmine/include/logging.hpp similarity index 100% rename from yasmine/yasmine/logging.hpp rename to libyasmine/include/logging.hpp diff --git a/yasmine/yasmine/macro_helpers.hpp b/libyasmine/include/macro_helpers.hpp similarity index 83% rename from yasmine/yasmine/macro_helpers.hpp rename to libyasmine/include/macro_helpers.hpp index 311bec5..4b97f6c 100644 --- a/yasmine/yasmine/macro_helpers.hpp +++ b/libyasmine/include/macro_helpers.hpp @@ -12,14 +12,20 @@ #ifndef MACRO_HELPERS_D52C3077_E0EF_4C4E_B451_1472DEE602E8 #define MACRO_HELPERS_D52C3077_E0EF_4C4E_B451_1472DEE602E8 + +#ifndef Y_NO_VARIADIC_MACRO + #define EXPAND( x ) x #define CAT( A, B ) A ## B #define SELECT( NAME, NUM ) CAT( NAME ## _, NUM ) -#define GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, COUNT, ... ) COUNT -#define VA_SIZE( ... ) EXPAND( GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 ) ) +#define GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, COUNT, ... ) COUNT +#define VA_SIZE( ... ) EXPAND( GET_COUNT( __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1 ) ) #define VA_SELECT( NAME, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__) ) #endif + + +#endif diff --git a/yasmine/yasmine/non_copyable.hpp b/libyasmine/include/non_copyable.hpp similarity index 100% rename from yasmine/yasmine/non_copyable.hpp rename to libyasmine/include/non_copyable.hpp diff --git a/yasmine/yasmine/optimization.hpp b/libyasmine/include/optimization.hpp similarity index 100% rename from yasmine/yasmine/optimization.hpp rename to libyasmine/include/optimization.hpp diff --git a/yasmine/yasmine/pseudostate.hpp b/libyasmine/include/pseudostate.hpp similarity index 100% rename from yasmine/yasmine/pseudostate.hpp rename to libyasmine/include/pseudostate.hpp diff --git a/yasmine/yasmine/pseudostate_fwd.hpp b/libyasmine/include/pseudostate_fwd.hpp similarity index 99% rename from yasmine/yasmine/pseudostate_fwd.hpp rename to libyasmine/include/pseudostate_fwd.hpp index 1d3479c..3f60f08 100644 --- a/yasmine/yasmine/pseudostate_fwd.hpp +++ b/libyasmine/include/pseudostate_fwd.hpp @@ -14,6 +14,7 @@ #include + #include "compatibility.hpp" diff --git a/yasmine/yasmine/region.hpp b/libyasmine/include/region.hpp similarity index 81% rename from yasmine/yasmine/region.hpp rename to libyasmine/include/region.hpp index a1fb5fe..5bc7438 100644 --- a/yasmine/yasmine/region.hpp +++ b/libyasmine/include/region.hpp @@ -23,9 +23,10 @@ #include "join_fwd.hpp" #include "junction_fwd.hpp" #include "terminate_pseudostate_fwd.hpp" -#include "behaviour_fwd.hpp" -#include "async_behaviour.hpp" -#include "event.hpp" +#include "behavior_fwd.hpp" +#include "async_behavior.hpp" +#include "event_fwd.hpp" +#include "event_id.hpp" namespace sxy @@ -36,8 +37,9 @@ class vertex; class composite_state; class simple_state; class final_state; -class region: - public virtual state_machine_element + + +class region: public virtual state_machine_element { public: region() @@ -77,24 +79,24 @@ class region: 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 behaviour_function& _behaviour = behaviour_function(), - const behaviour_function& _entry_behaviour = behaviour_function(), - const behaviour_function& _exit_behaviour = behaviour_function() ) = 0; + 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 behaviour_function& _behaviour = behaviour_function(), - const behaviour_function& _entry_behaviour = behaviour_function(), - const behaviour_function& _exit_behaviour = behaviour_function(), + 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_behaviour_uptr _do_action = async_behaviour_uptr(), const behaviour_function& _entry_behaviour = behaviour_function(), - const behaviour_function& _exit_behaviour = behaviour_function(), + 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 behaviour_function& _entry_action = behaviour_function(), - const behaviour_function& _exit_action = behaviour_function() ) = 0; + 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 behaviour_function& _entry_action = behaviour_function(), - const behaviour_function& _exit_action = behaviour_function() ) = 0; + 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; diff --git a/yasmine/yasmine/region_fwd.hpp b/libyasmine/include/region_fwd.hpp similarity index 100% rename from yasmine/yasmine/region_fwd.hpp rename to libyasmine/include/region_fwd.hpp diff --git a/yasmine/yasmine/region_pseudostate.hpp b/libyasmine/include/region_pseudostate.hpp similarity index 100% rename from yasmine/yasmine/region_pseudostate.hpp rename to libyasmine/include/region_pseudostate.hpp diff --git a/yasmine/yasmine/region_pseudostates.hpp b/libyasmine/include/region_pseudostates.hpp similarity index 100% rename from yasmine/yasmine/region_pseudostates.hpp rename to libyasmine/include/region_pseudostates.hpp diff --git a/yasmine/yasmine/shallow_history.hpp b/libyasmine/include/shallow_history.hpp similarity index 100% rename from yasmine/yasmine/shallow_history.hpp rename to libyasmine/include/shallow_history.hpp diff --git a/yasmine/yasmine/shallow_history_fwd.hpp b/libyasmine/include/shallow_history_fwd.hpp similarity index 100% rename from yasmine/yasmine/shallow_history_fwd.hpp rename to libyasmine/include/shallow_history_fwd.hpp diff --git a/yasmine/yasmine/simple_state.hpp b/libyasmine/include/simple_state.hpp similarity index 100% rename from yasmine/yasmine/simple_state.hpp rename to libyasmine/include/simple_state.hpp diff --git a/yasmine/yasmine/simple_state_base.hpp b/libyasmine/include/simple_state_base.hpp similarity index 95% rename from yasmine/yasmine/simple_state_base.hpp rename to libyasmine/include/simple_state_base.hpp index 7a95a44..8313841 100644 --- a/yasmine/yasmine/simple_state_base.hpp +++ b/libyasmine/include/simple_state_base.hpp @@ -27,7 +27,7 @@ class simple_state_base: public: - simple_state_base( const std::string& _name, behaviour_uptr _entry_action, behaviour_uptr _exit_action, + 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() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(simple_state_base) diff --git a/yasmine/yasmine/specialized_event.hpp b/libyasmine/include/specialized_event.hpp similarity index 97% rename from yasmine/yasmine/specialized_event.hpp rename to libyasmine/include/specialized_event.hpp index 3c8715c..8d858b2 100644 --- a/yasmine/yasmine/specialized_event.hpp +++ b/libyasmine/include/specialized_event.hpp @@ -41,7 +41,7 @@ class specialized_event: public event_impl Y_NO_COPY(specialized_event) - virtual std::string get_name() const + virtual std::string get_name() const Y_OVERRIDE { const std::string name = name_.empty() ? event_impl::get_name() : name_; return(name); diff --git a/yasmine/yasmine/state.hpp b/libyasmine/include/state.hpp similarity index 86% rename from yasmine/yasmine/state.hpp rename to libyasmine/include/state.hpp index 4d48131..1939f09 100644 --- a/yasmine/yasmine/state.hpp +++ b/libyasmine/include/state.hpp @@ -24,7 +24,7 @@ namespace sxy class state_visitor; -class behaviour; +class behavior; class event; class async_event_handler; @@ -51,8 +51,8 @@ class state: 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 behaviour * get_entry_behaviour() const = 0; - virtual behaviour * get_exit_behaviour() 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; @@ -63,9 +63,9 @@ class state: virtual void set_was_active() = 0; virtual const regions& get_regions() const = 0; virtual regions& get_regions() = 0; - virtual void execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const = 0; - virtual void execute_enter_behaviour( const event& _event ) const = 0; - virtual void execute_exit_behaviour( const event& _event ) const = 0; + virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const = 0; + virtual void execute_enter_behavior( const event& _event ) const = 0; + virtual void execute_exit_behavior( const event& _event ) const = 0; virtual void accept_state_visitor( state_visitor& _visitor ) const = 0; virtual void enter_state( const event& _event ) = 0; virtual void exit_state( const event& _event ) = 0; diff --git a/yasmine/yasmine/state_fwd.hpp b/libyasmine/include/state_fwd.hpp similarity index 100% rename from yasmine/yasmine/state_fwd.hpp rename to libyasmine/include/state_fwd.hpp diff --git a/yasmine/yasmine/state_impl.hpp b/libyasmine/include/state_impl.hpp similarity index 88% rename from yasmine/yasmine/state_impl.hpp rename to libyasmine/include/state_impl.hpp index 5061194..e727949 100644 --- a/yasmine/yasmine/state_impl.hpp +++ b/libyasmine/include/state_impl.hpp @@ -15,7 +15,7 @@ #include "state.hpp" #include "vertex_impl.hpp" -#include "behaviour_fwd.hpp" +#include "behavior_fwd.hpp" #include "event_fwd.hpp" #include "optimization.hpp" @@ -37,7 +37,8 @@ class state_impl: virtual size_t get_parent_region_index() const Y_OVERRIDE; virtual region * get_region( const std::string& _region_name ) const Y_OVERRIDE; virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const Y_OVERRIDE; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor ) const Y_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const Y_OVERRIDE; virtual raw_regions get_ancestors_as_regions() const Y_OVERRIDE; virtual std::size_t get_nesting_level() const Y_OVERRIDE; virtual void set_was_active() Y_OVERRIDE; @@ -46,9 +47,9 @@ class state_impl: virtual void set_inactive() Y_OVERRIDE; virtual bool is_active() const Y_OVERRIDE; virtual bool is_complete() const Y_OVERRIDE; - virtual void execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; - virtual void execute_enter_behaviour( const event& _event ) const Y_OVERRIDE; - virtual void execute_exit_behaviour( const event& _event ) const Y_OVERRIDE; + virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; + virtual void execute_enter_behavior( const event& _event ) const Y_OVERRIDE; + virtual void execute_exit_behavior( const event& _event ) const Y_OVERRIDE; virtual void enter_state( const event& _event ) Y_OVERRIDE; virtual void exit_state( const event& _event ) Y_OVERRIDE; virtual bool has_error_event() const Y_OVERRIDE; diff --git a/yasmine/yasmine/state_machine.hpp b/libyasmine/include/state_machine.hpp similarity index 83% rename from yasmine/yasmine/state_machine.hpp rename to libyasmine/include/state_machine.hpp index 92235ca..290ac2e 100644 --- a/yasmine/yasmine/state_machine.hpp +++ b/libyasmine/include/state_machine.hpp @@ -13,24 +13,29 @@ #define STATE_MACHINE_0DD08953_1A90_4992_A22E_118A42B1E45A -#include - - #include "state_machine_introspection.hpp" -#include "composite_state.hpp" #include "transition_kind.hpp" #include "constraint_fwd.hpp" -#include "behaviour_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" +#include "thread.hpp" namespace sxy { +class vertex; +class async_event_handler; class event_processing_callback; class uri; class region; + //!\class 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. @@ -60,36 +65,36 @@ class state_machine: //!\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 behaviour between the given source and + //!\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 given as parameter. //!\param _event_id ID of the event for which the transition will be 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 _behaviour The behaviour 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 new 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 behaviour_function& _behaviour = behaviour_function() ); + const behavior_function& _behavior = behavior_function() ); - //!\brief Creates a transition with the given name, kind, event, guard and behaviour between the given source and - // target and adds it to the state machine given as parameter. + //!\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 given as parameter. //!\param event_ids List of IDs of the events for which the transition will be 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 _behaviour The behaviour 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 new 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 behaviour_function& _behaviour = behaviour_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 given as parameter. There is no behaviour provided. + // target and adds it to the state machine given as parameter. There is no behavior provided. //!\param _event_id ID of the event for which the transition will be enabled. //!\param _source The source vertex. //!\param _target The target vertex. @@ -99,29 +104,29 @@ class state_machine: 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, event, guard and behaviour between the given source and - // target and adds it to the state machine given as parameter. + //!\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 given as parameter. //!\param _event_id ID of the event for which the transition will be enabled. //!\param _source The source vertex. //!\param _target The target vertex. //!\param _guard The guard of the transition. - //!\param _behaviour The behaviour of the transition. + //!\param _behavior The behavior of the transition. //!\param _kind Transition kind. Default is EXTERNAL. //!\return a reference to the new created transition. virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const constraint_function& _guard, const behaviour_function& _behaviour, + 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 behaviour between the given source and - // target and adds it to the state machine given as parameter. There is no guard provided. + //!\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 given as parameter. There is no guard provided. //!\param _event_id ID of the event for which the transition will be enabled. //!\param _source The source vertex. //!\param _target The target vertex. - //!\param _behaviour The behaviour of the transition. + //!\param _behavior The behavior of the transition. //!\param _kind Transition kind. Default is EXTERNAL. //!\return a reference to the new created transition. virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const behaviour_function& _behaviour, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); //!\brief Fire the given event. //!\param _event Event to be fired. @@ -137,10 +142,10 @@ class state_machine: //!\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 start_state_machine(); + virtual bool run(); - //!\brief Stops the state machine. It checks for active asynchronous simple states and stops their do behaviours. - virtual void stop_state_machine(); + //!\brief Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors. + virtual void halt(); protected: @@ -149,10 +154,10 @@ class state_machine: //!\brief Starts the state machine. //!\param _async_event_handler Pointer to an asynchronous event handler. For example, it's necessary for //!the asynchronous state machine if it is needed to process the asynchronous errors that occurs in the - //!asynchronous behaviour of asynchronous simple states. + //!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 start_state_machine( async_event_handler* const _async_event_handler ); + 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 ); @@ -171,7 +176,7 @@ class state_machine: composite_state_uptr root_state_; transitions transitions_; events deferred_events_; - bool state_machine_is_running_; + sxy::atomic state_machine_is_running_; #ifdef Y_PROFILER sxy::uint32_t processed_events_; #endif diff --git a/yasmine/yasmine/state_machine_defect.hpp b/libyasmine/include/state_machine_defect.hpp similarity index 98% rename from yasmine/yasmine/state_machine_defect.hpp rename to libyasmine/include/state_machine_defect.hpp index d5c08f8..78e0973 100644 --- a/yasmine/yasmine/state_machine_defect.hpp +++ b/libyasmine/include/state_machine_defect.hpp @@ -13,11 +13,7 @@ #define STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC -#include -#include - #include "yprintf.hpp" -#include "log.hpp" #include "compatibility.hpp" #include "state_machine_defect_fwd.hpp" diff --git a/yasmine/yasmine/state_machine_defect_fwd.hpp b/libyasmine/include/state_machine_defect_fwd.hpp similarity index 100% rename from yasmine/yasmine/state_machine_defect_fwd.hpp rename to libyasmine/include/state_machine_defect_fwd.hpp diff --git a/yasmine/yasmine/state_machine_element.hpp b/libyasmine/include/state_machine_element.hpp similarity index 100% rename from yasmine/yasmine/state_machine_element.hpp rename to libyasmine/include/state_machine_element.hpp diff --git a/yasmine/yasmine/state_machine_element_impl.hpp b/libyasmine/include/state_machine_element_impl.hpp similarity index 100% rename from yasmine/yasmine/state_machine_element_impl.hpp rename to libyasmine/include/state_machine_element_impl.hpp diff --git a/yasmine/yasmine/state_machine_introspection.hpp b/libyasmine/include/state_machine_introspection.hpp similarity index 100% rename from yasmine/yasmine/state_machine_introspection.hpp rename to libyasmine/include/state_machine_introspection.hpp diff --git a/libyasmine/include/state_machine_status.hpp b/libyasmine/include/state_machine_status.hpp new file mode 100644 index 0000000..b78dbee --- /dev/null +++ b/libyasmine/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 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 +#define STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 + + +namespace sxy +{ + + +#ifndef Y_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/yasmine/state_pseudostate.hpp b/libyasmine/include/state_pseudostate.hpp similarity index 100% rename from yasmine/yasmine/state_pseudostate.hpp rename to libyasmine/include/state_pseudostate.hpp diff --git a/yasmine/yasmine/state_pseudostates.hpp b/libyasmine/include/state_pseudostates.hpp similarity index 100% rename from yasmine/yasmine/state_pseudostates.hpp rename to libyasmine/include/state_pseudostates.hpp diff --git a/yasmine/yasmine/states.hpp b/libyasmine/include/states.hpp similarity index 100% rename from yasmine/yasmine/states.hpp rename to libyasmine/include/states.hpp diff --git a/yasmine/yasmine/states_nesting_comparer.hpp b/libyasmine/include/states_nesting_comparer.hpp similarity index 100% rename from yasmine/yasmine/states_nesting_comparer.hpp rename to libyasmine/include/states_nesting_comparer.hpp diff --git a/yasmine/yasmine/states_nesting_comparer_ascending.hpp b/libyasmine/include/states_nesting_comparer_ascending.hpp similarity index 100% rename from yasmine/yasmine/states_nesting_comparer_ascending.hpp rename to libyasmine/include/states_nesting_comparer_ascending.hpp diff --git a/yasmine/yasmine/std_timestamp_policy.hpp b/libyasmine/include/std_timestamp_policy.hpp similarity index 100% rename from yasmine/yasmine/std_timestamp_policy.hpp rename to libyasmine/include/std_timestamp_policy.hpp diff --git a/yasmine/yasmine/terminate_pseudostate.hpp b/libyasmine/include/terminate_pseudostate.hpp similarity index 100% rename from yasmine/yasmine/terminate_pseudostate.hpp rename to libyasmine/include/terminate_pseudostate.hpp diff --git a/yasmine/yasmine/terminate_pseudostate_fwd.hpp b/libyasmine/include/terminate_pseudostate_fwd.hpp similarity index 100% rename from yasmine/yasmine/terminate_pseudostate_fwd.hpp rename to libyasmine/include/terminate_pseudostate_fwd.hpp diff --git a/yasmine/yasmine/thread.hpp b/libyasmine/include/thread.hpp similarity index 90% rename from yasmine/yasmine/thread.hpp rename to libyasmine/include/thread.hpp index 5c747d1..a302118 100644 --- a/yasmine/yasmine/thread.hpp +++ b/libyasmine/include/thread.hpp @@ -15,12 +15,14 @@ #ifdef Y_CPP03_BOOST #include +#include #else #include #include #include +#include #endif @@ -30,7 +32,7 @@ namespace sxy { -#ifdef Y_CPP03_BOOST // c++03 compatibility +#ifdef Y_CPP03_BOOST // C++03 compatibility using boost::thread; using boost::unique_lock; @@ -38,9 +40,10 @@ namespace sxy using boost::lock_guard; using boost::condition_variable; using boost::this_thread::sleep_for; + using boost::atomic; -#else // c++11 compatibility +#else // C++11 compatibility using std::thread; @@ -49,6 +52,7 @@ namespace sxy using std::lock_guard; using std::condition_variable; using std::this_thread::sleep_for; + using std::atomic; #endif diff --git a/yasmine/yasmine/timed_event_creator.hpp b/libyasmine/include/timed_event_creator.hpp similarity index 89% rename from yasmine/yasmine/timed_event_creator.hpp rename to libyasmine/include/timed_event_creator.hpp index 622f040..4bbce6f 100644 --- a/yasmine/yasmine/timed_event_creator.hpp +++ b/libyasmine/include/timed_event_creator.hpp @@ -15,10 +15,9 @@ #include -#include "compatibility.hpp" -#include "thread.hpp" #include "event_creation_request_time_comparer.hpp" #include "event_creation_request.hpp" +#include "thread.hpp" namespace sxy @@ -26,7 +25,7 @@ namespace sxy class async_state_machine; -class event_creation_request; + typedef std::set< event_creation_request, event_creation_request_time_comparer > event_queue; @@ -67,14 +66,25 @@ class timed_event_creator Y_FINAL //!\brief Starts the event creator. This has to be called before creating timed events. //!\return void - //!\sa stop() - void start(); + //!\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 will not be cleaned-up correctly. //!\return void - //!\sa start() - void stop(); + //!\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 will not be cleaned-up correctly. + //!\return void + //!\sa run(), join(), halt() + void halt_and_join(); private: diff --git a/yasmine/yasmine/transition.hpp b/libyasmine/include/transition.hpp similarity index 92% rename from yasmine/yasmine/transition.hpp rename to libyasmine/include/transition.hpp index e5fbdcc..c3835b4 100644 --- a/yasmine/yasmine/transition.hpp +++ b/libyasmine/include/transition.hpp @@ -26,7 +26,7 @@ namespace sxy class vertex; class constraint; -class behaviour; +class behavior; class event; @@ -51,9 +51,9 @@ class transition: virtual const vertex& get_target() const = 0; virtual vertex& get_target() = 0; virtual const constraint * get_guard() const = 0; - virtual const behaviour * get_behaviour() const = 0; + virtual const behavior * get_behavior() const = 0; virtual sxy::transition_kind get_kind() const = 0; - virtual void on_transition_behaviour( const event& _event ) const = 0; + virtual void on_transition_behavior( const event& _event ) const = 0; virtual bool check_guard( const event& _event ) const = 0; virtual bool check( state_machine_defects& _defects ) const Y_OVERRIDE = 0; virtual bool can_accept_event( const event_id _event ) const = 0; diff --git a/yasmine/yasmine/transition_fwd.hpp b/libyasmine/include/transition_fwd.hpp similarity index 100% rename from yasmine/yasmine/transition_fwd.hpp rename to libyasmine/include/transition_fwd.hpp diff --git a/yasmine/yasmine/transition_impl.hpp b/libyasmine/include/transition_impl.hpp similarity index 79% rename from yasmine/yasmine/transition_impl.hpp rename to libyasmine/include/transition_impl.hpp index 846d8c7..a4e8e9d 100644 --- a/yasmine/yasmine/transition_impl.hpp +++ b/libyasmine/include/transition_impl.hpp @@ -16,7 +16,7 @@ #include "transition.hpp" #include "state_machine_element_impl.hpp" #include "constraint.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" namespace sxy @@ -32,22 +32,22 @@ class transition_impl Y_FINAL: 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(), behaviour_uptr _behaviour = behaviour_uptr()); + 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(), behaviour_uptr _behaviour = behaviour_uptr()); + constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); virtual ~transition_impl() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(transition_impl) virtual const vertex& get_source() const Y_OVERRIDE; virtual const vertex& get_target() const Y_OVERRIDE; virtual vertex& get_target() Y_OVERRIDE; virtual const constraint * get_guard() const Y_OVERRIDE; - virtual const behaviour * get_behaviour() const Y_OVERRIDE; + virtual const behavior * get_behavior() const Y_OVERRIDE; virtual uri get_uri() const Y_OVERRIDE; virtual const state_machine_element * get_parent() const Y_OVERRIDE; virtual sxy::transition_kind get_kind() const Y_OVERRIDE; virtual void add_ancestor_uri( uri& _uri ) const Y_OVERRIDE; - virtual void on_transition_behaviour( const event& _event ) const Y_OVERRIDE; + virtual void on_transition_behavior( const event& _event ) const Y_OVERRIDE; virtual bool check_guard( const event& _event ) const Y_OVERRIDE; virtual bool check( state_machine_defects& _defects ) const Y_OVERRIDE; virtual bool can_accept_event( const event_id _event ) const Y_OVERRIDE; @@ -58,13 +58,16 @@ class transition_impl Y_FINAL: 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_; - behaviour_uptr behaviour_; + behavior_uptr behavior_; transition_kind kind_; }; diff --git a/yasmine/yasmine/transition_kind.hpp b/libyasmine/include/transition_kind.hpp similarity index 100% rename from yasmine/yasmine/transition_kind.hpp rename to libyasmine/include/transition_kind.hpp diff --git a/yasmine/yasmine/uri.hpp b/libyasmine/include/uri.hpp similarity index 98% rename from yasmine/yasmine/uri.hpp rename to libyasmine/include/uri.hpp index fe94cd2..21a7cd5 100644 --- a/yasmine/yasmine/uri.hpp +++ b/libyasmine/include/uri.hpp @@ -14,7 +14,6 @@ #include -#include #include "compatibility.hpp" diff --git a/yasmine/yasmine/utils.hpp b/libyasmine/include/utils.hpp similarity index 100% rename from yasmine/yasmine/utils.hpp rename to libyasmine/include/utils.hpp diff --git a/yasmine/yasmine/version.hpp b/libyasmine/include/version.hpp similarity index 98% rename from yasmine/yasmine/version.hpp rename to libyasmine/include/version.hpp index 26bd11e..edb5821 100644 --- a/yasmine/yasmine/version.hpp +++ b/libyasmine/include/version.hpp @@ -17,7 +17,7 @@ #include "compatibility.hpp" -namespace yasmine +namespace sxy { diff --git a/yasmine/yasmine/vertex.hpp b/libyasmine/include/vertex.hpp similarity index 92% rename from yasmine/yasmine/vertex.hpp rename to libyasmine/include/vertex.hpp index e85ad8f..4207a7c 100644 --- a/yasmine/yasmine/vertex.hpp +++ b/libyasmine/include/vertex.hpp @@ -48,7 +48,9 @@ class vertex: } - Y_NO_COPY(vertex) + Y_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; @@ -56,7 +58,8 @@ class vertex: 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 ) 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 ) const = 0; virtual region * LCA_region( const vertex& _target_vertex ) const = 0; virtual composite_state * LCA_composite_state( const vertex& _rhs ) const = 0; diff --git a/yasmine/yasmine/vertex_fwd.hpp b/libyasmine/include/vertex_fwd.hpp similarity index 100% rename from yasmine/yasmine/vertex_fwd.hpp rename to libyasmine/include/vertex_fwd.hpp diff --git a/yasmine/yasmine/vertex_impl.hpp b/libyasmine/include/vertex_impl.hpp similarity index 87% rename from yasmine/yasmine/vertex_impl.hpp rename to libyasmine/include/vertex_impl.hpp index d987f2e..6a3580b 100644 --- a/yasmine/yasmine/vertex_impl.hpp +++ b/libyasmine/include/vertex_impl.hpp @@ -29,7 +29,9 @@ class vertex_impl: public: explicit vertex_impl( const std::string& _name ); virtual ~vertex_impl() Y_NOEXCEPT Y_OVERRIDE; - Y_NO_COPY(vertex_impl) + Y_NO_COPY( vertex_impl ) + virtual composite_state* get_root_state() Y_OVERRIDE; + virtual const composite_state* get_root_state() const Y_OVERRIDE; virtual void add_outgoing_transition( transition& _outgoing_transition ) Y_OVERRIDE; virtual void add_incoming_transition( transition& _incoming_transition ) Y_OVERRIDE; virtual void remove_outgoing_transition( const transition& _outgoing_transition ) Y_OVERRIDE; @@ -44,6 +46,8 @@ class vertex_impl: private: void add_ancestor_uri( uri& _uri ) const Y_OVERRIDE; + raw_transitions::const_iterator find_first_transition_without_guard( const raw_transitions& _vector_of_transitions ); + static bool has_no_guard( const transition* const _transition ); raw_transitions outgoing_transitions_; diff --git a/libyasmine/include/waiter.hpp b/libyasmine/include/waiter.hpp new file mode 100644 index 0000000..b693d38 --- /dev/null +++ b/libyasmine/include/waiter.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef Y_NO_LOGGING + + +#ifndef WAITER_5E57D733_02DD_413D_A906_5047979A5DFD +#define WAITER_5E57D733_02DD_413D_A906_5047979A5DFD + + +#include "log_callback.hpp" +#include "thread.hpp" + + +namespace sxy +{ + + + class waiter : public log_callback + { + public: + waiter(); + virtual ~waiter() Y_NOEXCEPT Y_OVERRIDE; + virtual void wait() Y_OVERRIDE; + virtual void done() Y_OVERRIDE; + virtual bool is_done() Y_OVERRIDE; + + + private: + sxy::mutex done_mutex_; + sxy::condition_variable done_condition_variable_; + bool done_; + }; + +} + + +#endif + + +#endif diff --git a/yasmine/yasmine/yasmine.hpp b/libyasmine/include/yasmine.hpp similarity index 92% rename from yasmine/yasmine/yasmine.hpp rename to libyasmine/include/yasmine.hpp index c0e195e..3cb173e 100644 --- a/yasmine/yasmine/yasmine.hpp +++ b/libyasmine/include/yasmine.hpp @@ -24,8 +24,9 @@ #include "region_pseudostates.hpp" #include "transition.hpp" -#include "behaviour.hpp" -#include "behaviour_exception.hpp" +#include "transition_impl.hpp" +#include "behavior.hpp" +#include "behavior_exception.hpp" #include "event_impl.hpp" #include "event_template.hpp" @@ -39,13 +40,14 @@ #include "chrono.hpp" #include "thread.hpp" #include "non_copyable.hpp" +#include "version.hpp" #ifndef Y_LEAN_AND_MEAN #include "state_pseudostates.hpp" -#include "async_behaviour.hpp" +#include "async_behavior.hpp" #endif diff --git a/yasmine/yasmine/yprintf.hpp b/libyasmine/include/yprintf.hpp similarity index 98% rename from yasmine/yasmine/yprintf.hpp rename to libyasmine/include/yprintf.hpp index 6c2489c..c6c4bfe 100644 --- a/yasmine/yasmine/yprintf.hpp +++ b/libyasmine/include/yprintf.hpp @@ -71,7 +71,8 @@ struct stream_writer< sxy::uint8_t > }; -std::ostream& operator<<( std::ostream& _os, const sxy::format_settings& _format ); +// cppcheck-suppress unusedFunction +std::ostream& operator<<( std::ostream& _os, const sxy::format_settings& _format ); sxy::format_settings parse_format_string( const char** const _format ); diff --git a/yasmine/yasmine/behaviour_impl.hpp b/libyasmine/include_impl/behavior_impl.hpp similarity index 61% rename from yasmine/yasmine/behaviour_impl.hpp rename to libyasmine/include_impl/behavior_impl.hpp index 4c0d49b..4d7f81e 100644 --- a/yasmine/yasmine/behaviour_impl.hpp +++ b/libyasmine/include_impl/behavior_impl.hpp @@ -9,11 +9,11 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef BEHAVIOUR_IMPL_687393A8_48A8_4AB2_BC6B_99017F70AEAC -#define BEHAVIOUR_IMPL_687393A8_48A8_4AB2_BC6B_99017F70AEAC +#ifndef BEHAVIOR_IMPL_44F1A85F_F127_46DE_811B_DD146F1AECD6 +#define BEHAVIOR_IMPL_44F1A85F_F127_46DE_811B_DD146F1AECD6 -#include "behaviour.hpp" +#include "behavior.hpp" namespace sxy @@ -23,23 +23,23 @@ namespace sxy class event; -class behaviour_impl Y_FINAL: - public virtual behaviour +class behavior_impl Y_FINAL: + public virtual behavior { public: - explicit behaviour_impl( const behaviour_function& _function ); - virtual ~behaviour_impl() Y_NOEXCEPT Y_OVERRIDE; - Y_NO_COPY(behaviour_impl) + explicit behavior_impl( const behavior_function& _function ); + virtual ~behavior_impl() Y_NOEXCEPT Y_OVERRIDE; + Y_NO_COPY( behavior_impl ) virtual void operator()( const event& _event ) const Y_OVERRIDE; - //!\brief Creates a behaviour with the given function that implements the behaviour. - //!\param _function Function that implements the behaviour. - //!\return A unique pointer to the created behaviour. - static behaviour_uptr create_behaviour( const behaviour_function& _function ); + //!\brief Creates a behavior with the given function that implements the behavior. + //!\param _function Function that implements the behavior. + //!\return A unique pointer to the created behavior. + static behavior_uptr create_behavior( const behavior_function& _function ); private: - behaviour_function function_; + behavior_function function_; }; diff --git a/yasmine/yasmine/build_number.hpp b/libyasmine/include_impl/build_number.hpp similarity index 95% rename from yasmine/yasmine/build_number.hpp rename to libyasmine/include_impl/build_number.hpp index b552774..0a93e69 100644 --- a/yasmine/yasmine/build_number.hpp +++ b/libyasmine/include_impl/build_number.hpp @@ -16,7 +16,7 @@ #include "compatibility.hpp" -namespace yasmine +namespace sxy { @@ -24,7 +24,7 @@ namespace version { -const sxy::uint16_t BUILD_NUMBER( 427 ); +const sxy::uint16_t BUILD_NUMBER( 504 ); } diff --git a/yasmine/yasmine/build_transition_steps_visitor.hpp b/libyasmine/include_impl/build_transition_steps_visitor.hpp similarity index 100% rename from yasmine/yasmine/build_transition_steps_visitor.hpp rename to libyasmine/include_impl/build_transition_steps_visitor.hpp diff --git a/yasmine/yasmine/check_if_all_incoming_transitions_sources_are_active_visitor.hpp b/libyasmine/include_impl/check_if_all_incoming_transitions_sources_are_active_visitor.hpp similarity index 100% rename from yasmine/yasmine/check_if_all_incoming_transitions_sources_are_active_visitor.hpp rename to libyasmine/include_impl/check_if_all_incoming_transitions_sources_are_active_visitor.hpp diff --git a/yasmine/yasmine/choice_impl.hpp b/libyasmine/include_impl/choice_impl.hpp similarity index 100% rename from yasmine/yasmine/choice_impl.hpp rename to libyasmine/include_impl/choice_impl.hpp diff --git a/yasmine/yasmine/complex_state_visitor.hpp b/libyasmine/include_impl/complex_state_visitor.hpp similarity index 100% rename from yasmine/yasmine/complex_state_visitor.hpp rename to libyasmine/include_impl/complex_state_visitor.hpp diff --git a/yasmine/yasmine/composite_state_impl.hpp b/libyasmine/include_impl/composite_state_impl.hpp similarity index 97% rename from yasmine/yasmine/composite_state_impl.hpp rename to libyasmine/include_impl/composite_state_impl.hpp index 3130687..3a5a971 100644 --- a/yasmine/yasmine/composite_state_impl.hpp +++ b/libyasmine/include_impl/composite_state_impl.hpp @@ -29,8 +29,8 @@ class composite_state_impl Y_FINAL: public virtual composite_state, public complex_state_impl { public: - explicit composite_state_impl( const std::string& _name, behaviour_uptr _entry_action = behaviour_uptr(), - behaviour_uptr _exit_action = behaviour_uptr(), const event_ids& _deferred_events = event_ids() ); + explicit composite_state_impl( const std::string& _name, behavior_uptr _entry_action = behavior_uptr(), + behavior_uptr _exit_action = behavior_uptr(), const event_ids& _deferred_events = event_ids() ); virtual ~composite_state_impl() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(composite_state_impl) virtual region& add_region( region_uptr _region ) Y_OVERRIDE; diff --git a/yasmine/yasmine/compound_transition.hpp b/libyasmine/include_impl/compound_transition.hpp similarity index 100% rename from yasmine/yasmine/compound_transition.hpp rename to libyasmine/include_impl/compound_transition.hpp diff --git a/yasmine/yasmine/compound_transition_builder.hpp b/libyasmine/include_impl/compound_transition_builder.hpp similarity index 100% rename from yasmine/yasmine/compound_transition_builder.hpp rename to libyasmine/include_impl/compound_transition_builder.hpp diff --git a/yasmine/yasmine/compound_transition_consumer.hpp b/libyasmine/include_impl/compound_transition_consumer.hpp similarity index 100% rename from yasmine/yasmine/compound_transition_consumer.hpp rename to libyasmine/include_impl/compound_transition_consumer.hpp diff --git a/yasmine/yasmine/compound_transition_fwd.hpp b/libyasmine/include_impl/compound_transition_fwd.hpp similarity index 86% rename from yasmine/yasmine/compound_transition_fwd.hpp rename to libyasmine/include_impl/compound_transition_fwd.hpp index fa56e92..2afd3a1 100644 --- a/yasmine/yasmine/compound_transition_fwd.hpp +++ b/libyasmine/include_impl/compound_transition_fwd.hpp @@ -26,16 +26,7 @@ class compound_transition; class compound_transition_consumer; -#ifdef _MSC_VER -#if _MSC_VER >= 1900 typedef sxy::Y_UNIQUE_PTR< compound_transition > compound_transition_uptr; -#elif _MSC_VER <= 1800 -typedef sxy::shared_ptr< compound_transition > compound_transition_uptr; -#endif -#else -typedef Y_UNIQUE_PTR< compound_transition > compound_transition_uptr; -#endif - typedef std::vector< compound_transition* > raw_compound_transitions; typedef std::vector< compound_transition_uptr > compound_transitions; diff --git a/yasmine/yasmine/compound_transition_impl.hpp b/libyasmine/include_impl/compound_transition_impl.hpp similarity index 100% rename from yasmine/yasmine/compound_transition_impl.hpp rename to libyasmine/include_impl/compound_transition_impl.hpp diff --git a/yasmine/yasmine/compound_transition_step.hpp b/libyasmine/include_impl/compound_transition_step.hpp similarity index 95% rename from yasmine/yasmine/compound_transition_step.hpp rename to libyasmine/include_impl/compound_transition_step.hpp index bf9387c..c86e22c 100644 --- a/yasmine/yasmine/compound_transition_step.hpp +++ b/libyasmine/include_impl/compound_transition_step.hpp @@ -33,7 +33,7 @@ class compound_transition_step Y_FINAL: virtual const exit_point * get_exit_point() const Y_OVERRIDE; virtual const entry_point * get_entry_point() const Y_OVERRIDE; virtual const raw_const_vertices get_target_vertices() Y_OVERRIDE; - void execute_transition_behaviours( const event& _event ) const Y_OVERRIDE; + void execute_transition_behaviors( const event& _event ) const Y_OVERRIDE; private: diff --git a/yasmine/yasmine/const_vertex_visitor.hpp b/libyasmine/include_impl/const_vertex_visitor.hpp similarity index 100% rename from yasmine/yasmine/const_vertex_visitor.hpp rename to libyasmine/include_impl/const_vertex_visitor.hpp diff --git a/yasmine/yasmine/constraint_impl.hpp b/libyasmine/include_impl/constraint_impl.hpp similarity index 100% rename from yasmine/yasmine/constraint_impl.hpp rename to libyasmine/include_impl/constraint_impl.hpp diff --git a/yasmine/yasmine/conversion.hpp b/libyasmine/include_impl/conversion.hpp similarity index 100% rename from yasmine/yasmine/conversion.hpp rename to libyasmine/include_impl/conversion.hpp diff --git a/yasmine/yasmine/deep_history_impl.hpp b/libyasmine/include_impl/deep_history_impl.hpp similarity index 100% rename from yasmine/yasmine/deep_history_impl.hpp rename to libyasmine/include_impl/deep_history_impl.hpp diff --git a/yasmine/yasmine/entry_point_impl.hpp b/libyasmine/include_impl/entry_point_impl.hpp similarity index 100% rename from yasmine/yasmine/entry_point_impl.hpp rename to libyasmine/include_impl/entry_point_impl.hpp diff --git a/yasmine/yasmine/event_processing_callback.hpp b/libyasmine/include_impl/event_processing_callback.hpp similarity index 88% rename from yasmine/yasmine/event_processing_callback.hpp rename to libyasmine/include_impl/event_processing_callback.hpp index dc4e677..c85f4a7 100644 --- a/yasmine/yasmine/event_processing_callback.hpp +++ b/libyasmine/include_impl/event_processing_callback.hpp @@ -102,23 +102,23 @@ class event_processing_callback //!\return void virtual void after_enter( const state& _state ) = 0; - //!\brief Callback before execution of a state behaviour ("do behaviour"). - //!\param _state State whose behaviour will be executed. + //!\brief Callback before execution of a state behavior ("do behavior"). + //!\param _state State whose behavior will be executed. //!\return void virtual void before_do( const state& _state ) = 0; - //!\brief Callback after execution of a state behaviour ("do behaviour"). - //!\param _state State whose behaviour was executed. + //!\brief Callback after execution of a state behavior ("do behavior"). + //!\param _state State whose behavior was executed. //!\return void virtual void after_do( const state& _state ) = 0; - //!\brief Callback before execution of a transition behaviour. - //!\param _transition Transition whose behaviour will be executed. + //!\brief Callback before execution of a transition behavior. + //!\param _transition Transition whose behavior will be executed. //!\return void virtual void before_transition( const transition& _transition ) = 0; - //!\brief Callback after execution of a transition behaviour. - //!\param _transition Transition whose behaviour was executed. + //!\brief Callback after execution of a transition behavior. + //!\param _transition Transition whose behavior was executed. //!\return void virtual void after_transition( const transition& _transition ) = 0; }; diff --git a/yasmine/yasmine/execution_state_do_step.hpp b/libyasmine/include_impl/execution_state_do_step.hpp similarity index 94% rename from yasmine/yasmine/execution_state_do_step.hpp rename to libyasmine/include_impl/execution_state_do_step.hpp index 562924a..f42f1cf 100644 --- a/yasmine/yasmine/execution_state_do_step.hpp +++ b/libyasmine/include_impl/execution_state_do_step.hpp @@ -32,7 +32,7 @@ class execution_state_do_step Y_FINAL : explicit execution_state_do_step(const state& _state); virtual ~execution_state_do_step() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(execution_state_do_step) - virtual bool execute_behaviour( event_processing_callback* const _event_processing_callback, + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; virtual void accept( execution_step_visitor& _visitor ) const Y_OVERRIDE; const state& get_state() const; diff --git a/yasmine/yasmine/execution_state_enter_step.hpp b/libyasmine/include_impl/execution_state_enter_step.hpp similarity index 94% rename from yasmine/yasmine/execution_state_enter_step.hpp rename to libyasmine/include_impl/execution_state_enter_step.hpp index b146fb1..9bc4c15 100644 --- a/yasmine/yasmine/execution_state_enter_step.hpp +++ b/libyasmine/include_impl/execution_state_enter_step.hpp @@ -30,7 +30,7 @@ class execution_state_enter_step Y_FINAL: explicit execution_state_enter_step( state& _state ); virtual ~execution_state_enter_step() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(execution_state_enter_step) - virtual bool execute_behaviour( event_processing_callback* const _event_processing_callback, + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; virtual void accept( execution_step_visitor& _visitor ) const Y_OVERRIDE; const state& get_state() const; diff --git a/yasmine/yasmine/execution_state_exit_step.hpp b/libyasmine/include_impl/execution_state_exit_step.hpp similarity index 94% rename from yasmine/yasmine/execution_state_exit_step.hpp rename to libyasmine/include_impl/execution_state_exit_step.hpp index 380110e..90b4da7 100644 --- a/yasmine/yasmine/execution_state_exit_step.hpp +++ b/libyasmine/include_impl/execution_state_exit_step.hpp @@ -30,7 +30,7 @@ class execution_state_exit_step Y_FINAL: explicit execution_state_exit_step( state& _state ); virtual ~execution_state_exit_step() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(execution_state_exit_step) - virtual bool execute_behaviour( event_processing_callback* const _event_processing_callback, + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; virtual void accept( execution_step_visitor& _visitor ) const Y_OVERRIDE; const state& get_state() const; diff --git a/yasmine/yasmine/execution_step.hpp b/libyasmine/include_impl/execution_step.hpp similarity index 92% rename from yasmine/yasmine/execution_step.hpp rename to libyasmine/include_impl/execution_step.hpp index 875489d..f83866a 100644 --- a/yasmine/yasmine/execution_step.hpp +++ b/libyasmine/include_impl/execution_step.hpp @@ -14,7 +14,7 @@ #include "execution_step_fwd.hpp" -#include "behaviour_exception_fwd.hpp" +#include "behavior_exception_fwd.hpp" #include "event_fwd.hpp" #include "non_copyable.hpp" @@ -44,7 +44,7 @@ class execution_step Y_NO_COPY(execution_step) - virtual bool execute_behaviour( event_processing_callback* const _event_processing_callback, + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const = 0; virtual void accept( execution_step_visitor& _visitor ) const = 0; diff --git a/yasmine/yasmine/execution_step_fwd.hpp b/libyasmine/include_impl/execution_step_fwd.hpp similarity index 100% rename from yasmine/yasmine/execution_step_fwd.hpp rename to libyasmine/include_impl/execution_step_fwd.hpp diff --git a/yasmine/yasmine/execution_step_visitor.hpp b/libyasmine/include_impl/execution_step_visitor.hpp similarity index 100% rename from yasmine/yasmine/execution_step_visitor.hpp rename to libyasmine/include_impl/execution_step_visitor.hpp diff --git a/yasmine/yasmine/execution_transition_step.hpp b/libyasmine/include_impl/execution_transition_step.hpp similarity index 94% rename from yasmine/yasmine/execution_transition_step.hpp rename to libyasmine/include_impl/execution_transition_step.hpp index 6be1534..38fecb3 100644 --- a/yasmine/yasmine/execution_transition_step.hpp +++ b/libyasmine/include_impl/execution_transition_step.hpp @@ -30,7 +30,7 @@ class execution_transition_step Y_FINAL: explicit execution_transition_step( transition_step& _transition_step ); virtual ~execution_transition_step() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(execution_transition_step) - virtual bool execute_behaviour( event_processing_callback* const _event_processing_callback, + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; virtual void accept( execution_step_visitor& _visitor ) const Y_OVERRIDE; const transition_step& get_transition_step() const; diff --git a/yasmine/yasmine/exit_point_impl.hpp b/libyasmine/include_impl/exit_point_impl.hpp similarity index 100% rename from yasmine/yasmine/exit_point_impl.hpp rename to libyasmine/include_impl/exit_point_impl.hpp diff --git a/yasmine/yasmine/file_system.hpp b/libyasmine/include_impl/file_system.hpp similarity index 100% rename from yasmine/yasmine/file_system.hpp rename to libyasmine/include_impl/file_system.hpp diff --git a/yasmine/yasmine/final_state_impl.hpp b/libyasmine/include_impl/final_state_impl.hpp similarity index 93% rename from yasmine/yasmine/final_state_impl.hpp rename to libyasmine/include_impl/final_state_impl.hpp index a005e67..4644982 100644 --- a/yasmine/yasmine/final_state_impl.hpp +++ b/libyasmine/include_impl/final_state_impl.hpp @@ -28,8 +28,8 @@ class final_state_impl Y_FINAL: explicit final_state_impl( const std::string& _name ); virtual ~final_state_impl() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(final_state_impl) - virtual behaviour * get_entry_behaviour() const Y_OVERRIDE; - virtual behaviour * get_exit_behaviour() const Y_OVERRIDE; + virtual behavior * get_entry_behavior() const Y_OVERRIDE; + virtual behavior * get_exit_behavior() const Y_OVERRIDE; virtual const regions& get_regions() const Y_OVERRIDE; virtual regions& get_regions() Y_OVERRIDE; virtual bool check( state_machine_defects& _defects ) const Y_OVERRIDE; diff --git a/yasmine/yasmine/fork_impl.hpp b/libyasmine/include_impl/fork_impl.hpp similarity index 100% rename from yasmine/yasmine/fork_impl.hpp rename to libyasmine/include_impl/fork_impl.hpp diff --git a/yasmine/yasmine/globals.hpp b/libyasmine/include_impl/globals.hpp similarity index 100% rename from yasmine/yasmine/globals.hpp rename to libyasmine/include_impl/globals.hpp diff --git a/yasmine/yasmine/history_impl.hpp b/libyasmine/include_impl/history_impl.hpp similarity index 100% rename from yasmine/yasmine/history_impl.hpp rename to libyasmine/include_impl/history_impl.hpp diff --git a/yasmine/yasmine/initial_pseudostate_impl.hpp b/libyasmine/include_impl/initial_pseudostate_impl.hpp similarity index 100% rename from yasmine/yasmine/initial_pseudostate_impl.hpp rename to libyasmine/include_impl/initial_pseudostate_impl.hpp diff --git a/yasmine/yasmine/join_impl.hpp b/libyasmine/include_impl/join_impl.hpp similarity index 100% rename from yasmine/yasmine/join_impl.hpp rename to libyasmine/include_impl/join_impl.hpp diff --git a/yasmine/yasmine/junction_impl.hpp b/libyasmine/include_impl/junction_impl.hpp similarity index 100% rename from yasmine/yasmine/junction_impl.hpp rename to libyasmine/include_impl/junction_impl.hpp diff --git a/yasmine/yasmine/log_and_throw.hpp b/libyasmine/include_impl/log_and_throw.hpp similarity index 60% rename from yasmine/yasmine/log_and_throw.hpp rename to libyasmine/include_impl/log_and_throw.hpp index 6cce686..533fda8 100644 --- a/yasmine/yasmine/log_and_throw.hpp +++ b/libyasmine/include_impl/log_and_throw.hpp @@ -45,8 +45,8 @@ namespace sxy #define Y_CAT( A, B ) A ## B #define Y_SELECT( NAME, NUM ) Y_CAT( NAME ## _, NUM ) -#define Y_GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, COUNT, ... ) COUNT -#define Y_VA_SIZE( ... ) Y_EXPAND( Y_GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 ) ) +#define Y_GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, COUNT, ... ) COUNT +#define Y_VA_SIZE( ... ) Y_EXPAND( Y_GET_COUNT( __VA_ARGS__, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1 ) ) #define Y_VA_SELECT( NAME, _level, ... ) Y_EXPAND( Y_SELECT( NAME, Y_VA_SIZE(__VA_ARGS__) )( _level, __VA_ARGS__) ) @@ -83,6 +83,31 @@ namespace sxy throw exception( _what, _value1, _value2, _value3, _value4, _value5 ); +#define LOG_AND_THROW_PARAM_7( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6 ) \ + Y_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6 ); \ + throw exception( _what, _value1, _value2, _value3, _value4, _value5, _value6 ); + + +#define LOG_AND_THROW_PARAM_8( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ) \ + Y_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); \ + throw exception( _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); + + +#define LOG_AND_THROW_PARAM_9( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ) \ + Y_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); \ + throw exception( _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); + + +#define LOG_AND_THROW_PARAM_10( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) \ + Y_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); \ + throw exception( _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); + + +#define LOG_AND_THROW_PARAM_11( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) \ + Y_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); \ + throw exception( _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); + + #else #define LOG_AND_THROW sxy::log_and_throw_helper( __FILE__, __LINE__ ).log diff --git a/yasmine/yasmine/log_and_throw_helper.hpp b/libyasmine/include_impl/log_and_throw_helper.hpp similarity index 100% rename from yasmine/yasmine/log_and_throw_helper.hpp rename to libyasmine/include_impl/log_and_throw_helper.hpp diff --git a/yasmine/yasmine/pseudostate_impl.hpp b/libyasmine/include_impl/pseudostate_impl.hpp similarity index 100% rename from yasmine/yasmine/pseudostate_impl.hpp rename to libyasmine/include_impl/pseudostate_impl.hpp diff --git a/yasmine/yasmine/pseudostate_visitor.hpp b/libyasmine/include_impl/pseudostate_visitor.hpp similarity index 100% rename from yasmine/yasmine/pseudostate_visitor.hpp rename to libyasmine/include_impl/pseudostate_visitor.hpp diff --git a/yasmine/yasmine/region_impl.hpp b/libyasmine/include_impl/region_impl.hpp similarity index 86% rename from yasmine/yasmine/region_impl.hpp rename to libyasmine/include_impl/region_impl.hpp index 2987e9e..18fa94f 100644 --- a/yasmine/yasmine/region_impl.hpp +++ b/libyasmine/include_impl/region_impl.hpp @@ -53,24 +53,24 @@ class region_impl Y_FINAL: virtual initial_pseudostate& add_initial_pseudostate( const std::string& _initial_state_name ) Y_OVERRIDE; virtual state& add_state( state_uptr _state ) Y_OVERRIDE; virtual simple_state& add_simple_state( const std::string& _name, - const behaviour_function& _behaviour = behaviour_function(), - const behaviour_function& _entry_behaviour = behaviour_function(), - const behaviour_function& _exit_behaviour = behaviour_function() ) Y_OVERRIDE; + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function() ) Y_OVERRIDE; virtual simple_state& add_simple_state( const std::string& _name, const event_ids& _deferred_events, - const behaviour_function& _behaviour = behaviour_function(), - const behaviour_function& _entry_behaviour = behaviour_function(), - const behaviour_function& _exit_behaviour = behaviour_function(), + 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() ) Y_OVERRIDE; virtual simple_state& add_async_simple_state( const std::string& _name, const event_ids& _deferred_events, - async_behaviour_uptr _do_action = async_behaviour_uptr(), const behaviour_function& _entry_behaviour = behaviour_function(), - const behaviour_function& _exit_behaviour = behaviour_function(), + 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() ) Y_OVERRIDE; virtual composite_state& add_composite_state( const std::string& _name, - const behaviour_function& _entry_action = behaviour_function(), - const behaviour_function& _exit_action = behaviour_function() ) Y_OVERRIDE; + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) Y_OVERRIDE; virtual composite_state& add_composite_state( const std::string& _name, const event_ids& _deferred_events, - const behaviour_function& _entry_action = behaviour_function(), - const behaviour_function& _exit_action = behaviour_function() ) Y_OVERRIDE; + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) Y_OVERRIDE; virtual final_state& add_final_state( const std::string& _name ) Y_OVERRIDE; virtual choice& add_choice( choice_uptr _choice ) Y_OVERRIDE; diff --git a/yasmine/yasmine/region_pseudostate_impl.hpp b/libyasmine/include_impl/region_pseudostate_impl.hpp similarity index 96% rename from yasmine/yasmine/region_pseudostate_impl.hpp rename to libyasmine/include_impl/region_pseudostate_impl.hpp index ae21767..23e52ac 100644 --- a/yasmine/yasmine/region_pseudostate_impl.hpp +++ b/libyasmine/include_impl/region_pseudostate_impl.hpp @@ -31,7 +31,8 @@ class region_pseudostate_impl: virtual const state_machine_element * get_parent() const Y_OVERRIDE; virtual region * get_parent_region() const Y_OVERRIDE; virtual void set_parent_region( region* const _parent_region ) Y_OVERRIDE; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor ) const Y_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const Y_OVERRIDE; virtual raw_regions get_ancestors_as_regions() const Y_OVERRIDE; diff --git a/yasmine/yasmine/shallow_history_impl.hpp b/libyasmine/include_impl/shallow_history_impl.hpp similarity index 100% rename from yasmine/yasmine/shallow_history_impl.hpp rename to libyasmine/include_impl/shallow_history_impl.hpp diff --git a/yasmine/yasmine/simple_state_impl.hpp b/libyasmine/include_impl/simple_state_impl.hpp similarity index 78% rename from yasmine/yasmine/simple_state_impl.hpp rename to libyasmine/include_impl/simple_state_impl.hpp index 262e365..37accf7 100644 --- a/yasmine/yasmine/simple_state_impl.hpp +++ b/libyasmine/include_impl/simple_state_impl.hpp @@ -24,17 +24,17 @@ class simple_state_impl Y_FINAL: public simple_state_base { public: - explicit simple_state_impl( const std::string& _name, behaviour_uptr do_action = behaviour_uptr(), - behaviour_uptr _entry_action = behaviour_uptr(), behaviour_uptr _exit_action = behaviour_uptr(), + explicit simple_state_impl( const std::string& _name, behavior_uptr do_action = behavior_uptr(), + 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 ~simple_state_impl() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(simple_state_impl) - void execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; + void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const Y_OVERRIDE; private: - const behaviour * get_do() const; + const behavior * get_do() const; - behaviour_uptr do_; + behavior_uptr do_; }; diff --git a/yasmine/yasmine/simple_transition_step.hpp b/libyasmine/include_impl/simple_transition_step.hpp similarity index 96% rename from yasmine/yasmine/simple_transition_step.hpp rename to libyasmine/include_impl/simple_transition_step.hpp index 4005165..ac29715 100644 --- a/yasmine/yasmine/simple_transition_step.hpp +++ b/libyasmine/include_impl/simple_transition_step.hpp @@ -37,7 +37,7 @@ class simple_transition_step Y_FINAL: virtual const exit_point * get_exit_point() const Y_OVERRIDE; virtual const entry_point * get_entry_point() const Y_OVERRIDE; virtual const raw_const_vertices get_target_vertices() Y_OVERRIDE; - void execute_transition_behaviours( const event& _event ) const Y_OVERRIDE; + void execute_transition_behaviors( const event& _event ) const Y_OVERRIDE; private: diff --git a/yasmine/yasmine/state_pseudostate_impl.hpp b/libyasmine/include_impl/state_pseudostate_impl.hpp similarity index 92% rename from yasmine/yasmine/state_pseudostate_impl.hpp rename to libyasmine/include_impl/state_pseudostate_impl.hpp index 8a9e06c..63e172b 100644 --- a/yasmine/yasmine/state_pseudostate_impl.hpp +++ b/libyasmine/include_impl/state_pseudostate_impl.hpp @@ -32,12 +32,14 @@ class state_pseudostate_impl: virtual const state_machine_element * get_parent() const Y_OVERRIDE; virtual composite_state& get_parent_state() const Y_OVERRIDE; virtual void set_parent_state( composite_state* const _parent_state ) Y_OVERRIDE; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor ) const Y_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const Y_OVERRIDE; virtual raw_regions get_ancestors_as_regions() const Y_OVERRIDE; private: - void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor )const; + void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor, + bool _include_final_ancestor )const; composite_state* parent_; #ifdef Y_OPTIMIZE_4_SPEED diff --git a/yasmine/yasmine/state_visitor.hpp b/libyasmine/include_impl/state_visitor.hpp similarity index 100% rename from yasmine/yasmine/state_visitor.hpp rename to libyasmine/include_impl/state_visitor.hpp diff --git a/yasmine/yasmine/states_to_enter_visitor_impl.hpp b/libyasmine/include_impl/states_to_enter_visitor_impl.hpp similarity index 89% rename from yasmine/yasmine/states_to_enter_visitor_impl.hpp rename to libyasmine/include_impl/states_to_enter_visitor_impl.hpp index db8a823..016af0c 100644 --- a/yasmine/yasmine/states_to_enter_visitor_impl.hpp +++ b/libyasmine/include_impl/states_to_enter_visitor_impl.hpp @@ -22,12 +22,16 @@ namespace sxy { +class vertex; + + class states_to_enter_visitor_impl: public virtual vertex_visitor { public: states_to_enter_visitor_impl( raw_states_by_nesting_level& _states_to_enter, - raw_const_region_set& _regions_to_enter, composite_state& _LCA_of_compound_transition ); + raw_const_region_set& _regions_to_enter, composite_state& _LCA_of_compound_transition, + const vertex& _source_of_transition ); virtual ~states_to_enter_visitor_impl() Y_NOEXCEPT Y_OVERRIDE; Y_NO_COPY(states_to_enter_visitor_impl) @@ -50,12 +54,14 @@ class states_to_enter_visitor_impl: void get_states_up_to_LCA( state& _state ); void get_regions_up_to_LCA( const state& _state ); void add_last_active_child_states_to_enter( const state& _state ); - void insert_states_to_enter( state& _state ); + void insert_states_to_enter( state& _state ); + void get_all_parent_states_to_enter( choice& _choice ); raw_states_by_nesting_level& states_to_enter_; raw_const_region_set& regions_to_enter_; composite_state& LCA_of_compound_transition_; + const vertex& source_of_transition_; }; diff --git a/yasmine/yasmine/terminate_pseudostate_impl.hpp b/libyasmine/include_impl/terminate_pseudostate_impl.hpp similarity index 100% rename from yasmine/yasmine/terminate_pseudostate_impl.hpp rename to libyasmine/include_impl/terminate_pseudostate_impl.hpp diff --git a/yasmine/yasmine/transition_controller.hpp b/libyasmine/include_impl/transition_controller.hpp similarity index 87% rename from yasmine/yasmine/transition_controller.hpp rename to libyasmine/include_impl/transition_controller.hpp index 5715144..c898db8 100644 --- a/yasmine/yasmine/transition_controller.hpp +++ b/libyasmine/include_impl/transition_controller.hpp @@ -16,15 +16,15 @@ #include "choice_fwd.hpp" #include "compound_transition_fwd.hpp" #include "event_id.hpp" -#include "behaviour_exception_fwd.hpp" +#include "behavior_exception_fwd.hpp" #include "non_copyable.hpp" +#include "event_fwd.hpp" namespace sxy { -class event; class composite_state; class event_processing_callback; class async_event_handler; @@ -47,6 +47,9 @@ class transition_controller Y_FINAL static bool execute_transitions( const composite_state& _main_composite_state, compound_transitions& compound_transitions, event_processing_callback* const _event_processing_callback, const event& _event, async_event_handler* const _async_event_handler ); + static void handle_execution_events( events& _exception_events, event_processing_callback* const _event_processing_callback, + const composite_state& _main_composite_state, compound_transitions& _compound_transitions, + async_event_handler* const _async_event_handler ); static void search_choice_transitions( const raw_const_choices& _choices, compound_transitions& compound_transitions, const event& _event ); static void search_completion_event_transitions( const composite_state& _main_composite_state, diff --git a/yasmine/yasmine/transition_executor.hpp b/libyasmine/include_impl/transition_executor.hpp similarity index 97% rename from yasmine/yasmine/transition_executor.hpp rename to libyasmine/include_impl/transition_executor.hpp index 38d3cc2..18ac374 100644 --- a/yasmine/yasmine/transition_executor.hpp +++ b/libyasmine/include_impl/transition_executor.hpp @@ -16,7 +16,7 @@ #include "non_copyable.hpp" #include "choice_fwd.hpp" #include "compound_transition_fwd.hpp" -#include "behaviour_exception_fwd.hpp" +#include "behavior_exception_fwd.hpp" #include "event_fwd.hpp" diff --git a/yasmine/yasmine/transition_executor_impl.hpp b/libyasmine/include_impl/transition_executor_impl.hpp similarity index 89% rename from yasmine/yasmine/transition_executor_impl.hpp rename to libyasmine/include_impl/transition_executor_impl.hpp index 221bf8e..ee24d01 100644 --- a/yasmine/yasmine/transition_executor_impl.hpp +++ b/libyasmine/include_impl/transition_executor_impl.hpp @@ -19,9 +19,10 @@ #include "compound_transition_fwd.hpp" #include "transition_step_fwd.hpp" #include "execution_step_fwd.hpp" -#include "behaviour_exception_fwd.hpp" +#include "behavior_exception_fwd.hpp" #include "event_fwd.hpp" #include "non_copyable.hpp" +#include "transition_kind.hpp" namespace sxy @@ -31,6 +32,8 @@ namespace sxy class event_processing_callback; class composite_state; class async_event_handler; +class choice; +class vertex; namespace impl @@ -77,17 +80,26 @@ class transition_executor_impl void add_remained_transitions( transition_steps::const_iterator& _transition_start, const transition_steps::const_iterator& _transition_end, execution_steps& _execution_steps ); void fill_vector_of_choices( raw_const_choices& _choices, const compound_transitions& _compound_transitions ); - void find_all_states_to_enter_and_exit( compound_transition& new_compound_transition, + void find_already_entered_regions( compound_transition& new_compound_transition, raw_const_region_set& _entered_regions, const event& _event ); void find_states_to_enter_and_to_exit_and_calculate_execution_steps( compound_transition_consumer& compound_transition, execution_steps& _execution_steps, - raw_const_region_set& _entered_regions, const event& _event ); + raw_const_region_set& _entered_regions, const event& _event, bool _find_states_to_exit ); void check_conflicts_from_source_state_to_LCA( const state& _state, raw_const_state_set& _unique_exit_states, const composite_state* _LCA ) const; + + +private: + void get_all_parent_states_to_enter( raw_states_by_nesting_level& _states_to_enter, choice& _choice, + const vertex& source_vertex ) const; + void fill_vector_of_states_to_exit( region* _LCA_region, raw_states_by_nesting_level_ascending& _states_to_exit, + const transition_kind _compound_transition_kind ); }; } + + } #endif diff --git a/yasmine/yasmine/transition_finder.hpp b/libyasmine/include_impl/transition_finder.hpp similarity index 100% rename from yasmine/yasmine/transition_finder.hpp rename to libyasmine/include_impl/transition_finder.hpp diff --git a/yasmine/yasmine/transition_priority.hpp b/libyasmine/include_impl/transition_priority.hpp similarity index 100% rename from yasmine/yasmine/transition_priority.hpp rename to libyasmine/include_impl/transition_priority.hpp diff --git a/yasmine/yasmine/transition_step.hpp b/libyasmine/include_impl/transition_step.hpp similarity index 95% rename from yasmine/yasmine/transition_step.hpp rename to libyasmine/include_impl/transition_step.hpp index c4bb614..e9467c2 100644 --- a/yasmine/yasmine/transition_step.hpp +++ b/libyasmine/include_impl/transition_step.hpp @@ -47,7 +47,7 @@ class transition_step virtual const raw_transitions& get_transitions() const = 0; virtual const vertex& get_unique_source() const = 0; virtual const vertex& get_unique_target() const = 0; - virtual void execute_transition_behaviours( const event& _event ) const = 0; + virtual void execute_transition_behaviors( const event& _event ) const = 0; virtual const exit_point * get_exit_point() const = 0; virtual const entry_point * get_entry_point() const = 0; virtual const raw_const_vertices get_target_vertices() = 0; diff --git a/yasmine/yasmine/transition_step_fwd.hpp b/libyasmine/include_impl/transition_step_fwd.hpp similarity index 100% rename from yasmine/yasmine/transition_step_fwd.hpp rename to libyasmine/include_impl/transition_step_fwd.hpp diff --git a/yasmine/yasmine/try_to_build_compound_transition_visitor.hpp b/libyasmine/include_impl/try_to_build_compound_transition_visitor.hpp similarity index 100% rename from yasmine/yasmine/try_to_build_compound_transition_visitor.hpp rename to libyasmine/include_impl/try_to_build_compound_transition_visitor.hpp diff --git a/yasmine/yasmine/vertex_visitor.hpp b/libyasmine/include_impl/vertex_visitor.hpp similarity index 100% rename from yasmine/yasmine/vertex_visitor.hpp rename to libyasmine/include_impl/vertex_visitor.hpp diff --git a/yasmine/yasmine/yasmine.vcxproj b/libyasmine/libyasmine.vcxproj similarity index 64% rename from yasmine/yasmine/yasmine.vcxproj rename to libyasmine/libyasmine.vcxproj index f18ec57..e90af5c 100644 --- a/yasmine/yasmine/yasmine.vcxproj +++ b/libyasmine/libyasmine.vcxproj @@ -67,284 +67,291 @@ - - - - + + + + - + - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - + + + + + - + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -352,7 +359,7 @@ {A728DDFB-BE51-49B5-8593-4E89E024A500} Win32Proj - yasmine + libyasmine 8.1 @@ -473,10 +480,12 @@ + + @@ -692,6 +701,7 @@ true true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + None Windows diff --git a/yasmine/yasmine/yasmine.vcxproj.filters b/libyasmine/libyasmine.vcxproj.filters similarity index 65% rename from yasmine/yasmine/yasmine.vcxproj.filters rename to libyasmine/libyasmine.vcxproj.filters index 749a1ae..af8de5b 100644 --- a/yasmine/yasmine/yasmine.vcxproj.filters +++ b/libyasmine/libyasmine.vcxproj.filters @@ -126,726 +126,747 @@ - + Headerdateien\core\state machine\element - + Headerdateien\core\algorithm\transition controller - + Headerdateien\core\algorithm\transition executor\execution step\visitor - + Headerdateien\core\algorithm\transition executor\execution step - + Headerdateien\core\algorithm\transition executor\execution step - + Headerdateien\core\algorithm\transition executor\execution step - + Headerdateien\core\algorithm\transition executor\execution step - + Headerdateien\core\algorithm\transition executor\execution step - + Headerdateien\core\algorithm\transition executor\execution step - + Headerdateien\core\algorithm\transition executor\impl - + Headerdateien\core\algorithm\transition executor - + Headerdateien\core\algorithm\transition executor - + Headerdateien\core\algorithm\transition executor - + Headerdateien\core\algorithm\transition executor - + Headerdateien\core\algorithm\transition executor - + Headerdateien\core\algorithm\transition finder\transition step - + Headerdateien\core\algorithm\transition finder\transition step - + Headerdateien\core\algorithm\transition finder\transition step - + Headerdateien\core\algorithm\transition finder\transition step - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\transition finder - + Headerdateien\core\algorithm\visitor - + Headerdateien\core\algorithm\visitor - + Headerdateien\core\algorithm\visitor - + Headerdateien\core\algorithm\visitor - + Headerdateien\core\algorithm\visitor - + Headerdateien\core\state machine\collection header - + Headerdateien\core\state machine\collection header - + Headerdateien\core\state machine\collection header - + Headerdateien\core\state machine\collection header - + Headerdateien\core\state machine\collection header - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\timed event - + Headerdateien\core\state machine\timed event - + Headerdateien\core\state machine\timed event - + Headerdateien\core\state machine\vertex\pseudostate\algorithm - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\pseudostate - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex\state - + Headerdateien\core\state machine\vertex - + Headerdateien\core\state machine\vertex - + Headerdateien\core\state machine\vertex - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\core\state machine - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien - + Headerdateien - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine - + Headerdateien\core\state machine\element - + Headerdateien\infrastructure - + Headerdateien\core\algorithm - + Headerdateien\infrastructure - - Headerdateien\infrastructure - - + Headerdateien\core\state machine\element - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\infrastructure - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine - + Headerdateien\infrastructure\log - + Headerdateien\infrastructure\log - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + + Headerdateien\core\state machine\element + + + Headerdateien\core\state machine\element + + + Headerdateien\infrastructure\log + + + Headerdateien\infrastructure\log + + + Headerdateien\infrastructure\log + + Headerdateien\core\state machine\element - + Headerdateien\core\state machine\element - + Quelldateien\infrastructure - + Quelldateien\infrastructure - + Quelldateien\infrastructure - + Quelldateien\infrastructure - + Quelldateien - + Quelldateien\core\algorithm\transition controller - + Quelldateien\core\algorithm\transition executor\execution step - + Quelldateien\core\algorithm\transition executor\execution step - + Quelldateien\core\algorithm\transition executor\execution step - + Quelldateien\core\algorithm\transition executor\execution step - + Quelldateien\core\algorithm\transition executor - + Quelldateien\core\algorithm\transition executor - + Quelldateien\core\algorithm\transition executor - + Quelldateien\core\algorithm\transition executor - + Quelldateien\core\algorithm\transition executor - + Quelldateien\core\algorithm\transition finder\transition step - + Quelldateien\core\algorithm\transition finder\transition step - + Quelldateien\core\algorithm\transition finder - + Quelldateien\core\algorithm\transition finder - + Quelldateien\core\algorithm\transition finder - + Quelldateien\core\algorithm\transition finder - + Quelldateien\core\state machine\element - + Quelldateien\core\state machine\element - + Quelldateien\core\state machine\element - + Quelldateien\core\state machine\element - + Quelldateien\core\state machine\element - + Quelldateien\core\state machine\timed event - + Quelldateien\core\state machine\timed event - + Quelldateien\core\state machine\timed event - + Quelldateien\core\state machine\vertex\pseudostate\algorithm - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\pseudostate - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex - + Quelldateien\core\state machine - + Quelldateien\core\state machine - + Quelldateien\core\state machine - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + Quelldateien\core\algorithm\transition executor\impl - + Quelldateien\core\state machine - + Quelldateien\infrastructure - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\state machine\vertex\state - + Quelldateien\core\algorithm\transition finder - + Quelldateien\core\algorithm - + Quelldateien\core\state machine\element - + Quelldateien\infrastructure\log - + Quelldateien\infrastructure\log - + + Quelldateien\core\state machine\element + + Quelldateien\core\state machine\element - + + Quelldateien\core\state machine\element + + + Quelldateien\infrastructure\log + + Quelldateien\core\state machine\element - + Quelldateien\core\state machine\element diff --git a/yasmine/yasmine/algorithm_parameters.cpp b/libyasmine/source/algorithm_parameters.cpp similarity index 100% rename from yasmine/yasmine/algorithm_parameters.cpp rename to libyasmine/source/algorithm_parameters.cpp diff --git a/yasmine/yasmine/async_behaviour.cpp b/libyasmine/source/async_behavior.cpp similarity index 70% rename from yasmine/yasmine/async_behaviour.cpp rename to libyasmine/source/async_behavior.cpp index 0f61b56..8a121ff 100644 --- a/yasmine/yasmine/async_behaviour.cpp +++ b/libyasmine/source/async_behavior.cpp @@ -9,20 +9,20 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#include "async_behaviour.hpp" +#include "async_behavior.hpp" #include "log.hpp" -#include "event_impl.hpp" -#include "behaviour_exception.hpp" +#include "behavior_exception.hpp" #include "simple_state_base.hpp" #include "async_event_handler.hpp" +#include "event.hpp" namespace sxy { -async_behaviour::async_behaviour() +async_behavior::async_behavior() : worker_(), mutex_(), run_(false) @@ -31,22 +31,22 @@ async_behaviour::async_behaviour() } -async_behaviour::~async_behaviour() Y_NOEXCEPT +async_behavior::~async_behavior() Y_NOEXCEPT { Y_ASSERT( !run_, "Thread is still running! It was not stopped." ); Y_ASSERT( !worker_, "The thread still exists!" ); } -void async_behaviour::start( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) +void async_behavior::run( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) { run_ = true; - worker_ = Y_MAKE_UNIQUE< sxy::thread >( sxy::bind( &async_behaviour::run, this, sxy::ref( _event ), sxy::ref( _simple_state ), sxy::ref( _async_event_handler ) ) ); + worker_ = Y_MAKE_UNIQUE< sxy::thread >( sxy::bind( &async_behavior::work, this, sxy::ref( _event ), sxy::ref( _simple_state ), sxy::ref( _async_event_handler ) ) ); } -void async_behaviour::stop() +void async_behavior::halt() { { sxy::lock_guard< sxy::mutex > lock( mutex_ ); @@ -58,55 +58,54 @@ void async_behaviour::stop() } -// cppcheck-suppress unusedFunction -bool async_behaviour::should_stop() const +bool async_behavior::should_stop() const { sxy::lock_guard< sxy::mutex > lock( mutex_ ); return( !run_ ); } -void async_behaviour::notify_should_stop() +void async_behavior::notify_should_stop() { // Nothing to do... } -void async_behaviour::run( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) +void async_behavior::work( const event& _event, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) { try { run_impl( _event, _async_event_handler ); } - catch( const sxy::behaviour_exception& exception ) + catch( const sxy::behavior_exception& exception ) { - Y_LOG( log_level::LL_DEBUG, "behaviour_exception while running async_behaviour: %", exception.what() ); + Y_LOG( log_level::LL_DEBUG, "behavior_exception while running async_behavior: %", exception.what() ); _async_event_handler.on_event( exception.get_error_event() ); } catch( const std::exception& exception ) { - Y_LOG( log_level::LL_DEBUG, "std::exception while running async_behaviour: %", exception.what() ); + Y_LOG( log_level::LL_DEBUG, "std::exception while running async_behavior: %", exception.what() ); if( _simple_state.has_error_event() ) { _async_event_handler.on_event( _simple_state.get_error_event() ); } else { - Y_LOG( log_level::LL_FATAL, "Unknown exception while running async_behaviour!" ); + Y_LOG( log_level::LL_FATAL, "Unknown exception while running async_behavior!" ); throw; } } catch( ... ) { - Y_LOG( log_level::LL_FATAL, "Unknown exception while running async_behaviour!" ); + Y_LOG( log_level::LL_FATAL, "Unknown exception while running async_behavior!" ); throw; } } -void async_behaviour::join() +void async_behavior::join() { - Y_ASSERT( worker_->joinable(), "Async behaviour thread is not joinable!" ); + Y_ASSERT( worker_->joinable(), "Async behavior thread is not joinable!" ); worker_->join(); worker_.reset(); } diff --git a/yasmine/yasmine/async_simple_state_impl.cpp b/libyasmine/source/async_simple_state_impl.cpp similarity index 67% rename from yasmine/yasmine/async_simple_state_impl.cpp rename to libyasmine/source/async_simple_state_impl.cpp index 05fe13c..968404a 100644 --- a/yasmine/yasmine/async_simple_state_impl.cpp +++ b/libyasmine/source/async_simple_state_impl.cpp @@ -12,20 +12,21 @@ #include "async_simple_state_impl.hpp" #include "base.hpp" +#include "async_behavior.hpp" namespace sxy { -async_simple_state_impl::async_simple_state_impl( const std::string& _name, async_behaviour_uptr _do_action, - behaviour_uptr _entry_action, behaviour_uptr _exit_action, const event_ids& _deferred_events, +async_simple_state_impl::async_simple_state_impl( const std::string& _name, async_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, sxy::move( _entry_action ), sxy::move( _exit_action ), _deferred_events, _error_event ), do_( sxy::move( _do_action ) ) { - Y_ASSERT( do_, "Async simple state must have an 'async do behaviour' asigned!" ); + Y_ASSERT( do_, "Async simple state must have an 'async do behavior' asigned!" ); } @@ -35,30 +36,30 @@ async_simple_state_impl::~async_simple_state_impl() Y_NOEXCEPT } -void async_simple_state_impl::execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const +void async_simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const { - const async_behaviour* const behaviour = do_.get(); - if( behaviour ) + const async_behavior* const behavior = do_.get(); + if( behavior ) { - do_->start( _event, *this, *_async_event_handler ); + do_->run( _event, *this, *_async_event_handler ); } } -void async_simple_state_impl::execute_exit_behaviour( const event& _event ) const +void async_simple_state_impl::execute_exit_behavior( const event& _event ) const { - stop_do_behaviour(); + stop_do_behavior(); - complex_state_impl::execute_exit_behaviour( _event ); + complex_state_impl::execute_exit_behavior( _event ); } -void async_simple_state_impl::stop_do_behaviour() const +void async_simple_state_impl::stop_do_behavior() const { - const async_behaviour* const behaviour = do_.get(); - if( behaviour ) + const async_behavior* const behavior = do_.get(); + if( behavior ) { - do_->stop(); + do_->halt(); } } diff --git a/yasmine/yasmine/async_state_machine.cpp b/libyasmine/source/async_state_machine.cpp similarity index 56% rename from yasmine/yasmine/async_state_machine.cpp rename to libyasmine/source/async_state_machine.cpp index 4186696..41e4165 100644 --- a/yasmine/yasmine/async_state_machine.cpp +++ b/libyasmine/source/async_state_machine.cpp @@ -8,6 +8,7 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// + #include "async_state_machine.hpp" #include @@ -25,11 +26,11 @@ namespace sxy async_state_machine::async_state_machine( const std::string& _name, event_processing_callback* const _event_processing_callback ) : state_machine( _name, _event_processing_callback ), - status_( status::NEW ), + status_( state_machine_status::NEW ), run_and_event_mutex_(), run_and_event_condition_(), - worker_thread_(), - run_( false ), + terminated_condition_(), + worker_thread_(), event_list_() { Y_LOG( sxy::log_level::LL_TRACE, "Creating async state_machine '%'.", _name ); @@ -42,7 +43,7 @@ async_state_machine::~async_state_machine() Y_NOEXCEPT { Y_LOG( sxy::log_level::LL_TRACE, "Destroying async state_machine '%'.", get_name() ); - Y_ASSERT( ( status::NEW == status_ ) || ( status::STOPPED == status_ ), + Y_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), "Status is neither 'NEW' nor 'STOPPED' on destruction!" ); Y_LOG( sxy::log_level::LL_TRACE, "Destroyed async state_machine '%'.", get_name() ); @@ -55,19 +56,19 @@ bool async_state_machine::fire_event( const event_sptr& _event ) } -bool async_state_machine::start_state_machine() +bool async_state_machine::run() { Y_LOG( log_level::LL_INFO, "Starting async state machine '%'.", get_name() ); - const bool state_machine_started = state_machine::start_state_machine( this ); + const bool state_machine_started = state_machine::run( this ); if( state_machine_started ) { - start(); + start_state_machine(); } else { - Y_LOG( log_level::LL_INFO, "Terminate pseudostate was reached in %.", get_name() ); - status_ = status::STOPPED; + Y_LOG( log_level::LL_INFO, "Terminate pseudostate was reached in %.", get_name() ); + status_ = state_machine_status::STOPPED; } Y_LOG( log_level::LL_INFO, "Started async state machine '%'.", get_name() ); @@ -76,46 +77,28 @@ bool async_state_machine::start_state_machine() } -void async_state_machine::stop_state_machine() +void async_state_machine::halt_and_join() { - Y_LOG( log_level::LL_INFO, "Stopping async state machine '%'.", get_name() ); - - stop(); - join(); - state_machine::stop_state_machine(); - - Y_LOG( log_level::LL_INFO, "Stopped async state machine '%'.", get_name() ); -} + Y_LOG( log_level::LL_INFO, "Stopping and joining async state machine '%'.", get_name() ); + halt(); + join(); -void async_state_machine::on_event( const event_sptr& _event ) -{ - insert( _event ); + Y_LOG( log_level::LL_INFO, "Stopped and joined async state machine '%'.", get_name() ); } -void async_state_machine::start() -{ - Y_ASSERT( ( status::NEW == status_ ) || ( status::STOPPED == status_ ), - "Status is neither 'NEW' nor 'STOPPED' on start!" ); - run_ = true; - worker_thread_ = Y_MAKE_UNIQUE< sxy::thread >( &async_state_machine::work, this ); - status_ = status::STARTED; -} - - -void async_state_machine::stop() +void async_state_machine::halt() { Y_LOG( log_level::LL_TRACE, "Stopping async state machine '%'.", get_name() ); - Y_ASSERT( ( status::STARTED == status_ ) || ( status::STOP_REQUESTED == status_ ), - "Status is not 'STARTED' or 'STOP_REQUESTED' on stop!" ); { sxy::lock_guard< sxy::mutex > lock( run_and_event_mutex_ ); - run_ = false; + Y_ASSERT( ( state_machine_status::STARTED == status_ ) || ( state_machine_status::TERMINATED == status_ ), + "Status is not 'STARTED' or 'TERMINATED' on stop!" ); + status_ = state_machine_status::STOP_REQUESTED; } - run_and_event_condition_.notify_one(); - status_ = status::STOP_REQUESTED; + run_and_event_condition_.notify_one(); Y_LOG( log_level::LL_TRACE, "Stopped state machine ''%'.", get_name() ); } @@ -125,23 +108,69 @@ void async_state_machine::join() { Y_LOG( log_level::LL_TRACE, "Joining state machine '%'.", get_name() ); - Y_ASSERT( status::STOP_REQUESTED == status_, "Status is not 'STOP_REQUESTED' when joining!" ); + { + sxy::lock_guard< sxy::mutex > lock( run_and_event_mutex_ ); + Y_ASSERT( ( state_machine_status::STOP_REQUESTED == status_ ) || ( state_machine_status::TERMINATED == status_ ), + "Status is not 'STOP_REQUESTED' or 'TERMNINATED' when joining!" ); + } + + state_machine::halt(); worker_thread_->join(); worker_thread_.reset(); - status_ = status::STOPPED; + status_ = state_machine_status::STOPPED; Y_LOG( log_level::LL_TRACE, "Joined state machine '%'.", get_name() ); } +bool async_state_machine::wait( const sxy::milliseconds _timeoutInMs ) const +{ + Y_LOG( log_level::LL_INFO, "Waiting for async state machine '%' to terminate. Timeout: %ms", get_name(), _timeoutInMs.count() ); + { + sxy::unique_lock lock( run_and_event_mutex_ ); + terminated_condition_.wait_for( lock, _timeoutInMs, sxy::bind( &async_state_machine::wait_stop_condition, this ) ); + } + Y_LOG( log_level::LL_INFO, "Waited for async state machine '%' to terminate.", get_name() ); + return( terminated() ); +} + + +void async_state_machine::wait() const +{ + Y_LOG( log_level::LL_INFO, "Waiting for async state machine '%' to terminate.", get_name() ); + { + sxy::unique_lock lock( run_and_event_mutex_ ); + terminated_condition_.wait( lock, sxy::bind( &async_state_machine::wait_stop_condition, this ) ); + } + Y_LOG( log_level::LL_INFO, "Waited for async state machine '%' to terminate.", get_name() ); +} + + +bool async_state_machine::terminated() const +{ + sxy::lock_guard< sxy::mutex > lock( run_and_event_mutex_ ); + return( ( state_machine_status::TERMINATED == status_ ) || ( state_machine_status::STOPPED == status_ ) ); +} + + +void async_state_machine::start_state_machine() +{ + Y_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_ = Y_MAKE_UNIQUE< sxy::thread >( &async_state_machine::work, this ); +} + + bool async_state_machine::insert( const event_sptr& _event ) { Y_ASSERT( _event, "_event is nullptr!" ); bool event_added = false; { - sxy::lock_guard< sxy::mutex > lock( run_and_event_mutex_ ); - if( run_ ) + sxy::lock_guard< sxy::mutex > lock( run_and_event_mutex_ ); + if( status_ == state_machine_status::STARTED ) { insert_impl( _event ); event_added = true; @@ -175,11 +204,7 @@ void async_state_machine::insert_impl( const event_sptr& _event ) else { std::list< event_sptr >::iterator position = event_list_.begin(); -#ifndef Y_CPP03_BOOST - while ( position != std::end( event_list_ ) ) -#else - while ( position != event_list_.end() ) -#endif + while( position != event_list_.end() ) { if (_event->operator>(**position)) { @@ -187,20 +212,21 @@ void async_state_machine::insert_impl( const event_sptr& _event ) } ++position; } -#ifndef Y_CPP03_BOOST - Y_ASSERT( position != std::end( event_list_ ), "No element found before which to insert!" ); -#else Y_ASSERT( position != event_list_.end(), "No element found before which to insert!" ); -#endif - event_list_.insert( position, _event ); - + event_list_.insert( position, _event ); } } bool async_state_machine::wait_predicate() const +{ + return( !( status_ == state_machine_status::STARTED ) || !event_list_.empty() ); +} + + +bool async_state_machine::wait_stop_condition() const { - return( !run_ || !event_list_.empty() ); + return( ( state_machine_status::TERMINATED == status_ ) || ( state_machine_status::STOPPED == status_ ) ); } @@ -213,13 +239,11 @@ void async_state_machine::work() event_sptr event; { sxy::unique_lock< sxy::mutex > lock( run_and_event_mutex_ ); - run_and_event_condition_.wait( lock, sxy::bind( &async_state_machine::wait_predicate, this ) ); - - if( !run_ && event_list_.empty() ) + run_and_event_condition_.wait( lock, sxy::bind( &async_state_machine::wait_predicate, this ) ); + if( !( status_ == state_machine_status::STARTED ) && event_list_.empty() ) { break; } - Y_ASSERT( !event_list_.empty(), "Event list is empty!" ); event = event_list_.front(); event_list_.pop_front(); @@ -232,14 +256,29 @@ void async_state_machine::work() } catch ( const std::exception& exception ) { - Y_LOG( sxy::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); - run_ = false; + Y_LOG( sxy::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); + status_ = state_machine_status::STOPPED; } catch ( ... ) { - Y_LOG( sxy::log_level::LL_FATAL, "Unknown exception!" ); - run_ = false; + Y_LOG( sxy::log_level::LL_FATAL, "Unknown exception!" ); + status_ = state_machine_status::STOPPED; } + + { + sxy::lock_guard< sxy::mutex > lock( run_and_event_mutex_ ); + status_ = state_machine_status::TERMINATED; + } + + terminated_condition_.notify_all(); + Y_LOG( log_level::LL_INFO, "Async state machine '%' terminated.", get_name() ); } + +void async_state_machine::on_event( const event_sptr& _event ) +{ + insert( _event ); +} + + } diff --git a/yasmine/yasmine/behaviour_exception.cpp b/libyasmine/source/behavior_exception.cpp similarity index 83% rename from yasmine/yasmine/behaviour_exception.cpp rename to libyasmine/source/behavior_exception.cpp index e12f84f..559fbfe 100644 --- a/yasmine/yasmine/behaviour_exception.cpp +++ b/libyasmine/source/behavior_exception.cpp @@ -9,14 +9,14 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#include "behaviour_exception.hpp" +#include "behavior_exception.hpp" namespace sxy { -behaviour_exception::behaviour_exception( const event_sptr& _event ) +behavior_exception::behavior_exception( const event_sptr& _event ) : exception("Error handle exception."), error_event_( _event ) { @@ -24,13 +24,13 @@ behaviour_exception::behaviour_exception( const event_sptr& _event ) } -behaviour_exception::~behaviour_exception() Y_NOEXCEPT +behavior_exception::~behavior_exception() Y_NOEXCEPT { // Nothing to do... } -const event_sptr behaviour_exception::get_error_event() const +const event_sptr behavior_exception::get_error_event() const { return( error_event_ ); } diff --git a/yasmine/yasmine/behaviour_impl.cpp b/libyasmine/source/behavior_impl.cpp similarity index 73% rename from yasmine/yasmine/behaviour_impl.cpp rename to libyasmine/source/behavior_impl.cpp index 9ac26a1..426e514 100644 --- a/yasmine/yasmine/behaviour_impl.cpp +++ b/libyasmine/source/behavior_impl.cpp @@ -9,7 +9,7 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#include "behaviour_impl.hpp" +#include "behavior_impl.hpp" #include "event_impl.hpp" @@ -17,20 +17,20 @@ namespace sxy { -behaviour_impl::behaviour_impl( const behaviour_function& _function ) + behavior_impl::behavior_impl( const behavior_function& _function ) : function_( _function ) { - // Nothing to do. + // Nothing to do... } -behaviour_impl::~behaviour_impl() Y_NOEXCEPT + behavior_impl::~behavior_impl() Y_NOEXCEPT { - // Nothing to do. + // Nothing to do... } -void behaviour_impl::operator()( const event& _event ) const +void behavior_impl::operator()( const event& _event ) const { if( function_ ) { @@ -39,9 +39,9 @@ void behaviour_impl::operator()( const event& _event ) const } -behaviour_uptr behaviour_impl::create_behaviour( const behaviour_function& _function ) +behavior_uptr behavior_impl::create_behavior( const behavior_function& _function ) { - return( Y_MAKE_UNIQUE< sxy::behaviour_impl >( _function ) ); + return( Y_MAKE_UNIQUE< sxy::behavior_impl >( _function ) ); } diff --git a/yasmine/yasmine/build_transition_steps_visitor.cpp b/libyasmine/source/build_transition_steps_visitor.cpp similarity index 100% rename from yasmine/yasmine/build_transition_steps_visitor.cpp rename to libyasmine/source/build_transition_steps_visitor.cpp diff --git a/yasmine/yasmine/check_if_all_incoming_transitions_sources_are_active_visitor.cpp b/libyasmine/source/check_if_all_incoming_transitions_sources_are_active_visitor.cpp similarity index 100% rename from yasmine/yasmine/check_if_all_incoming_transitions_sources_are_active_visitor.cpp rename to libyasmine/source/check_if_all_incoming_transitions_sources_are_active_visitor.cpp diff --git a/yasmine/yasmine/choice_impl.cpp b/libyasmine/source/choice_impl.cpp similarity index 99% rename from yasmine/yasmine/choice_impl.cpp rename to libyasmine/source/choice_impl.cpp index a168ead..5152ce1 100644 --- a/yasmine/yasmine/choice_impl.cpp +++ b/libyasmine/source/choice_impl.cpp @@ -17,6 +17,7 @@ #include "state_machine_defect.hpp" #include "region.hpp" #include "transition.hpp" +#include "log.hpp" namespace sxy @@ -108,7 +109,6 @@ void choice_impl::accept_vertex_visitor( vertex_visitor& _visitor ) } -// cppcheck-suppress unusedFunction void choice_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const { _visitor.visit( *this ); diff --git a/yasmine/yasmine/color_mapping.cpp b/libyasmine/source/color_mapping.cpp similarity index 91% rename from yasmine/yasmine/color_mapping.cpp rename to libyasmine/source/color_mapping.cpp index 840297e..f319df6 100644 --- a/yasmine/yasmine/color_mapping.cpp +++ b/libyasmine/source/color_mapping.cpp @@ -29,8 +29,7 @@ color_mapping::color_mapping() { log_level::LL_FATAL, color::C_RED }, { log_level::LL_ERROR, color::C_DARK_RED }, { log_level::LL_ASSERT, color::C_DARK_RED }, { log_level::LL_WARN, color::C_YELLOW }, { log_level::LL_INFO, color::C_DARK_YELLOW }, { log_level::LL_DEBUG, color::C_DARK_GREEN }, - { log_level::LL_TRACE,color::C_DARK_GREEN }, { log_level::LL_SPAM, color::C_GREEN }, - { log_level::LL_PROTOCOL, color::C_BLUE } + { log_level::LL_TRACE,color::C_DARK_GREEN }, { log_level::LL_SPAM, color::C_GREEN } } ) { // Nothing to do... @@ -50,7 +49,6 @@ color_mapping::color_mapping() color_map_[ log_level::LL_DEBUG ] = color::C_DARK_GREEN; color_map_[ log_level::LL_TRACE ] = color::C_DARK_GREEN; color_map_[ log_level::LL_SPAM ] = color::C_GREEN; - color_map_[ log_level::LL_PROTOCOL ] = color::C_BLUE; } @@ -65,13 +63,13 @@ color_mapping::~color_mapping() Y_NOEXCEPT color color_mapping::get_color( const sxy::log_level _log_level ) const { - color color = color::C_WHITE; + color color_to_use = color::C_WHITE; color_map::const_iterator search = color_map_.find( _log_level ); if (search != color_map_.end()) { - color = search->second; + color_to_use = search->second; } - return( color ); + return( color_to_use ); } diff --git a/libyasmine/source/completion_event.cpp b/libyasmine/source/completion_event.cpp new file mode 100644 index 0000000..a3bba2f --- /dev/null +++ b/libyasmine/source/completion_event.cpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef Y_CPP03_BOOST + + +#include "completion_event.hpp" + +namespace sxy +{ + const event_id Y_COMPLETION_EVENT_ID = std::numeric_limits::max(); +} + + +#else + #ifdef _MSC_VER + #if _MSC_VER <= 1800 + + +#include "completion_event.hpp" + +namespace sxy +{ + const event_id Y_COMPLETION_EVENT_ID = std::numeric_limits::max(); +} + + + #endif + #endif +#endif diff --git a/yasmine/yasmine/complex_state_impl.cpp b/libyasmine/source/complex_state_impl.cpp similarity index 87% rename from yasmine/yasmine/complex_state_impl.cpp rename to libyasmine/source/complex_state_impl.cpp index b26666a..72160a5 100644 --- a/yasmine/yasmine/complex_state_impl.cpp +++ b/libyasmine/source/complex_state_impl.cpp @@ -21,11 +21,11 @@ namespace sxy { -complex_state_impl::complex_state_impl( const std::string& _name, behaviour_uptr _entry_behaviour, - behaviour_uptr _exit_behaviour, const event_ids& _deferred_events ) +complex_state_impl::complex_state_impl( const std::string& _name, behavior_uptr _entry_behavior, + behavior_uptr _exit_behavior, const event_ids& _deferred_events ) : state_impl( _name ), - entry_( sxy::move( _entry_behaviour ) ), - exit_( sxy::move( _exit_behaviour ) ), + entry_( sxy::move( _entry_behavior ) ), + exit_( sxy::move( _exit_behavior ) ), deferred_events_( _deferred_events ) { // Nothing to do... @@ -38,13 +38,13 @@ complex_state_impl::~complex_state_impl() Y_NOEXCEPT } -behaviour* complex_state_impl::get_entry_behaviour() const +behavior* complex_state_impl::get_entry_behavior() const { return( entry_.get() ); } -behaviour* complex_state_impl::get_exit_behaviour() const +behavior* complex_state_impl::get_exit_behavior() const { return( exit_.get() ); } diff --git a/yasmine/yasmine/composite_state_impl.cpp b/libyasmine/source/composite_state_impl.cpp similarity index 95% rename from yasmine/yasmine/composite_state_impl.cpp rename to libyasmine/source/composite_state_impl.cpp index cb323ae..8ecd705 100644 --- a/yasmine/yasmine/composite_state_impl.cpp +++ b/libyasmine/source/composite_state_impl.cpp @@ -22,7 +22,7 @@ #include "shallow_history_impl.hpp" #include "exit_point_impl.hpp" #include "entry_point_impl.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" #include "state_machine_defect.hpp" #include "uri.hpp" #include "log_and_throw.hpp" @@ -32,8 +32,8 @@ namespace sxy { -composite_state_impl::composite_state_impl( const std::string& _name, behaviour_uptr _entry_action, - behaviour_uptr _exit_action, const event_ids& _deferred_events ) +composite_state_impl::composite_state_impl( const std::string& _name, behavior_uptr _entry_action, + behavior_uptr _exit_action, const event_ids& _deferred_events ) : complex_state_impl( _name, sxy::move( _entry_action ), sxy::move( _exit_action ), _deferred_events ), regions_(), deep_history_(deep_history_uptr()), @@ -60,7 +60,6 @@ region& composite_state_impl::add_region( region_uptr _region ) } -// cppcheck-suppress unusedFunction region& composite_state_impl::add_region( const std::string& _region_name ) { Y_UNIQUE_PTR< sxy::region_impl > region = Y_MAKE_UNIQUE< sxy::region_impl >( _region_name ); @@ -83,7 +82,6 @@ regions& composite_state_impl::get_regions() } -// cppcheck-suppress unusedFunction region* composite_state_impl::get_region( const std::string& _region_name ) const { region* found_region = Y_NULLPTR; @@ -113,7 +111,6 @@ const deep_history* composite_state_impl::get_deep_history() const } -// cppcheck-suppress unusedFunction deep_history& composite_state_impl::add_deep_history( deep_history_uptr _deep_history ) { if( deep_history_ ) @@ -148,7 +145,6 @@ shallow_history* composite_state_impl::get_shallow_history() const } -// cppcheck-suppress unusedFunction shallow_history& composite_state_impl::add_shallow_history( shallow_history_uptr _shallow_history ) { if( shallow_history_ ) @@ -191,7 +187,6 @@ const raw_const_entry_points composite_state_impl::get_entry_points() const } -// cppcheck-suppress unusedFunction entry_point& composite_state_impl::add_entry_point( entry_point_uptr _entry_point ) { _entry_point->set_parent_state( this ); @@ -224,7 +219,6 @@ const raw_const_exit_points composite_state_impl::get_exit_points() const } -// cppcheck-suppress unusedFunction exit_point& composite_state_impl::add_exit_point( exit_point_uptr _exit_point ) { _exit_point->set_parent_state( this ); @@ -242,7 +236,6 @@ exit_point& composite_state_impl::add_exit_point( const std::string& _exit_point } -// cppcheck-suppress unusedFunction vertex* composite_state_impl::get_pseudostate( const std::string& _name_of_pseudostate ) const { vertex* found_vertex = Y_NULLPTR; @@ -319,7 +312,8 @@ bool composite_state_impl::check( state_machine_defects& _defects ) const } // 15.3.11 State -> Constraint [5]: An orthogonal state is a composite state with at least 2 regions. - // Not reason to check this. We don't care. + // Not reason to check this. For yasmine this is not relevant. + Y_FOR( const region_uptr& region, get_regions() ) { if( !region->check( _defects ) ) @@ -392,7 +386,6 @@ void composite_state_impl::accept_complex_state_visitor( complex_state_visitor& } -// cppcheck-suppress unusedFunction void composite_state_impl::accept_state_visitor( state_visitor& _visitor ) const { _visitor.visit( *this ); diff --git a/yasmine/yasmine/compound_transition_builder.cpp b/libyasmine/source/compound_transition_builder.cpp similarity index 86% rename from yasmine/yasmine/compound_transition_builder.cpp rename to libyasmine/source/compound_transition_builder.cpp index 4a611bc..6ea80a5 100644 --- a/yasmine/yasmine/compound_transition_builder.cpp +++ b/libyasmine/source/compound_transition_builder.cpp @@ -50,15 +50,7 @@ bool try_to_build_compound_transition( transition& _enabled_transition, compound_transition_uptr build_compound_transition( transition& _first_transition, const event& _event ) { -#ifdef _MSC_VER -#if _MSC_VER >= 1900 Y_UNIQUE_PTR< compound_transition_impl > new_compound_transition = Y_MAKE_UNIQUE< compound_transition_impl >(); -#elif _MSC_VER <= 1800 - sxy::shared_ptr< compound_transition_impl > new_compound_transition = Y_MAKE_SHARED< compound_transition_impl >(); -#endif -#else - Y_UNIQUE_PTR< compound_transition_impl > new_compound_transition = Y_MAKE_UNIQUE< compound_transition_impl >(); -#endif Y_LOG( log_level::LL_SPAM, "Create and check transition path for transition '%'.", _first_transition.get_name() ); const bool built_compound_transition = new_compound_transition->create_and_check_transition_path( _first_transition, @@ -75,15 +67,7 @@ compound_transition_uptr build_compound_transition( transition& _first_transitio _first_transition.get_name() ); } -#ifdef _MSC_VER -#if _MSC_VER >= 1900 - return( sxy::move( new_compound_transition ) ); -#elif _MSC_VER <= 1800 - return( new_compound_transition ); -#endif -#else return( sxy::move( new_compound_transition ) ); -#endif } diff --git a/yasmine/yasmine/compound_transition_impl.cpp b/libyasmine/source/compound_transition_impl.cpp similarity index 99% rename from yasmine/yasmine/compound_transition_impl.cpp rename to libyasmine/source/compound_transition_impl.cpp index aec1cec..e96d796 100644 --- a/yasmine/yasmine/compound_transition_impl.cpp +++ b/libyasmine/source/compound_transition_impl.cpp @@ -77,7 +77,6 @@ region* compound_transition_impl::get_LCA_region() } -// cppcheck-suppress unusedFunction composite_state* compound_transition_impl::get_LCA_composite_state() { const transition_step* const step1 = transition_steps_.front().get(); diff --git a/yasmine/yasmine/compound_transition_step.cpp b/libyasmine/source/compound_transition_step.cpp similarity index 92% rename from yasmine/yasmine/compound_transition_step.cpp rename to libyasmine/source/compound_transition_step.cpp index f6c2625..0edec5d 100644 --- a/yasmine/yasmine/compound_transition_step.cpp +++ b/libyasmine/source/compound_transition_step.cpp @@ -70,7 +70,6 @@ const entry_point* compound_transition_step::get_entry_point() const } -// cppcheck-suppress unusedFunction const raw_const_vertices compound_transition_step::get_target_vertices() { raw_const_vertices target_vertices; @@ -86,12 +85,11 @@ const raw_const_vertices compound_transition_step::get_target_vertices() } -// cppcheck-suppress unusedFunction -void compound_transition_step::execute_transition_behaviours( const event& _event ) const +void compound_transition_step::execute_transition_behaviors( const event& _event ) const { Y_FOR( const transition* const transition, transitions_ ) { - transition->on_transition_behaviour( _event ); + transition->on_transition_behavior( _event ); } } diff --git a/yasmine/yasmine/constraint_impl.cpp b/libyasmine/source/constraint_impl.cpp similarity index 100% rename from yasmine/yasmine/constraint_impl.cpp rename to libyasmine/source/constraint_impl.cpp diff --git a/yasmine/yasmine/conversion.cpp b/libyasmine/source/conversion.cpp similarity index 100% rename from yasmine/yasmine/conversion.cpp rename to libyasmine/source/conversion.cpp diff --git a/yasmine/yasmine/cout_logger.cpp b/libyasmine/source/cout_logger.cpp similarity index 98% rename from yasmine/yasmine/cout_logger.cpp rename to libyasmine/source/cout_logger.cpp index 0c5d329..cdbec8c 100644 --- a/yasmine/yasmine/cout_logger.cpp +++ b/libyasmine/source/cout_logger.cpp @@ -17,6 +17,7 @@ #include #include "conversion.hpp" +#include "log_message.hpp" #ifdef WIN32 diff --git a/yasmine/yasmine/deep_history_impl.cpp b/libyasmine/source/deep_history_impl.cpp similarity index 100% rename from yasmine/yasmine/deep_history_impl.cpp rename to libyasmine/source/deep_history_impl.cpp diff --git a/yasmine/yasmine/entry_point_impl.cpp b/libyasmine/source/entry_point_impl.cpp similarity index 100% rename from yasmine/yasmine/entry_point_impl.cpp rename to libyasmine/source/entry_point_impl.cpp diff --git a/yasmine/yasmine/event_creation_request.cpp b/libyasmine/source/event_creation_request.cpp similarity index 99% rename from yasmine/yasmine/event_creation_request.cpp rename to libyasmine/source/event_creation_request.cpp index 0ada6cc..3810dcc 100644 --- a/yasmine/yasmine/event_creation_request.cpp +++ b/libyasmine/source/event_creation_request.cpp @@ -14,6 +14,7 @@ #include #include "event.hpp" +#include "log.hpp" namespace sxy diff --git a/yasmine/yasmine/event_creation_request_time_comparer.cpp b/libyasmine/source/event_creation_request_time_comparer.cpp similarity index 96% rename from yasmine/yasmine/event_creation_request_time_comparer.cpp rename to libyasmine/source/event_creation_request_time_comparer.cpp index 9ef9898..469e3e2 100644 --- a/yasmine/yasmine/event_creation_request_time_comparer.cpp +++ b/libyasmine/source/event_creation_request_time_comparer.cpp @@ -11,6 +11,8 @@ #include "event_creation_request_time_comparer.hpp" +#include "event_creation_request.hpp" + namespace sxy { diff --git a/yasmine/yasmine/event_handle.cpp b/libyasmine/source/event_handle.cpp similarity index 100% rename from yasmine/yasmine/event_handle.cpp rename to libyasmine/source/event_handle.cpp diff --git a/yasmine/yasmine/event_impl.cpp b/libyasmine/source/event_impl.cpp similarity index 100% rename from yasmine/yasmine/event_impl.cpp rename to libyasmine/source/event_impl.cpp diff --git a/yasmine/yasmine/execution_state_do_step.cpp b/libyasmine/source/execution_state_do_step.cpp similarity index 81% rename from yasmine/yasmine/execution_state_do_step.cpp rename to libyasmine/source/execution_state_do_step.cpp index 19be506..86a9c5b 100644 --- a/yasmine/yasmine/execution_state_do_step.cpp +++ b/libyasmine/source/execution_state_do_step.cpp @@ -15,7 +15,7 @@ #include "state.hpp" #include "event_processing_callback.hpp" #include "execution_step_visitor.hpp" -#include "behaviour_exception.hpp" +#include "behavior_exception.hpp" @@ -34,13 +34,13 @@ execution_state_do_step::execution_state_do_step( const state& _state ) execution_state_do_step::~execution_state_do_step() Y_NOEXCEPT { // Nothing to do... -}; +} -bool execution_state_do_step::execute_behaviour( event_processing_callback* const _event_processing_callback, +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 ) const { - Y_LOG( sxy::log_level::LL_TRACE, "Executing do behaviour of state '%'.", state_.get_name() ); + Y_LOG( sxy::log_level::LL_TRACE, "Executing do behavior of state '%'.", state_.get_name() ); if( _event_processing_callback ) { _event_processing_callback->before_do( state_ ); @@ -48,9 +48,9 @@ bool execution_state_do_step::execute_behaviour( event_processing_callback* cons try { - state_.execute_do_behaviour(_event, _async_event_handler); + state_.execute_do_behavior(_event, _async_event_handler); } - catch (const sxy::behaviour_exception& exception) + catch (const sxy::behavior_exception& exception) { _exception_events.push_back(exception.get_error_event()); } @@ -73,7 +73,7 @@ bool execution_state_do_step::execute_behaviour( event_processing_callback* cons _event_processing_callback->after_do( state_ ); } - Y_LOG( sxy::log_level::LL_TRACE, "'do behaviour' of state '%' executed.", state_.get_name() ); + Y_LOG( sxy::log_level::LL_TRACE, "'do behavior' of state '%' executed.", state_.get_name() ); return( false ); } @@ -84,7 +84,6 @@ void execution_state_do_step::accept( execution_step_visitor& _visitor ) const } -// cppcheck-suppress unusedFunction const state& execution_state_do_step::get_state() const { return( state_ ); diff --git a/yasmine/yasmine/execution_state_enter_step.cpp b/libyasmine/source/execution_state_enter_step.cpp similarity index 94% rename from yasmine/yasmine/execution_state_enter_step.cpp rename to libyasmine/source/execution_state_enter_step.cpp index 631f872..69d212e 100644 --- a/yasmine/yasmine/execution_state_enter_step.cpp +++ b/libyasmine/source/execution_state_enter_step.cpp @@ -35,7 +35,7 @@ execution_state_enter_step::~execution_state_enter_step() Y_NOEXCEPT } -bool execution_state_enter_step::execute_behaviour( event_processing_callback* const _event_processing_callback, +bool execution_state_enter_step::execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const { Y_UNUSED_PARAMETER( _exception_events ); diff --git a/yasmine/yasmine/execution_state_exit_step.cpp b/libyasmine/source/execution_state_exit_step.cpp similarity index 94% rename from yasmine/yasmine/execution_state_exit_step.cpp rename to libyasmine/source/execution_state_exit_step.cpp index bb2678d..506bd6c 100644 --- a/yasmine/yasmine/execution_state_exit_step.cpp +++ b/libyasmine/source/execution_state_exit_step.cpp @@ -35,7 +35,7 @@ execution_state_exit_step::~execution_state_exit_step() Y_NOEXCEPT } -bool execution_state_exit_step::execute_behaviour( event_processing_callback* const _event_processing_callback, +bool execution_state_exit_step::execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const { Y_UNUSED_PARAMETER( _exception_events ); diff --git a/yasmine/yasmine/execution_transition_step.cpp b/libyasmine/source/execution_transition_step.cpp similarity index 92% rename from yasmine/yasmine/execution_transition_step.cpp rename to libyasmine/source/execution_transition_step.cpp index 0fad72b..b8001fb 100644 --- a/yasmine/yasmine/execution_transition_step.cpp +++ b/libyasmine/source/execution_transition_step.cpp @@ -37,7 +37,7 @@ execution_transition_step::~execution_transition_step() Y_NOEXCEPT } -bool execution_transition_step::execute_behaviour( event_processing_callback* const _event_processing_callback, +bool execution_transition_step::execute_behavior( event_processing_callback* const _event_processing_callback, const event& _event, events& _exception_events, async_event_handler* const _async_event_handler ) const { Y_UNUSED_PARAMETER( _exception_events ); @@ -52,7 +52,7 @@ bool execution_transition_step::execute_behaviour( event_processing_callback* co _event_processing_callback->before_transition( *transition ); } - transition->on_transition_behaviour( _event ); + transition->on_transition_behavior( _event ); if( _event_processing_callback ) { @@ -76,7 +76,6 @@ void execution_transition_step::accept( execution_step_visitor& _visitor ) const } -// cppcheck-suppress unusedFunction const transition_step& execution_transition_step::get_transition_step() const { return( transition_step_ ); diff --git a/yasmine/yasmine/exit_point_impl.cpp b/libyasmine/source/exit_point_impl.cpp similarity index 100% rename from yasmine/yasmine/exit_point_impl.cpp rename to libyasmine/source/exit_point_impl.cpp diff --git a/yasmine/yasmine/file_logger.cpp b/libyasmine/source/file_logger.cpp similarity index 99% rename from yasmine/yasmine/file_logger.cpp rename to libyasmine/source/file_logger.cpp index 0cdc906..72a6973 100644 --- a/yasmine/yasmine/file_logger.cpp +++ b/libyasmine/source/file_logger.cpp @@ -20,6 +20,7 @@ #include "file_system.hpp" #include "globals.hpp" #include "conversion.hpp" +#include "log_message.hpp" namespace sxy diff --git a/yasmine/yasmine/file_system.cpp b/libyasmine/source/file_system.cpp similarity index 100% rename from yasmine/yasmine/file_system.cpp rename to libyasmine/source/file_system.cpp diff --git a/yasmine/yasmine/final_state_impl.cpp b/libyasmine/source/final_state_impl.cpp similarity index 91% rename from yasmine/yasmine/final_state_impl.cpp rename to libyasmine/source/final_state_impl.cpp index 34fafc1..d9e4fca 100644 --- a/yasmine/yasmine/final_state_impl.cpp +++ b/libyasmine/source/final_state_impl.cpp @@ -16,6 +16,7 @@ #include "state_visitor.hpp" #include "region.hpp" #include "state_machine_defect.hpp" +#include "base.hpp" namespace sxy @@ -35,13 +36,13 @@ final_state_impl::~final_state_impl() Y_NOEXCEPT } -behaviour* final_state_impl::get_entry_behaviour() const +behavior* final_state_impl::get_entry_behavior() const { return( Y_NULLPTR ); } -behaviour* final_state_impl::get_exit_behaviour() const +behavior* final_state_impl::get_exit_behavior() const { return( Y_NULLPTR ); } @@ -83,23 +84,23 @@ bool final_state_impl::check( state_machine_defects& _defects ) const // 15.3.2 Final State -> Constraint [3]: A final state cannot reference a submachine. // Does not apply. - // 15.3.2 Final State -> Constraint [4]: A final state has no entry behaviour. - if( get_entry_behaviour() ) + // 15.3.2 Final State -> Constraint [4]: A final state has no entry behavior. + if( get_entry_behavior() ) { - _defects.push_back( state_machine_defect( *this, "Final state '%' has entry behaviour!", + _defects.push_back( state_machine_defect( *this, "Final state '%' has entry behavior!", get_name() ) ); check_ok = false; } - // 15.3.2 Final State -> Constraint [5]: A final state has no exit behaviour. - if( get_exit_behaviour() ) + // 15.3.2 Final State -> Constraint [5]: A final state has no exit behavior. + if( get_exit_behavior() ) { - _defects.push_back( state_machine_defect( *this, "Final state '%' has exit behaviour!", + _defects.push_back( state_machine_defect( *this, "Final state '%' has exit behavior!", get_name() ) ); check_ok = false; } - // 15.3.2 Final State -> Constraint [6]: A final state has no state (doActivity) behaviour. + // 15.3.2 Final State -> Constraint [6]: A final state has no state (doActivity) behavior. // Enforced by design. return( check_ok ); } diff --git a/yasmine/yasmine/fork_impl.cpp b/libyasmine/source/fork_impl.cpp similarity index 99% rename from yasmine/yasmine/fork_impl.cpp rename to libyasmine/source/fork_impl.cpp index 7e63b25..f9180b1 100644 --- a/yasmine/yasmine/fork_impl.cpp +++ b/libyasmine/source/fork_impl.cpp @@ -21,6 +21,7 @@ #include "state.hpp" #include "state_machine_defect.hpp" #include "region.hpp" +#include "base.hpp" namespace sxy diff --git a/yasmine/yasmine/format_settings.cpp b/libyasmine/source/format_settings.cpp similarity index 100% rename from yasmine/yasmine/format_settings.cpp rename to libyasmine/source/format_settings.cpp diff --git a/yasmine/yasmine/globals.cpp b/libyasmine/source/globals.cpp similarity index 100% rename from yasmine/yasmine/globals.cpp rename to libyasmine/source/globals.cpp diff --git a/yasmine/yasmine/history_impl.cpp b/libyasmine/source/history_impl.cpp similarity index 97% rename from yasmine/yasmine/history_impl.cpp rename to libyasmine/source/history_impl.cpp index 5977671..e287d7f 100644 --- a/yasmine/yasmine/history_impl.cpp +++ b/libyasmine/source/history_impl.cpp @@ -38,7 +38,6 @@ raw_transitions history_impl::get_default_transitions() const } -// cppcheck-suppress unusedFunction void history_impl::add_default_transition( transition& _default_transition ) { vertex_impl::add_outgoing_transition( _default_transition ); diff --git a/yasmine/yasmine/initial_pseudostate_impl.cpp b/libyasmine/source/initial_pseudostate_impl.cpp similarity index 98% rename from yasmine/yasmine/initial_pseudostate_impl.cpp rename to libyasmine/source/initial_pseudostate_impl.cpp index ee749f8..cfb2858 100644 --- a/yasmine/yasmine/initial_pseudostate_impl.cpp +++ b/libyasmine/source/initial_pseudostate_impl.cpp @@ -58,7 +58,7 @@ bool initial_pseudostate_impl::check( state_machine_defects& _defects ) const check_ok = false; } - // 15.3.8 Pseudostate -> Constraint [9]: Outgoing transition from an initial vertex may have a behaviour, but not a + // 15.3.8 Pseudostate -> Constraint [9]: Outgoing transition from an initial vertex may have a behavior, but not a // trigger or guard. Y_FOR( const transition* const transition, get_outgoing_transitions() ) { @@ -75,6 +75,7 @@ bool initial_pseudostate_impl::check( state_machine_defects& _defects ) const { check_ok = false; } + return( check_ok ); } diff --git a/yasmine/yasmine/join_impl.cpp b/libyasmine/source/join_impl.cpp similarity index 100% rename from yasmine/yasmine/join_impl.cpp rename to libyasmine/source/join_impl.cpp diff --git a/yasmine/yasmine/junction_impl.cpp b/libyasmine/source/junction_impl.cpp similarity index 99% rename from yasmine/yasmine/junction_impl.cpp rename to libyasmine/source/junction_impl.cpp index ef93f49..e4f1b38 100644 --- a/yasmine/yasmine/junction_impl.cpp +++ b/libyasmine/source/junction_impl.cpp @@ -11,6 +11,7 @@ #include "junction_impl.hpp" +#include "log.hpp" #include "const_vertex_visitor.hpp" #include "vertex_visitor.hpp" #include "pseudostate_visitor.hpp" diff --git a/yasmine/yasmine/log_and_throw_helper.cpp b/libyasmine/source/log_and_throw_helper.cpp similarity index 100% rename from yasmine/yasmine/log_and_throw_helper.cpp rename to libyasmine/source/log_and_throw_helper.cpp diff --git a/yasmine/yasmine/log_helper.cpp b/libyasmine/source/log_helper.cpp similarity index 100% rename from yasmine/yasmine/log_helper.cpp rename to libyasmine/source/log_helper.cpp diff --git a/yasmine/yasmine/log_level.cpp b/libyasmine/source/log_level.cpp similarity index 95% rename from yasmine/yasmine/log_level.cpp rename to libyasmine/source/log_level.cpp index 33c3565..f62715c 100644 --- a/yasmine/yasmine/log_level.cpp +++ b/libyasmine/source/log_level.cpp @@ -77,12 +77,6 @@ std::string log_level_to_string( const log_level _log_level ) } break; - case ( log_level::LL_PROTOCOL ): - { - log_level_string = "PROTOCOL"; - } - break; - default: Y_ASSERT_NO_LOG( false, "Unknown log level!" ); break; @@ -96,7 +90,7 @@ std::string log_level_to_string( const log_level _log_level ) #ifdef Y_CPP03_BOOST - +// cppcheck-suppress unusedFunction bool operator==(const sxy::log_level& _lhs, const sxy::log_level::inner _rhs) { return( _lhs.value_ == _rhs ); @@ -109,12 +103,14 @@ bool operator==(const sxy::log_level::inner _lhs, const sxy::log_level& _rhs) } +// cppcheck-suppress unusedFunction bool operator<(const sxy::log_level _lhs, const sxy::log_level _rhs) { return ( _lhs.value_ < _rhs.value_ ); } +// cppcheck-suppress unusedFunction bool operator<=( const sxy::log_level _lhs, const sxy::log_level _rhs ) { return ( _lhs.value_ <= _rhs.value_ ); diff --git a/yasmine/yasmine/log_message.cpp b/libyasmine/source/log_message.cpp similarity index 80% rename from yasmine/yasmine/log_message.cpp rename to libyasmine/source/log_message.cpp index f63bd7e..526b024 100644 --- a/yasmine/yasmine/log_message.cpp +++ b/libyasmine/source/log_message.cpp @@ -11,6 +11,7 @@ #ifndef Y_NO_LOGGING #include "log_message.hpp" +#include "log_callback.hpp" namespace sxy @@ -22,24 +23,35 @@ log_message::log_message() time_stamp_(), file_(), line_(), - message_() + message_(), + log_callback_() { // Nothing to do... } -log_message::log_message( const log_level _log_level, const std::string& _time_stamp, +log_message::log_message( log_callback* _log_callback, const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, const std::string& _message ) : log_level_( _log_level ), time_stamp_( _time_stamp ), file_( _file ), line_( _line ), - message_( _message ) + message_( _message ), + log_callback_( _log_callback ) { // Nothing to do... } +void log_message::done() +{ + if( log_callback_ ) + { + log_callback_->done(); + } +} + + } #endif diff --git a/yasmine/yasmine/pseudostate_impl.cpp b/libyasmine/source/pseudostate_impl.cpp similarity index 95% rename from yasmine/yasmine/pseudostate_impl.cpp rename to libyasmine/source/pseudostate_impl.cpp index 489cc9b..5b89558 100644 --- a/yasmine/yasmine/pseudostate_impl.cpp +++ b/libyasmine/source/pseudostate_impl.cpp @@ -41,7 +41,7 @@ bool pseudostate_impl::check( state_machine_defects& _defects ) const Y_FOR( const transition* const outgoing_transition, get_outgoing_transitions() ) { - if( !outgoing_transition->can_accept_event( COMPLETION_EVENT_ID ) ) + if( !outgoing_transition->can_accept_event( sxy::completion_event::get_event_id() ) ) { _defects.push_back( state_machine_defect( *this, "'%' has outgoing transition with trigger!", get_name() ) ); diff --git a/yasmine/yasmine/region_impl.cpp b/libyasmine/source/region_impl.cpp similarity index 84% rename from yasmine/yasmine/region_impl.cpp rename to libyasmine/source/region_impl.cpp index fe4ed27..4ca4b77 100644 --- a/yasmine/yasmine/region_impl.cpp +++ b/libyasmine/source/region_impl.cpp @@ -22,8 +22,9 @@ #include "simple_state_impl.hpp" #include "composite_state_impl.hpp" #include "final_state_impl.hpp" -#include "behaviour_impl.hpp" +#include "behavior_impl.hpp" #include "async_simple_state_impl.hpp" +#include "async_behavior.hpp" #include "state_machine_defect.hpp" #include "uri.hpp" @@ -85,7 +86,6 @@ composite_state& region_impl::get_parent_state() } -// cppcheck-suppress unusedFunction vertex* region_impl::get_vertex( const std::string& _vertex_name ) const { vertex* found_vertex = Y_NULLPTR; @@ -227,7 +227,6 @@ state* region_impl::get_last_active_state() } -// cppcheck-suppress unusedFunction initial_pseudostate& region_impl::add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) { Y_ASSERT( !initial_pseudostate_, "There is already a initial pseudostate in the region." ); @@ -252,7 +251,6 @@ initial_pseudostate& region_impl::add_initial_pseudostate( const std::string& _i } -// cppcheck-suppress unusedFunction state& region_impl::add_state( state_uptr _state ) { _state->set_parent_region( this ); @@ -262,15 +260,14 @@ state& region_impl::add_state( state_uptr _state ) } -// cppcheck-suppress unusedFunction -simple_state& region_impl::add_simple_state( const std::string& _name, const behaviour_function& _behaviour, - const behaviour_function& _entry_behaviour, const behaviour_function& _exit_behaviour ) +simple_state& region_impl::add_simple_state( const std::string& _name, const behavior_function& _behavior, + const behavior_function& _entry_behavior, const behavior_function& _exit_behavior ) { - behaviour_uptr behaviour = behaviour_impl::create_behaviour( _behaviour ); - behaviour_uptr entry_behaviour = behaviour_impl::create_behaviour( _entry_behaviour ); - behaviour_uptr exit_behaviour = behaviour_impl::create_behaviour( _exit_behaviour ); + behavior_uptr behavior = behavior_impl::create_behavior( _behavior ); + behavior_uptr entry_behavior = behavior_impl::create_behavior( _entry_behavior ); + behavior_uptr exit_behavior = behavior_impl::create_behavior( _exit_behavior ); Y_UNIQUE_PTR< sxy::simple_state_impl > simple_state = Y_MAKE_UNIQUE< sxy::simple_state_impl >( _name, - sxy::move( behaviour ), sxy::move( entry_behaviour ), sxy::move( exit_behaviour ) ); + sxy::move( behavior ), sxy::move( entry_behavior ), sxy::move( exit_behavior ) ); simple_state->set_parent_region( this ); simple_state_impl& state = *simple_state; states_.push_back( sxy::move( simple_state ) ); @@ -279,14 +276,14 @@ simple_state& region_impl::add_simple_state( const std::string& _name, const beh simple_state& region_impl::add_simple_state( const std::string& _name, const event_ids& _deferred_events, - const behaviour_function& _behaviour, const behaviour_function& _entry_behaviour, - const behaviour_function& _exit_behaviour, event_sptr _error_event ) + const behavior_function& _behavior, const behavior_function& _entry_behavior, + const behavior_function& _exit_behavior, event_sptr _error_event ) { Y_UNIQUE_PTR< sxy::simple_state_impl > simple_state = Y_MAKE_UNIQUE< sxy::simple_state_impl >( _name, - ( !_behaviour ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _behaviour ) ) ), - ( !_entry_behaviour ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _entry_behaviour ) ) ), - ( !_exit_behaviour ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _exit_behaviour ) ) ), _deferred_events, + ( !_behavior ? behavior_uptr() : ( behavior_impl::create_behavior( _behavior ) ) ), + ( !_entry_behavior ? behavior_uptr() : ( behavior_impl::create_behavior( _entry_behavior ) ) ), + ( !_exit_behavior ? behavior_uptr() : ( behavior_impl::create_behavior( _exit_behavior ) ) ), _deferred_events, _error_event ); simple_state->set_parent_region( this ); simple_state_impl& state = *simple_state; @@ -295,15 +292,14 @@ simple_state& region_impl::add_simple_state( const std::string& _name, const eve } -// cppcheck-suppress unusedFunction simple_state& region_impl::add_async_simple_state( const std::string& _name, const event_ids& _deferred_events, - async_behaviour_uptr _do_action, const behaviour_function& _entry_behaviour, const behaviour_function& _exit_behaviour, + async_behavior_uptr _do_action, const behavior_function& _entry_behavior, const behavior_function& _exit_behavior, event_sptr _error_event ) { Y_UNIQUE_PTR< sxy::async_simple_state_impl > simple_state = Y_MAKE_UNIQUE< sxy::async_simple_state_impl >( _name, sxy::move( _do_action ), - ( !_entry_behaviour ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _entry_behaviour ) ) ), - ( !_exit_behaviour ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _exit_behaviour ) ) ), _deferred_events, + ( !_entry_behavior ? behavior_uptr() : ( behavior_impl::create_behavior( _entry_behavior ) ) ), + ( !_exit_behavior ? behavior_uptr() : ( behavior_impl::create_behavior( _exit_behavior ) ) ), _deferred_events, _error_event ); simple_state->set_parent_region( this ); async_simple_state_impl& state = *simple_state; @@ -312,14 +308,13 @@ simple_state& region_impl::add_async_simple_state( const std::string& _name, con } -// cppcheck-suppress unusedFunction -composite_state& region_impl::add_composite_state( const std::string& _name, const behaviour_function& _entry_action, - const behaviour_function& _exit_action ) +composite_state& region_impl::add_composite_state( const std::string& _name, const behavior_function& _entry_action, + const behavior_function& _exit_action ) { Y_UNIQUE_PTR< sxy::composite_state_impl > composite_state = Y_MAKE_UNIQUE< sxy::composite_state_impl >( _name, - ( !_entry_action ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _entry_action ) ) ), - ( !_exit_action ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _exit_action ) ) ) ); + ( !_entry_action ? behavior_uptr() : ( behavior_impl::create_behavior( _entry_action ) ) ), + ( !_exit_action ? behavior_uptr() : ( behavior_impl::create_behavior( _exit_action ) ) ) ); composite_state->set_parent_region( this ); composite_state_impl& state = *composite_state; states_.push_back( sxy::move( composite_state ) ); @@ -328,12 +323,12 @@ composite_state& region_impl::add_composite_state( const std::string& _name, con composite_state& region_impl::add_composite_state( const std::string& _name, const event_ids& _deferred_events, - const behaviour_function& _entry_action, const behaviour_function& _exit_action ) + const behavior_function& _entry_action, const behavior_function& _exit_action ) { Y_UNIQUE_PTR< sxy::composite_state_impl > composite_state = Y_MAKE_UNIQUE< sxy::composite_state_impl >( _name, - ( !_entry_action ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _entry_action ) ) ), - ( !_exit_action ? behaviour_uptr() : ( behaviour_impl::create_behaviour( _exit_action ) ) ), _deferred_events ); + ( !_entry_action ? behavior_uptr() : ( behavior_impl::create_behavior( _entry_action ) ) ), + ( !_exit_action ? behavior_uptr() : ( behavior_impl::create_behavior( _exit_action ) ) ), _deferred_events ); composite_state->set_parent_region( this ); composite_state_impl& state = *composite_state; states_.push_back( sxy::move( composite_state ) ); @@ -341,7 +336,6 @@ composite_state& region_impl::add_composite_state( const std::string& _name, con } -// cppcheck-suppress unusedFunction final_state& region_impl::add_final_state( const std::string& _name ) { Y_UNIQUE_PTR< sxy::final_state_impl > final_state = Y_MAKE_UNIQUE< sxy::final_state_impl >( _name ); @@ -352,7 +346,6 @@ final_state& region_impl::add_final_state( const std::string& _name ) } -// cppcheck-suppress unusedFunction choice& region_impl::add_choice( choice_uptr _choice ) { _choice->set_parent_region( this ); @@ -372,7 +365,6 @@ choice& region_impl::add_choice( const std::string& _choice_name ) } -// cppcheck-suppress unusedFunction fork& region_impl::add_fork( fork_uptr _fork ) { _fork->set_parent_region( this ); @@ -392,7 +384,6 @@ fork& region_impl::add_fork( const std::string& _fork_name ) } -// cppcheck-suppress unusedFunction join& region_impl::add_join( join_uptr _join ) { _join->set_parent_region( this ); @@ -412,7 +403,6 @@ join& region_impl::add_join( const std::string& _join_name ) } -// cppcheck-suppress unusedFunction junction& region_impl::add_junction( junction_uptr _junction ) { _junction->set_parent_region( this ); @@ -431,7 +421,6 @@ junction& region_impl::add_junction( const std::string& _junction_name ) return( new_junction ); } -// cppcheck-suppress unusedFunction terminate_pseudostate& region_impl::add_terminate_pseudostate( terminate_pseudostate_uptr _terminate_pseudostate ) { _terminate_pseudostate->set_parent_region( this ); diff --git a/yasmine/yasmine/region_pseudostate_impl.cpp b/libyasmine/source/region_pseudostate_impl.cpp similarity index 91% rename from yasmine/yasmine/region_pseudostate_impl.cpp rename to libyasmine/source/region_pseudostate_impl.cpp index 52acc6c..b434e0a 100644 --- a/yasmine/yasmine/region_pseudostate_impl.cpp +++ b/libyasmine/source/region_pseudostate_impl.cpp @@ -64,7 +64,8 @@ void region_pseudostate_impl::set_parent_region( region* const _parent_region ) } -raw_composite_states region_pseudostate_impl::get_ancestors( composite_state* const _final_ancestor ) const +raw_composite_states region_pseudostate_impl::get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor ) const { #ifdef Y_OPTIMIZE_4_SPEED if( ancestors_.empty() ) @@ -82,7 +83,11 @@ 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 ); } else @@ -93,7 +98,11 @@ 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() ); + } return( ancestors ); #endif } diff --git a/yasmine/yasmine/shallow_history_impl.cpp b/libyasmine/source/shallow_history_impl.cpp similarity index 100% rename from yasmine/yasmine/shallow_history_impl.cpp rename to libyasmine/source/shallow_history_impl.cpp diff --git a/yasmine/yasmine/simple_state_base.cpp b/libyasmine/source/simple_state_base.cpp similarity index 96% rename from yasmine/yasmine/simple_state_base.cpp rename to libyasmine/source/simple_state_base.cpp index dbb2630..9952d5b 100644 --- a/yasmine/yasmine/simple_state_base.cpp +++ b/libyasmine/source/simple_state_base.cpp @@ -24,8 +24,8 @@ namespace sxy { -simple_state_base::simple_state_base( const std::string& _name, behaviour_uptr _entry_action, - behaviour_uptr _exit_action, const event_ids& _deferred_events, event_sptr _error_event) +simple_state_base::simple_state_base( const std::string& _name, behavior_uptr _entry_action, + behavior_uptr _exit_action, const event_ids& _deferred_events, event_sptr _error_event) : complex_state_impl( _name, sxy::move( _entry_action ), sxy::move( _exit_action ), _deferred_events ), error_event_( _error_event ) { diff --git a/yasmine/yasmine/simple_state_impl.cpp b/libyasmine/source/simple_state_impl.cpp similarity index 76% rename from yasmine/yasmine/simple_state_impl.cpp rename to libyasmine/source/simple_state_impl.cpp index d2b0372..1127dda 100644 --- a/yasmine/yasmine/simple_state_impl.cpp +++ b/libyasmine/source/simple_state_impl.cpp @@ -12,15 +12,15 @@ #include "simple_state_impl.hpp" #include "log.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" namespace sxy { -simple_state_impl::simple_state_impl( const std::string& _name, behaviour_uptr _do_action, behaviour_uptr _entry_action, - behaviour_uptr _exit_action, const event_ids& _deferred_events, event_sptr _error_event ) +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, sxy::move( _entry_action ), sxy::move( _exit_action ), _deferred_events, _error_event ), do_( sxy::move( _do_action ) ) @@ -35,19 +35,19 @@ simple_state_impl::~simple_state_impl() Y_NOEXCEPT } -void simple_state_impl::execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const +void simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const { Y_UNUSED_PARAMETER( _async_event_handler ); - const behaviour* const behaviour = get_do(); - if( behaviour ) + const behavior* const behavior = get_do(); + if( behavior ) { - Y_LOG( sxy::log_level::LL_TRACE, "Executing state's '%' do behaviour.", get_name() ); - ( *behaviour )( _event ); + Y_LOG( sxy::log_level::LL_TRACE, "Executing state's '%' do behavior.", get_name() ); + ( *behavior )( _event ); } } -const behaviour* simple_state_impl::get_do() const +const behavior* simple_state_impl::get_do() const { return( do_.get() ); } diff --git a/yasmine/yasmine/simple_transition_step.cpp b/libyasmine/source/simple_transition_step.cpp similarity index 94% rename from yasmine/yasmine/simple_transition_step.cpp rename to libyasmine/source/simple_transition_step.cpp index 747307f..994df04 100644 --- a/yasmine/yasmine/simple_transition_step.cpp +++ b/libyasmine/source/simple_transition_step.cpp @@ -77,11 +77,11 @@ const raw_const_vertices simple_transition_step::get_target_vertices() } -void simple_transition_step::execute_transition_behaviours( const event& _event ) const +void simple_transition_step::execute_transition_behaviors( const event& _event ) const { Y_FOR( const transition* const transition, transition_step_ ) { - transition->on_transition_behaviour( _event ); + transition->on_transition_behavior( _event ); } } diff --git a/yasmine/yasmine/state_impl.cpp b/libyasmine/source/state_impl.cpp similarity index 81% rename from yasmine/yasmine/state_impl.cpp rename to libyasmine/source/state_impl.cpp index 8fe38b0..6645575 100644 --- a/yasmine/yasmine/state_impl.cpp +++ b/libyasmine/source/state_impl.cpp @@ -17,10 +17,11 @@ #include "region.hpp" #include "exception.hpp" #include "composite_state.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" #include "log_and_throw.hpp" -#include "behaviour_exception.hpp" +#include "behavior_exception.hpp" #include "algorithm_parameters.hpp" +#include "event.hpp" #include @@ -99,7 +100,8 @@ vertex* state_impl::get_pseudostate( const std::string& _name_of_pseudostate ) c // Gets ancestors in ascending order (from child to parent) up to the given composite state. -raw_composite_states state_impl::get_ancestors( composite_state* const _final_ancestor ) const +raw_composite_states state_impl::get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor ) const { #ifdef Y_OPTIMIZE_4_SPEED if( ancestors_.empty() ) @@ -118,7 +120,11 @@ raw_composite_states state_impl::get_ancestors( composite_state* const _final_an 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( final_ancestor ); + } return( ancestors ); } else @@ -129,7 +135,11 @@ raw_composite_states state_impl::get_ancestors( composite_state* const _final_an } #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() ); + } return( ancestors ); #endif } @@ -175,9 +185,21 @@ bool state_impl::was_active() const void state_impl::set_active() { region* const parent_region = get_parent_region(); - parent_region->set_active_state( this ); - parent_region->set_state_was_active( this ); - Y_LOG( log_level::LL_DEBUG, "State '%' is now active.", get_uri().to_string() ); + if( parent_region ) + { + parent_region->set_active_state( this ); + parent_region->set_state_was_active( this ); + Y_LOG( log_level::LL_DEBUG, "State '%' is now active.", get_uri().to_string() ); + } + else + { + composite_state* root_state = get_root_state(); + composite_state* this_state = dynamic_cast< composite_state* >( this ); + if( this_state != root_state ) + { + Y_ASSERT( parent_region, "State has no parent region!" ); + } + } } @@ -213,38 +235,38 @@ bool state_impl::is_complete() const } -void state_impl::execute_do_behaviour( const event& _event, async_event_handler* const _async_event_handler ) const +void state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler ) const { Y_UNUSED_PARAMETER( _event ); Y_UNUSED_PARAMETER( _async_event_handler ); } -void state_impl::execute_enter_behaviour( const event& _event ) const +void state_impl::execute_enter_behavior( const event& _event ) const { - const behaviour* const behaviour = get_entry_behaviour(); - if( behaviour ) + const behavior* const behavior = get_entry_behavior(); + if( behavior ) { - Y_LOG( sxy::log_level::LL_TRACE, "Executing state's '%' enter behaviour.", get_name() ); - ( *behaviour )( _event ); + Y_LOG( sxy::log_level::LL_TRACE, "Executing state's '%' enter behavior.", get_name() ); + ( *behavior )( _event ); } } -void state_impl::execute_exit_behaviour( const event& _event ) const +void state_impl::execute_exit_behavior( const event& _event ) const { - const behaviour* const behaviour = get_exit_behaviour(); - if( behaviour ) + const behavior* const behavior = get_exit_behavior(); + if( behavior ) { - Y_LOG( sxy::log_level::LL_TRACE, "Executing state's '%' exit behaviour.", get_name().c_str() ); - ( *behaviour )( _event ); + Y_LOG( sxy::log_level::LL_TRACE, "Executing state's '%' exit behavior.", get_name() ); + ( *behavior )( _event ); } } void state_impl::enter_state( const event& _event ) { - execute_enter_behaviour( _event ); + execute_enter_behavior( _event ); set_active(); set_was_active(); } @@ -252,7 +274,7 @@ void state_impl::enter_state( const event& _event ) void state_impl::exit_state( const event& _event ) { - execute_exit_behaviour( _event ); + execute_exit_behavior( _event ); set_inactive(); } @@ -279,7 +301,7 @@ void state_impl::collect_ancestors( raw_composite_states& _ancestors, composite_ region* const parent_region = current_vertex->get_parent_region(); if( parent_region != Y_NULLPTR ) { - composite_state& parent_state = parent_region->get_parent_state(); + composite_state& parent_state = parent_region->get_parent_state(); _ancestors.push_back( &parent_state ); current_vertex = &parent_state; } diff --git a/yasmine/yasmine/state_machine.cpp b/libyasmine/source/state_machine.cpp similarity index 89% rename from yasmine/yasmine/state_machine.cpp rename to libyasmine/source/state_machine.cpp index 08ee306..c1d3b84 100644 --- a/yasmine/yasmine/state_machine.cpp +++ b/libyasmine/source/state_machine.cpp @@ -11,8 +11,6 @@ #include "state_machine.hpp" -#include - #include "base.hpp" #include "log_and_throw.hpp" #include "event_processing_callback.hpp" @@ -21,7 +19,7 @@ #include "transition_controller.hpp" #include "uri.hpp" #include "region.hpp" -#include "behaviour_impl.hpp" +#include "behavior_impl.hpp" #include "constraint_impl.hpp" #include "transition_impl.hpp" #include "exception.hpp" @@ -76,7 +74,6 @@ composite_state& state_machine::get_root_state() const #ifdef Y_PROFILER -// cppcheck-suppress unusedFunction sxy::uint32_t state_machine::get_number_of_processed_events() const { return( processed_events_ ); @@ -84,7 +81,6 @@ sxy::uint32_t state_machine::get_number_of_processed_events() const #endif -// cppcheck-suppress unusedFunction transition& state_machine::add_transition( transition_uptr _transition ) { transition& transition = *_transition; @@ -94,12 +90,12 @@ transition& state_machine::add_transition( transition_uptr _transition ) transition& state_machine::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, const constraint_function& _guard, const behaviour_function& _behaviour ) + const sxy::transition_kind _kind, const constraint_function& _guard, const behavior_function& _behavior ) { Y_UNIQUE_PTR< sxy::transition_impl > l_transition = Y_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxy::ref( _source ), sxy::ref( _target ), _kind, ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behaviour ? ( behaviour_impl::create_behaviour( sxy::ref( _behaviour ) ) ) : behaviour_uptr() ) ); + ( _behavior ? ( behavior_impl::create_behavior( sxy::ref( _behavior ) ) ) : behavior_uptr() ) ); transition_impl& transition = *l_transition; transitions_.push_back( sxy::move( l_transition ) ); return( transition ); @@ -107,12 +103,12 @@ transition& state_machine::add_transition( const event_id _event_id, vertex& _so transition& state_machine::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, const constraint_function& _guard, const behaviour_function& _behaviour ) + const sxy::transition_kind _kind, const constraint_function& _guard, const behavior_function& _behavior ) { Y_UNIQUE_PTR< sxy::transition_impl > l_transition = Y_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxy::ref( _source ), sxy::ref( _target ), _kind, ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behaviour ? ( behaviour_impl::create_behaviour( sxy::ref( _behaviour ) ) ) : behaviour_uptr() ) ); + ( _behavior ? ( behavior_impl::create_behavior( sxy::ref( _behavior ) ) ) : behavior_uptr() ) ); transition_impl& transition = *l_transition; transitions_.push_back( sxy::move( l_transition ) ); return( transition ); @@ -124,7 +120,7 @@ transition& state_machine::add_transition( const event_id _event_id, vertex& _so { Y_UNIQUE_PTR< sxy::transition_impl > l_transition = Y_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxy::ref( _source ), sxy::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), behaviour_uptr()); + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), behavior_uptr()); transition_impl& transition = *l_transition; transitions_.push_back( sxy::move( l_transition ) ); return( transition ); @@ -132,12 +128,12 @@ transition& state_machine::add_transition( const event_id _event_id, vertex& _so transition& state_machine::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const constraint_function& _guard, const behaviour_function& _behaviour, const sxy::transition_kind _kind ) + const constraint_function& _guard, const behavior_function& _behavior, const sxy::transition_kind _kind ) { Y_UNIQUE_PTR< sxy::transition_impl > l_transition = Y_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxy::ref( _source ), sxy::ref( _target ), _kind, ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behaviour ? ( behaviour_impl::create_behaviour( sxy::ref( _behaviour ) ) ) : behaviour_uptr() ) ); + ( _behavior ? ( behavior_impl::create_behavior( sxy::ref( _behavior ) ) ) : behavior_uptr() ) ); transition_impl& transition = *l_transition; transitions_.push_back( sxy::move( l_transition ) ); return( transition ); @@ -145,12 +141,12 @@ transition& state_machine::add_transition( const event_id _event_id, vertex& _so transition& state_machine::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const behaviour_function& _behaviour, const sxy::transition_kind _kind ) + const behavior_function& _behavior, const sxy::transition_kind _kind ) { Y_UNIQUE_PTR< sxy::transition_impl > l_transition = Y_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxy::ref( _source ), sxy::ref( _target ), _kind, constraint_uptr(), - ( _behaviour ? ( behaviour_impl::create_behaviour( sxy::ref( _behaviour ) ) ) : behaviour_uptr() ) ); + ( _behavior ? ( behavior_impl::create_behavior( sxy::ref( _behavior ) ) ) : behavior_uptr() ) ); transition_impl& transition = *l_transition; transitions_.push_back( sxy::move( l_transition ) ); return( transition ); @@ -187,11 +183,11 @@ bool state_machine::check( state_machine_defects& _defects ) const } -bool state_machine::start_state_machine() +bool state_machine::run() { Y_LOG( log_level::LL_INFO, "Starting state machine '%'.", name_ ); - const bool state_machine_started = start_state_machine( Y_NULLPTR ); + const bool state_machine_started = run( Y_NULLPTR ); Y_LOG( log_level::LL_INFO, "Started state machine '%'.", name_ ); @@ -200,24 +196,26 @@ bool state_machine::start_state_machine() } -void state_machine::stop_state_machine() +void state_machine::halt() { Y_LOG( log_level::LL_INFO, "Stopping state machine '%'.", name_ ); - - Y_ASSERT( state_machine_is_running_, "State machine is not running!" ); - stop_all_async_states( *root_state_ ); - state_machine_is_running_ = false; + if( state_machine_is_running_ ) + { + stop_all_async_states( *root_state_ ); + state_machine_is_running_ = false; + } Y_LOG( log_level::LL_INFO, "Stopped state machine '%'.", name_ ); } + std::string state_machine::get_name() const { return( name_ ); } -bool state_machine::start_state_machine( async_event_handler* const _async_event_handler ) +bool state_machine::run( async_event_handler* const _async_event_handler ) { Y_ASSERT( root_state_, "No root state!" ); bool state_machine_started = false; @@ -226,7 +224,7 @@ bool state_machine::start_state_machine( async_event_handler* const _async_event { if( event_processing_callback_ ) { - event_processing_callback_->before_event( COMPLETION_EVENT_ID ); + event_processing_callback_->before_event( sxy::completion_event::get_event_id() ); } transition_controller transition_controller; @@ -234,7 +232,7 @@ bool state_machine::start_state_machine( async_event_handler* const _async_event _async_event_handler ); if( event_processing_callback_ ) { - event_processing_callback_->after_event( COMPLETION_EVENT_ID ); + event_processing_callback_->after_event( sxy::completion_event::get_event_id() ); } if( !state_machine_started ) @@ -316,29 +314,34 @@ bool state_machine::process_event( const event_sptr& _event, async_event_handler { Y_LOG( sxy::log_level::LL_FATAL, "std::exception occurred during event processing in state machine '%': %", get_name(), exception.what() ); state_machine_is_running_ = false; + stop_all_async_states( *root_state_ ); throw; } catch( ... ) { Y_LOG( sxy::log_level::LL_FATAL, "Unknown exception occurred in state machine '%'!", get_name() ); state_machine_is_running_ = false; + stop_all_async_states( *root_state_ ); throw; } Y_LOG( log_level::LL_INFO, "'%' processed event '%' (%).", get_name(), _event->get_name(), _event->get_id()); + if( terminate_pseudostate_has_been_reached ) + { + stop_all_async_states( *root_state_ ); + } + return( terminate_pseudostate_has_been_reached ); } -// cppcheck-suppress unusedFunction const events& state_machine::get_deferred_events() const { return( deferred_events_ ); } -// cppcheck-suppress unusedFunction raw_const_states state_machine::get_active_state_configuration() const { raw_const_states active_state_configuration; @@ -433,7 +436,7 @@ void state_machine::stop_all_async_states_from_region( region_uptr& _region) async_simple_state_impl* const async_state = dynamic_cast< async_simple_state_impl* >( active_state ); if( async_state ) { - async_state->stop_do_behaviour(); + async_state->stop_do_behavior(); } else { diff --git a/yasmine/yasmine/state_machine_defect.cpp b/libyasmine/source/state_machine_defect.cpp similarity index 95% rename from yasmine/yasmine/state_machine_defect.cpp rename to libyasmine/source/state_machine_defect.cpp index a45014b..2298046 100644 --- a/yasmine/yasmine/state_machine_defect.cpp +++ b/libyasmine/source/state_machine_defect.cpp @@ -11,6 +11,8 @@ #include "state_machine_defect.hpp" +#include "log.hpp" + namespace sxy { @@ -23,7 +25,7 @@ namespace sxy : element_( &_element ), message_( yprintf( _message.c_str() ) ) { - // Nothing to do. + // Nothing to do... } @@ -32,7 +34,7 @@ state_machine_defect::state_machine_defect( const state_machine_element& _elemen : element_( &_element ), message_( yprintf( _message.c_str(), _value ) ) { - // Nothing to do. + // Nothing to do... } @@ -41,7 +43,7 @@ state_machine_defect::state_machine_defect( const state_machine_element& _elemen : element_( &_element ), message_( yprintf( _message.c_str(), _value1, _value2 ) ) { - // Nothing to do. + // Nothing to do... } @@ -50,7 +52,7 @@ state_machine_defect::state_machine_defect( const state_machine_element& _elemen : element_( &_element ), message_( yprintf( _message.c_str(), _value1, _value2, _value3 ) ) { - // Nothing to do. + // Nothing to do... } @@ -59,7 +61,7 @@ state_machine_defect::state_machine_defect( const state_machine_element& _elemen : element_( &_element ), message_( yprintf( _message.c_str(), _value1, _value2, _value3, _value4 ) ) { - // Nothing to do. + // Nothing to do... } @@ -69,7 +71,7 @@ state_machine_defect::state_machine_defect( const state_machine_element& _elemen : element_( &_element ), message_( yprintf( _message.c_str(), _value1, _value2, _value3, _value4, _value5 ) ) { - // Nothing to do. + // Nothing to do... } @@ -82,7 +84,6 @@ state_machine_defect::~state_machine_defect() Y_NOEXCEPT } -// cppcheck-suppress unusedFunction const state_machine_element& state_machine_defect::get_element() const { return( *element_ ); diff --git a/yasmine/yasmine/state_machine_element_impl.cpp b/libyasmine/source/state_machine_element_impl.cpp similarity index 100% rename from yasmine/yasmine/state_machine_element_impl.cpp rename to libyasmine/source/state_machine_element_impl.cpp diff --git a/libyasmine/source/state_machine_status.cpp b/libyasmine/source/state_machine_status.cpp new file mode 100644 index 0000000..0f159a0 --- /dev/null +++ b/libyasmine/source/state_machine_status.cpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_status.hpp" + + +namespace sxy +{ + + +#ifdef Y_CPP03_BOOST + + + bool operator==( const state_machine_status& _lhs, const state_machine_status::inner _rhs ) + { + return( _lhs.value_ == _rhs ); + } + + + bool operator==( const state_machine_status::inner _lhs, const state_machine_status& _rhs ) + { + return( _lhs == _rhs.value_ ); + } + + +#endif + + +} + \ No newline at end of file diff --git a/yasmine/yasmine/state_pseudostate_impl.cpp b/libyasmine/source/state_pseudostate_impl.cpp similarity index 87% rename from yasmine/yasmine/state_pseudostate_impl.cpp rename to libyasmine/source/state_pseudostate_impl.cpp index 21be6ba..ca7fd42 100644 --- a/yasmine/yasmine/state_pseudostate_impl.cpp +++ b/libyasmine/source/state_pseudostate_impl.cpp @@ -59,17 +59,18 @@ void state_pseudostate_impl::set_parent_state( composite_state* const _parent_st } -raw_composite_states state_pseudostate_impl::get_ancestors( composite_state* const _final_ancestor ) const +raw_composite_states state_pseudostate_impl::get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor ) const { #ifdef Y_OPTIMIZE_4_SPEED if( ancestors_.empty() ) { - collect_ancestors( ancestors_, _final_ancestor ); + collect_ancestors( ancestors_, _final_ancestor, _include_final_ancestor ); } return( ancestors_ ); #else raw_composite_states ancestors; - collect_ancestors( ancestors, _final_ancestor ); + collect_ancestors( ancestors, _final_ancestor, _include_final_ancestor ); return( ancestors ); #endif } @@ -90,11 +91,15 @@ raw_regions state_pseudostate_impl::get_ancestors_as_regions() const void state_pseudostate_impl::collect_ancestors( raw_composite_states& _ancestors, - composite_state* const _final_ancestor ) const + composite_state* const _final_ancestor, bool _include_final_ancestor ) const { _ancestors.push_back( &get_parent_state() ); const raw_composite_states& ancestors_of_parent_state = get_parent_state().get_ancestors( _final_ancestor ); _ancestors.insert( _ancestors.end(), ancestors_of_parent_state.begin(), ancestors_of_parent_state.end() ); + if( !_include_final_ancestor ) + { + _ancestors.erase( _ancestors.end() ); + } } diff --git a/yasmine/yasmine/states_nesting_comparer.cpp b/libyasmine/source/states_nesting_comparer.cpp similarity index 100% rename from yasmine/yasmine/states_nesting_comparer.cpp rename to libyasmine/source/states_nesting_comparer.cpp diff --git a/yasmine/yasmine/states_nesting_comparer_ascending.cpp b/libyasmine/source/states_nesting_comparer_ascending.cpp similarity index 100% rename from yasmine/yasmine/states_nesting_comparer_ascending.cpp rename to libyasmine/source/states_nesting_comparer_ascending.cpp diff --git a/yasmine/yasmine/states_to_enter_visitor_impl.cpp b/libyasmine/source/states_to_enter_visitor_impl.cpp similarity index 89% rename from yasmine/yasmine/states_to_enter_visitor_impl.cpp rename to libyasmine/source/states_to_enter_visitor_impl.cpp index bac0cd7..67600ae 100644 --- a/yasmine/yasmine/states_to_enter_visitor_impl.cpp +++ b/libyasmine/source/states_to_enter_visitor_impl.cpp @@ -35,10 +35,12 @@ namespace sxy states_to_enter_visitor_impl::states_to_enter_visitor_impl( raw_states_by_nesting_level& _states_to_enter, - raw_const_region_set& _regions_to_enter, composite_state& _LCA_of_compound_transition ) + raw_const_region_set& _regions_to_enter, composite_state& _LCA_of_compound_transition, + const vertex& _source_of_transition ) : states_to_enter_( _states_to_enter ), regions_to_enter_( _regions_to_enter ), - LCA_of_compound_transition_( _LCA_of_compound_transition ) + LCA_of_compound_transition_( _LCA_of_compound_transition ), + source_of_transition_( _source_of_transition ) { // Nothing to do... } @@ -77,7 +79,7 @@ void states_to_enter_visitor_impl::visit( initial_pseudostate& _initial_pseudost void states_to_enter_visitor_impl::visit( choice& _choice ) { - Y_UNUSED_PARAMETER( _choice ); + get_all_parent_states_to_enter( _choice ); } @@ -199,4 +201,17 @@ void states_to_enter_visitor_impl::insert_states_to_enter( state& _state ) } +void states_to_enter_visitor_impl::get_all_parent_states_to_enter( choice& _choice ) +{ + sxy::composite_state* lca = source_of_transition_.LCA_composite_state( _choice ); + Y_ASSERT( lca, "There is no last common ancestor for transitions's source and choice!" ); + raw_composite_states ancestors = _choice.get_ancestors( lca, false ); + Y_FOR( composite_state* ancestor, ancestors ) + { + states_to_enter_.insert( ancestor ); + } + +} + + } diff --git a/yasmine/yasmine/std_timestamp_policy.cpp b/libyasmine/source/std_timestamp_policy.cpp similarity index 100% rename from yasmine/yasmine/std_timestamp_policy.cpp rename to libyasmine/source/std_timestamp_policy.cpp diff --git a/yasmine/yasmine/terminate_pseudostate_impl.cpp b/libyasmine/source/terminate_pseudostate_impl.cpp similarity index 100% rename from yasmine/yasmine/terminate_pseudostate_impl.cpp rename to libyasmine/source/terminate_pseudostate_impl.cpp diff --git a/yasmine/yasmine/timed_event_creator.cpp b/libyasmine/source/timed_event_creator.cpp similarity index 93% rename from yasmine/yasmine/timed_event_creator.cpp rename to libyasmine/source/timed_event_creator.cpp index c6854f9..8cf7c7d 100644 --- a/yasmine/yasmine/timed_event_creator.cpp +++ b/libyasmine/source/timed_event_creator.cpp @@ -38,7 +38,7 @@ timed_event_creator::timed_event_creator( async_state_machine& _async_state_mach timed_event_creator::~timed_event_creator() Y_NOEXCEPT -{ +{ Y_ASSERT( !run_, "Thread is still running! It was not stopped." ); Y_ASSERT( !worker_, "The thread still exists!" ); } @@ -75,7 +75,6 @@ handle_type timed_event_creator::create_event_creation_request( } -// cppcheck-suppress unusedFunction bool timed_event_creator::cancel( const handle_type _handle ) { bool cancelled = false; @@ -97,7 +96,7 @@ bool timed_event_creator::cancel( const handle_type _handle ) } -void timed_event_creator::start() +void timed_event_creator::run() { Y_LOG( log_level::LL_TRACE, "Event creator is starting." ); run_ = true; @@ -106,7 +105,27 @@ void timed_event_creator::start() } -void timed_event_creator::stop() +void timed_event_creator::halt() +{ + Y_LOG( log_level::LL_TRACE, "Event creator is stopping." ); + { + sxy::lock_guard< sxy::mutex > lock( mutex_ ); + run_ = false; + } + condition_variable_.notify_all(); +} + + +void timed_event_creator::join() +{ + Y_ASSERT( worker_->joinable(), "Time event generator thread is not joinable!" ); + worker_->join(); + worker_.reset(); + Y_LOG( log_level::LL_TRACE, "Event creator stopped." ); +} + + +void timed_event_creator::halt_and_join() { Y_LOG( log_level::LL_TRACE, "Event creator is stopping." ); { diff --git a/yasmine/yasmine/transition_controller.cpp b/libyasmine/source/transition_controller.cpp similarity index 84% rename from yasmine/yasmine/transition_controller.cpp rename to libyasmine/source/transition_controller.cpp index 7e1bb7e..05e68f8 100644 --- a/yasmine/yasmine/transition_controller.cpp +++ b/libyasmine/source/transition_controller.cpp @@ -19,7 +19,7 @@ #include "event_processing_callback.hpp" #include "compound_transition_impl.hpp" #include "log_and_throw.hpp" -#include "behaviour_exception.hpp" +#include "behavior_exception.hpp" #include "conversion.hpp" #include "algorithm_parameters.hpp" #include "completion_event.hpp" @@ -90,7 +90,7 @@ bool transition_controller::start_state_machine( const composite_state& _main_co { Y_LOG( log_level::LL_TRACE, "Found % compound transition(s) after searching for initial transitions.", enabled_compound_transitions.size() ); - Y_LOG( log_level::LL_TRACE, "Executing transitions." ); + Y_LOG( log_level::LL_TRACE, "Executing transitions." ); if( execute_transitions( _main_composite_state, enabled_compound_transitions, _event_processing_callback, *completion_event::create(), _async_event_handler ) ) { @@ -149,31 +149,13 @@ bool transition_controller::execute_transitions( const composite_state& _main_co { _event_processing_callback->after_event_processings_stage( choices ); } - - - sxy::event_sptr error_event = exception_events.front(); - transition_finder transition_finder; - bool event_is_deferred = false; - - if( _event_processing_callback ) - { - _event_processing_callback->before_event( error_event->get_id(), error_event->get_priority() ); - } - - transition_finder.search_for_enabled_transitions_in_all_regions( _main_composite_state, *error_event, compound_transitions, event_is_deferred ); - execute_transitions( _main_composite_state, compound_transitions, _event_processing_callback, *error_event, _async_event_handler ); - exception_events.erase( exception_events.begin(), exception_events.begin() + 1 ); - - - if( _event_processing_callback ) - { - _event_processing_callback->after_event( error_event->get_id() ); - } - + + handle_execution_events( exception_events, _event_processing_callback, _main_composite_state, + compound_transitions, _async_event_handler ); } Y_LOG( log_level::LL_TRACE, "Searching for completion event transitions." ); - search_completion_event_transitions( _main_composite_state, compound_transitions ); + search_completion_event_transitions( _main_composite_state, compound_transitions ); } if( _event_processing_callback ) @@ -186,6 +168,33 @@ bool transition_controller::execute_transitions( const composite_state& _main_co } +void transition_controller::handle_execution_events( events& _exception_events, + event_processing_callback* const _event_processing_callback, const composite_state& _main_composite_state, + compound_transitions& _compound_transitions, async_event_handler* const _async_event_handler ) +{ + sxy::event_sptr error_event = _exception_events.front(); + transition_finder transition_finder; + bool event_is_deferred = false; + + if( _event_processing_callback ) + { + _event_processing_callback->before_event( error_event->get_id(), error_event->get_priority() ); + } + + transition_finder.search_for_enabled_transitions_in_all_regions( _main_composite_state, *error_event, + _compound_transitions, event_is_deferred ); + execute_transitions( _main_composite_state, _compound_transitions, _event_processing_callback, *error_event, + _async_event_handler ); + _exception_events.erase( _exception_events.begin(), _exception_events.begin() + 1 ); + + + if( _event_processing_callback ) + { + _event_processing_callback->after_event( error_event->get_id() ); + } +} + + void transition_controller::search_choice_transitions( const raw_const_choices& _choices, compound_transitions& compound_transitions, const event& _event ) { diff --git a/yasmine/yasmine/transition_executor.cpp b/libyasmine/source/transition_executor.cpp similarity index 98% rename from yasmine/yasmine/transition_executor.cpp rename to libyasmine/source/transition_executor.cpp index d9a26ef..709db80 100644 --- a/yasmine/yasmine/transition_executor.cpp +++ b/libyasmine/source/transition_executor.cpp @@ -65,7 +65,7 @@ bool transition_executor::check_sort_and_execute_transitions( const compound_tra raw_const_region_set entered_regions; Y_LOG( 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 ); + execution_steps, entered_regions, _event, true ); Y_LOG( log_level::LL_TRACE, "Found % execution step(s).", execution_steps.size() ); Y_LOG( log_level::LL_TRACE, "Start running execution step(s)." ); terminate_pseudostate_has_been_reached = transition_executor_impl_->run_execution_steps( execution_steps, diff --git a/yasmine/yasmine/transition_executor_impl.cpp b/libyasmine/source/transition_executor_impl.cpp similarity index 82% rename from yasmine/yasmine/transition_executor_impl.cpp rename to libyasmine/source/transition_executor_impl.cpp index 26579b3..cbb9c14 100644 --- a/yasmine/yasmine/transition_executor_impl.cpp +++ b/libyasmine/source/transition_executor_impl.cpp @@ -124,15 +124,7 @@ void transition_executor_impl::get_all_states_to_enter_from_regions_that_are_not Y_LOG( log_level::LL_TRACE, "Found initial pseudostate '%' in region '%'.", initial_pseudostate->get_name(), region->get_name() ); -#ifdef _MSC_VER -#if _MSC_VER >= 1900 Y_UNIQUE_PTR< compound_transition_impl > new_compound_transition = Y_MAKE_UNIQUE< compound_transition_impl >(); -#elif _MSC_VER <= 1800 - sxy::shared_ptr< compound_transition_impl > new_compound_transition = Y_MAKE_SHARED< compound_transition_impl >(); -#endif -#else - Y_UNIQUE_PTR< compound_transition_impl > new_compound_transition = Y_MAKE_UNIQUE< compound_transition_impl >(); -#endif Y_LOG( log_level::LL_TRACE, "New compound transition created for event with ID %.", _event.get_id() ); const bool built_compound_transition = new_compound_transition->create_and_check_transition_path( @@ -142,23 +134,13 @@ void transition_executor_impl::get_all_states_to_enter_from_regions_that_are_not if( built_compound_transition ) { Y_LOG( log_level::LL_TRACE, "Build sub compound transition for '%' transition.", - initial_pseudostate->get_name() ); - find_all_states_to_enter_and_exit( *new_compound_transition, _entered_regions, _event ); - compound_transition_impl* const compound_transition = dynamic_cast< compound_transition_impl* >( &_compound_transition ); - -#ifdef _MSC_VER -#if _MSC_VER >= 1900 - compound_transition->add_sub_compound_transition( sxy::move( new_compound_transition ) ); -#elif _MSC_VER <= 1800 - compound_transition->add_sub_compound_transition( new_compound_transition ); -#endif -#else - compound_transition->add_sub_compound_transition( sxy::move( new_compound_transition ) ); -#endif - //Y_LOG( log_level::LL_SPAM, - //"New compound transition added to compound transition as a sub compound transition." ); + initial_pseudostate->get_name() ); + find_already_entered_regions( *new_compound_transition, _entered_regions, _event ); + compound_transition_impl* const compound_transition = + dynamic_cast< compound_transition_impl* >( &_compound_transition ); - Y_LOG( log_level::LL_SPAM, + compound_transition->add_sub_compound_transition( sxy::move( new_compound_transition ) ); + Y_LOG( log_level::LL_SPAM, "New compound transition added to compound transition as a sub compound transition." ); } } @@ -345,7 +327,7 @@ void transition_executor_impl::calculate_execution_steps( compound_transition_co Y_LOG( log_level::LL_SPAM, "Compound transition has % sub compound transition(s).", _compound_transition.get_sub_compound_transitions().size() ); find_states_to_enter_and_to_exit_and_calculate_execution_steps( *sub_compound_transition, _execution_steps, - _entered_regions, _event ); + _entered_regions, _event, false ); } } @@ -359,7 +341,7 @@ bool transition_executor_impl::run_execution_steps( const execution_steps& _exec Y_FOR( const execution_step_uptr& execution_step, _execution_steps ) { - if( execution_step->execute_behaviour( _event_processing_callback, _event, _exception_events, _async_event_handler ) ) + if( execution_step->execute_behavior( _event_processing_callback, _event, _exception_events, _async_event_handler ) ) { run_reached_terminate_pseudostate = true; break; @@ -388,8 +370,17 @@ void transition_executor_impl::conflict_check( const compound_transitions& _comp if( l_state ) { Y_LOG( log_level::LL_TRACE, "Source of compound transition is a state ( '%' ).", l_state->get_name() ); - check_conflicts_from_source_state_to_LCA( *l_state, unique_exit_states, - &compound_transition->get_LCA_region()->get_parent_state() ); + const region* LCA_region = compound_transition->get_LCA_region(); + const composite_state* parent_state = Y_NULLPTR; + if( LCA_region ) + { + parent_state = &LCA_region->get_parent_state(); + } + else + { + parent_state = l_state->get_root_state(); + } + check_conflicts_from_source_state_to_LCA( *l_state, unique_exit_states, parent_state ); } } } @@ -425,41 +416,16 @@ raw_compound_transitions transition_executor_impl::sort_compound_transitions( void transition_executor_impl::find_all_states_to_exit( compound_transition_consumer& _compound_transition, raw_states_by_nesting_level_ascending& _states_to_exit ) { - const transition_kind compound_transition_kind = _compound_transition.get_transition_kind(); - if( !(transition_kind::INTERNAL == compound_transition_kind) ) + const transition_kind compound_transition_kind = _compound_transition.get_transition_kind(); + if( !( transition_kind::INTERNAL == compound_transition_kind ) ) { - region* const least_common_ancestor = _compound_transition.get_LCA_region(); - if( transition_kind::EXTERNAL == compound_transition_kind ) - { - if( least_common_ancestor->get_parent_state().is_active() ) - { - get_active_states_from_region( *least_common_ancestor, _states_to_exit ); - Y_LOG( log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); - } - else - { - Y_LOG( log_level::LL_SPAM, - "Least common ancestor '%' of compound transition is not active. No states to exit.", - least_common_ancestor->get_parent_state().get_name() ); - } - } - else - if( transition_kind::LOCAL == compound_transition_kind ) + region* LCA_region = _compound_transition.get_LCA_region(); + if( !LCA_region ) { - if( least_common_ancestor->get_active_state() ) - { - Y_FOR( const region_uptr& region, least_common_ancestor->get_active_state()->get_regions() ) - { - get_active_states_from_region( *region, _states_to_exit ); - Y_LOG( log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); - } - } - else - { - Y_LOG( log_level::LL_TRACE, "Least common ancestor '%' of compound transition, has no active state. .", - least_common_ancestor->get_name() ); - } + const composite_state* const root_state = _compound_transition.get_last_target().get_root_state(); + LCA_region = root_state->get_regions().front().get(); } + fill_vector_of_states_to_exit( LCA_region, _states_to_exit, compound_transition_kind ); } else { @@ -482,21 +448,40 @@ void transition_executor_impl::find_all_states_to_enter( compound_transition_con Y_LOG( log_level::LL_SPAM, "Target of transition '%' is '%'.", transition->get_name(), vertex.get_name() ); if( transition_kind::LOCAL == compound_transition_kind ) { - composite_state* const active_state_as_composite_state = - dynamic_cast< composite_state* >( _compound_transition.get_LCA_region()->get_active_state() ); + region* LCA_region = _compound_transition.get_LCA_region(); + composite_state* active_state_as_composite_state = Y_NULLPTR; + if( LCA_region ) + { + active_state_as_composite_state = dynamic_cast< composite_state* >( LCA_region->get_active_state() ); + } + else + { + active_state_as_composite_state = vertex.get_root_state(); + } + if( active_state_as_composite_state ) { - states_to_enter_visitor_impl visitor( _states_to_enter, _regions_to_enter, - *active_state_as_composite_state ); + states_to_enter_visitor_impl visitor( _states_to_enter, _regions_to_enter, *active_state_as_composite_state, + transition->get_source() ); vertex.accept_vertex_visitor( visitor ); _states_to_enter.erase( active_state_as_composite_state ); - } + } } else - { - states_to_enter_visitor_impl visitor( _states_to_enter, _regions_to_enter, - _compound_transition.get_LCA_region()->get_parent_state() ); - vertex.accept_vertex_visitor( visitor ); + { + region* LCA_region = _compound_transition.get_LCA_region(); + composite_state* parent_state = Y_NULLPTR; + if( LCA_region ) + { + parent_state = &LCA_region->get_parent_state(); + } + else + { + parent_state = vertex.get_root_state(); + } + states_to_enter_visitor_impl visitor( _states_to_enter, _regions_to_enter, *parent_state, + transition->get_source() ); + vertex.accept_vertex_visitor( visitor ); } } @@ -575,28 +560,26 @@ void transition_executor_impl::fill_vector_of_choices( raw_const_choices& _choic } -void transition_executor_impl::find_all_states_to_enter_and_exit( compound_transition& new_compound_transition, +void transition_executor_impl::find_already_entered_regions( compound_transition& new_compound_transition, raw_const_region_set& _entered_regions, const event& _event ) -{ - raw_states_by_nesting_level_ascending states_to_exit; - Y_LOG( log_level::LL_TRACE, "Start searching states to exit." ); - find_all_states_to_exit( new_compound_transition, states_to_exit ); - Y_LOG( log_level::LL_TRACE, "Found % state(s) to exit.", states_to_exit.size() ); - raw_states_by_nesting_level states_to_enter; - Y_LOG( log_level::LL_TRACE, "Start searching states to enter." ); - find_all_states_to_enter( new_compound_transition, states_to_enter, _entered_regions, _event ); - Y_LOG( log_level::LL_TRACE, "Found % state(s) to enter.", states_to_enter.size() ); +{ + raw_states_by_nesting_level states_to_enter; + find_all_states_to_enter( new_compound_transition, states_to_enter, _entered_regions, _event ); } void transition_executor_impl::find_states_to_enter_and_to_exit_and_calculate_execution_steps( compound_transition_consumer& _compound_transition, execution_steps& _execution_steps, - raw_const_region_set& _entered_regions, const event& _event ) + raw_const_region_set& _entered_regions, const event& _event, bool _find_states_to_exit ) { - raw_states_by_nesting_level_ascending states_to_exit; + raw_states_by_nesting_level_ascending states_to_exit; Y_LOG( log_level::LL_TRACE, "Start searching states to exit." ); - find_all_states_to_exit( _compound_transition, states_to_exit ); - Y_LOG( log_level::LL_TRACE, "Found % state(s) to exit.", states_to_exit.size() ); + + if( _find_states_to_exit ) + { + find_all_states_to_exit( _compound_transition, states_to_exit ); + Y_LOG( log_level::LL_TRACE, "Found % state(s) to exit.", states_to_exit.size() ); + } raw_states_by_nesting_level states_to_enter; Y_LOG( log_level::LL_TRACE, "Start searching states to enter." ); find_all_states_to_enter( _compound_transition, states_to_enter, _entered_regions, _event ); @@ -610,28 +593,73 @@ void transition_executor_impl::find_states_to_enter_and_to_exit_and_calculate_ex void transition_executor_impl::check_conflicts_from_source_state_to_LCA( const state& _state, raw_const_state_set& _unique_exit_states, const composite_state* _LCA ) const -{ - Y_LOG( log_level::LL_TRACE, "Checking conflicts from source '%' up to LCA '%'.", _state.get_name(), - _LCA->get_name() ); - const std::pair< raw_const_state_set::const_iterator, bool > insert_result = _unique_exit_states.insert( &_state ); - if( !insert_result.second ) +{ + if( &_state != _LCA ) { - LOG_AND_THROW( log_level::LL_FATAL, "There are conflicts. The intersection of states '%' and '%' is not empty.", - _state.get_name(), _LCA->get_name() ); + Y_LOG( log_level::LL_TRACE, "Checking conflicts from source '%' up to LCA '%'.", _state.get_name(), + _LCA->get_name() ); + const std::pair< raw_const_state_set::const_iterator, bool > insert_result = _unique_exit_states.insert( &_state ); + if( !insert_result.second ) + { + LOG_AND_THROW( log_level::LL_FATAL, "There are conflicts. The intersection of states '%' and '%' is not empty.", + _state.get_name(), _LCA->get_name() ); + } + else + { + Y_LOG( log_level::LL_TRACE, "There are no conflicts. The intersection of states '%' and '%' is empty.", + _state.get_name(), _LCA->get_name() ); + } + + Y_ASSERT( _state.get_parent_region(), "State has no parent region!" ); + const composite_state& parent_state = _state.get_parent_region()->get_parent_state(); + Y_LOG( log_level::LL_SPAM, "Parent state of the state '%' is '%'.", _state.get_name(), parent_state.get_name() ); + if( &parent_state != _LCA ) + { + check_conflicts_from_source_state_to_LCA( parent_state, _unique_exit_states, _LCA ); + } } else { - Y_LOG( log_level::LL_TRACE, "There are no conflicts. The intersection of states '%' and '%' is empty.", - _state.get_name(), _LCA->get_name() ); + // Nothing to check. No conflicts. } +} - Y_ASSERT( _state.get_parent_region(), "State has no parent region!" ); - const composite_state& parent_state = _state.get_parent_region()->get_parent_state(); - Y_LOG( log_level::LL_SPAM, "Parent state of the state '%' is '%'.", _state.get_name(), parent_state.get_name() ); - if( &parent_state != _LCA ) + +void transition_executor_impl::fill_vector_of_states_to_exit( region* _LCA_region, + raw_states_by_nesting_level_ascending& _states_to_exit, const transition_kind _compound_transition_kind ) +{ + if( transition_kind::EXTERNAL == _compound_transition_kind ) { - check_conflicts_from_source_state_to_LCA( parent_state, _unique_exit_states, _LCA ); + if( _LCA_region->get_parent_state().is_active() ) + { + get_active_states_from_region( *_LCA_region, _states_to_exit ); + Y_LOG( log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); + } + else + { + Y_LOG( log_level::LL_SPAM, + "Least common ancestor '%' of compound transition is not active. No states to exit.", + _LCA_region->get_parent_state().get_name() ); + } } + else + if( transition_kind::LOCAL == _compound_transition_kind ) + { + sxy::state* active_state = _LCA_region->get_active_state(); + if( active_state ) + { + Y_FOR( const region_uptr& region, active_state->get_regions() ) + { + get_active_states_from_region( *region, _states_to_exit ); + Y_LOG( log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); + } + } + else + { + Y_LOG( log_level::LL_TRACE, "Least common ancestor '%' of compound transition, has no active state. .", + _LCA_region->get_name() ); + } + } } diff --git a/yasmine/yasmine/transition_finder.cpp b/libyasmine/source/transition_finder.cpp similarity index 92% rename from yasmine/yasmine/transition_finder.cpp rename to libyasmine/source/transition_finder.cpp index 5e3801b..8c7f258 100644 --- a/yasmine/yasmine/transition_finder.cpp +++ b/libyasmine/source/transition_finder.cpp @@ -28,13 +28,13 @@ namespace sxy transition_finder::transition_finder() { - // Nothing to do.. + // Nothing to do... } transition_finder::~transition_finder() Y_NOEXCEPT { - // Nothing to do.. + // Nothing to do... } @@ -48,8 +48,8 @@ void transition_finder::search_for_enabled_transitions_in_all_regions( const sta void transition_finder::search_for_enabled_completion_transitions_in_all_regions( const state& _current_state, compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred ) const { - const sxy::shared_ptr< event_impl > completion_event = Y_MAKE_SHARED< event_impl >( COMPLETION_EVENT_ID ); - search_for_transition( _current_state, _enabled_compound_transitions, *completion_event, _event_is_deferred ); + search_for_transition( _current_state, _enabled_compound_transitions, *sxy::completion_event::create(), + _event_is_deferred ); } @@ -58,15 +58,14 @@ void transition_finder::search_initial_transitions( const composite_state& _stat { Y_FOR( const region_uptr& region, _state.get_regions() ) { - Y_LOG( log_level::LL_TRACE, "Searching for initial state in region '%'.", region->get_name() ); + Y_LOG( log_level::LL_TRACE, "Searching for initial pseudostate in region '%'.", region->get_name() ); const initial_pseudostate* const initial_pseudostate = region->get_initial_pseudostate(); if( initial_pseudostate ) { Y_LOG( log_level::LL_TRACE, "Initial pseudostate '%' found in region '%'.", initial_pseudostate->get_name(), region->get_name() ); transition* const transition = initial_pseudostate->get_transition(); - const sxy::shared_ptr< event_impl > complition_event = Y_MAKE_SHARED< event_impl >( COMPLETION_EVENT_ID ); - if( !try_to_build_compound_transition( *transition, _compound_transitions, *complition_event ) ) + if( !try_to_build_compound_transition( *transition, _compound_transitions, *sxy::completion_event::create() ) ) { std::string message = sxy::yprintf( "A compound transition could not be built for the initial transition emitting from the initial pseudostate '%'!", @@ -94,7 +93,7 @@ void transition_finder::search_choice_transitions( const raw_const_choices& _cho Y_FOR( transition* const transition, choice->get_outgoing_transitions()) { - Y_ASSERT(transition->can_accept_event( COMPLETION_EVENT_ID ), + Y_ASSERT(transition->can_accept_event( sxy::completion_event::get_event_id() ), "Transition leaving choice is not a completion transition!" ); Y_LOG( log_level::LL_SPAM, "Checking outgoing transition '%' of choice '%' for guard.", transition->get_name(), choice->get_name() ); @@ -136,7 +135,7 @@ transition* transition_finder::search_completion_transition( const state& _state if( _state.is_complete() ) { Y_LOG( log_level::LL_SPAM, "State '%' is complete.", _state.get_name() ); - const sxy::shared_ptr< event_impl > completion_event = Y_MAKE_SHARED< event_impl >( COMPLETION_EVENT_ID ); + const sxy::shared_ptr< event_impl > completion_event = Y_MAKE_SHARED< event_impl >( sxy::completion_event::get_event_id() ); completion_transition = _state.search_transition( *completion_event ); } @@ -179,7 +178,7 @@ bool transition_finder::search_for_transition( const state& _current_state, if( !found ) { transition* transition = Y_NULLPTR; - if( COMPLETION_EVENT_ID == _event.get_id() ) + if( sxy::completion_event::get_event_id() == _event.get_id() ) { Y_LOG( log_level::LL_TRACE, "Search completion transition in state '%'.", _current_state.get_name() ); transition = search_completion_transition( _current_state ); diff --git a/yasmine/yasmine/transition_impl.cpp b/libyasmine/source/transition_impl.cpp similarity index 53% rename from yasmine/yasmine/transition_impl.cpp rename to libyasmine/source/transition_impl.cpp index 063fc04..6b6131d 100644 --- a/yasmine/yasmine/transition_impl.cpp +++ b/libyasmine/source/transition_impl.cpp @@ -11,10 +11,12 @@ #include "transition_impl.hpp" +#include "log.hpp" + #include #include "vertex.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" #include "constraint.hpp" #include "event.hpp" #include "uri.hpp" @@ -23,6 +25,8 @@ #include "state.hpp" #include "pseudostate.hpp" #include "composite_state.hpp" +#include "initial_pseudostate.hpp" +#include "exit_point.hpp" namespace sxy @@ -30,19 +34,20 @@ namespace sxy #ifdef Y_CPP03_BOOST +#pragma warning( push ) #pragma warning( disable : 4100 ) #endif #ifdef Y_CPP03_BOOST transition_impl::transition_impl( const event_id _event_id, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, constraint_uptr _guard, behaviour_uptr _behaviour ) + const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) : state_machine_element_impl( get_transition_name(_source, _target, event_ids( 1, _event_id ) ) ), event_ids_( event_ids( 1, _event_id ) ), source_( _source ), target_( _target ), guard_( sxy::move( _guard ) ), - behaviour_( sxy::move( _behaviour ) ), + behavior_( sxy::move( _behavior ) ), kind_( _kind ) { source_.add_outgoing_transition( *this ); @@ -50,24 +55,60 @@ transition_impl::transition_impl( const event_id _event_id, vertex& _source, ver } #else - transition_impl::transition_impl( const event_id _event_id, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, constraint_uptr _guard, behaviour_uptr _behaviour ) - : transition_impl( event_ids{ _event_id }, _source, _target, _kind, sxy::move( _guard ), sxy::move( _behaviour ) ) - { - // Nothing to do... - } + #ifdef _MSC_VER + #if _MSC_VER <= 1800 + transition_impl::transition_impl( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) + :state_machine_element_impl( get_transition_name( _source, _target, event_ids( 1, _event_id ) ) ), + event_ids_( event_ids( 1, _event_id ) ), + source_( _source ), + target_( _target ), + guard_( sxy::move( _guard ) ), + behavior_( sxy::move( _behavior ) ), + kind_( _kind ) + { + source_.add_outgoing_transition( *this ); + target_.add_incoming_transition( *this ); + } + #else + transition_impl::transition_impl( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) + : transition_impl( event_ids( 1, _event_id ), _source, _target, _kind, sxy::move( _guard ), sxy::move( _behavior ) ) + { + // Nothing to do... + } + #endif + #else + transition_impl::transition_impl( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) + :state_machine_element_impl( get_transition_name( _source, _target, event_ids( 1, _event_id ) ) ), + event_ids_( event_ids( 1, _event_id ) ), + source_( _source ), + target_( _target ), + guard_( sxy::move( _guard ) ), + behavior_( sxy::move( _behavior ) ), + kind_( _kind ) + { + source_.add_outgoing_transition( *this ); + target_.add_incoming_transition( *this ); + } + #endif #endif +#ifdef Y_CPP03_BOOST +#pragma warning( pop ) +#endif + transition_impl::transition_impl( const event_ids _event_ids, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, constraint_uptr _guard, behaviour_uptr _behaviour ) + const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) : state_machine_element_impl( get_transition_name( _source, _target, _event_ids ) ), event_ids_( _event_ids ), source_( _source ), target_( _target ), guard_( sxy::move( _guard ) ), - behaviour_( sxy::move( _behaviour ) ), + behavior_( sxy::move( _behavior ) ), kind_( _kind ) { source_.add_outgoing_transition( *this ); @@ -106,9 +147,9 @@ const constraint* transition_impl::get_guard() const } -const behaviour* transition_impl::get_behaviour() const +const behavior* transition_impl::get_behavior() const { - return( behaviour_.get() ); + return( behavior_.get() ); } @@ -135,19 +176,17 @@ sxy::transition_kind transition_impl::get_kind() const void transition_impl::add_ancestor_uri( uri& _uri ) const { Y_UNUSED_PARAMETER( _uri ); - - // Nothing to do... } -void transition_impl::on_transition_behaviour( const event& _event ) const +void transition_impl::on_transition_behavior( const event& _event ) const { Y_LOG( sxy::log_level::LL_TRACE, "Executing transition '%' from '%' to '%'.", get_name(), get_source().get_name(), get_target().get_name() ); - const behaviour* const behaviour = get_behaviour(); - if( behaviour != Y_NULLPTR ) + const behavior* const behavior = get_behavior(); + if( behavior != Y_NULLPTR ) { - ( *behaviour )( _event ); + ( *behavior )( _event ); } Y_LOG( sxy::log_level::LL_TRACE, "Executed transition '%' from '%' to '%'.", get_name(), get_source().get_name(), @@ -168,46 +207,8 @@ bool transition_impl::check_guard( const event& _event ) const bool transition_impl::check( state_machine_defects& _defects ) const -{ - Y_UNUSED_PARAMETER( _defects ); - bool check_ok = true; - const vertex& source = get_source(); - const raw_regions& source_ancestors = source.get_ancestors_as_regions(); - const vertex& target = get_target(); - const raw_regions& target_ancestors = target.get_ancestors_as_regions(); - const region* const lca_of_source_target = source.LCA_region( target ); - raw_regions::const_iterator found_source_itr = - std::find( source_ancestors.begin(), source_ancestors.end(), lca_of_source_target ); - if( found_source_itr != source_ancestors.begin() ) - { - --found_source_itr; - } - - raw_regions::const_iterator found_target_itr = - std::find( target_ancestors.begin(), target_ancestors.end(), lca_of_source_target ); - if( found_target_itr != target_ancestors.begin() ) - { - --found_target_itr; - } - - if( ( ( **found_source_itr ).get_uri().to_string() == lca_of_source_target->get_uri().to_string() ) || - ( ( **found_target_itr ).get_uri().to_string() == lca_of_source_target->get_uri().to_string() ) ) - { - } - else - if( ( **found_source_itr ).get_uri().to_string() != ( **found_target_itr ).get_uri().to_string() ) - { - const composite_state& source_composite_state = ( **found_source_itr ).get_parent_state(); - const composite_state& target_composite_state = ( **found_target_itr ).get_parent_state(); - if( source_composite_state.get_uri().to_string() == target_composite_state.get_uri().to_string() ) - { - const std::string message = - "Transition '%' has source ('%') and target ('%') in different regions of the same composite state."; - _defects.push_back( state_machine_defect( *this, message, get_name(), - source.get_name(), target.get_name() ) ); - check_ok = false; - } - } +{ + bool check_ok = check_for_cross_region_transition( _defects ); if( sxy::transition_kind::INTERNAL == get_kind() ) { @@ -246,13 +247,40 @@ bool transition_impl::check( state_machine_defects& _defects ) const if( transition_kind::LOCAL == get_kind() ) { - if( !check_if_source_and_target_are_in_ancestor_relationship( get_source(), get_target() ) ) + if( !check_if_source_and_target_are_in_ancestor_relationship( get_source(), get_target() ) ) { _defects.push_back( state_machine_defect( *this, "Transition's '%' source '%' and target '%' are not in a ancestor relationship!", get_name(), get_source().get_name(), get_target().get_name() ) ); check_ok = false; } + + if( check_ok ) + { + check_ok = check_child_parent_relationship_of_source_target_of_transition( _defects ); + } + else + { + check_child_parent_relationship_of_source_target_of_transition( _defects ); + } + } + + if( check_ok ) + { + check_ok = check_initial_pseudostate( _defects ); + } + else + { + check_initial_pseudostate( _defects ); + } + + if( check_ok ) + { + check_ok = check_exit_point( _defects ); + } + else + { + check_exit_point( _defects ); } return( check_ok ); @@ -336,4 +364,118 @@ std::string transition_impl::get_transition_name( vertex& _source, vertex& _targ } +bool transition_impl::check_for_cross_region_transition( state_machine_defects& _defects ) const +{ + bool check_ok = true; + const vertex& source = get_source(); + const vertex& target = get_target(); + const region* const lca_of_source_target = source.LCA_region( target ); + if( lca_of_source_target ) + { + const raw_regions& source_ancestors = source.get_ancestors_as_regions(); + raw_regions::const_iterator found_source_itr = + std::find( source_ancestors.begin(), source_ancestors.end(), lca_of_source_target ); + if( found_source_itr != source_ancestors.begin() ) + { + --found_source_itr; + } + + const raw_regions& target_ancestors = target.get_ancestors_as_regions(); + raw_regions::const_iterator found_target_itr = + std::find( target_ancestors.begin(), target_ancestors.end(), lca_of_source_target ); + if( found_target_itr != target_ancestors.begin() ) + { + --found_target_itr; + } + + if( ( ( **found_source_itr ).get_uri().to_string() == lca_of_source_target->get_uri().to_string() ) || + ( ( **found_target_itr ).get_uri().to_string() == lca_of_source_target->get_uri().to_string() ) ) + { + } + else + if( ( **found_source_itr ).get_uri().to_string() != ( **found_target_itr ).get_uri().to_string() ) + { + const composite_state& source_composite_state = ( **found_source_itr ).get_parent_state(); + const composite_state& target_composite_state = ( **found_target_itr ).get_parent_state(); + if( source_composite_state.get_uri().to_string() == target_composite_state.get_uri().to_string() ) + { + const std::string message = + "Transition '%' has source ('%') and target ('%') in different regions of the same composite state."; + _defects.push_back( state_machine_defect( *this, message, get_name(), + source.get_name(), target.get_name() ) ); + check_ok = false; + } + } + + } + return( check_ok ); +} + + +bool transition_impl::check_child_parent_relationship_of_source_target_of_transition( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + const vertex& target = get_target(); + const vertex& source = get_source(); + + if( &target != &source ) + { + raw_composite_states ancestors = target.get_ancestors( Y_NULLPTR ); + raw_composite_states::const_iterator found_source_itr = std::find( ancestors.begin(), ancestors.end(), &source ); + if( found_source_itr == ancestors.end() ) + { + _defects.push_back( state_machine_defect( *this, + "Transition's '%' target '%' is not a child of the source '%' or the source vertex.", + get_name(), get_target().get_name(), get_source().get_name() ) ); + check_ok = false; + } + } + + return ( check_ok ); +} + + +bool transition_impl::check_initial_pseudostate( state_machine_defects& _defects ) const +{ + bool check_ok = true; + const initial_pseudostate* const initial = dynamic_cast< const initial_pseudostate* const >( &get_source() ); + if( initial ) + { + const state* const target_state = dynamic_cast< const state* const >( &get_target() ); + if( !target_state ) + { + _defects.push_back( state_machine_defect( *this, + "Transition's '%' target '%' is not a state! The target of the transition emanating from initial pseudostate is always a state.", + get_name(), get_target().get_name() ) ); + check_ok = false; + } + } + + return( check_ok ); +} + + +// Transition's source is a child of target's parent state or the parent state itself, when the target is an exit point. +bool transition_impl::check_exit_point( state_machine_defects& _defects ) const +{ + bool check_ok = true; + const exit_point* const target_exit_point = dynamic_cast< const exit_point* const >( &get_target() ); + if( target_exit_point ) + { + sxy::composite_state& parent_of_exit_point = target_exit_point->get_parent_state(); + raw_composite_states ancestors = get_source().get_ancestors( Y_NULLPTR ); + raw_composite_states::const_iterator found_source_itr = std::find( ancestors.begin(), ancestors.end(), &parent_of_exit_point ); + if( found_source_itr == ancestors.end() ) + { + _defects.push_back( state_machine_defect( *this, + "Transition '%' emanates from outside of the parent state of the exit point '%', which is the target of the transition.", + get_name(), get_target().get_name() ) ); + check_ok = false; + } + } + return( check_ok ); +} + + } diff --git a/yasmine/yasmine/transition_kind.cpp b/libyasmine/source/transition_kind.cpp similarity index 100% rename from yasmine/yasmine/transition_kind.cpp rename to libyasmine/source/transition_kind.cpp diff --git a/yasmine/yasmine/transition_priority.cpp b/libyasmine/source/transition_priority.cpp similarity index 89% rename from yasmine/yasmine/transition_priority.cpp rename to libyasmine/source/transition_priority.cpp index c59f96e..438b416 100644 --- a/yasmine/yasmine/transition_priority.cpp +++ b/libyasmine/source/transition_priority.cpp @@ -16,7 +16,7 @@ #include "region.hpp" #include "deep_history.hpp" #include "shallow_history.hpp" -#include "behaviour.hpp" +#include "behavior.hpp" namespace sxy @@ -25,9 +25,13 @@ namespace sxy transition_priority::transition_priority( compound_transition& _compound_transition ) : compound_transition_( &_compound_transition ), - priority_( _compound_transition.get_LCA_region()->get_parent_state().get_nesting_level() ) + priority_( 0 ) { - // Nothing to do... + const region* const lca_region = _compound_transition.get_LCA_region(); + if( lca_region ) + { + priority_ = lca_region->get_parent_state().get_nesting_level(); + } } diff --git a/yasmine/yasmine/try_to_build_compound_transition_visitor.cpp b/libyasmine/source/try_to_build_compound_transition_visitor.cpp similarity index 98% rename from yasmine/yasmine/try_to_build_compound_transition_visitor.cpp rename to libyasmine/source/try_to_build_compound_transition_visitor.cpp index 4e825e0..07296d7 100644 --- a/yasmine/yasmine/try_to_build_compound_transition_visitor.cpp +++ b/libyasmine/source/try_to_build_compound_transition_visitor.cpp @@ -88,7 +88,7 @@ void try_to_build_compound_transition_visitor::visit( const choice& _choice ) } -void try_to_build_compound_transition_visitor::visit( const junction& _junction ) +void try_to_build_compound_transition_visitor::visit( const junction& _junction ) { Y_UNUSED_PARAMETER( _junction ); build_compound_transition_and_insert_in_container(); diff --git a/yasmine/yasmine/uri.cpp b/libyasmine/source/uri.cpp similarity index 96% rename from yasmine/yasmine/uri.cpp rename to libyasmine/source/uri.cpp index 21b09ba..b0e5c21 100644 --- a/yasmine/yasmine/uri.cpp +++ b/libyasmine/source/uri.cpp @@ -35,7 +35,6 @@ uri::~uri() Y_NOEXCEPT } -// cppcheck-suppress unusedFunction bool uri::is_empty() const { return( uri_.empty() ); @@ -48,7 +47,6 @@ const std::string uri::to_string() const } -// cppcheck-suppress unusedFunction const std::string& uri::get_front() const { Y_ASSERT( !uri_.empty(), "Uri is empty!" ); @@ -56,7 +54,6 @@ const std::string& uri::get_front() const } -// cppcheck-suppress unusedFunction const std::string& uri::get_back() { Y_ASSERT( !uri_.empty(), "Uri is empty!" ); diff --git a/yasmine/yasmine/utils.cpp b/libyasmine/source/utils.cpp similarity index 100% rename from yasmine/yasmine/utils.cpp rename to libyasmine/source/utils.cpp diff --git a/yasmine/yasmine/version.cpp b/libyasmine/source/version.cpp similarity index 94% rename from yasmine/yasmine/version.cpp rename to libyasmine/source/version.cpp index 1568833..c1319c9 100644 --- a/yasmine/yasmine/version.cpp +++ b/libyasmine/source/version.cpp @@ -17,7 +17,7 @@ #include "compatibility.hpp" -namespace yasmine +namespace sxy { @@ -29,8 +29,8 @@ namespace { -const sxy::uint16_t VERSION_MAJOR( 0 ); -const sxy::uint16_t VERSION_MINOR( 6 ); +const sxy::uint16_t VERSION_MAJOR( 1 ); +const sxy::uint16_t VERSION_MINOR( 0 ); const sxy::uint16_t VERSION_PATCH( 0 ); diff --git a/yasmine/yasmine/vertex_impl.cpp b/libyasmine/source/vertex_impl.cpp similarity index 65% rename from yasmine/yasmine/vertex_impl.cpp rename to libyasmine/source/vertex_impl.cpp index 61706b6..499b583 100644 --- a/yasmine/yasmine/vertex_impl.cpp +++ b/libyasmine/source/vertex_impl.cpp @@ -20,6 +20,7 @@ #include "uri.hpp" #include "log.hpp" #include "event.hpp" +#include "constraint.hpp" namespace sxy @@ -41,9 +42,63 @@ vertex_impl::~vertex_impl() Y_NOEXCEPT } -void vertex_impl::add_outgoing_transition( transition& _outgoing_transition ) +composite_state* vertex_impl::get_root_state() +{ + raw_composite_states ancestors = get_ancestors( Y_NULLPTR ); + composite_state* root = Y_NULLPTR; + if( ancestors.empty() ) + { + root = dynamic_cast< composite_state* >( this ); + } + else + { + root = ancestors.back(); + } + return ( root ); +} + + +const composite_state* vertex_impl::get_root_state() const { - outgoing_transitions_.push_back( &_outgoing_transition ); + raw_composite_states ancestors = get_ancestors( Y_NULLPTR ); + const composite_state* root = Y_NULLPTR; + if( ancestors.empty() ) + { + root = dynamic_cast< const composite_state* >( this ); + } + else + { + root = ancestors.back(); + } + return ( root ); +} + + +void vertex_impl::add_outgoing_transition( transition& _outgoing_transition ) +{ + if( has_no_guard( &_outgoing_transition ) ) + { + outgoing_transitions_.push_back( &_outgoing_transition ); + } + else + { + raw_transitions::const_iterator insert_position = find_first_transition_without_guard( outgoing_transitions_ ); + if( insert_position != outgoing_transitions_.end() ) + { +#ifdef Y_CPP03_BOOST + raw_transitions::iterator insert_position_03 = + outgoing_transitions_.begin() + + std::distance( const_cast(outgoing_transitions_).begin(), insert_position ); + outgoing_transitions_.insert( insert_position_03, &_outgoing_transition ); +#else + outgoing_transitions_.insert( insert_position, &_outgoing_transition ); +#endif + } + else + { + outgoing_transitions_.push_back( &_outgoing_transition ); + } + } } @@ -117,24 +172,28 @@ region* vertex_impl::LCA_region( const vertex& _rhs ) const region* lca = Y_NULLPTR; const raw_regions& ancestors_of_lhs = get_ancestors_as_regions(); const raw_regions& ancestors_of_rhs = _rhs.get_ancestors_as_regions(); - Y_ASSERT( ancestors_of_lhs.size() >= 1 && ancestors_of_rhs.size() >= 1, - "One of the ancestor region lists is empty!" ); - size_t r_idx = ancestors_of_rhs.size() - 1; - size_t l_idx = ancestors_of_lhs.size() - 1; - while( ancestors_of_rhs[ r_idx ] == ancestors_of_lhs[ l_idx ] ) - { - lca = ancestors_of_lhs[ l_idx ]; - if( ( l_idx == 0 ) || ( r_idx == 0 ) ) + if( ancestors_of_lhs.empty() || ancestors_of_rhs.empty() ) + { + Y_LOG( log_level::LL_SPAM, + "LCA region not found. This means one of the elements is the root state. The root state has no parent region." ); + } + else + { + size_t r_idx = ancestors_of_rhs.size() - 1; + size_t l_idx = ancestors_of_lhs.size() - 1; + while( ancestors_of_rhs[r_idx] == ancestors_of_lhs[l_idx] ) { - break; - } + lca = ancestors_of_lhs[l_idx]; + if( ( l_idx == 0 ) || ( r_idx == 0 ) ) + { + break; + } - --r_idx; - --l_idx; + --r_idx; + --l_idx; + } + Y_LOG( log_level::LL_SPAM, "LCA region found: '%'.", lca->get_name() ); } - - Y_ASSERT( lca, "No LCA_region has been found!" ); - Y_LOG( log_level::LL_SPAM, "LCA region found: '%'.", lca->get_name() ); return( lca ); } @@ -156,7 +215,6 @@ composite_state* vertex_impl::LCA_composite_state( const vertex& _rhs ) const { break; } - --r_idx; --l_idx; } @@ -185,4 +243,18 @@ void vertex_impl::add_ancestor_uri( uri& _uri ) const } +raw_transitions::const_iterator vertex_impl::find_first_transition_without_guard( const raw_transitions& _vector_of_transitions ) +{ + raw_transitions::const_iterator found_position = std::find_if( _vector_of_transitions.begin(), _vector_of_transitions.end(), + ( sxy::bind( &vertex_impl::has_no_guard, sxy::_1 ) ) ); + return( found_position ); +} + + +bool vertex_impl::has_no_guard( const transition* const _transition ) +{ + return ( !_transition->get_guard() ); +} + + } diff --git a/libyasmine/source/waiter.cpp b/libyasmine/source/waiter.cpp new file mode 100644 index 0000000..7ec01ec --- /dev/null +++ b/libyasmine/source/waiter.cpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016 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/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef Y_NO_LOGGING + + +#include "waiter.hpp" + + +namespace sxy +{ + + +waiter::waiter() + : done_mutex_(), + done_condition_variable_(), + done_() +{ + // Nothing to do... +} + + +waiter::~waiter() Y_NOEXCEPT +{ + // Nothing to do... +} + + +void waiter::wait() +{ + sxy::unique_lock lock( done_mutex_ ); + done_condition_variable_.wait( lock, sxy::bind( &waiter::is_done, this ) ); +} + + +void waiter::done() +{ + sxy::lock_guard lock( done_mutex_ ); + done_ = true; +} + + +bool waiter::is_done() +{ + // no locking necessary, only used within wait of condition variable + return( done_ ); +} + + +} + + +#endif diff --git a/yasmine/yasmine/yprintf.cpp b/libyasmine/source/yprintf.cpp similarity index 95% rename from yasmine/yasmine/yprintf.cpp rename to libyasmine/source/yprintf.cpp index 3dcb846..e02dba3 100644 --- a/yasmine/yasmine/yprintf.cpp +++ b/libyasmine/source/yprintf.cpp @@ -37,7 +37,8 @@ const char CAPS_X = 'X'; } -std::ostream& operator<<( std::ostream& _os, const sxy::format_settings& _format ) +// cppcheck-suppress unusedFunction +std::ostream& operator<<( std::ostream& _os, const sxy::format_settings& _format ) { if( !_format.correct_ ) { @@ -530,42 +531,32 @@ const char* yprintf_impl( std::ostream& _os, const char* _format, log_values::co } -void yprintf( std::ostream& _os, const char*const _format, const log_values& _values ) -{ +void yprintf( std::ostream& _os, const char * const _format, const log_values& _values ) +{ + Y_ASSERT_NO_LOG( _format, "No format string to parse was passed!" ); + const char* current_position = _format; + log_values::const_iterator _end = _values.end(); - log_values::const_iterator _position = _values.begin(); - const char* current_position = _format; - - bool printed = false; - for( ; _position != _end; ++_position ) + log_values::const_iterator _position = _values.begin(); + while( _position != _end ) { - printed = false; + bool printed = false; current_position = yprintf_impl( _os, current_position, _position, _end, printed ); - if( ( current_position != NULL ) && ( current_position[0] == '\0' ) ) + if( printed ) + { + ++_position; + } + if( current_position[0] == '\0' ) { break; } } + + yprintf( _os, current_position ); - if( printed ) + if( _position != _end ) { - if( _position != _end ) - { - ++_position; - } - } - - - if( !(( current_position != NULL ) && ( current_position[0] == '\0' )) ) - { - yprintf( _os, current_position ); - } - else - { - if( _position != _end ) - { - print_superfluous_parameters( _os, _values, _position ); - } + print_superfluous_parameters( _os, _values, _position ); } } diff --git a/yasmine/license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf b/license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf similarity index 100% rename from yasmine/license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf rename to license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf diff --git a/yasmine/license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf b/license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf similarity index 100% rename from yasmine/license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf rename to license/Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf diff --git a/yasmine/license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf b/license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf similarity index 100% rename from yasmine/license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf rename to license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf diff --git a/yasmine/license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf b/license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf similarity index 100% rename from yasmine/license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf rename to license/Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf diff --git a/yasmine/license/license.txt b/license/license.txt similarity index 100% rename from yasmine/license/license.txt rename to license/license.txt diff --git a/yasmine/yasmine.sln b/yasmine.sln similarity index 95% rename from yasmine/yasmine.sln rename to yasmine.sln index 84bc8dc..994653d 100644 --- a/yasmine/yasmine.sln +++ b/yasmine.sln @@ -1,215 +1,215 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yasmine", "yasmine\yasmine.vcxproj", "{A728DDFB-BE51-49B5-8593-4E89E024A500}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_yasmine", "hello_yasmine\hello_yasmine.vcxproj", "{C231C585-F237-4F08-8BF5-8DC7106599D4}" - ProjectSection(ProjectDependencies) = postProject - {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "license", "license", "{FBC833F8-033B-4400-8CBA-C71A32CF62B4}" - ProjectSection(SolutionItems) = preProject - license\license.txt = license\license.txt - license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf - license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf - license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf - license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "classic_farmroad", "classic_farmroad\classic_farmroad.vcxproj", "{DDCFB59A-D19C-4382-ACFD-747105EB8D03}" - ProjectSection(ProjectDependencies) = postProject - {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B7DF480E-DC38-410F-86E7-330696F7D5AB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "forty_two", "forty_two\forty_two.vcxproj", "{5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}" - ProjectSection(ProjectDependencies) = postProject - {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "events_with_parameters", "events_with_parameters\events_with_parameters.vcxproj", "{44767840-E79D-4049-B97B-867D32783090}" - ProjectSection(ProjectDependencies) = postProject - {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "substatemachines_and_variables", "substatemachines_and_variables\substatemachines_and_variables.vcxproj", "{E27E791D-29D2-4FAA-A683-D58228818F67}" - ProjectSection(ProjectDependencies) = postProject - {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - C++ 03|Win32 = Debug - C++ 03|Win32 - Debug - C++ 03|x64 = Debug - C++ 03|x64 - Debug - VS 2013|Win32 = Debug - VS 2013|Win32 - Debug - VS 2013|x64 = Debug - VS 2013|x64 - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release - C++ 03|Win32 = Release - C++ 03|Win32 - Release - C++ 03|x64 = Release - C++ 03|x64 - Release - VS 2013|Win32 = Release - VS 2013|Win32 - Release - VS 2013|x64 = Release - VS 2013|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|Win32.ActiveCfg = Debug|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|Win32.Build.0 = Debug|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|x64.ActiveCfg = Debug|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|x64.Build.0 = Debug|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|Win32.ActiveCfg = Release|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|Win32.Build.0 = Release|Win32 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|x64.ActiveCfg = Release|x64 - {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|x64.Build.0 = Release|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|Win32.ActiveCfg = Debug|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|Win32.Build.0 = Debug|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|x64.ActiveCfg = Debug|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|x64.Build.0 = Debug|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|Win32.ActiveCfg = Release|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|Win32.Build.0 = Release|Win32 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|x64.ActiveCfg = Release|x64 - {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|x64.Build.0 = Release|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|Win32.ActiveCfg = Debug|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|Win32.Build.0 = Debug|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|x64.ActiveCfg = Debug|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|x64.Build.0 = Debug|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|Win32.ActiveCfg = Release|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|Win32.Build.0 = Release|Win32 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|x64.ActiveCfg = Release|x64 - {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|x64.Build.0 = Release|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|Win32.Build.0 = Debug|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|x64.ActiveCfg = Debug|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|x64.Build.0 = Debug|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|Win32.ActiveCfg = Release|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|Win32.Build.0 = Release|Win32 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|x64.ActiveCfg = Release|x64 - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|x64.Build.0 = Release|x64 - {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 - {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 - {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 - {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 - {44767840-E79D-4049-B97B-867D32783090}.Debug|Win32.ActiveCfg = Debug|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Debug|Win32.Build.0 = Debug|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Debug|x64.ActiveCfg = Debug|x64 - {44767840-E79D-4049-B97B-867D32783090}.Debug|x64.Build.0 = Debug|x64 - {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 - {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 - {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 - {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 - {44767840-E79D-4049-B97B-867D32783090}.Release|Win32.ActiveCfg = Release|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Release|Win32.Build.0 = Release|Win32 - {44767840-E79D-4049-B97B-867D32783090}.Release|x64.ActiveCfg = Release|x64 - {44767840-E79D-4049-B97B-867D32783090}.Release|x64.Build.0 = Release|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|Win32.ActiveCfg = Debug|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|Win32.Build.0 = Debug|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|x64.ActiveCfg = Debug|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|x64.Build.0 = Debug|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|Win32.ActiveCfg = Release|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|Win32.Build.0 = Release|Win32 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|x64.ActiveCfg = Release|x64 - {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {C231C585-F237-4F08-8BF5-8DC7106599D4} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} - {DDCFB59A-D19C-4382-ACFD-747105EB8D03} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} - {44767840-E79D-4049-B97B-867D32783090} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} - {E27E791D-29D2-4FAA-A683-D58228818F67} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasmine", "libyasmine\libyasmine.vcxproj", "{A728DDFB-BE51-49B5-8593-4E89E024A500}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_yasmine", "examples\hello_yasmine\hello_yasmine.vcxproj", "{C231C585-F237-4F08-8BF5-8DC7106599D4}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "license", "license", "{FBC833F8-033B-4400-8CBA-C71A32CF62B4}" + ProjectSection(SolutionItems) = preProject + license\license.txt = license\license.txt + license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804.pdf + license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20160804_en.pdf + license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804.pdf + license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20160804_en.pdf + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "classic_farmroad", "examples\classic_farmroad\classic_farmroad.vcxproj", "{DDCFB59A-D19C-4382-ACFD-747105EB8D03}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B7DF480E-DC38-410F-86E7-330696F7D5AB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "forty_two", "examples\forty_two\forty_two.vcxproj", "{5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "events_with_parameters", "examples\events_with_parameters\events_with_parameters.vcxproj", "{44767840-E79D-4049-B97B-867D32783090}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "substatemachines_and_variables", "examples\substatemachines_and_variables\substatemachines_and_variables.vcxproj", "{E27E791D-29D2-4FAA-A683-D58228818F67}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug - C++ 03|Win32 = Debug - C++ 03|Win32 + Debug - C++ 03|x64 = Debug - C++ 03|x64 + Debug - VS 2013|Win32 = Debug - VS 2013|Win32 + Debug - VS 2013|x64 = Debug - VS 2013|x64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release - C++ 03|Win32 = Release - C++ 03|Win32 + Release - C++ 03|x64 = Release - C++ 03|x64 + Release - VS 2013|Win32 = Release - VS 2013|Win32 + Release - VS 2013|x64 = Release - VS 2013|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|Win32.ActiveCfg = Debug|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|Win32.Build.0 = Debug|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|x64.ActiveCfg = Debug|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug|x64.Build.0 = Debug|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|Win32.ActiveCfg = Release|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|Win32.Build.0 = Release|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|x64.ActiveCfg = Release|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release|x64.Build.0 = Release|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|Win32.ActiveCfg = Debug|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|Win32.Build.0 = Debug|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|x64.ActiveCfg = Debug|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug|x64.Build.0 = Debug|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|Win32.ActiveCfg = Release|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|Win32.Build.0 = Release|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|x64.ActiveCfg = Release|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release|x64.Build.0 = Release|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|Win32.ActiveCfg = Debug|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|Win32.Build.0 = Debug|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|x64.ActiveCfg = Debug|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug|x64.Build.0 = Debug|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|Win32.ActiveCfg = Release|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|Win32.Build.0 = Release|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|x64.ActiveCfg = Release|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release|x64.Build.0 = Release|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|Win32.ActiveCfg = Debug|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|Win32.Build.0 = Debug|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|x64.ActiveCfg = Debug|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug|x64.Build.0 = Debug|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|Win32.ActiveCfg = Release|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|Win32.Build.0 = Release|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|x64.ActiveCfg = Release|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release|x64.Build.0 = Release|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug|Win32.ActiveCfg = Debug|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug|Win32.Build.0 = Debug|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug|x64.ActiveCfg = Debug|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug|x64.Build.0 = Debug|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release|Win32.ActiveCfg = Release|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release|Win32.Build.0 = Release|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release|x64.ActiveCfg = Release|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release|x64.Build.0 = Release|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|Win32.ActiveCfg = Debug|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|Win32.Build.0 = Debug|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|x64.ActiveCfg = Debug|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug|x64.Build.0 = Debug|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|Win32.ActiveCfg = Release|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|Win32.Build.0 = Release|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|x64.ActiveCfg = Release|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C231C585-F237-4F08-8BF5-8DC7106599D4} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {DDCFB59A-D19C-4382-ACFD-747105EB8D03} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {44767840-E79D-4049-B97B-867D32783090} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {E27E791D-29D2-4FAA-A683-D58228818F67} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + EndGlobalSection +EndGlobal diff --git a/yasmine/classic_farmroad/CMakeLists.txt b/yasmine/classic_farmroad/CMakeLists.txt deleted file mode 100644 index 89232d1..0000000 --- a/yasmine/classic_farmroad/CMakeLists.txt +++ /dev/null @@ -1,171 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(classic_farmroad) - -set(CMAKE_VERBOSE_MAKEFILE, 1) - -set(HEADER_FILES "./../yasmine/*.hpp") -file(GLOB classic_farmroad_SRC "./../classic_farmroad/*.cpp" ${HEADER_FILES}) - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - else() - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -g -Wno-unknown-pragmas -D \"Y_CPP03_BOOST\"") - else() - set(extra_flags "${extra_flags} -std=c++14 -Wall -g") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("Y_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${Y_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"Y_NO_LOGGING\"") - endif() - - option("Y_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${Y_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"Y_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("Y_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${Y_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_NO_LOGGING\"") - endif() - - option("Y_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${Y_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - -endif() - -# for release -if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - -# for debug -elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") -endif() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") - -if("${CPP_VERSION}" STREQUAL "11" OR "${CPP_VERSION}" STREQUAL "14") - add_executable(classic_farmroad ${classic_farmroad_SRC}) -endif() - -include_directories("./../yasmine") - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "11" OR "${CPP_VERSION}" STREQUAL "14") - target_link_libraries (classic_farmroad LINK_PUBLIC yasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (classic_farmroad LINK_PUBLIC yasmine) -endif() - - -if("${CPP_VERSION}" STREQUAL "11" OR "${CPP_VERSION}" STREQUAL "14") - install(TARGETS classic_farmroad DESTINATION bin) -endif() \ No newline at end of file diff --git a/yasmine/classic_farmroad/intersection.cpp b/yasmine/classic_farmroad/intersection.cpp deleted file mode 100644 index f78b0e7..0000000 --- a/yasmine/classic_farmroad/intersection.cpp +++ /dev/null @@ -1,413 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016 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/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "intersection.hpp" - -#include - -#include "yasmine.hpp" - - -namespace sxy -{ - - -namespace -{ - - -const event_id DETECTOR_ON = 1; -Y_EVENT_WITH_ID( detector_on_event, DETECTOR_ON ); - -const event_id DETECTOR_OFF = 2; -Y_EVENT_WITH_ID( detector_off_event, DETECTOR_OFF ); - -const event_id TIMER_HIGHWAY_MINIMUM_TIME = 3; -Y_EVENT_WITH_ID( timer_highway_minimum_time_event, TIMER_HIGHWAY_MINIMUM_TIME ); - -const event_id TIMER_PHASE_1 = 4; -Y_EVENT_WITH_ID( timer_phase_1_event, TIMER_PHASE_1 ); - -const event_id TIMER_PHASE_2 = 5; -Y_EVENT_WITH_ID( timer_phase_2_event, TIMER_PHASE_2 ); - -const event_id TIMER_FARMROAD_MAXIMUM_TIME = 6; -Y_EVENT_WITH_ID( timer_farmroad_maximum_time_event, TIMER_FARMROAD_MAXIMUM_TIME ); - -const event_id EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED = 7; -Y_EVENT_WITH_ID( event_farmroad_maximum_time_elapsed_event, EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED ); - -const event_ids EVENTS_EXIT_FARMROAD_OPEN = -{ detector_on_event::get_event_id(), event_farmroad_maximum_time_elapsed_event::get_event_id() }; - -const sxy::milliseconds TIMER_HIGHWAY_MINIMUM_TIME_DURATION( 5 ); -const sxy::milliseconds TIMER_PHASE_1_DURATION( 1 ); -const sxy::milliseconds TIMER_PHASE_2_DURATION( 1 ); -const sxy::milliseconds TIMER_FARMROAD_MAXIMUM_TIME_DURATION( 3 ); -const std::string FARMROAD_ASCII_ART = "--- "; -const std::string HIGHWAY_ASCII_ART = "==== "; - -} - - -intersection::intersection() - : detector_callback(), - intersection_state_machine_( "intersection state machine" ), - highway_traffic_light_( "highway traffic light", HIGHWAY_ASCII_ART ), - farmroad_traffic_light_( "farmroad traffic light", FARMROAD_ASCII_ART ), - timed_event_creator_( intersection_state_machine_ ), - detector_( *this ), - farmroad_maximum_time_event_handle_() -{ - build_intersection_state_machine(); -} - - -intersection::~intersection() Y_NOEXCEPT -{ - // Nothing to do... -} - - -bool intersection::start() -{ - bool started = false; - state_machine_defects defects; - intersection_state_machine_.check( defects ); - if( defects.empty() ) - { - farmroad_traffic_light_.start(); - highway_traffic_light_.start(); - timed_event_creator_.start(); - intersection_state_machine_.start_state_machine(); - detector_.start(); - started = true; - } - else - { - std::cout << "The state machine is defect." << std::endl; - write_defects_to_log( defects ); - } - - return( started ); -} - - -void intersection::stop() -{ - detector_.stop(); - intersection_state_machine_.stop_state_machine(); - timed_event_creator_.stop(); - highway_traffic_light_.stop(); - farmroad_traffic_light_.stop(); -} - - -void intersection::detector_on() -{ - std::cout << "Detector is on." << std::endl; - intersection_state_machine_.fire_event( detector_on_event::create() ); -} - - -void intersection::detector_off() -{ - std::cout << "Detector is off." << std::endl; - intersection_state_machine_.fire_event( detector_off_event::create() ); -} - - -int intersection::fire_timed_event( const sxy::milliseconds _milliseconds, const event_sptr _event ) -{ - handle_type event_handle = - timed_event_creator_.create_event_creation_request( sxy::milliseconds( _milliseconds ), _event ); - return( event_handle ); -} - - -void intersection::highway_open_entry() -{ - Y_LOG( log_level::LL_INFO, "Highway open." ); - highway_traffic_light_.switch_to_green(); - fire_timed_event( TIMER_HIGHWAY_MINIMUM_TIME_DURATION, timer_highway_minimum_time_event::create() ); -} - - -void intersection::highway_open_exit() const -{ - Y_LOG( log_level::LL_INFO, "Highway closed." ); -} - - -void intersection::switching_to_farmroad_phase_1() -{ - Y_LOG( log_level::LL_INFO, "Switching highway to farmroad. Phase 1." ); - highway_traffic_light_.switch_to_yellow(); - farmroad_traffic_light_.switch_to_red_yellow(); - fire_timed_event( TIMER_PHASE_1_DURATION, timer_phase_1_event::create() ); -} - - -void intersection::switching_to_farmroad_phase_2() -{ - Y_LOG( log_level::LL_INFO, "Switching highway to farmroad. Phase 2." ); - highway_traffic_light_.switch_to_red(); - fire_timed_event( TIMER_PHASE_2_DURATION, timer_phase_2_event::create() ); -} - - -void intersection::farmroad_open_entry() -{ - Y_LOG( log_level::LL_INFO, "Farmroad open." ); - farmroad_traffic_light_.switch_to_green(); - farmroad_maximum_time_event_handle_ = fire_timed_event( TIMER_FARMROAD_MAXIMUM_TIME_DURATION, - timer_farmroad_maximum_time_event::create() ); -} - - -void intersection::farmroad_open_exit() const -{ - Y_LOG( log_level::LL_INFO, "Farmroad closed." ); -} - - -void intersection::minimum_time_not_elapsed() const -{ - Y_LOG( log_level::LL_INFO, "Minimum time not elapsed." ); -} - - -void intersection::minimum_time_elapsed() const -{ - Y_LOG( log_level::LL_INFO, "Minimum time elapsed." ); -} - - -void intersection::minimum_time_not_elapsed_farmroad_waiting() const -{ - Y_LOG( log_level::LL_INFO, "Minimum time not elapsed. Farmroad waiting." ); -} - - -void intersection::switching_to_highway_phase_1() -{ - Y_LOG( log_level::LL_INFO, "Switching farmroad to highway. Phase 1." ); - highway_traffic_light_.switch_to_red_yellow(); - farmroad_traffic_light_.switch_to_yellow(); - fire_timed_event( TIMER_PHASE_1_DURATION, timer_phase_1_event::create() ); -} - - -void intersection::switching_to_highway_phase_2() -{ - Y_LOG( log_level::LL_INFO, "Switching farmroad to highway. Phase 2." ); - farmroad_traffic_light_.switch_to_red(); - fire_timed_event( TIMER_PHASE_2_DURATION, timer_phase_2_event::create() ); -} - - -bool intersection::check_detector_is_on() -{ - return( detector_.is_on() ); -} - - -bool intersection::check_detector_is_off() -{ - return( !detector_.is_on() ); -} - - -void intersection::cancel_timer_event_on_detector_off( const sxy::event& _event ) -{ - if( _event.get_id() == detector_off_event::get_event_id() ) - { - if( farmroad_maximum_time_event_handle_ > 0 ) - { - Y_LOG( log_level::LL_INFO, "Try to cancel event with handle %.", farmroad_maximum_time_event_handle_ ); - if( timed_event_creator_.cancel( farmroad_maximum_time_event_handle_ ) ) - { - Y_LOG( log_level::LL_INFO, "Event with handle % was cancelled.", farmroad_maximum_time_event_handle_ ); - } - else - { - Y_LOG( log_level::LL_INFO, "Event with handle % could not be canceled.", farmroad_maximum_time_event_handle_ ); - } - - farmroad_maximum_time_event_handle_ = 0; - } - else - { - Y_LOG( log_level::LL_INFO, "There is no event to be cancelled on detector off." ); - } - } -} - - -void intersection::build_intersection_state_machine() -{ - composite_state& root = intersection_state_machine_.get_root_state(); - region& main_region = root.add_region( "main_region" ); - initial_pseudostate& initial_pseudostate = main_region.add_initial_pseudostate( "initial" ); - - // highway open -#ifdef Y_CPP03_BOOST - composite_state& l_highway_open = - main_region.add_composite_state( "highway open", - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, highway_open_entry ), - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, highway_open_exit ) ); -#else - composite_state& l_highway_open = - main_region.add_composite_state( "highway open", - Y_BEHAVIOUR_METHOD_NO_EVENT( highway_open_entry ), - Y_BEHAVIOUR_METHOD_NO_EVENT( highway_open_exit ) ); -#endif - - region& highway_open_region = l_highway_open.add_region( "highway region" ); - sxy::initial_pseudostate& initial_highway = highway_open_region.add_initial_pseudostate( "initial highway" ); - simple_state& initialize_dummy = highway_open_region.add_simple_state( "initialize dummy" ); - junction& detector_junction = highway_open_region.add_junction( "detector junction" ); - -#ifdef Y_CPP03_BOOST - simple_state& l_minimum_time_not_elapsed = highway_open_region.add_simple_state( "minimum time not elapsed", - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, minimum_time_not_elapsed ) ); - simple_state& l_minimum_time_elapsed = highway_open_region.add_simple_state( "minimum time elapsed", - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, minimum_time_elapsed ) ); - simple_state& l_minimum_time_not_elapsed_farmroad_waiting = highway_open_region.add_simple_state( - "Minimum time not elapsed and farmroad waiting", - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, minimum_time_not_elapsed_farmroad_waiting ) ); -#else - simple_state& l_minimum_time_not_elapsed = highway_open_region.add_simple_state( "minimum time not elapsed", - Y_BEHAVIOUR_METHOD_NO_EVENT( minimum_time_not_elapsed ) ); - simple_state& l_minimum_time_elapsed = highway_open_region.add_simple_state( "minimum time elapsed", - Y_BEHAVIOUR_METHOD_NO_EVENT( minimum_time_elapsed ) ); - simple_state& l_minimum_time_not_elapsed_farmroad_waiting = highway_open_region.add_simple_state( - "Minimum time not elapsed and farmroad waiting", - Y_BEHAVIOUR_METHOD_NO_EVENT( minimum_time_not_elapsed_farmroad_waiting ) ); -#endif - - - final_state& highway_finished = highway_open_region.add_final_state( "highway finished" ); - - // switching highway to farmroad - composite_state& switching_to_farmroad = main_region.add_composite_state( "switching highway to farmroad" ); - region& switching_to_farmroad_region = switching_to_farmroad.add_region( "region switching to farmroad" ); - sxy::initial_pseudostate& initial_switching_to_farmroad = - switching_to_farmroad_region.add_initial_pseudostate( "initial switching highway to farmroad" ); - -#ifdef Y_CPP03_BOOST - simple_state& l_switching_to_farmroad_phase_1 = switching_to_farmroad_region.add_simple_state( - "switching to farmroad phase 1", Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, switching_to_farmroad_phase_1 ) ); - simple_state& state_switching_to_farmroad_phase_2 = switching_to_farmroad_region.add_simple_state( - "switching to farmroad phase 2", behaviour_function(), - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, switching_to_farmroad_phase_2 ) ); - simple_state& farmroad_open = - main_region.add_simple_state( "farmroad open", behaviour_function(), - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, farmroad_open_entry ), - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, farmroad_open_exit ) ); -#else - simple_state& l_switching_to_farmroad_phase_1 = switching_to_farmroad_region.add_simple_state( - "switching to farmroad phase 1", Y_BEHAVIOUR_METHOD_NO_EVENT( switching_to_farmroad_phase_1 ) ); - simple_state& state_switching_to_farmroad_phase_2 = switching_to_farmroad_region.add_simple_state( - "switching to farmroad phase 2", Y_NULLPTR, Y_BEHAVIOUR_METHOD_NO_EVENT( switching_to_farmroad_phase_2 ) ); - simple_state& farmroad_open = - main_region.add_simple_state( "farmroad open", Y_NULLPTR, - Y_BEHAVIOUR_METHOD_NO_EVENT( farmroad_open_entry ), Y_BEHAVIOUR_METHOD_NO_EVENT( farmroad_open_exit ) ); -#endif - - final_state& switching_to_farmroad_finished = - switching_to_farmroad_region.add_final_state( "switching to farmroad finished" ); - - // switching farmroad to highway - composite_state& switching_to_highway = main_region.add_composite_state( "switching farmroad to highway" ); - region& switching_to_highway_region = switching_to_highway.add_region( "region switching to highway" ); - sxy::initial_pseudostate& initial_switching_to_highway = - switching_to_highway_region.add_initial_pseudostate( "initial switching to highway" ); - -#ifdef Y_CPP03_BOOST - simple_state& l_switching_to_highway_phase_1 = switching_to_highway_region.add_simple_state( - "switching to highway phase 1", behaviour_function(), - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, switching_to_highway_phase_1 ) ); - simple_state& l_switching_to_highway_phase_2 = switching_to_highway_region.add_simple_state( - "switching to highway phase 2", behaviour_function(), - Y_BEHAVIOUR_METHOD_NO_EVENT( intersection, switching_to_highway_phase_2 ) ); -#else - simple_state& l_switching_to_highway_phase_1 = switching_to_highway_region.add_simple_state( - "switching to highway phase 1", Y_NULLPTR, Y_BEHAVIOUR_METHOD_NO_EVENT( switching_to_highway_phase_1 ) ); - simple_state& l_switching_to_highway_phase_2 = switching_to_highway_region.add_simple_state( - "switching to highway phase 2", Y_NULLPTR, Y_BEHAVIOUR_METHOD_NO_EVENT( switching_to_highway_phase_2 ) ); -#endif - - - final_state& switching_to_highway_finished = - switching_to_highway_region.add_final_state( "switching to highway finished" ); - - // transitions - // in main region - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, initial_pseudostate, l_highway_open ); - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, l_highway_open, switching_to_farmroad ); - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, switching_to_farmroad, farmroad_open ); -#ifdef Y_CPP03_BOOST - intersection_state_machine_.add_transition( EVENTS_EXIT_FARMROAD_OPEN, farmroad_open, switching_to_highway, - transition_kind::EXTERNAL, constraint_function(), - Y_BEHAVIOUR_METHOD( intersection, cancel_timer_event_on_detector_off ) ); -#else - intersection_state_machine_.add_transition( EVENTS_EXIT_FARMROAD_OPEN, farmroad_open, switching_to_highway, - transition_kind::EXTERNAL, Y_NULLPTR, Y_BEHAVIOUR_METHOD( cancel_timer_event_on_detector_off ) ); -#endif - - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, switching_to_highway, l_highway_open ); - - // inside highway open - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, initial_highway, initialize_dummy ); - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, initialize_dummy, detector_junction ); -#ifdef Y_CPP03_BOOST - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, detector_junction, - l_minimum_time_not_elapsed_farmroad_waiting, transition_kind::EXTERNAL, - Y_GUARD_METHOD_NO_EVENT( intersection, check_detector_is_on ) ); - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, detector_junction, l_minimum_time_not_elapsed, - transition_kind::EXTERNAL, Y_GUARD_METHOD_NO_EVENT( intersection, check_detector_is_off ) ); -#else - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, detector_junction, - l_minimum_time_not_elapsed_farmroad_waiting, transition_kind::EXTERNAL, - Y_GUARD_METHOD_NO_EVENT( check_detector_is_on ) ); - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, detector_junction, l_minimum_time_not_elapsed, - transition_kind::EXTERNAL, Y_GUARD_METHOD_NO_EVENT( check_detector_is_off ) ); -#endif - - intersection_state_machine_.add_transition( - detector_on_event::get_event_id(), l_minimum_time_not_elapsed, l_minimum_time_not_elapsed_farmroad_waiting ); - intersection_state_machine_.add_transition( - timer_highway_minimum_time_event::get_event_id(), l_minimum_time_not_elapsed, l_minimum_time_elapsed ); - intersection_state_machine_.add_transition( - timer_highway_minimum_time_event::get_event_id(), l_minimum_time_not_elapsed_farmroad_waiting, highway_finished ); - intersection_state_machine_.add_transition( - detector_on_event::get_event_id(), l_minimum_time_elapsed, highway_finished ); - - // inside switching highway to farmroad - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, initial_switching_to_farmroad, - l_switching_to_farmroad_phase_1 ); - intersection_state_machine_.add_transition( - timer_phase_1_event::get_event_id(), l_switching_to_farmroad_phase_1, state_switching_to_farmroad_phase_2 ); - intersection_state_machine_.add_transition( - timer_phase_2_event::get_event_id(), state_switching_to_farmroad_phase_2, switching_to_farmroad_finished ); - - // inside switching farmroad to highway - intersection_state_machine_.add_transition( COMPLETION_EVENT_ID, initial_switching_to_highway, - l_switching_to_highway_phase_1 ); - intersection_state_machine_.add_transition( - timer_phase_1_event::get_event_id(), l_switching_to_highway_phase_1, l_switching_to_highway_phase_2 ); - intersection_state_machine_.add_transition( - timer_phase_2_event::get_event_id(), l_switching_to_highway_phase_2, switching_to_highway_finished ); -} - - -} diff --git a/yasmine/forty_two/forty_two.cpp b/yasmine/forty_two/forty_two.cpp deleted file mode 100644 index c75164d..0000000 --- a/yasmine/forty_two/forty_two.cpp +++ /dev/null @@ -1,395 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016 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/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "forty_two.hpp" - -#include -#include -#include - -#ifdef Y_PROFILER - #include "conversion.hpp" -#endif - -namespace sxy -{ - -Y_EVENT_WITH_ID( event_A, 1 ); -Y_EVENT_WITH_ID( event_B, 2 ); -Y_EVENT_WITH_ID( event_C, 3 ); -Y_EVENT_WITH_ID( event_D, 4 ); -Y_EVENT_WITH_ID( event_E, 5 ); -Y_EVENT_WITH_ID( event_F, 6 ); -Y_EVENT_WITH_ID( event_G, 7 ); -Y_EVENT_WITH_ID( event_H, 8 ); -Y_EVENT_WITH_ID( event_I, 9 ); -Y_EVENT_WITH_ID( event_J, 10 ); -Y_EVENT_WITH_ID( event_K, 11 ); -Y_EVENT_WITH_ID( event_L, 12 ); -Y_EVENT_WITH_ID( event_M, 13 ); -Y_EVENT_WITH_ID( event_N, 14 ); -Y_EVENT_WITH_ID( event_O, 15 ); -Y_EVENT_WITH_ID( event_P, 16 ); -Y_EVENT_WITH_ID( event_Q, 17 ); -Y_EVENT_WITH_ID( event_R, 18 ); -Y_EVENT_WITH_ID( event_S, 19 ); -Y_EVENT_WITH_ID( event_T, 20 ); - - -forty_two::forty_two( const sxy::uint32_t _max_iterations ) - : state_machine_( build_state_machine() ), - iterations_( 0 ), - max_iterations_( _max_iterations ) -{ - Y_ASSERT( check_state_machine(), "State machine has defects!" ); - run(); -} - - -forty_two::~forty_two() Y_NOEXCEPT -{ - // Nothing to do... -} - - -forty_two::state_machine_uptr forty_two::build_state_machine() -{ - Y_UNIQUE_PTR< state_machine > l_state_machine = Y_MAKE_UNIQUE< state_machine >( "forty two state machine" ); - composite_state& root_state = l_state_machine->get_root_state(); - region& main_region = root_state.add_region( "main region" ); - initial_pseudostate& i1 = main_region.add_initial_pseudostate( "initial pseudostate 1" ); -#ifdef Y_CPP03_BOOST - simple_state& s1 = - main_region.add_simple_state( "s1", Y_BEHAVIOUR_METHOD_NO_EVENT( forty_two, increment_iterations ) ); -#else - simple_state& s1 = main_region.add_simple_state( "s1", Y_BEHAVIOUR_METHOD_NO_EVENT( increment_iterations ) ); -#endif - simple_state& s2 = main_region.add_simple_state( "s2" ); - composite_state& s3 = main_region.add_composite_state( "s3" ); - region& r3_1 = s3.add_region( "s3_r1" ); - region& r3_2 = s3.add_region( "s3_r2" ); - region& r3_3 = s3.add_region( "s3_r3" ); - initial_pseudostate& i2 = r3_1.add_initial_pseudostate( "initial pseudostate 2" ); - simple_state& s3_1_1 = r3_1.add_simple_state( "s3_r1_s1" ); - final_state& final1 = r3_1.add_final_state( "final state 1" ); - initial_pseudostate& i3 = r3_2.add_initial_pseudostate( "initial pseudostate 3" ); - composite_state& s3_2_1 = r3_2.add_composite_state( "s3_r2_s1" ); - region& r3_2_1_1 = s3_2_1.add_region( "s3_r2_s1_r1" ); - initial_pseudostate& i4 = r3_2_1_1.add_initial_pseudostate( "initial pseudostate 4" ); - composite_state& s3_2_1_1_1 = r3_2_1_1.add_composite_state( "s3_r2_s1_r1_s1" ); - region& r3_2_1_1_1_1 = s3_2_1_1_1.add_region( "s3_r2_s1_r1_s1_r1" ); - initial_pseudostate& i5 = r3_2_1_1_1_1.add_initial_pseudostate( "initial pseudostate 5" ); - simple_state& s3_2_1_1_1_1_1 = r3_2_1_1_1_1.add_simple_state( "s3_r2_s1_r1_s1_r1_s1" ); - final_state& final2 = r3_2.add_final_state( "final state 2" ); - initial_pseudostate& i6 = r3_3.add_initial_pseudostate( "initial pseudostate 6" ); - simple_state& s3_3_1 = r3_3.add_simple_state( "s3_r3_s1" ); - final_state& final3 = r3_3.add_final_state( "final state 3" ); - simple_state& s4 = main_region.add_simple_state( "s4" ); - composite_state& s5 = main_region.add_composite_state( "s5" ); - region& r5_1 = s5.add_region( "s5_r1" ); - composite_state& s5_1_1 = r5_1.add_composite_state( "s5_r1_s1" ); - region& r5_1_1_1 = s5_1_1.add_region( "s5_r1_s1_r1" ); - composite_state& s5_1_1_1_1 = r5_1_1_1.add_composite_state( "s5_r1_s1_r1_s1" ); - region& r5_1_1_1_1_1 = s5_1_1_1_1.add_region( "s5_r1_s1_r1_s1_r1" ); - simple_state& s5_1_1_1_1_1_1 = r5_1_1_1_1_1.add_simple_state( "s5_r1_s1_r1_s1_r1_s1" ); - simple_state& s5_1_1_1_1_1_2 = r5_1_1_1_1_1.add_simple_state( "s5_r1_s1_r1_s1_r1_s2" ); - exit_point& exit1 = s5_1_1_1_1.add_exit_point( "exit1" ); - exit_point& exit2 = s5.add_exit_point( "exit2" ); - simple_state& s6 = main_region.add_simple_state( "s6" ); - composite_state& s7 = main_region.add_composite_state( "s7" ); - region& r7_1 = s7.add_region( "s7_r1" ); - composite_state& s7_1_1 = r7_1.add_composite_state( "s7_r1_s1" ); - region& r7_1_1_1 = s7_1_1.add_region( "s7_r1_s1_r1" ); - composite_state& s7_1_1_1_1 = r7_1_1_1.add_composite_state( "s7_r1_s1_r1_s1" ); - region& r7_1_1_1_1_1 = s7_1_1_1_1.add_region( "s7_r1_s1_r1_s1_r1" ); - composite_state& s7_1_1_1_1_1_1 = r7_1_1_1_1_1.add_composite_state( "s7_r1_s1_r1_s1_r1_s1" ); - region& r7_1_1_1_1_1_1_1 = s7_1_1_1_1_1_1.add_region( "s7_r1_s1_r1_s1_r1_s1_r1" ); - simple_state& s7_1_1_1_1_1_1_1_1 = r7_1_1_1_1_1_1_1.add_simple_state( "s7_r1_s1_r1_s1_r1_s1_r1_s1" ); - entry_point& entry1 = s7_1_1_1_1.add_entry_point( "entry1" ); - entry_point& entry2 = s7.add_entry_point( "entry2" ); - simple_state& s8 = main_region.add_simple_state( "s8" ); - simple_state& s9 = main_region.add_simple_state( "s9" ); - composite_state& s10 = main_region.add_composite_state( "s10" ); - region& r10_1 = s10.add_region( "s10_r1" ); - initial_pseudostate& i7 = r10_1.add_initial_pseudostate( "initial pseudostate 7" ); - composite_state& s10_1_1 = r10_1.add_composite_state( "s10_r1_s1" ); - region& r10_1_1_1 = s10_1_1.add_region( "s10_r1_s1_r1" ); - initial_pseudostate& i8 = r10_1_1_1.add_initial_pseudostate( "initial pseudostate 8" ); - simple_state& s10_1_1_1_1 = r10_1_1_1.add_simple_state( "s10_r1_s1_r1_s1" ); - composite_state& s10_1_1_1_2 = r10_1_1_1.add_composite_state( "s10_r1_s1_r1_s2" ); - region& r10_1_1_1_2_1 = s10_1_1_1_2.add_region( "s10_r1_s1_r1_s2_r1" ); - initial_pseudostate& i9 = r10_1_1_1_2_1.add_initial_pseudostate( "initial pseudostate 9" ); - simple_state& s10_1_1_1_2_1_1 = r10_1_1_1_2_1.add_simple_state( "r10_r1_s1_r1_s2_r1_s1" ); - simple_state& s10_1_2 = r10_1.add_simple_state( "s10_r1_s2" ); - simple_state& s10_1_3 = r10_1.add_simple_state( "s10_r1_s3" ); - shallow_history& shallow_history1 = s10.add_shallow_history( "shallow history 1" ); - simple_state& s11 = main_region.add_simple_state( "s11" ); - simple_state& s12 = main_region.add_simple_state( "s12" ); - composite_state& s13 = main_region.add_composite_state( "s13" ); - region& r13_1 = s13.add_region( "s13_r1" ); - initial_pseudostate& i10 = r13_1.add_initial_pseudostate( "initial pseudostate 10" ); - composite_state& s13_1_1 = r13_1.add_composite_state( "s13_r1_s1" ); - region& r13_1_1_1 = s13_1_1.add_region( "s13_r1_s1_r1" ); - initial_pseudostate& i11 = r13_1_1_1.add_initial_pseudostate( "initial pseudostate 11" ); - simple_state& s13_1_1_1_1 = r13_1_1_1.add_simple_state( "s13_r1_s1_r1_s1" ); - composite_state& s13_1_1_1_2 = r13_1_1_1.add_composite_state( "s13_r1_s1_r1_s2" ); - region& r13_1_1_1_2_1 = s13_1_1_1_2.add_region( "s13_r1_s1_r1_s2_r1" ); - initial_pseudostate& i12 = r13_1_1_1_2_1.add_initial_pseudostate( "initial pseudostate 12" ); - simple_state& s13_1_1_1_2_1_1 = r13_1_1_1_2_1.add_simple_state( "r13_r1_s1_r1_s2_r1_s1" ); - simple_state& s13_1_2 = r13_1.add_simple_state( "s13_r1_s2" ); - simple_state& s13_1_3 = r13_1.add_simple_state( "s13_r1_s3" ); - shallow_history& deep_history1 = s13.add_shallow_history( "deep history 1" ); - simple_state& s14 = main_region.add_simple_state( "s14" ); - simple_state& s15 = main_region.add_simple_state( "s15" ); - fork& fork1 = main_region.add_fork( "fork 1" ); - composite_state& s16 = main_region.add_composite_state( "s16" ); - region& r16_1 = s16.add_region( "s16_r1" ); - region& r16_2 = s16.add_region( "s16_r2" ); - region& r16_3 = s16.add_region( "s16_r3" ); - region& r16_4 = s16.add_region( "s16_r4" ); - initial_pseudostate& i13 = r16_1.add_initial_pseudostate( "initial pseudostate 13" ); - simple_state& s16_1_1 = r16_1.add_simple_state( "s16_r1_s1" ); - simple_state& s16_1_2 = r16_1.add_simple_state( "s16_r1_s2" ); - simple_state& s16_1_3 = r16_1.add_simple_state( "s16_r1_s3" ); - simple_state& s16_2_1 = r16_2.add_simple_state( "s16_r2_s1" ); - simple_state& s16_2_2 = r16_2.add_simple_state( "s16_r2_s2" ); - simple_state& s16_2_3 = r16_2.add_simple_state( "s16_r2_s3" ); - simple_state& s16_3_1 = r16_3.add_simple_state( "s16_r3_s1" ); - simple_state& s16_3_2 = r16_3.add_simple_state( "s16_r3_s2" ); - simple_state& s16_4_1 = r16_4.add_simple_state( "s16_r4_s1" ); - simple_state& s16_4_2 = r16_4.add_simple_state( "s16_r4_s2" ); - simple_state& s16_4_3 = r16_4.add_simple_state( "s16_r4_s3" ); - simple_state& s17 = main_region.add_simple_state( "s17" ); - join& join1 = main_region.add_join( "join 1" ); - simple_state& s18 = main_region.add_simple_state( "s18" ); - choice& choice1 = main_region.add_choice( "choice 1" ); - simple_state& s19 = main_region.add_simple_state( "s19" ); - junction& junction1 = main_region.add_junction( "junction 1" ); - simple_state& s20 = main_region.add_simple_state( "s20" ); - simple_state& s21 = main_region.add_simple_state( "s21" ); - simple_state& s22 = main_region.add_simple_state( "s22" ); - sxy::event_ids deferred_events_ids; - deferred_events_ids.push_back( event_S::get_event_id() ); - simple_state& s23 = main_region.add_simple_state( "s23", deferred_events_ids ); - simple_state& s24 = main_region.add_simple_state( "s24" ); - junction& junction2 = main_region.add_junction( "junction 2" ); - terminate_pseudostate& terminate_pseudostate_1 = main_region.add_terminate_pseudostate( "terminate pseudostate 1" ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i1, s1 ); - l_state_machine->add_transition( event_B::get_event_id(), s1, s2 ); - l_state_machine->add_transition( event_A::get_event_id(), s1, s3 ); - l_state_machine->add_transition( event_C::get_event_id(), s3, s2 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i2, s3_1_1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s3_1_1, final1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i3, s3_2_1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i4, s3_2_1_1_1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i5, s3_2_1_1_1_1_1 ); - l_state_machine->add_transition( event_D::get_event_id(), s3_2_1_1_1_1_1, final2 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i6, s3_3_1 ); - l_state_machine->add_transition( event_C::get_event_id(), s3_3_1, final3 ); - l_state_machine->add_transition( event_A::get_event_id(), s3, s4 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s3, s5_1_1_1_1_1_1 ); - l_state_machine->add_transition( event_A::get_event_id(), s5_1_1_1_1_1_1, s5_1_1_1_1_1_2 ); - l_state_machine->add_transition( event_E::get_event_id(), s5_1_1_1_1_1_1, exit1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, exit1, exit2 ); - l_state_machine->add_transition( event_E::get_event_id(), s5, s6 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, exit2, entry2 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, entry2, entry1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, entry1, s7_1_1_1_1_1_1_1_1 ); - l_state_machine->add_transition( event_F::get_event_id(), s7, s8 ); - l_state_machine->add_transition( event_A::get_event_id(), s7, s9 ); - l_state_machine->add_transition( event_F::get_event_id(), s7_1_1_1_1_1_1_1_1, s10 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i7, s10_1_2 ); - l_state_machine->add_transition( event_A::get_event_id(), s10_1_2, s10_1_3 ); - l_state_machine->add_transition( event_G::get_event_id(), s10_1_2, s10_1_1 ); - l_state_machine->add_transition( event_A::get_event_id(), s10_1_1, s10_1_3 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i8, s10_1_1_1_1 ); - l_state_machine->add_transition( event_H::get_event_id(), s10_1_1_1_1, s10_1_1_1_2 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i9, s10_1_1_1_2_1_1 ); - l_state_machine->add_transition( event_I::get_event_id(), s10_1_1, s11 ); - l_state_machine->add_transition( event_A::get_event_id(), s11, s12 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s11, shallow_history1 ); - l_state_machine->add_transition( event_K::get_event_id(), s10, s13 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i10, s13_1_2 ); - l_state_machine->add_transition( event_A::get_event_id(), s13_1_2, s13_1_3 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s13_1_2, s13_1_1 ); - l_state_machine->add_transition( event_A::get_event_id(), s13_1_1, s13_1_3 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i11, s13_1_1_1_1 ); - l_state_machine->add_transition( event_L::get_event_id(), s13_1_1_1_1, s13_1_1_1_2 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i12, s13_1_1_1_2_1_1 ); - l_state_machine->add_transition( event_M::get_event_id(), s13_1_1, s14 ); - l_state_machine->add_transition( event_A::get_event_id(), s14, s15 ); - l_state_machine->add_transition( event_N::get_event_id(), s14, deep_history1 ); - l_state_machine->add_transition( event_O::get_event_id(), s13, fork1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, fork1, s16_2_1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, fork1, s16_3_1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, fork1, s16_4_1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, i13, s16_1_1 ); - l_state_machine->add_transition( event_A::get_event_id(), s16_1_1, s16_1_2 ); - l_state_machine->add_transition( event_Q::get_event_id(), s16_1_1, s16_1_3 ); - l_state_machine->add_transition( event_A::get_event_id(), s16_2_1, s16_2_2 ); - l_state_machine->add_transition( event_Q::get_event_id(), s16_2_1, s16_2_3 ); - l_state_machine->add_transition( event_Q::get_event_id(), s16_3_1, s16_3_2 ); - l_state_machine->add_transition( event_A::get_event_id(), s16_4_1, s16_4_2 ); - l_state_machine->add_transition( event_Q::get_event_id(), s16_4_1, s16_4_3 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s16_1_3, join1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s16_2_3, join1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s16_3_2, join1 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s16_4_3, join1 ); - l_state_machine->add_transition( event_B::get_event_id(), s16, s17 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, join1, s18 ); - l_state_machine->add_transition( event_R::get_event_id(), s18, choice1 ); - -#ifdef Y_CPP03_BOOST - l_state_machine->add_transition( COMPLETION_EVENT_ID, choice1, s19, - Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_divided_by_2 ) ); -#else - l_state_machine->add_transition( COMPLETION_EVENT_ID, choice1, s19, - Y_GUARD_METHOD_NO_EVENT( check_iterations_divided_by_2 ) ); -#endif - l_state_machine->add_transition( COMPLETION_EVENT_ID, choice1, junction1 ); - -#ifdef Y_CPP03_BOOST - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction1, s20, - Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_divided_by_3 ) ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction1, s21, - Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_divided_by_5 ) ); -#else - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction1, s20, - Y_GUARD_METHOD_NO_EVENT( check_iterations_divided_by_3 ) ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction1, s21, - Y_GUARD_METHOD_NO_EVENT( check_iterations_divided_by_5 ) ); -#endif - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction1, s22 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s19, s23 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s20, s23 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s21, s23 ); - l_state_machine->add_transition( COMPLETION_EVENT_ID, s22, s23 ); - l_state_machine->add_transition( event_T::get_event_id(), s23, s24 ); - l_state_machine->add_transition( event_S::get_event_id(), s24, junction2 ); - -#ifdef Y_CPP03_BOOST - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction2, terminate_pseudostate_1, - Y_GUARD_METHOD_NO_EVENT( forty_two, check_iterations_exceded ) ); -#else - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction2, terminate_pseudostate_1, - Y_GUARD_METHOD_NO_EVENT( check_iterations_exceded ) ); -#endif - l_state_machine->add_transition( COMPLETION_EVENT_ID, junction2, s1 ); - return( sxy::move( l_state_machine ) ); -} - - -bool forty_two::check_state_machine() const -{ - bool state_machine_is_ok = true; - sxy::state_machine_defects defects; - state_machine_->check( defects ); - if( !defects.empty() ) - { - state_machine_is_ok = false; - } - - return( state_machine_is_ok ); -} - - -void forty_two::increment_iterations() -{ - ++iterations_; - Y_LOG( log_level::LL_DEBUG, "iterator incremented to %", iterations_ ); -} - - -bool forty_two::check_iterations_divided_by_2() const -{ - return( iterations_ % 2 == 0 ); -} - - -bool forty_two::check_iterations_divided_by_3() const -{ - return( iterations_ % 3 == 0 ); -} - - -bool forty_two::check_iterations_divided_by_5() const -{ - return( iterations_ % 5 == 0 ); -} - - -bool forty_two::check_iterations_exceded() const -{ - return( iterations_ > max_iterations_ ); -} - - -void forty_two::run() -{ -#ifndef Y_NO_LOGGING - sxy::log_manager_template& log_manager = sxy::log_manager::get_instance(); - log_manager.set_log_level( sxy::log_level::LL_DEBUG ); - log_manager.add_logger( Y_MAKE_UNIQUE< sxy::cout_logger >() ); - log_manager.start(); -#endif - - const sxy::time_point start = sxy::steady_clock::now(); - - - bool starting_success = state_machine_->start_state_machine(); - Y_ASSERT( starting_success, "State machine was not started!" ); - - for( uint32_t iteration = 0; iteration < max_iterations_; ++iteration ) - { - state_machine_->fire_event( event_A::create() ); - state_machine_->fire_event( event_B::create() ); - state_machine_->fire_event( event_C::create() ); - state_machine_->fire_event( event_D::create() ); - state_machine_->fire_event( event_E::create() ); - state_machine_->fire_event( event_F::create() ); - state_machine_->fire_event( event_G::create() ); - state_machine_->fire_event( event_H::create() ); - state_machine_->fire_event( event_I::create() ); - state_machine_->fire_event( event_J::create() ); - state_machine_->fire_event( event_K::create() ); - state_machine_->fire_event( event_L::create() ); - state_machine_->fire_event( event_M::create() ); - state_machine_->fire_event( event_N::create() ); - state_machine_->fire_event( event_O::create() ); - state_machine_->fire_event( event_P::create() ); - state_machine_->fire_event( event_Q::create() ); - state_machine_->fire_event( event_R::create() ); - state_machine_->fire_event( event_S::create() ); - state_machine_->fire_event( event_T::create() ); - } - - const sxy::time_point stop = sxy::steady_clock::now(); - -#ifdef Y_PROFILER - Y_LOG( log_level::LL_INFO, "% events were fired.", - sxy::to_string( state_machine_->get_number_of_processed_events() ) ); -#endif - - state_machine_->stop_state_machine(); - - Y_LOG( log_level::LL_INFO, "Run time: % seconds", - sxy::duration_cast< sxy::seconds >( stop - start ).count() ); - -#ifndef Y_NO_LOGGING - log_manager.stop(); - log_manager.join(); -#endif - - std::cin.get(); -} - - -} diff --git a/yasmine/yasmine/assembly.hpp b/yasmine/yasmine/assembly.hpp deleted file mode 100644 index b638747..0000000 --- a/yasmine/yasmine/assembly.hpp +++ /dev/null @@ -1,130 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016 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/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 -#define ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 - - -#include "macro_helpers.hpp" -#include "behaviour_fwd.hpp" -#include "constraint_fwd.hpp" -#include "caller.hpp" - - -#ifndef Y_CPP03_BOOST - - -#define Y_BEHAVIOUR_METHOD( ... ) EXPAND( VA_SELECT( Y_BEHAVIOUR_METHOD_SELECT, __VA_ARGS__ ) ) -#define Y_BEHAVIOUR_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOUR_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) -#define Y_GUARD_METHOD( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_SELECT, __VA_ARGS__ ) ) -#define Y_GUARD_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) - - -#else - -#define Y_BEHAVIOUR_METHOD( _class_name, _method_name ) Y_BEHAVIOUR_METHOD_SELECT_2( _class_name, _method_name ) -#define Y_BEHAVIOUR_METHOD_NO_EVENT( _class_name, _method_name ) Y_BEHAVIOUR_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 ) - -#endif - - -//!\brief Macro for using a class method as a behaviour. -#define Y_BEHAVIOUR_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::behaviour_function( sxy::bind( &_class_name::_method_name, this, sxy::_1 ) ) - -//!\brief Macro for using a class method as a behaviour without an event. -#define Y_BEHAVIOUR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ - sxy::behaviour_function( sxy::bind( &_class_name::_method_name, this ) ) - -#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::constraint_function( sxy::bind( &_class_name::_method_name, this, sxy::_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( sxy::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( sxy::bind( &_function_name, sxy::_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( sxy::bind( &_function_name ) ) - - -//!\brief Macro for using a free function as a behaviour. -#define Y_BEHAVIOUR_FUNCTION( _function_name ) \ - sxy::behaviour_function( sxy::bind( &_function_name, sxy::_1 ) ) - - -//!\brief Macro for using a free function as a behaviour without an event. -#define Y_BEHAVIOUR_FUNCTION_NO_EVENT( _function_name ) \ - sxy::behaviour_function( sxy::bind( &_function_name ) ) - - -#ifndef Y_CPP03_BOOST - -//!\brief Macro for using a class method as a behaviour. -#define Y_BEHAVIOUR_METHOD_SELECT_1( _method_name ) \ - sxy::behaviour_function( [ this ]( const sxy::event& _event ){ this->_method_name( _event ); } ) - - -//!\brief Macro for using a class method as a behaviour without an event. -#define Y_BEHAVIOUR_METHOD_NO_EVENT_SELECT_1( _method_name ) \ - sxy::behaviour_function( [ this ]( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); this->_method_name(); } ) - - -//!\brief Macro for using a class method as a guard. -#define Y_GUARD_METHOD_SELECT_1( _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event ){ return( this->_method_name( _event ) ); } ) - - -//!\brief Macro for using a class method as a guard without an event. -#define Y_GUARD_METHOD_NO_EVENT_SELECT_1( _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event ){ Y_UNUSED_PARAMETER(_event); return( this->_method_name() ); } ) - -#endif - - -//!\brief Macro for an empty behaviour. -#define Y_EMPTY_BEHAVIOUR sxy::behaviour_function() - - -#ifndef Y_CPP03_BOOST // C++11 only - // Macros for passing handlers as behaviour - - //!\ The macro adds the specified class method(s) as behaviour(s) to states or transitions. - //!\ The macro is variadic and can take up to 5 class methods pointers as parameters. - #define Y_BEHAVIOUR_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_BEHAVIOUR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) - - //!\ The macro adds the specified function(s) as behaviour(s) to states or transitions. - //!\ The macro is variadic and can take up to 5 function pointers as parameters. - #define Y_BEHAVIOUR_FUNCTION_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOUR_FUNCTION_EVENT_SELECT, __VA_ARGS__ ) ) - - #define Y_BEHAVIOUR_METHOD_EVENT_SELECT_1( _method ) sxy::behaviour_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method ); } ) - #define Y_BEHAVIOUR_METHOD_EVENT_SELECT_2( _method1, _method2 ) sxy::behaviour_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2 ); } ) - #define Y_BEHAVIOUR_METHOD_EVENT_SELECT_3( _method1, _method2, _method3 ) sxy::behaviour_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3 ); } ) - #define Y_BEHAVIOUR_METHOD_EVENT_SELECT_4( _method1, _method2, _method3, _method4 ) sxy::behaviour_function( [this]( const sxy::event& _event ) { method_caller( event, this, _method1, _method2, _method3, _method4 ); } ) - #define Y_BEHAVIOUR_METHOD_EVENT_SELECT_5( _method1, _method2, _method3, _method4, _method5 ) sxy::behaviour_function( [this]( const sxy::event& _event ) { method_caller( _event, this, _method1, _method2, _method3, _method4, _method5 ); } ) - - - #define Y_BEHAVIOUR_FUNCTION_EVENT_SELECT_1( _function) sxy::behaviour_function( []( const sxy::event& _event ) { function_caller( _event, _function ); }) - #define Y_BEHAVIOUR_FUNCTION_EVENT_SELECT_2( _function1, _function2 ) sxy::behaviour_function( [](const sxy::event& _event ) { function_caller( _event, _function1, _function2 ); } ) - #define Y_BEHAVIOUR_FUNCTION_EVENT_SELECT_3( _function1, _function2, _function3 ) sxy::behaviour_function( [](const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3 ); } ) - #define Y_BEHAVIOUR_FUNCTION_EVENT_SELECT_4( _function1, _function2, _function3, _function4 ) sxy::behaviour_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4 ); } ) - #define Y_BEHAVIOUR_FUNCTION_EVENT_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) sxy::behaviour_function( []( const sxy::event& _event ) { function_caller( _event, _function1, _function2, _function3, _function4, _function5 ); } ) - -#endif - -#endif diff --git a/yasmine/yasmine/behaviour_exception_fwd.hpp b/yasmine/yasmine/behaviour_exception_fwd.hpp deleted file mode 100644 index 715f39b..0000000 --- a/yasmine/yasmine/behaviour_exception_fwd.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BEHAVIOUR_EXCEPTION_FWD_FDC9BCAD_9B60_4678_97D8_C2291378BD5A -#define BEHAVIOUR_EXCEPTION_FWD_FDC9BCAD_9B60_4678_97D8_C2291378BD5A - - -#include - -#include "compatibility.hpp" - - -namespace sxy -{ - - -class behaviour_exception; - - -typedef Y_UNIQUE_PTR< behaviour_exception > behaviour_exception_uptr; -typedef std::vector< behaviour_exception_uptr > behaviour_exceptions; - -} - - -#endif diff --git a/yasmine/yasmine/caller.hpp b/yasmine/yasmine/caller.hpp deleted file mode 100644 index 7fa6272..0000000 --- a/yasmine/yasmine/caller.hpp +++ /dev/null @@ -1,742 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016 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/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F -#define CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F - - -#include "event.hpp" -#include "base.hpp" - - -namespace sxy -{ - - -template -const _event_type& adjust_event_type(const event& _event) -{ -#ifdef NDEBUG - return( static_cast( _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) - { - Y_LOG( sxy::log_level::LL_ASSERT, message ); - Y_ASSERT_NO_LOG( false, "Invalid event type!" ); - } - return( *specialized_event ); -#endif -} - - -template< typename _class, typename _event_type > -void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method )( const _event_type& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); - if( specialized_event ) - { - if( _event.get_id() == specialized_event->get_id() ) - { - ( _this->*_method )( *specialized_event ); - } - } - else - { - throw sxy::exception( "Invalid event type!" ); - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); - ( _this->*_method )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _class, typename _event_type1, typename _event_type2 > -void method_caller( const sxy::event& _event, _class* _this, - void ( _class::* _method1 )( const _event_type1& ), void ( _class::* _method2 )( const _event_type2& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( _this->*_method1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( _this->*_method2 )( *specialized_event2 ); - } - else - { - throw sxy::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); - ( _this->*_method1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >(_event); - ( _this->*_method2 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _class, typename _event_type1, typename _event_type2, typename _event_type3 > -void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method1 )( const _event_type1& ), - void ( _class::* _method2 )( const _event_type2& ), void ( _class::* _method3 )( const _event_type3& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( _this->*_method1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( _this->*_method2 )( *specialized_event2 ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - ( _this->*_method3 )( *specialized_event3 ); - } - else - { - throw sxy::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 ); - ( _this->*_method1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - ( _this->*_method2 )( specialized_event ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - ( _this->*_method3 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _class, typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > -void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method1 )( const _event_type1& ), - void ( _class::* _method2 )( const _event_type2& ), void ( _class::* _method3 )( const _event_type3& ), - void ( _class::* _method4 )( const _event_type4& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( _this->*_method1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( _this->*_method2 )( *specialized_event2 ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - ( _this->*_method3 )( *specialized_event3 ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - ( _this->*_method4 )( *specialized_event4 ); - } - else - { - throw sxy::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 ); - ( _this->*_method1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - ( _this->*_method2 )( specialized_event ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - ( _this->*_method3 )( specialized_event ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - ( _this->*_method4 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _class, typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5 > -void method_caller( const sxy::event& _event, _class* _this, void ( _class::* _method1 )( const _event_type1& ), - void ( _class::* _method2 )( const _event_type2& ), void ( _class::* _method3 )( const _event_type3& ), - void ( _class::* _method4 )( const _event_type4& ), void ( _class::* _method5 )( const _event_type5& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( _this->*_method1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( _this->*_method2 )( *specialized_event2 ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - ( _this->*_method3 )( *specialized_event3 ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - ( _this->*_method4 )( *specialized_event4 ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - ( _this->*_method5 )( *specialized_event5 ); - } - else - { - throw sxy::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 ); - ( _this->*_method1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - ( _this->*_method2 )( specialized_event ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - ( _this->*_method3 )( specialized_event ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - ( _this->*_method4 )( specialized_event ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - ( _this->*_method5 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type > -void function_caller( const sxy::event& _event, void ( *_function )( const _event_type& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); - if( specialized_event ) - { - ( *_function )( *specialized_event ); - } - else - { - throw sxy::exception( "Invalid event type!" ); - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type >(_event); - ( *_function )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2 > -void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), - void ( *_function_2 )( const _event_type2& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( *_function_1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( *_function_2 )( *specialized_event2 ); - } - else - { - throw sxy::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); - ( *_function_1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >(_event); - ( *_function_2 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3 > -void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), - void ( * _function_2 )( const _event_type2& ), void ( *_function_3 )( const _event_type3& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( *_function_1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( *_function_2 )( *specialized_event2 ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - ( *_function_3 )( *specialized_event3 ); - } - else - { - throw sxy::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 ); - ( *_function_1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - ( *_function_2 )( specialized_event ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - ( *_function_3 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > -void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), - void ( * _function_2 )( const _event_type2& ), void ( *_function_3 )( const _event_type3& ), - void ( * _function_4 )( const _event_type4& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( *_function_1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( *_function_2 )( *specialized_event2 ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - ( *_function_3 )( *specialized_event3 ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - ( *_function_4 )( *specialized_event3 ); - } - else - { - throw sxy::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 ); - ( *_function_1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - ( *_function_2 )( specialized_event ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - ( *_function_3 )( specialized_event ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - ( *_function_4 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5 > -void function_caller( const sxy::event& _event, void ( *_function_1 )( const _event_type1& ), - void ( *_function_2 )( const _event_type2& ), void ( *_function_3 )( const _event_type3& ), - void ( *_function_4 )( const _event_type4& ), void ( *_function_5 )( const _event_type5& ) ) -{ -#if defined( Y_CPP03_BOOST ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - ( *_function_1 )( *specialized_event ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - ( *_function_2 )( *specialized_event2 ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - ( *_function_3 )( *specialized_event3 ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - ( *_function_4 )( *specialized_event3 ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - ( *_function_5 )( *specialized_event3 ); - } - else - { - throw sxy::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 ); - ( *_function_1 )( specialized_event ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - ( *_function_2 )( specialized_event ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - ( *_function_3 )( specialized_event ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - ( *_function_4 )( specialized_event ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - ( *_function_5 )( specialized_event ); - break; - } - - default: - Y_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -} - - -#endif diff --git a/yasmine/yasmine/event_template.hpp b/yasmine/yasmine/event_template.hpp deleted file mode 100644 index b618658..0000000 --- a/yasmine/yasmine/event_template.hpp +++ /dev/null @@ -1,492 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016 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/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 -#define EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 - - -#include "specialized_event.hpp" -#include "compatibility.hpp" - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ -public: \ - explicit _class_name() \ - : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ) \ - { \ - } \ -\ -\ - virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ - { \ - } \ -\ -\ - Y_NO_COPY(_class_name)\ -\ -\ - static sxy::shared_ptr< _class_name > create() { \ - return( Y_MAKE_SHARED< _class_name >() ); \ - } \ -\ -\ - virtual sxy::event_id get_id() const Y_OVERRIDE\ - { \ - return( _event_id ); \ - } \ -\ -\ - static Y_CONSTEXPR sxy::event_id get_event_id() \ - { \ - return( _event_id ); \ - } \ -\ -\ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event priority will be 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, DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ -public: \ - explicit _class_name( const _parameter_type1& _p1 ) \ - : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ - { \ - } \ -\ -\ -Y_NO_COPY(_class_name)\ -\ -\ - const _parameter_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - static sxy::shared_ptr< _class_name > create( const _parameter_type1& _p1 ) \ - { \ - return( Y_MAKE_SHARED< _class_name >( _p1 ) ); \ - } \ -\ -\ - virtual sxy::event_id get_id() const Y_OVERRIDE\ - { \ - return( _event_id ); \ - } \ -\ -\ - static Y_CONSTEXPR sxy::event_id get_event_id() \ - { \ - return( _event_id ); \ - } \ -\ -\ -private: \ - const _parameter_type1 p1_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have one parameter. The event priority will be 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, DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ -public: \ - explicit _class_name( const _parameter_type1& _p1, const _parameter_type2& _p2 ) \ - : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ - { \ - } \ -\ -\ - Y_NO_COPY(_class_name)\ -\ -\ - const _parameter_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _parameter_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - static sxy::shared_ptr< _class_name > create( const _parameter_type1& _p1, const _parameter_type2& _p2 ) \ - { \ - return( Y_MAKE_SHARED< _class_name >( _p1, _p2 ) ); \ - } \ -\ -\ - virtual sxy::event_id get_id() const Y_OVERRIDE\ - { \ - return( _event_id ); \ - } \ -\ -\ - static Y_CONSTEXPR sxy::event_id get_event_id() \ - { \ - return( _event_id ); \ - } \ -\ -\ -private: \ - const _parameter_type1 p1_; \ - const _parameter_type2 p2_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have two parameters. The event priority will be 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, DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ -public: \ - explicit _class_name( const _parameter_type1& _p1, const _parameter_type2& _p2, const _parameter_type3& _p3 ) \ - : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ - { \ - } \ -\ -\ - Y_NO_COPY(_class_name)\ -\ -\ - const _parameter_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _parameter_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _parameter_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - static sxy::shared_ptr< _class_name > create( const _parameter_type1& _p1, const _parameter_type2& _p2, const _parameter_type3& _p3 ) \ - { \ - return( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3 ) ); \ - } \ -\ -\ - virtual sxy::event_id get_id() const Y_OVERRIDE\ - { \ - return( _event_id ); \ - } \ -\ -\ - static Y_CONSTEXPR sxy::event_id get_event_id() \ - { \ - return( _event_id ); \ - } \ -\ -\ -private: \ - const _parameter_type1 p1_; \ - const _parameter_type2 p2_; \ - const _parameter_type3 p3_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have three parameters. The event priority will be 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, DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ -public: \ - explicit _class_name( const _parameter_type1& _p1, const _parameter_type2& _p2, const _parameter_type3& _p3, const _parameter_type4& _p4 ) \ - : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ - { \ - } \ -\ -\ - Y_NO_COPY(_class_name)\ -\ -\ - const _parameter_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _parameter_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _parameter_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _parameter_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - static sxy::shared_ptr< _class_name > create( const _parameter_type1& _p1, const _parameter_type2& _p2, const _parameter_type3& _p3, const _parameter_type4& _p4 ) \ - { \ - return( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4 ) ); \ - } \ -\ -\ - virtual sxy::event_id get_id() const Y_OVERRIDE\ - { \ - return( _event_id ); \ - } \ -\ -\ - static Y_CONSTEXPR sxy::event_id get_event_id() \ - { \ - return( _event_id ); \ - } \ -\ -\ -private: \ - const _parameter_type1 p1_; \ - const _parameter_type2 p2_; \ - const _parameter_type3 p3_; \ - const _parameter_type4 p4_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have four parameters. The event priority will be 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, DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have 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< struct _class_name##_tag, _event_id, _event_priority > { \ -public: \ - explicit _class_name( const _parameter_type1& _p1, const _parameter_type2& _p2, const _parameter_type3& _p3, const _parameter_type4& _p4, const _parameter_type5& _p5 ) \ - : sxy::specialized_event< struct _class_name##_tag, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() Y_NOEXCEPT Y_OVERRIDE \ - { \ - } \ -\ -\ - Y_NO_COPY(_class_name)\ -\ -\ - const _parameter_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _parameter_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _parameter_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _parameter_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _parameter_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ - static sxy::shared_ptr< _class_name > create( const _parameter_type1& _p1, const _parameter_type2& _p2, const _parameter_type3& _p3, const _parameter_type4& _p4, const _parameter_type5& _p5 ) \ - { \ - return( Y_MAKE_SHARED< _class_name >( _p1, _p2, _p3, _p4, _p5 ) ); \ - } \ -\ -\ - virtual sxy::event_id get_id() const Y_OVERRIDE\ - { \ - return( _event_id ); \ - } \ -\ -\ - static Y_CONSTEXPR sxy::event_id get_event_id() \ - { \ - return( _event_id ); \ - } \ -\ -\ -private: \ - const _parameter_type1 p1_; \ - const _parameter_type2 p2_; \ - const _parameter_type3 p3_; \ - const _parameter_type4 p4_; \ - const _parameter_type5 p5_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event will have five parameters. The event priority will be 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, DEFAULT_EVENT_PRIORITY ) - - -#endif diff --git a/yasmine/yasmine/log_manager_template.hpp b/yasmine/yasmine/log_manager_template.hpp deleted file mode 100644 index 798fe2a..0000000 --- a/yasmine/yasmine/log_manager_template.hpp +++ /dev/null @@ -1,377 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016 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/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef Y_NO_LOGGING - - -#ifndef LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B -#define LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B - - -#include -#include - - -#include "thread.hpp" -#include "base.hpp" -#include "logger.hpp" -#include "log_message.hpp" -#include "log_level.hpp" -#include "yprintf.hpp" - - -namespace sxy -{ - - -namespace -{ - - -bool LOG_MANAGER_EXISTS = false; - - -} - -//!\class t_log_manager_template -//!\brief The log manager (a singleton) controls the different loggers, manages the current log level, and takes care -//!of dispatching log messages. -template< typename time_stamp_policy > -class log_manager_template Y_FINAL -{ -public: - //!\brief Get a reference to the single instance of the log manager template. - static log_manager_template& get_instance( void ) - { - static log_manager_template instance; - return( instance ); - } - - - Y_NO_COPY(log_manager_template) - - //!\brief Gets the currently set log level. - //!\return Current log level. - log_level get_log_level() const - { - return( log_level_ ); - } - - - //!\brief Sets a new log level. - //!\param _log_level Log level to be set. - //!\return void - void set_log_level( const log_level _log_level ) - { - log_level_ = _log_level; - } - - -#ifndef Y_CPP03_BOOST - - - //!\brief Add a message to the queue of messages that will be processed. - //!\param _log_level Log level of the message. - //!\param _time_stamp Date and time when the log message was created. - //!\param _file The file from where the log was called. - //!\param _line The line from where the log was called. - //!\param _message The message text for the log. - //!\param _args Parameters that are inserted in the message. - //!\return void - //!\sa Y_LOG(), yprintf - template< typename ... args > - void log( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, args ... _args ) - { - { - log_message message( _log_level, _time_stamp, _file, _line, sxy::yprintf( _message.c_str(), _args ... ) ); - sxy::lock_guard< sxy::mutex > lock( mutex_ ); - messages_.push( message ); - } - condition_.notify_one(); - } - - -#else - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str())); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4, const log_value& _value5) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4, const log_value& _value5, const log_value& _value6) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, - const log_value& _value8) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, - const log_value& _value8, const log_value& _value9) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const log_value& _value1, const log_value& _value2, const log_value& _value3, - const log_value& _value4, const log_value& _value5, const log_value& _value6, const log_value& _value7, - const log_value& _value8, const log_value& _value9, const log_value& _value10) - { - { - log_message message(_log_level, _time_stamp, _file, _line, sxy::yprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10)); - sxy::lock_guard< sxy::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - - -#endif - - - //!\brief Adds a logger to which the log will be written. - //!\param _logger - The logger to be added. - //!\return void - void add_logger( logger_uptr _logger ) - { - Y_ASSERT_NO_LOG( stop_, "Logger cannot be added while running!" ); - sxy::lock_guard< sxy::mutex > lock( mutex_ ); - loggers_.push_back( sxy::move( _logger ) ); - } - - - //!\brief Starts the logging. On starting, a new thread is created which processes the enqueued log message by - //!sending them to each logger. The thread has to be stopped and joined before the log manager is destroyed! - //!\return void - //!\sa stop, join - void start() - { - stop_ = false; - thread_ = sxy::thread( sxy::bind( &log_manager_template::work, this ) ); - } - - - //!\brief Stops the logging. The thread that processes the log messages is notified that it should stop. It still has - //!to be joined later. - //!\return void - //!\sa start, join - void stop() - { - { - sxy::lock_guard< sxy::mutex > lock( mutex_ ); - stop_ = true; - } - condition_.notify_one(); - } - - - //!\brief Joins the thread that processed the log messages. Join has to be called after the stop function. - //!\return void - //!\sa stop, start - void join() - { - thread_.join(); - } - - - //!\brief Gets the current date and time as a string. - //!\return String containing the date and time. - static std::string get_timestamp() - { - return( time_stamp_policy::get_timestamp() ); - } - - -private: - log_manager_template() - : thread_(), - mutex_(), - condition_(), - stop_( true ), - loggers_(), - messages_(), - log_level_( log_level::LL_OFF ) - { - Y_ASSERT_NO_LOG( !LOG_MANAGER_EXISTS, "Log manager already exists!" ); - LOG_MANAGER_EXISTS = true; - } - - - ~log_manager_template() - { - // Nothing to do... - } - - - bool should_be_running() const - { - return( stop_ || !messages_.empty() ); - } - - - bool finished() const - { - return( stop_ && messages_.empty() ); - } - - - void work() - { - while( true ) - { - log_message message; - { - sxy::unique_lock< sxy::mutex > lock( mutex_ ); - condition_.wait( lock, sxy::bind( &log_manager_template::should_be_running, this ) ); - - if( finished() ) - { - break; - } - - message = messages_.front(); - messages_.pop(); - } - - Y_FOR(const logger_uptr& logger, loggers_) - { - logger->log( message ); - } - } - } - - - sxy::thread thread_; - sxy::mutex mutex_; - sxy::condition_variable condition_; - bool stop_; - loggers loggers_; - std::queue< log_message > messages_; - log_level log_level_; -}; - - -} - - -#endif - -#endif