diff --git a/CMakeLists.txt b/CMakeLists.txt index 42de343..1a8248d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,5 +2,9 @@ cmake_minimum_required(VERSION 3.0) project(yasmine) add_subdirectory(libyasmine) +add_subdirectory(yasmine_model) +add_subdirectory(genesis) +add_subdirectory(libygen) +add_subdirectory(ygen) add_subdirectory(examples) \ No newline at end of file diff --git a/build/c++03.props b/build/c++03.props index e714807..24c4801 100644 --- a/build/c++03.props +++ b/build/c++03.props @@ -1,31 +1,31 @@ - - - - - ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0 - ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0\stage\VS2015\$(Platform)\lib - - - <_PropertySheetDisplayName>c++03 - - - - SX_NO_VARIADIC_MACRO;SX_CPP03_BOOST;BOOST_SP_USE_STD_ATOMIC;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(BOOST_PATH);%(AdditionalIncludeDirectories) - - - - $(BOOST_LIB_PATH);$(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) - - - - - $(BOOST_PATH) - true - - - $(BOOST_LIB_PATH) - true - - + + + + + ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0 + ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0\stage\VS2015\$(Platform)\lib + + + <_PropertySheetDisplayName>c++03 + + + + SX_NO_VARIADIC_MACRO;SX_CPP03_BOOST;BOOST_SP_USE_STD_ATOMIC;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(BOOST_PATH);%(AdditionalIncludeDirectories) + + + + $(BOOST_LIB_PATH);$(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + + + + + $(BOOST_PATH) + true + + + $(BOOST_LIB_PATH) + true + + \ No newline at end of file diff --git a/build/debug_info.props b/build/debug_info.props index 5dc702b..d3df256 100644 --- a/build/debug_info.props +++ b/build/debug_info.props @@ -1,18 +1,18 @@ - - - - - - - - - NotSet - true - - - EditAndContinue - WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - + + + + + + + + + NotSet + true + + + EditAndContinue + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + \ No newline at end of file diff --git a/build/generator.props b/build/generator.props new file mode 100644 index 0000000..aee9f20 --- /dev/null +++ b/build/generator.props @@ -0,0 +1,30 @@ + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + Level4 + 4127;4250 + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + None + false + true + include;%(AdditionalIncludeDirectories) + + + + + + No + Default + + + false + + + + \ No newline at end of file diff --git a/build/genesis.props b/build/genesis.props new file mode 100644 index 0000000..aee9f20 --- /dev/null +++ b/build/genesis.props @@ -0,0 +1,30 @@ + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + Level4 + 4127;4250 + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + None + false + true + include;%(AdditionalIncludeDirectories) + + + + + + No + Default + + + false + + + + \ No newline at end of file diff --git a/build/rapidjson.props b/build/rapidjson.props new file mode 100644 index 0000000..c4a78aa --- /dev/null +++ b/build/rapidjson.props @@ -0,0 +1,19 @@ + + + + + ..\..\..\..\..\3rd party\rapidjson\Content\rapidjson-1.0.2\rapidjson + + + + + $(RAPIDJSON_PATH)\include;$(RAPIDJSON_PATH)\include\rapidjson;%(AdditionalIncludeDirectories) + + + + + $(RAPIDJSON_PATH) + true + + + \ No newline at end of file diff --git a/build/use_boost.props b/build/use_boost.props new file mode 100644 index 0000000..b62e3b1 --- /dev/null +++ b/build/use_boost.props @@ -0,0 +1,30 @@ + + + + + ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0 + ..\..\..\..\..\3rd party\boost\Content\boost_1_60_0\stage\VS2015\$(Platform)\lib + + + + + + $(BOOST_PATH);%(AdditionalIncludeDirectories) + Y_USE_BOOST;BOOST_SP_USE_STD_ATOMIC;%(PreprocessorDefinitions) + + + $(BOOST_LIB_PATH);%(AdditionalLibraryDirectories) + + + + + + $(BOOST_PATH) + true + + + $(BOOST_LIB_PATH) + true + + + \ No newline at end of file diff --git a/build/use_c++03.props b/build/use_c++03.props index 12ec154..b440a1c 100644 --- a/build/use_c++03.props +++ b/build/use_c++03.props @@ -1,20 +1,20 @@ - - - - - - <_PropertySheetDisplayName>use_c++03 - - - - SX_NO_VARIADIC_MACRO;SX_CPP03_BOOST;BOOST_SP_USE_STD_ATOMIC;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\$(BOOST_PATH);%(AdditionalIncludeDirectories) - - - - - ..\$(BOOST_LIB_PATH);%(AdditionalLibraryDirectories) - - - + + + + + + <_PropertySheetDisplayName>use_c++03 + + + + SX_NO_VARIADIC_MACRO;SX_CPP03_BOOST;BOOST_SP_USE_STD_ATOMIC;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + + + ..\$(BOOST_LIB_PATH);%(AdditionalLibraryDirectories) + + + \ No newline at end of file diff --git a/build/use_essentials.props b/build/use_essentials.props index 0f58107..b08106d 100644 --- a/build/use_essentials.props +++ b/build/use_essentials.props @@ -1,18 +1,18 @@ - - - - - - - - ..\externals\essentials\include;%(AdditionalIncludeDirectories) - None - - - - $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) - %(AdditionalDependencies) - - - + + + + + + + + None + ..\externals\essentials\include;%(AdditionalIncludeDirectories) + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + %(AdditionalDependencies) + + + \ No newline at end of file diff --git a/build/use_essentials_examples.props b/build/use_essentials_examples.props index bf94163..2c2df7b 100644 --- a/build/use_essentials_examples.props +++ b/build/use_essentials_examples.props @@ -1,18 +1,18 @@ - - - - - - - - None - ..\..\externals\essentials\include;%(AdditionalIncludeDirectories) - - - - $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) - %(AdditionalDependencies) - - - + + + + + + + + None + ..\..\externals\essentials\include;%(AdditionalIncludeDirectories) + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + %(AdditionalDependencies) + + + \ No newline at end of file diff --git a/build/use_genesis.props b/build/use_genesis.props new file mode 100644 index 0000000..b39f8e7 --- /dev/null +++ b/build/use_genesis.props @@ -0,0 +1,18 @@ + + + + + + + + ..\genesis\include;%(AdditionalIncludeDirectories) + None + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + genesis.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/build/use_genesis_examples.props b/build/use_genesis_examples.props new file mode 100644 index 0000000..2b2e0b8 --- /dev/null +++ b/build/use_genesis_examples.props @@ -0,0 +1,18 @@ + + + + + + + + ..\..\genesis\include;%(AdditionalIncludeDirectories) + None + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + genesis.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/build/use_hermes.props b/build/use_hermes.props index 36176ba..08a894d 100644 --- a/build/use_hermes.props +++ b/build/use_hermes.props @@ -1,13 +1,13 @@ - - - - - - - - ..\externals\hermes\include;%(AdditionalIncludeDirectories) - - - - + + + + + + + + ..\externals\hermes\include;%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/build/use_hermes_examples.props b/build/use_hermes_examples.props index b67588a..13c24de 100644 --- a/build/use_hermes_examples.props +++ b/build/use_hermes_examples.props @@ -1,15 +1,15 @@ - - - - - - - - - - - ..\..\externals\hermes\include;%(AdditionalIncludeDirectories) - - - + + + + + + + + + + + ..\..\externals\hermes\include;%(AdditionalIncludeDirectories) + + + \ No newline at end of file diff --git a/build/use_libygen.props b/build/use_libygen.props new file mode 100644 index 0000000..a3e3011 --- /dev/null +++ b/build/use_libygen.props @@ -0,0 +1,18 @@ + + + + + + + + + + $(BOOST_LIB_PATH);%(AdditionalLibraryDirectories) + libygen.lib;%(AdditionalDependencies) + + + ..\libygen\include;%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/build/use_yasmine.props b/build/use_yasmine.props index b9a7423..4fad614 100644 --- a/build/use_yasmine.props +++ b/build/use_yasmine.props @@ -1,18 +1,18 @@ - - - - - - - - ..\..\libyasmine\include;..\..\libyasmine\include_impl;%(AdditionalIncludeDirectories) - None - - - - $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) - libyasmine.lib;%(AdditionalDependencies) - - - + + + + + + + + ..\..\libyasmine\include;..\..\libyasmine\include_impl;%(AdditionalIncludeDirectories) + None + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + libyasmine.lib;%(AdditionalDependencies) + + + \ No newline at end of file diff --git a/build/use_yasmine_base.props b/build/use_yasmine_base.props index f779770..4272a36 100644 --- a/build/use_yasmine_base.props +++ b/build/use_yasmine_base.props @@ -1,18 +1,18 @@ - - - - - - - - ..\libyasmine\include;..\libyasmine\include_impl;%(AdditionalIncludeDirectories) - None - - - - $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) - libyasmine.lib;%(AdditionalDependencies) - - - + + + + + + + + ..\libyasmine\include;..\libyasmine\include_impl;%(AdditionalIncludeDirectories) + None + + + + $(SolutionDir)\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) + libyasmine.lib;%(AdditionalDependencies) + + + \ No newline at end of file diff --git a/build/use_yasmine_model.props b/build/use_yasmine_model.props new file mode 100644 index 0000000..e0c9b9c --- /dev/null +++ b/build/use_yasmine_model.props @@ -0,0 +1,16 @@ + + + + + + + + yasmine_model.lib;%(AdditionalDependencies) + + + + ..\yasmine_model\include;%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/build/vs2013.props b/build/vs2013.props index 493cc29..b4c7977 100644 --- a/build/vs2013.props +++ b/build/vs2013.props @@ -1,16 +1,16 @@ - - - - - - - - false - SX_CPP03_BOOST;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - - - + + + + + + + + false + SX_CPP03_BOOST;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + + \ No newline at end of file diff --git a/build/yasmine.props b/build/yasmine.props index 600f7ae..07e5b07 100644 --- a/build/yasmine.props +++ b/build/yasmine.props @@ -1,30 +1,30 @@ - - - - - - $(SolutionDir)$(Platform)\$(Configuration)\ - - - - Level4 - 4127;4250 - Y_OPTIMIZE_4_SPEED;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - None - false - true - include;include_impl;%(AdditionalIncludeDirectories) - - - - - - No - Default - - - false - - - + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + Level4 + 4127;4250 + Y_OPTIMIZE_4_SPEED;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + None + false + true + include;include_impl;%(AdditionalIncludeDirectories) + + + + + + No + Default + + + false + + + \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 628dbf7..6607ac4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,4 +5,8 @@ add_subdirectory(classic_farmroad) add_subdirectory(forty_two) add_subdirectory(events_with_parameters) add_subdirectory(substatemachines_and_variables) -add_subdirectory(event_collector_example) \ No newline at end of file +add_subdirectory(event_collector_example) + +if(NOT "${CPP_VERSION}" STREQUAL "03") + add_subdirectory(generator_example) +endif() \ No newline at end of file diff --git a/examples/classic_farmroad/classic_farmroad.vcxproj b/examples/classic_farmroad/classic_farmroad.vcxproj index 3e410a4..fe99c34 100644 --- a/examples/classic_farmroad/classic_farmroad.vcxproj +++ b/examples/classic_farmroad/classic_farmroad.vcxproj @@ -1,416 +1,416 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - VS 2013 - Win32 - - - Debug - VS 2013 - x64 - - - Debug - Win32 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - VS 2013 - Win32 - - - Release - VS 2013 - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {DDCFB59A-D19C-4382-ACFD-747105EB8D03} - classic_farmroad - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Disabled - true - - - - - Level3 - Disabled - true - - - - - Level3 - Disabled - true - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - VS 2013 + Win32 + + + Debug - VS 2013 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {DDCFB59A-D19C-4382-ACFD-747105EB8D03} + classic_farmroad + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/classic_farmroad/classic_farmroad.vcxproj.filters b/examples/classic_farmroad/classic_farmroad.vcxproj.filters index 89cecd0..bbe533f 100644 --- a/examples/classic_farmroad/classic_farmroad.vcxproj.filters +++ b/examples/classic_farmroad/classic_farmroad.vcxproj.filters @@ -1,51 +1,51 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + \ No newline at end of file diff --git a/examples/classic_farmroad/detector.cpp b/examples/classic_farmroad/detector.cpp index dec3941..f6136c0 100644 --- a/examples/classic_farmroad/detector.cpp +++ b/examples/classic_farmroad/detector.cpp @@ -1,112 +1,112 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "detector.hpp" - -#include "essentials/base.hpp" -#include "essentials/compatibility/chrono.hpp" - -#include "detector_callback.hpp" -#include "random_generator.hpp" - - -namespace -{ - - - const unsigned int DETECTOR_OFF_LOWER_EXTREMITY(1); - const unsigned int DETECTOR_OFF_UPPER_EXTREMITY(12); - const unsigned int DETECTOR_ON_UPPER_EXTREMITY(3); - const unsigned int DETECTOR_ON_LOWER_RXTREMITY(1); - - -} - - -namespace examples -{ - - -detector::detector( detector_callback& _detector_callback ) - : detector_callback_( _detector_callback ), - is_on_( false ), - generate_random_detector_events_(), - run_( false ), - mutex_(), - condition_variable_() -{ - // Nothing to do... -} - - -detector::~detector() -{ - // Nothing to do... -} - - -void detector::start() -{ - run_ = true; - generate_random_detector_events_ = - SX_MAKE_UNIQUE< sxe::thread >( sxe::bind( &detector::generate_detector_events, this ) ); -} - - -void detector::stop() -{ - { - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - run_ = false; - } - condition_variable_.notify_all(); - SX_ASSERT( generate_random_detector_events_->joinable(), "Event generator thread is not joinable!" ); - generate_random_detector_events_->join(); - generate_random_detector_events_.reset(); -} - - -bool detector::is_on() -{ - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - return( is_on_ ); -} - - -void detector::generate_detector_events() -{ - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - while( run_ ) - { - random_generator generator; - is_on_ = false; - { - sxe::milliseconds time_to_wait = - sxe::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; - { - sxe::milliseconds time_to_wait = - sxe::milliseconds( generator.generate( DETECTOR_ON_UPPER_EXTREMITY, DETECTOR_ON_UPPER_EXTREMITY ) ); - condition_variable_.wait_for( lock, time_to_wait ); - - detector_callback_.detector_on(); - } - } - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "detector.hpp" + +#include "essentials/base.hpp" +#include "essentials/compatibility/chrono.hpp" + +#include "detector_callback.hpp" +#include "random_generator.hpp" + + +namespace +{ + + + const unsigned int DETECTOR_OFF_LOWER_EXTREMITY(1); + const unsigned int DETECTOR_OFF_UPPER_EXTREMITY(12); + const unsigned int DETECTOR_ON_UPPER_EXTREMITY(3); + const unsigned int DETECTOR_ON_LOWER_RXTREMITY(1); + + +} + + +namespace examples +{ + + +detector::detector( detector_callback& _detector_callback ) + : detector_callback_( _detector_callback ), + is_on_( false ), + generate_random_detector_events_(), + run_( false ), + mutex_(), + condition_variable_() +{ + // Nothing to do... +} + + +detector::~detector() +{ + // Nothing to do... +} + + +void detector::start() +{ + run_ = true; + generate_random_detector_events_ = + SX_MAKE_UNIQUE< sxe::thread >( sxe::bind( &detector::generate_detector_events, this ) ); +} + + +void detector::stop() +{ + { + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + run_ = false; + } + condition_variable_.notify_all(); + SX_ASSERT( generate_random_detector_events_->joinable(), "Event generator thread is not joinable!" ); + generate_random_detector_events_->join(); + generate_random_detector_events_.reset(); +} + + +bool detector::is_on() +{ + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + return( is_on_ ); +} + + +void detector::generate_detector_events() +{ + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + while( run_ ) + { + random_generator generator; + is_on_ = false; + { + sxe::milliseconds time_to_wait = + sxe::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; + { + sxe::milliseconds time_to_wait = + sxe::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/examples/classic_farmroad/detector.hpp b/examples/classic_farmroad/detector.hpp index 2b6444f..82683b1 100644 --- a/examples/classic_farmroad/detector.hpp +++ b/examples/classic_farmroad/detector.hpp @@ -1,55 +1,55 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DETECTOR_5EBE86D2_647F_4029_94D8_B5521F641349 -#define DETECTOR_5EBE86D2_647F_4029_94D8_B5521F641349 - - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/compatibility/thread.hpp" -#include "essentials/non_copyable.hpp" - - -namespace examples -{ - - -class detector_callback; - - -class detector SX_FINAL -{ -public: - explicit detector( detector_callback& _detector_callback ); - ~detector(); - SX_NO_COPY( detector ) - void start(); - void stop(); - bool is_on(); - - -private: - void generate_detector_events(); - - - detector_callback& detector_callback_; - bool is_on_; - sxe::SX_UNIQUE_PTR< sxe::thread > generate_random_detector_events_; - bool run_; - sxe::mutex mutex_; - sxe::condition_variable condition_variable_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DETECTOR_5EBE86D2_647F_4029_94D8_B5521F641349 +#define DETECTOR_5EBE86D2_647F_4029_94D8_B5521F641349 + + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/compatibility/thread.hpp" +#include "essentials/non_copyable.hpp" + + +namespace examples +{ + + +class detector_callback; + + +class detector SX_FINAL +{ +public: + explicit detector( detector_callback& _detector_callback ); + ~detector(); + SX_NO_COPY( detector ) + void start(); + void stop(); + bool is_on(); + + +private: + void generate_detector_events(); + + + detector_callback& detector_callback_; + bool is_on_; + sxe::SX_UNIQUE_PTR< sxe::thread > generate_random_detector_events_; + bool run_; + sxe::mutex mutex_; + sxe::condition_variable condition_variable_; +}; + + +} + + +#endif diff --git a/examples/classic_farmroad/detector_callback.hpp b/examples/classic_farmroad/detector_callback.hpp index 32cf78a..0cf0201 100644 --- a/examples/classic_farmroad/detector_callback.hpp +++ b/examples/classic_farmroad/detector_callback.hpp @@ -1,45 +1,45 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DETECTOR_CALLBACK_0AF0AB58_4818_48B8_A10D_3894B6652355 -#define DETECTOR_CALLBACK_0AF0AB58_4818_48B8_A10D_3894B6652355 - - -#include "essentials/non_copyable.hpp" -#include "essentials/compatibility/compatibility.hpp" - - -namespace examples -{ - - -class detector_callback -{ -public: - detector_callback() - { - // Nothing to do... - } - virtual ~detector_callback() SX_NOEXCEPT - { - // Nothing to do... - } - - SX_NO_COPY( detector_callback ) - virtual void detector_on() = 0; - virtual void detector_off() = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DETECTOR_CALLBACK_0AF0AB58_4818_48B8_A10D_3894B6652355 +#define DETECTOR_CALLBACK_0AF0AB58_4818_48B8_A10D_3894B6652355 + + +#include "essentials/non_copyable.hpp" +#include "essentials/compatibility/compatibility.hpp" + + +namespace examples +{ + + +class detector_callback +{ +public: + detector_callback() + { + // Nothing to do... + } + virtual ~detector_callback() SX_NOEXCEPT + { + // Nothing to do... + } + + SX_NO_COPY( detector_callback ) + virtual void detector_on() = 0; + virtual void detector_off() = 0; +}; + + +} + + +#endif diff --git a/examples/classic_farmroad/intersection.cpp b/examples/classic_farmroad/intersection.cpp index 904a7cf..e66643c 100644 --- a/examples/classic_farmroad/intersection.cpp +++ b/examples/classic_farmroad/intersection.cpp @@ -1,450 +1,450 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "intersection.hpp" - -#include - -#include "yasmine.hpp" - - -namespace examples -{ - - -namespace -{ - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - 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 ) - -#else - const sxy::event_id DETECTOR_ON = 1; - Y_EVENT_CREATE( detector_on_event, DETECTOR_ON ) - - const sxy::event_id DETECTOR_OFF = 2; - Y_EVENT_CREATE( detector_off_event, DETECTOR_OFF ) - - const sxy::event_id TIMER_HIGHWAY_MINIMUM_TIME = 3; - Y_EVENT_CREATE( timer_highway_minimum_time_event, TIMER_HIGHWAY_MINIMUM_TIME ) - - const sxy::event_id TIMER_PHASE_1 = 4; - Y_EVENT_CREATE( timer_phase_1_event, TIMER_PHASE_1 ) - - const sxy::event_id TIMER_PHASE_2 = 5; - Y_EVENT_CREATE( timer_phase_2_event, TIMER_PHASE_2 ) - - const sxy::event_id TIMER_FARMROAD_MAXIMUM_TIME = 6; - Y_EVENT_CREATE( timer_farmroad_maximum_time_event, TIMER_FARMROAD_MAXIMUM_TIME ) - - const sxy::event_id EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED = 7; - Y_EVENT_CREATE( event_farmroad_maximum_time_elapsed_event, EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED ) -#endif - - -#ifndef SX_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 sxe::milliseconds TIMER_HIGHWAY_MINIMUM_TIME_DURATION( 5 ); -const sxe::milliseconds TIMER_PHASE_1_DURATION( 1 ); -const sxe::milliseconds TIMER_PHASE_2_DURATION( 1 ); -const sxe::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() SX_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 sxe::milliseconds _milliseconds, const sxy::event_sptr _event ) -{ - sxy::handle_type event_handle = - timed_event_creator_.create_event_creation_request( sxe::milliseconds( _milliseconds ), _event ); - return( event_handle ); -} - - -void intersection::highway_open_entry() -{ - SX_LOG( hermes::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 -{ - SX_LOG( hermes::log_level::LL_INFO, "Highway closed." ); -} - - -void intersection::switching_to_farmroad_phase_1() -{ - SX_LOG( hermes::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() -{ - SX_LOG( hermes::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() -{ - SX_LOG( hermes::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 -{ - SX_LOG( hermes::log_level::LL_INFO, "Farmroad closed." ); -} - - -void intersection::minimum_time_not_elapsed() const -{ - SX_LOG( hermes::log_level::LL_INFO, "Minimum time not elapsed." ); -} - - -void intersection::minimum_time_elapsed() const -{ - SX_LOG( hermes::log_level::LL_INFO, "Minimum time elapsed." ); -} - - -void intersection::minimum_time_not_elapsed_farmroad_waiting() const -{ - SX_LOG( hermes::log_level::LL_INFO, "Minimum time not elapsed. Farmroad waiting." ); -} - - -void intersection::switching_to_highway_phase_1() -{ - SX_LOG( hermes::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() -{ - SX_LOG( hermes::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 ) - { - SX_LOG( hermes::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_ ) ) - { - SX_LOG( hermes::log_level::LL_INFO, "Event with handle % was cancelled.", farmroad_maximum_time_event_handle_ ); - } - else - { - SX_LOG( hermes::log_level::LL_INFO, "Event with handle % could not be canceled.", farmroad_maximum_time_event_handle_ ); - } - - farmroad_maximum_time_event_handle_ = 0; - } - else - { - SX_LOG( hermes::log_level::LL_INFO, "There is no event to be cancelled on detector off." ); - } - } -} - - -void intersection::build_intersection_state_machine() -{ -#ifdef SX_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 SX_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_METHOD2( this, &intersection::highway_open_entry ), - Y_BEHAVIOR_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &intersection::minimum_time_not_elapsed ) ); - sxy::simple_state& l_minimum_time_elapsed = highway_open_region.add_simple_state( "minimum time elapsed", - Y_BEHAVIOR_METHOD2( this, &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_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &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", SX_NULLPTR, - Y_BEHAVIOR_METHOD2( this, &intersection::switching_to_farmroad_phase_2 ) ); - sxy::simple_state& farmroad_open = - main_region.add_simple_state( "farmroad open", SX_NULLPTR, - Y_BEHAVIOR_METHOD2( this, &intersection::farmroad_open_entry ), - Y_BEHAVIOR_METHOD2( this, &intersection::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 SX_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", SX_NULLPTR, - Y_BEHAVIOR_METHOD2( this, &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", SX_NULLPTR, - Y_BEHAVIOR_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &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_METHOD2( this, &intersection::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 ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "intersection.hpp" + +#include + +#include "yasmine.hpp" + + +namespace examples +{ + + +namespace +{ + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + 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 ) + +#else + const sxy::event_id DETECTOR_ON = 1; + Y_EVENT_CREATE( detector_on_event, DETECTOR_ON ) + + const sxy::event_id DETECTOR_OFF = 2; + Y_EVENT_CREATE( detector_off_event, DETECTOR_OFF ) + + const sxy::event_id TIMER_HIGHWAY_MINIMUM_TIME = 3; + Y_EVENT_CREATE( timer_highway_minimum_time_event, TIMER_HIGHWAY_MINIMUM_TIME ) + + const sxy::event_id TIMER_PHASE_1 = 4; + Y_EVENT_CREATE( timer_phase_1_event, TIMER_PHASE_1 ) + + const sxy::event_id TIMER_PHASE_2 = 5; + Y_EVENT_CREATE( timer_phase_2_event, TIMER_PHASE_2 ) + + const sxy::event_id TIMER_FARMROAD_MAXIMUM_TIME = 6; + Y_EVENT_CREATE( timer_farmroad_maximum_time_event, TIMER_FARMROAD_MAXIMUM_TIME ) + + const sxy::event_id EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED = 7; + Y_EVENT_CREATE( event_farmroad_maximum_time_elapsed_event, EVENT_FARMROAD_MAXIMUM_TIME_ELAPSED ) +#endif + + +#ifndef SX_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 sxe::milliseconds TIMER_HIGHWAY_MINIMUM_TIME_DURATION( 5 ); +const sxe::milliseconds TIMER_PHASE_1_DURATION( 1 ); +const sxe::milliseconds TIMER_PHASE_2_DURATION( 1 ); +const sxe::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() SX_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 sxe::milliseconds _milliseconds, const sxy::event_sptr _event ) +{ + sxy::handle_type event_handle = + timed_event_creator_.create_event_creation_request( sxe::milliseconds( _milliseconds ), _event ); + return( event_handle ); +} + + +void intersection::highway_open_entry() +{ + SX_LOG( hermes::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 +{ + SX_LOG( hermes::log_level::LL_INFO, "Highway closed." ); +} + + +void intersection::switching_to_farmroad_phase_1() +{ + SX_LOG( hermes::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() +{ + SX_LOG( hermes::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() +{ + SX_LOG( hermes::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 +{ + SX_LOG( hermes::log_level::LL_INFO, "Farmroad closed." ); +} + + +void intersection::minimum_time_not_elapsed() const +{ + SX_LOG( hermes::log_level::LL_INFO, "Minimum time not elapsed." ); +} + + +void intersection::minimum_time_elapsed() const +{ + SX_LOG( hermes::log_level::LL_INFO, "Minimum time elapsed." ); +} + + +void intersection::minimum_time_not_elapsed_farmroad_waiting() const +{ + SX_LOG( hermes::log_level::LL_INFO, "Minimum time not elapsed. Farmroad waiting." ); +} + + +void intersection::switching_to_highway_phase_1() +{ + SX_LOG( hermes::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() +{ + SX_LOG( hermes::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 ) + { + SX_LOG( hermes::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_ ) ) + { + SX_LOG( hermes::log_level::LL_INFO, "Event with handle % was cancelled.", farmroad_maximum_time_event_handle_ ); + } + else + { + SX_LOG( hermes::log_level::LL_INFO, "Event with handle % could not be canceled.", farmroad_maximum_time_event_handle_ ); + } + + farmroad_maximum_time_event_handle_ = 0; + } + else + { + SX_LOG( hermes::log_level::LL_INFO, "There is no event to be cancelled on detector off." ); + } + } +} + + +void intersection::build_intersection_state_machine() +{ +#ifdef SX_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 SX_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_METHOD2( this, &intersection::highway_open_entry ), + Y_BEHAVIOR_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &intersection::minimum_time_not_elapsed ) ); + sxy::simple_state& l_minimum_time_elapsed = highway_open_region.add_simple_state( "minimum time elapsed", + Y_BEHAVIOR_METHOD2( this, &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_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &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", SX_NULLPTR, + Y_BEHAVIOR_METHOD2( this, &intersection::switching_to_farmroad_phase_2 ) ); + sxy::simple_state& farmroad_open = + main_region.add_simple_state( "farmroad open", SX_NULLPTR, + Y_BEHAVIOR_METHOD2( this, &intersection::farmroad_open_entry ), + Y_BEHAVIOR_METHOD2( this, &intersection::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 SX_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", SX_NULLPTR, + Y_BEHAVIOR_METHOD2( this, &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", SX_NULLPTR, + Y_BEHAVIOR_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &intersection::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 SX_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_METHOD2( this, &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_METHOD2( this, &intersection::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/examples/classic_farmroad/intersection.hpp b/examples/classic_farmroad/intersection.hpp index c6d8ca8..0585a73 100644 --- a/examples/classic_farmroad/intersection.hpp +++ b/examples/classic_farmroad/intersection.hpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef INTERSECTION_AF842AAC_E608_4AE1_A245_2AC8A4602CDE -#define INTERSECTION_AF842AAC_E608_4AE1_A245_2AC8A4602CDE - - -#include "detector_callback.hpp" -#include "timed_event_creator.hpp" -#include "traffic_light.hpp" -#include "detector.hpp" -#include "async_state_machine.hpp" - - -namespace examples -{ - - -class intersection SX_FINAL: private detector_callback -{ -public: - intersection(); - ~intersection() SX_NOEXCEPT; - SX_NO_COPY( intersection ) - bool start(); - void stop(); - - -private: - virtual void detector_on() SX_OVERRIDE; - virtual void detector_off() SX_OVERRIDE; - int fire_timed_event( const sxe::milliseconds _milliseconds, const sxy::event_sptr _event ); - void highway_open_entry(); - void highway_open_exit() const; - void switching_to_farmroad_phase_1(); - void switching_to_farmroad_phase_2(); - void farmroad_open_entry(); - void farmroad_open_exit() const; - void minimum_time_not_elapsed() const; - void minimum_time_elapsed() const; - void minimum_time_not_elapsed_farmroad_waiting() const; - void switching_to_highway_phase_1(); - void switching_to_highway_phase_2(); - void build_intersection_state_machine(); - bool check_detector_is_on(); - bool check_detector_is_off(); - void cancel_timer_event_on_detector_off( const sxy::event& _event ); - - - sxy::async_state_machine intersection_state_machine_; - traffic_light highway_traffic_light_; - traffic_light farmroad_traffic_light_; - sxy::timed_event_creator timed_event_creator_; - detector detector_; - unsigned int farmroad_maximum_time_event_handle_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INTERSECTION_AF842AAC_E608_4AE1_A245_2AC8A4602CDE +#define INTERSECTION_AF842AAC_E608_4AE1_A245_2AC8A4602CDE + + +#include "detector_callback.hpp" +#include "timed_event_creator.hpp" +#include "traffic_light.hpp" +#include "detector.hpp" +#include "async_state_machine.hpp" + + +namespace examples +{ + + +class intersection SX_FINAL: private detector_callback +{ +public: + intersection(); + ~intersection() SX_NOEXCEPT; + SX_NO_COPY( intersection ) + bool start(); + void stop(); + + +private: + virtual void detector_on() SX_OVERRIDE; + virtual void detector_off() SX_OVERRIDE; + int fire_timed_event( const sxe::milliseconds _milliseconds, const sxy::event_sptr _event ); + void highway_open_entry(); + void highway_open_exit() const; + void switching_to_farmroad_phase_1(); + void switching_to_farmroad_phase_2(); + void farmroad_open_entry(); + void farmroad_open_exit() const; + void minimum_time_not_elapsed() const; + void minimum_time_elapsed() const; + void minimum_time_not_elapsed_farmroad_waiting() const; + void switching_to_highway_phase_1(); + void switching_to_highway_phase_2(); + void build_intersection_state_machine(); + bool check_detector_is_on(); + bool check_detector_is_off(); + void cancel_timer_event_on_detector_off( const sxy::event& _event ); + + + sxy::async_state_machine intersection_state_machine_; + traffic_light highway_traffic_light_; + traffic_light farmroad_traffic_light_; + sxy::timed_event_creator timed_event_creator_; + detector detector_; + unsigned int farmroad_maximum_time_event_handle_; +}; + + +} + + +#endif diff --git a/examples/classic_farmroad/main.cpp b/examples/classic_farmroad/main.cpp index 252247f..3502a30 100644 --- a/examples/classic_farmroad/main.cpp +++ b/examples/classic_farmroad/main.cpp @@ -1,112 +1,112 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "intersection.hpp" - -#include - -#include "logging.hpp" -#ifdef WIN32 - #include "utils.hpp" -#endif -#include "version.hpp" - - -#ifdef WIN32 -void wait_for_quit_input() -{ - const HANDLE input_handle = GetStdHandle( STD_INPUT_HANDLE ); - bool continue_running = TRUE; - while( continue_running ) - { - INPUT_RECORD input_record; - DWORD number_read; - ReadConsoleInput( input_handle, &input_record, 1, &number_read ); - - switch( input_record.EventType ) - { - case KEY_EVENT: - if( input_record.Event.KeyEvent.uChar.AsciiChar == 'q' ) - { - continue_running = FALSE; - } - - break; - - default: - break; - } - } -} - - -#else -void wait_for_quit_input() -{ - while( true ) - { - std::string a = ""; - std::cin >> a; - if( a == "q" ) - { - break; - } - } -} - - -#endif - - -int main() -{ - int error_code = 0; - -#ifdef WIN32 - sxy::utils::set_window_size( 250, 9999 ); - sxy::utils::maximize_window(); -#endif - hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); - log_manager.set_log_level( hermes::log_level::LL_DEBUG ); - log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); - log_manager.run(); - sxy::version::log_version(); - -try -{ - examples::intersection intersection_of_roads; - if( intersection_of_roads.start() ) - { - std::cout << "To quit press 'q'." << std::endl; - wait_for_quit_input(); - intersection_of_roads.stop(); - } - else - { - SX_LOG( hermes::log_level::LL_FATAL, "The intersection could not be started." ); - error_code = 1; - } -} -catch ( const std::exception& _exception ) -{ - SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", _exception.what() ); - error_code = 2; -} -catch ( ... ) -{ - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); - error_code = 3; -} - -log_manager.halt_and_join(); - - return( error_code ); -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "intersection.hpp" + +#include + +#include "logging.hpp" +#ifdef WIN32 + #include "utils.hpp" +#endif +#include "version.hpp" + + +#ifdef WIN32 +void wait_for_quit_input() +{ + const HANDLE input_handle = GetStdHandle( STD_INPUT_HANDLE ); + bool continue_running = TRUE; + while( continue_running ) + { + INPUT_RECORD input_record; + DWORD number_read; + ReadConsoleInput( input_handle, &input_record, 1, &number_read ); + + switch( input_record.EventType ) + { + case KEY_EVENT: + if( input_record.Event.KeyEvent.uChar.AsciiChar == 'q' ) + { + continue_running = FALSE; + } + + break; + + default: + break; + } + } +} + + +#else +void wait_for_quit_input() +{ + while( true ) + { + std::string a = ""; + std::cin >> a; + if( a == "q" ) + { + break; + } + } +} + + +#endif + + +int main() +{ + int error_code = 0; + +#ifdef WIN32 + sxy::utils::set_window_size( 250, 9999 ); + sxy::utils::maximize_window(); +#endif + hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); + log_manager.set_log_level( hermes::log_level::LL_DEBUG ); + log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); + log_manager.run(); + sxy::version::log_version(); + +try +{ + examples::intersection intersection_of_roads; + if( intersection_of_roads.start() ) + { + std::cout << "To quit press 'q'." << std::endl; + wait_for_quit_input(); + intersection_of_roads.stop(); + } + else + { + SX_LOG( hermes::log_level::LL_FATAL, "The intersection could not be started." ); + error_code = 1; + } +} +catch ( const std::exception& _exception ) +{ + SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", _exception.what() ); + error_code = 2; +} +catch ( ... ) +{ + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); + error_code = 3; +} + +log_manager.halt_and_join(); + + return( error_code ); +} diff --git a/examples/classic_farmroad/random_generator.cpp b/examples/classic_farmroad/random_generator.cpp index 5f50ba3..43088b6 100644 --- a/examples/classic_farmroad/random_generator.cpp +++ b/examples/classic_farmroad/random_generator.cpp @@ -1,55 +1,55 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "random_generator.hpp" - - -#ifdef SX_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 SX_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 ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "random_generator.hpp" + + +#ifdef SX_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 SX_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 index 15378f7..08e4daa 100644 --- a/examples/classic_farmroad/random_generator.hpp +++ b/examples/classic_farmroad/random_generator.hpp @@ -1,42 +1,42 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef RANDOM_GENERATOR_63744576_1DBE_44C8_B2EE_3A3A1EE0B66F -#define RANDOM_GENERATOR_63744576_1DBE_44C8_B2EE_3A3A1EE0B66F - - -#include "essentials/non_copyable.hpp" - - -namespace examples -{ - - -class random_generator SX_FINAL -{ -public: - random_generator(); - ~random_generator(); - SX_NO_COPY( random_generator ) - - const unsigned int generate(const unsigned int _lower_extremity, const unsigned int _upper_extremity); - -private: - sxe::random_device random_device_; - - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef RANDOM_GENERATOR_63744576_1DBE_44C8_B2EE_3A3A1EE0B66F +#define RANDOM_GENERATOR_63744576_1DBE_44C8_B2EE_3A3A1EE0B66F + + +#include "essentials/non_copyable.hpp" + + +namespace examples +{ + + +class random_generator SX_FINAL +{ +public: + random_generator(); + ~random_generator(); + SX_NO_COPY( random_generator ) + + const unsigned int generate(const unsigned int _lower_extremity, const unsigned int _upper_extremity); + +private: + sxe::random_device random_device_; + + +}; + + +} + + +#endif diff --git a/examples/classic_farmroad/traffic_light.cpp b/examples/classic_farmroad/traffic_light.cpp index f07617b..8568552 100644 --- a/examples/classic_farmroad/traffic_light.cpp +++ b/examples/classic_farmroad/traffic_light.cpp @@ -1,162 +1,162 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "traffic_light.hpp" - -#include - -#include "yasmine.hpp" - - -namespace examples -{ - - -namespace -{ - - -#ifdef SX_CPP03_BOOST - 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 ) -#else - Y_EVENT_CREATE( EVENT_SWITCH_TO_RED_YELLOW, 1 ) - Y_EVENT_CREATE( EVENT_SWITCH_TO_GREEN, 2 ) - Y_EVENT_CREATE( EVENT_SWITCH_TO_YELLOW, 3 ) - Y_EVENT_CREATE( EVENT_SWITCH_TO_RED, 4 ) -#endif - - -} - - -traffic_light::traffic_light( const std::string& _name, const std::string& _ascii_prefix ) - : traffic_light_state_machine_( _name ), - name_( _name ), - ascii_prefix_( _ascii_prefix ) -{ - build_traffic_light_state_machine(); -} - - -traffic_light::~traffic_light() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void traffic_light::start() -{ - traffic_light_state_machine_.run(); -} - - -void traffic_light::stop() -{ - traffic_light_state_machine_.halt_and_join(); -} - - -void traffic_light::switch_to_red_yellow() -{ - traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_RED_YELLOW::create() ); -} - - -void traffic_light::switch_to_green() -{ - traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_GREEN::create() ); -} - - -void traffic_light::switch_to_yellow() -{ - traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_YELLOW::create() ); -} - - -void traffic_light::switch_to_red() -{ - traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_RED::create() ); -} - - -void traffic_light::on_traffic_light_red() const -{ - std::cout << display_road_name_with_ascii_prefix() << " is now red." << std::endl; -} - - -void traffic_light::on_traffic_light_red_yellow() const -{ - std::cout << display_road_name_with_ascii_prefix() << " is now red-yellow." << std::endl; -} - - -void traffic_light::on_traffic_light_green() const -{ - std::cout << display_road_name_with_ascii_prefix() << " is now green." << std::endl; -} - - -void traffic_light::on_traffic_light_yellow() const -{ - std::cout << display_road_name_with_ascii_prefix() << " is now yellow." << std::endl; -} - - -void traffic_light::build_traffic_light_state_machine() -{ - 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 SX_CPP03_BOOST - 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_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 - sxy::simple_state& red_state = main_region.add_simple_state( "Red", - Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_red ) ); - sxy::simple_state& red_yellow_state = main_region.add_simple_state( "Red-Yellow", - Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_red_yellow ) ); - sxy::simple_state& green_state = main_region.add_simple_state( "Green", - Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_green ) ); - sxy::simple_state& yellow_state = main_region.add_simple_state( "Yellow", - Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_yellow ) ); -#endif - - // transitions - 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 ); - traffic_light_state_machine_.add_transition( EVENT_SWITCH_TO_YELLOW::get_event_id(), green_state, yellow_state ); - traffic_light_state_machine_.add_transition( EVENT_SWITCH_TO_RED::get_event_id(), yellow_state, red_state ); -} - - -std::string traffic_light::display_road_name_with_ascii_prefix() const -{ - return( ascii_prefix_ + name_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "traffic_light.hpp" + +#include + +#include "yasmine.hpp" + + +namespace examples +{ + + +namespace +{ + + +#ifdef SX_CPP03_BOOST + 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 ) +#else + Y_EVENT_CREATE( EVENT_SWITCH_TO_RED_YELLOW, 1 ) + Y_EVENT_CREATE( EVENT_SWITCH_TO_GREEN, 2 ) + Y_EVENT_CREATE( EVENT_SWITCH_TO_YELLOW, 3 ) + Y_EVENT_CREATE( EVENT_SWITCH_TO_RED, 4 ) +#endif + + +} + + +traffic_light::traffic_light( const std::string& _name, const std::string& _ascii_prefix ) + : traffic_light_state_machine_( _name ), + name_( _name ), + ascii_prefix_( _ascii_prefix ) +{ + build_traffic_light_state_machine(); +} + + +traffic_light::~traffic_light() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void traffic_light::start() +{ + traffic_light_state_machine_.run(); +} + + +void traffic_light::stop() +{ + traffic_light_state_machine_.halt_and_join(); +} + + +void traffic_light::switch_to_red_yellow() +{ + traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_RED_YELLOW::create() ); +} + + +void traffic_light::switch_to_green() +{ + traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_GREEN::create() ); +} + + +void traffic_light::switch_to_yellow() +{ + traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_YELLOW::create() ); +} + + +void traffic_light::switch_to_red() +{ + traffic_light_state_machine_.fire_event( EVENT_SWITCH_TO_RED::create() ); +} + + +void traffic_light::on_traffic_light_red() const +{ + std::cout << display_road_name_with_ascii_prefix() << " is now red." << std::endl; +} + + +void traffic_light::on_traffic_light_red_yellow() const +{ + std::cout << display_road_name_with_ascii_prefix() << " is now red-yellow." << std::endl; +} + + +void traffic_light::on_traffic_light_green() const +{ + std::cout << display_road_name_with_ascii_prefix() << " is now green." << std::endl; +} + + +void traffic_light::on_traffic_light_yellow() const +{ + std::cout << display_road_name_with_ascii_prefix() << " is now yellow." << std::endl; +} + + +void traffic_light::build_traffic_light_state_machine() +{ + 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 SX_CPP03_BOOST + 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_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 + sxy::simple_state& red_state = main_region.add_simple_state( "Red", + Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_red ) ); + sxy::simple_state& red_yellow_state = main_region.add_simple_state( "Red-Yellow", + Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_red_yellow ) ); + sxy::simple_state& green_state = main_region.add_simple_state( "Green", + Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_green ) ); + sxy::simple_state& yellow_state = main_region.add_simple_state( "Yellow", + Y_BEHAVIOR_METHOD2( this, &traffic_light::on_traffic_light_yellow ) ); +#endif + + // transitions + 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 ); + traffic_light_state_machine_.add_transition( EVENT_SWITCH_TO_YELLOW::get_event_id(), green_state, yellow_state ); + traffic_light_state_machine_.add_transition( EVENT_SWITCH_TO_RED::get_event_id(), yellow_state, red_state ); +} + + +std::string traffic_light::display_road_name_with_ascii_prefix() const +{ + return( ascii_prefix_ + name_ ); +} + + +} diff --git a/examples/classic_farmroad/traffic_light.hpp b/examples/classic_farmroad/traffic_light.hpp index 8762fcd..162fe69 100644 --- a/examples/classic_farmroad/traffic_light.hpp +++ b/examples/classic_farmroad/traffic_light.hpp @@ -1,57 +1,57 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRAFFIC_LIGHT_3B22DEE5_C976_43FF_B528_127733D61CD8 -#define TRAFFIC_LIGHT_3B22DEE5_C976_43FF_B528_127733D61CD8 - - -#include - -#include "async_state_machine.hpp" - - -namespace examples -{ - - -class traffic_light SX_FINAL -{ -public: - traffic_light( const std::string& _name, const std::string& _ascii_prefix ); - ~traffic_light() SX_NOEXCEPT; - SX_NO_COPY( traffic_light ) - void start(); - void stop(); - void switch_to_red_yellow(); - void switch_to_green(); - void switch_to_yellow(); - void switch_to_red(); - - -private: - void on_traffic_light_red() const; - void on_traffic_light_red_yellow() const; - void on_traffic_light_green() const; - void on_traffic_light_yellow() const; - void build_traffic_light_state_machine(); - std::string display_road_name_with_ascii_prefix() const; - - - sxy::async_state_machine traffic_light_state_machine_; - const std::string name_; - const std::string ascii_prefix_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRAFFIC_LIGHT_3B22DEE5_C976_43FF_B528_127733D61CD8 +#define TRAFFIC_LIGHT_3B22DEE5_C976_43FF_B528_127733D61CD8 + + +#include + +#include "async_state_machine.hpp" + + +namespace examples +{ + + +class traffic_light SX_FINAL +{ +public: + traffic_light( const std::string& _name, const std::string& _ascii_prefix ); + ~traffic_light() SX_NOEXCEPT; + SX_NO_COPY( traffic_light ) + void start(); + void stop(); + void switch_to_red_yellow(); + void switch_to_green(); + void switch_to_yellow(); + void switch_to_red(); + + +private: + void on_traffic_light_red() const; + void on_traffic_light_red_yellow() const; + void on_traffic_light_green() const; + void on_traffic_light_yellow() const; + void build_traffic_light_state_machine(); + std::string display_road_name_with_ascii_prefix() const; + + + sxy::async_state_machine traffic_light_state_machine_; + const std::string name_; + const std::string ascii_prefix_; +}; + + +} + + +#endif diff --git a/examples/event_collector_example/action.cpp b/examples/event_collector_example/action.cpp index fe53543..d881808 100644 --- a/examples/event_collector_example/action.cpp +++ b/examples/event_collector_example/action.cpp @@ -1,86 +1,86 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "action.hpp" - -#include - -#include "events.hpp" - - -namespace examples -{ - - - action::action() - { - // Nothing to do... - } - - - action::~action() SX_NOEXCEPT - { - // Nothing to do... - } - - -#ifndef SX_CPP03_BOOST - - void action::fire_event_E3( sxy::event_collector& _event_collector ) - { - _event_collector.push( examples::E3::create() ); - } - - - void action::fire_event_E4( sxy::event_collector& _event_collector ) - { - _event_collector.push( examples::E4::create( "The transition from simple state 'S3' to the final state has been executed!" ) ); - } - - void action::print_message_from_event( const E4& _event ) - { - std::cout << _event.get_message() << std::endl; - } - -#else - - void action::fire_event_E3( const sxy::event& _event, sxy::event_collector& _event_collector ) - { - SX_UNUSED_PARAMETER( _event ); - _event_collector.push( examples::E3::create() ); - } - - - void action::fire_event_E4( const sxy::event& _event, sxy::event_collector& _event_collector ) - { - SX_UNUSED_PARAMETER( _event ); - _event_collector.push( examples::E4::create( "The transition from simple state 'S3' to the final state has been executed!" ) ); - } - - - void action::print_message_from_event( const sxy::event& _event ) - { - const E4* specialized_event = dynamic_cast< const E4* >( &_event ); - if( specialized_event ) - { - std::cout << specialized_event->get_message() << std::endl; - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - -#endif - - - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "action.hpp" + +#include + +#include "events.hpp" + + +namespace examples +{ + + + action::action() + { + // Nothing to do... + } + + + action::~action() SX_NOEXCEPT + { + // Nothing to do... + } + + +#ifndef SX_CPP03_BOOST + + void action::fire_event_E3( sxy::event_collector& _event_collector ) + { + _event_collector.push( examples::E3::create() ); + } + + + void action::fire_event_E4( sxy::event_collector& _event_collector ) + { + _event_collector.push( examples::E4::create( "The transition from simple state 'S3' to the final state has been executed!" ) ); + } + + void action::print_message_from_event( const E4& _event ) + { + std::cout << _event.get_message() << std::endl; + } + +#else + + void action::fire_event_E3( const sxy::event& _event, sxy::event_collector& _event_collector ) + { + SX_UNUSED_PARAMETER( _event ); + _event_collector.push( examples::E3::create() ); + } + + + void action::fire_event_E4( const sxy::event& _event, sxy::event_collector& _event_collector ) + { + SX_UNUSED_PARAMETER( _event ); + _event_collector.push( examples::E4::create( "The transition from simple state 'S3' to the final state has been executed!" ) ); + } + + + void action::print_message_from_event( const sxy::event& _event ) + { + const E4* specialized_event = dynamic_cast< const E4* >( &_event ); + if( specialized_event ) + { + std::cout << specialized_event->get_message() << std::endl; + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + +#endif + + + + +} diff --git a/examples/event_collector_example/action.hpp b/examples/event_collector_example/action.hpp index c549cc1..c1204ae 100644 --- a/examples/event_collector_example/action.hpp +++ b/examples/event_collector_example/action.hpp @@ -1,63 +1,63 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ACTION_DC893E1A_85B8_4181_AF46_91C00262AB2A -#define ACTION_DC893E1A_85B8_4181_AF46_91C00262AB2A - - -#include "essentials/non_copyable.hpp" - - -namespace sxy -{ - - -#ifdef SX_CPP03_BOOST - class event; -#endif - - -class event_collector; - - -} - - -namespace examples -{ - - -class E4; - - -class action SX_FINAL -{ -public: - action(); - ~action() SX_NOEXCEPT; - SX_NO_COPY( action ) -#ifndef SX_CPP03_BOOST - void fire_event_E3( sxy::event_collector& _event_collector ); - void fire_event_E4( sxy::event_collector& _event_collector ); - void print_message_from_event( const E4& _event ); -#else - void fire_event_E3( const sxy::event& _event, sxy::event_collector& _event_collector ); - void fire_event_E4( const sxy::event& _event, sxy::event_collector& _event_collector ); - void print_message_from_event( const sxy::event& _event ); -#endif - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ACTION_DC893E1A_85B8_4181_AF46_91C00262AB2A +#define ACTION_DC893E1A_85B8_4181_AF46_91C00262AB2A + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + +#ifdef SX_CPP03_BOOST + class event; +#endif + + +class event_collector; + + +} + + +namespace examples +{ + + +class E4; + + +class action SX_FINAL +{ +public: + action(); + ~action() SX_NOEXCEPT; + SX_NO_COPY( action ) +#ifndef SX_CPP03_BOOST + void fire_event_E3( sxy::event_collector& _event_collector ); + void fire_event_E4( sxy::event_collector& _event_collector ); + void print_message_from_event( const E4& _event ); +#else + void fire_event_E3( const sxy::event& _event, sxy::event_collector& _event_collector ); + void fire_event_E4( const sxy::event& _event, sxy::event_collector& _event_collector ); + void print_message_from_event( const sxy::event& _event ); +#endif + +}; + + +} + + +#endif diff --git a/examples/event_collector_example/event_collector_example.vcxproj b/examples/event_collector_example/event_collector_example.vcxproj index cc30604..85dfa83 100644 --- a/examples/event_collector_example/event_collector_example.vcxproj +++ b/examples/event_collector_example/event_collector_example.vcxproj @@ -1,283 +1,283 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - Win32 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E} - event_collector_example - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v110 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - - - - - - - - - - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E} + event_collector_example + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v110 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/event_collector_example/event_collector_example.vcxproj.filters b/examples/event_collector_example/event_collector_example.vcxproj.filters index 16013fe..fdc3b2a 100644 --- a/examples/event_collector_example/event_collector_example.vcxproj.filters +++ b/examples/event_collector_example/event_collector_example.vcxproj.filters @@ -1,39 +1,39 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + \ No newline at end of file diff --git a/examples/event_collector_example/events.hpp b/examples/event_collector_example/events.hpp index 48959c2..acc0414 100644 --- a/examples/event_collector_example/events.hpp +++ b/examples/event_collector_example/events.hpp @@ -1,51 +1,51 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENTS_3DF961B9_B77A_4349_9F81_6D8AA0877248 -#define EVENTS_3DF961B9_B77A_4349_9F81_6D8AA0877248 - - -#include "yasmine.hpp" - - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - #define EVENT_1 1 - #define EVENT_2 2 - #define EVENT_3 3 - #define EVENT_4 4 -#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; -#endif - - -namespace examples -{ - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - Y_EVENT_WITH_ID( E1, EVENT_1 ) - Y_EVENT_WITH_ID( E2, EVENT_2 ) - Y_EVENT_WITH_ID( E3, EVENT_3 ) - Y_EVENT_1PARAM_WITH_ID( E4, std::string, get_message, EVENT_4 ) -#else - Y_EVENT_CREATE( E1, EVENT_1 ) - Y_EVENT_CREATE( E2, EVENT_2 ) - Y_EVENT_CREATE( E3, EVENT_3 ) - Y_EVENT_CREATE( E4, EVENT_4, std::string, get_message ) -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENTS_3DF961B9_B77A_4349_9F81_6D8AA0877248 +#define EVENTS_3DF961B9_B77A_4349_9F81_6D8AA0877248 + + +#include "yasmine.hpp" + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + #define EVENT_1 1 + #define EVENT_2 2 + #define EVENT_3 3 + #define EVENT_4 4 +#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; +#endif + + +namespace examples +{ + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + Y_EVENT_WITH_ID( E1, EVENT_1 ) + Y_EVENT_WITH_ID( E2, EVENT_2 ) + Y_EVENT_WITH_ID( E3, EVENT_3 ) + Y_EVENT_1PARAM_WITH_ID( E4, std::string, get_message, EVENT_4 ) +#else + Y_EVENT_CREATE( E1, EVENT_1 ) + Y_EVENT_CREATE( E2, EVENT_2 ) + Y_EVENT_CREATE( E3, EVENT_3 ) + Y_EVENT_CREATE( E4, EVENT_4, std::string, get_message ) +#endif + + +} + + +#endif diff --git a/examples/event_collector_example/machine.cpp b/examples/event_collector_example/machine.cpp index eb95e1f..8ed5e5b 100644 --- a/examples/event_collector_example/machine.cpp +++ b/examples/event_collector_example/machine.cpp @@ -1,118 +1,118 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "machine.hpp" -#include "events.hpp" - - -namespace examples -{ - - machine::machine() - : state_machine_(), - action_() - { - state_machine_ = setup_state_machine( "event collector state machine" ); - run_machine(); - } - - - machine::~machine() SX_NOEXCEPT - { - // Nothing to do... - } - - - int machine::run_machine() - { - int error_code = 0; - if( check_state_machine_for_defects( *state_machine_ ) ) - { - state_machine_->run(); - try - { - state_machine_->fire_event( examples::E1::create() ); - state_machine_->halt(); - } - catch( const std::exception& exception ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); - error_code = 1; - } - catch( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); - error_code = 2; - } - } - else - { - error_code = 3; - } - - return( error_code ); - } - - - state_machine_uptr machine::setup_state_machine( const std::string& _name ) - { - state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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 = main_region.add_initial_pseudostate( "initial" ); - sxy::simple_state& s1 = main_region.add_simple_state( "S1" ); - action* action_ptr = &action_; -#ifndef SX_CPP03_BOOST - sxy::simple_state& s2 = main_region.add_simple_state( "S2", - Y_BEHAVIOR_METHOD2( action_ptr, &examples::action::fire_event_E3 ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR ); -#else - sxy::simple_state& s2 = main_region.add_simple_state( "S2", - sxy::behavior_function( sxe::bind( &action::fire_event_E3, action_ptr, sxe::_1, sxe::_2 ) ), - Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR ); -#endif - sxy::simple_state& s3 = main_region.add_simple_state( "S3" ); - sxy::simple_state& s4 = main_region.add_simple_state( "S4" ); - sxy::final_state& final = main_region.add_final_state( "final" ); - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial, s1 ); - state_machine->add_transition( examples::E1::get_event_id(), s1, s2 ); - state_machine->add_transition( examples::E2::get_event_id(), s2, s3 ); - state_machine->add_transition( examples::E3::get_event_id(), s2, s4 ); -#ifndef SX_CPP03_BOOST - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s4, s3, - Y_BEHAVIOR_METHOD2( action_ptr, &examples::action::fire_event_E4 ) ); - state_machine->add_transition( examples::E4::get_event_id(), s3, final, - Y_BEHAVIOR_METHOD2( action_ptr, &examples::action::print_message_from_event ) ); -#else - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s4, s3, - sxy::behavior_function( sxe::bind( &action::fire_event_E4, action_ptr, sxe::_1, sxe::_2 ) ) ); - state_machine->add_transition( examples::E4::get_event_id(), s3, final, - sxy::behavior_function( sxe::bind( &action::print_message_from_event, action_ptr, sxe::_1 ) ) - ); -#endif - state_machine->add_transition( examples::E1::get_event_id(), s3, s2 ); - - return( sxe::move( state_machine ) ); - } - - - bool machine::check_state_machine_for_defects( const sxy::sync_state_machine& _state_machine ) - { - sxy::state_machine_defects defects; - const bool state_machine_has_no_defects = _state_machine.check( defects ); - if( !state_machine_has_no_defects ) - { - sxy::write_defects_to_log( defects ); - } - - return( state_machine_has_no_defects ); - } - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "machine.hpp" +#include "events.hpp" + + +namespace examples +{ + + machine::machine() + : state_machine_(), + action_() + { + state_machine_ = setup_state_machine( "event collector state machine" ); + run_machine(); + } + + + machine::~machine() SX_NOEXCEPT + { + // Nothing to do... + } + + + int machine::run_machine() + { + int error_code = 0; + if( check_state_machine_for_defects( *state_machine_ ) ) + { + state_machine_->run(); + try + { + state_machine_->fire_event( examples::E1::create() ); + state_machine_->halt(); + } + catch( const std::exception& exception ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); + error_code = 1; + } + catch( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); + error_code = 2; + } + } + else + { + error_code = 3; + } + + return( error_code ); + } + + + state_machine_uptr machine::setup_state_machine( const std::string& _name ) + { + state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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 = main_region.add_initial_pseudostate( "initial" ); + sxy::simple_state& s1 = main_region.add_simple_state( "S1" ); + action* action_ptr = &action_; +#ifndef SX_CPP03_BOOST + sxy::simple_state& s2 = main_region.add_simple_state( "S2", + Y_BEHAVIOR_METHOD2( action_ptr, &examples::action::fire_event_E3 ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR ); +#else + sxy::simple_state& s2 = main_region.add_simple_state( "S2", + sxy::behavior_function( sxe::bind( &action::fire_event_E3, action_ptr, sxe::_1, sxe::_2 ) ), + Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR ); +#endif + sxy::simple_state& s3 = main_region.add_simple_state( "S3" ); + sxy::simple_state& s4 = main_region.add_simple_state( "S4" ); + sxy::final_state& final = main_region.add_final_state( "final" ); + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial, s1 ); + state_machine->add_transition( examples::E1::get_event_id(), s1, s2 ); + state_machine->add_transition( examples::E2::get_event_id(), s2, s3 ); + state_machine->add_transition( examples::E3::get_event_id(), s2, s4 ); +#ifndef SX_CPP03_BOOST + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s4, s3, + Y_BEHAVIOR_METHOD2( action_ptr, &examples::action::fire_event_E4 ) ); + state_machine->add_transition( examples::E4::get_event_id(), s3, final, + Y_BEHAVIOR_METHOD2( action_ptr, &examples::action::print_message_from_event ) ); +#else + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, s4, s3, + sxy::behavior_function( sxe::bind( &action::fire_event_E4, action_ptr, sxe::_1, sxe::_2 ) ) ); + state_machine->add_transition( examples::E4::get_event_id(), s3, final, + sxy::behavior_function( sxe::bind( &action::print_message_from_event, action_ptr, sxe::_1 ) ) + ); +#endif + state_machine->add_transition( examples::E1::get_event_id(), s3, s2 ); + + return( sxe::move( state_machine ) ); + } + + + bool machine::check_state_machine_for_defects( const sxy::sync_state_machine& _state_machine ) + { + sxy::state_machine_defects defects; + const bool state_machine_has_no_defects = _state_machine.check( defects ); + if( !state_machine_has_no_defects ) + { + sxy::write_defects_to_log( defects ); + } + + return( state_machine_has_no_defects ); + } + +} diff --git a/examples/event_collector_example/machine.hpp b/examples/event_collector_example/machine.hpp index 68f48c5..d774e32 100644 --- a/examples/event_collector_example/machine.hpp +++ b/examples/event_collector_example/machine.hpp @@ -1,58 +1,58 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef MACHINE_B41DB262_B103_4A14_9F5E_C75B945CB276 -#define MACHINE_B41DB262_B103_4A14_9F5E_C75B945CB276 - - -#include "essentials/non_copyable.hpp" - -#include "action.hpp" - - -namespace sxy -{ - - -class sync_state_machine; - - -} - - -namespace examples -{ - - -typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; - - -class machine SX_FINAL -{ - -public: - machine(); - ~machine() SX_NOEXCEPT; - SX_NO_COPY( machine ) -private: - int run_machine(); - state_machine_uptr setup_state_machine( const std::string& _name ); - bool check_state_machine_for_defects( const sxy::sync_state_machine& _state_machine ); - - state_machine_uptr state_machine_; - action action_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef MACHINE_B41DB262_B103_4A14_9F5E_C75B945CB276 +#define MACHINE_B41DB262_B103_4A14_9F5E_C75B945CB276 + + +#include "essentials/non_copyable.hpp" + +#include "action.hpp" + + +namespace sxy +{ + + +class sync_state_machine; + + +} + + +namespace examples +{ + + +typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; + + +class machine SX_FINAL +{ + +public: + machine(); + ~machine() SX_NOEXCEPT; + SX_NO_COPY( machine ) +private: + int run_machine(); + state_machine_uptr setup_state_machine( const std::string& _name ); + bool check_state_machine_for_defects( const sxy::sync_state_machine& _state_machine ); + + state_machine_uptr state_machine_; + action action_; +}; + + +} + + +#endif diff --git a/examples/event_collector_example/main.cpp b/examples/event_collector_example/main.cpp index 330fa32..0478272 100644 --- a/examples/event_collector_example/main.cpp +++ b/examples/event_collector_example/main.cpp @@ -1,32 +1,32 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include - -#include "machine.hpp" -#include "yasmine.hpp" - - -int main() -{ - int error_code = 0; - - hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); - log_manager.set_log_level( hermes::log_level::LL_ERROR ); - log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); - log_manager.run(); - sxy::version::log_version(); - - examples::machine machine_example; - - log_manager.halt_and_join(); - - return( error_code ); -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +#include "machine.hpp" +#include "yasmine.hpp" + + +int main() +{ + int error_code = 0; + + hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); + log_manager.set_log_level( hermes::log_level::LL_ERROR ); + log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); + log_manager.run(); + sxy::version::log_version(); + + examples::machine machine_example; + + log_manager.halt_and_join(); + + return( error_code ); +} diff --git a/examples/events_with_parameters/class_method_downcast.cpp b/examples/events_with_parameters/class_method_downcast.cpp index f1a1688..a654eda 100644 --- a/examples/events_with_parameters/class_method_downcast.cpp +++ b/examples/events_with_parameters/class_method_downcast.cpp @@ -1,172 +1,172 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "class_method_downcast.hpp" - -#include - -#include "event_collector.hpp" - - -namespace examples -{ - - -class_method_downcast::class_method_downcast() -{ - state_machine_uptr state_machine = setup_state_machine( "downcast_event_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->halt(); -} - - -class_method_downcast::~class_method_downcast() SX_NOEXCEPT -{ - // Nothing to do... -} - - -#ifndef SX_CPP03_BOOST -void class_method_downcast::do_something_event_2_parameters( const event_2& _event, sxy::event_collector& _event_collector ) -{ - SX_UNUSED_PARAMETER( _event_collector ); - std::cout << "Parameters of event " << _event.get_name() << " are:\n" << _event.get_param_1() << "\n" << - _event.get_param_2() << std::endl; -} -#else -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 ) - { - 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 - { - const sxy::completion_event* specialized_event2 = dynamic_cast< const sxy::completion_event* >( &_event ); - if( specialized_event2 ) - { - do_something_event_0_parameters( _event ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } -} -#endif - - -#ifndef SX_CPP03_BOOST -void class_method_downcast::do_something_event_1_parameter( const event_1& _event, sxy::event_collector& _event_collector ) -{ - SX_UNUSED_PARAMETER( _event_collector ); - 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 sxy::event& _event ) -{ - const event_1* specialized_event = dynamic_cast< const event_1* >( &_event ); - if( specialized_event ) - { - std::cout << "Parameter of event " << specialized_event->get_name() << " is: " << specialized_event->get_param() << std::endl; - } - else - { - throw sxe::exception( "Invalid event type!" ); - } -} -#endif - - -#ifndef SX_CPP03_BOOST -void class_method_downcast::do_something_event_0_parameters( const sxy::completion_event& _event, sxy::event_collector& _event_collector ) -{ - SX_UNUSED_PARAMETER( _event ); - SX_UNUSED_PARAMETER( _event_collector ); - std::cout << "Completion event has no parameters." << std::endl; -} -#else -void class_method_downcast::do_something_event_0_parameters( const sxy::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; - } - else - { - throw sxe::exception( "Invalid event type!" ); - } -} -#endif - - -state_machine_uptr class_method_downcast::setup_state_machine( const std::string& _name ) -{ - state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); -#ifndef SX_CPP03_BOOST - sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters, - &class_method_downcast::do_something_event_0_parameters ), - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters, - &class_method_downcast::do_something_event_0_parameters), - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ) ); - - sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ), - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ), - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters ) ); - - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_0_parameters ) ); - state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ) ); - state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters ) ); - -#else - sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ) ); - - sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ) ); - - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_0_parameters, this, sxe::_1 ) ) ); - state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ) ); - state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ) ); -#endif - - - return( sxe::move( state_machine ) ); -} - - -void use_method_downcast() -{ - class_method_downcast method_downcast; -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "class_method_downcast.hpp" + +#include + +#include "event_collector.hpp" + + +namespace examples +{ + + +class_method_downcast::class_method_downcast() +{ + state_machine_uptr state_machine = setup_state_machine( "downcast_event_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->halt(); +} + + +class_method_downcast::~class_method_downcast() SX_NOEXCEPT +{ + // Nothing to do... +} + + +#ifndef SX_CPP03_BOOST +void class_method_downcast::do_something_event_2_parameters( const event_2& _event, sxy::event_collector& _event_collector ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + std::cout << "Parameters of event " << _event.get_name() << " are:\n" << _event.get_param_1() << "\n" << + _event.get_param_2() << std::endl; +} +#else +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 ) + { + 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 + { + const sxy::completion_event* specialized_event2 = dynamic_cast< const sxy::completion_event* >( &_event ); + if( specialized_event2 ) + { + do_something_event_0_parameters( _event ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } +} +#endif + + +#ifndef SX_CPP03_BOOST +void class_method_downcast::do_something_event_1_parameter( const event_1& _event, sxy::event_collector& _event_collector ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + 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 sxy::event& _event ) +{ + const event_1* specialized_event = dynamic_cast< const event_1* >( &_event ); + if( specialized_event ) + { + std::cout << "Parameter of event " << specialized_event->get_name() << " is: " << specialized_event->get_param() << std::endl; + } + else + { + throw sxe::exception( "Invalid event type!" ); + } +} +#endif + + +#ifndef SX_CPP03_BOOST +void class_method_downcast::do_something_event_0_parameters( const sxy::completion_event& _event, sxy::event_collector& _event_collector ) +{ + SX_UNUSED_PARAMETER( _event ); + SX_UNUSED_PARAMETER( _event_collector ); + std::cout << "Completion event has no parameters." << std::endl; +} +#else +void class_method_downcast::do_something_event_0_parameters( const sxy::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; + } + else + { + throw sxe::exception( "Invalid event type!" ); + } +} +#endif + + +state_machine_uptr class_method_downcast::setup_state_machine( const std::string& _name ) +{ + state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); +#ifndef SX_CPP03_BOOST + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters, + &class_method_downcast::do_something_event_0_parameters ), + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters, + &class_method_downcast::do_something_event_0_parameters), + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ) ); + + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ), + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ), + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_0_parameters ) ); + state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_1_parameter ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + Y_BEHAVIOR_METHOD2( this, &class_method_downcast::do_something_event_2_parameters ) ); + +#else + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ) ); + + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_0_parameters, this, sxe::_1 ) ) ); + state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_1_parameter, this, sxe::_1 ) ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + sxy::behavior_function( sxe::bind( &class_method_downcast::do_something_event_2_parameters, this, sxe::_1 ) ) ); +#endif + + + return( sxe::move( state_machine ) ); +} + + +void use_method_downcast() +{ + class_method_downcast method_downcast; +} + + +} diff --git a/examples/events_with_parameters/class_method_downcast.hpp b/examples/events_with_parameters/class_method_downcast.hpp index d4b9e3b..4a20c8f 100644 --- a/examples/events_with_parameters/class_method_downcast.hpp +++ b/examples/events_with_parameters/class_method_downcast.hpp @@ -1,52 +1,52 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CLASS_METHOD_DOWNCAST_CCA48F47_4FDA_41C2_A6CE_EF8ED80002FA -#define CLASS_METHOD_DOWNCAST_CCA48F47_4FDA_41C2_A6CE_EF8ED80002FA - - -#include "events.hpp" - - -namespace examples -{ - - -typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; - - -class class_method_downcast SX_FINAL -{ -public: - class_method_downcast(); - ~class_method_downcast() SX_NOEXCEPT; - SX_NO_COPY( class_method_downcast ) - -private: -#ifndef SX_CPP03_BOOST - void do_something_event_2_parameters( const event_2& _event, sxy::event_collector& _event_collector ); - void do_something_event_1_parameter( const event_1& _event, sxy::event_collector& _event_collector ); - void do_something_event_0_parameters( const sxy::completion_event& _event, sxy::event_collector& _event_collector ); -#else - 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 ); -}; - - -void use_method_downcast(); - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CLASS_METHOD_DOWNCAST_CCA48F47_4FDA_41C2_A6CE_EF8ED80002FA +#define CLASS_METHOD_DOWNCAST_CCA48F47_4FDA_41C2_A6CE_EF8ED80002FA + + +#include "events.hpp" + + +namespace examples +{ + + +typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; + + +class class_method_downcast SX_FINAL +{ +public: + class_method_downcast(); + ~class_method_downcast() SX_NOEXCEPT; + SX_NO_COPY( class_method_downcast ) + +private: +#ifndef SX_CPP03_BOOST + void do_something_event_2_parameters( const event_2& _event, sxy::event_collector& _event_collector ); + void do_something_event_1_parameter( const event_1& _event, sxy::event_collector& _event_collector ); + void do_something_event_0_parameters( const sxy::completion_event& _event, sxy::event_collector& _event_collector ); +#else + 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 ); +}; + + +void use_method_downcast(); + + +} + +#endif diff --git a/examples/events_with_parameters/downcast_event.cpp b/examples/events_with_parameters/downcast_event.cpp index 11270e6..be072aa 100644 --- a/examples/events_with_parameters/downcast_event.cpp +++ b/examples/events_with_parameters/downcast_event.cpp @@ -1,124 +1,124 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "downcast_event.hpp" - -#include - -#include "events.hpp" - - -namespace -{ - -typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; - - -void do_something_event_2_parameters( const sxy::event& _event ) -{ - const examples::event_2* event_with_param = dynamic_cast< const examples::event_2* >( &_event ); - - if( event_with_param ) - { - std::cout << "Parameters of event " << event_with_param->get_name() << " are:\n" << - event_with_param->get_param_1() << "\n" << event_with_param->get_param_2() << std::endl; - } - else - { - std::cout << "No event parameter.\n"; - } -} - - -void do_something_event_1_parameter( const sxy::event& _event ) -{ - const examples::event_1* event_with_param = dynamic_cast< const examples::event_1* >( &_event ); - - if( event_with_param ) - { - std::cout << "Parameter of event " << event_with_param->get_name() << " is: " << event_with_param->get_param() << - std::endl; - } - else - { - SX_ASSERT( false, "No event parameter" ); - } -} - - -void do_something_event_0_parameters( const sxy::event& _event ) -{ - SX_UNUSED_PARAMETER( _event ); - std::cout << "Event with no parameters." << std::endl; -} - - -} - - -namespace examples -{ - - -state_machine_uptr setup_state_machine( const std::string& _name ) -{ - state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); -#ifdef SX_CPP03_BOOST - 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_BEHAVIOR_FUNCTION( do_something_event_1_parameter ) ); - state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOR_FUNCTION( do_something_event_2_parameters ) ); -#else - sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ), - Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ), - Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ) ); - sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ), - Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ), - Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ) ); - - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - Y_BEHAVIOR_FUNCTION2( do_something_event_0_parameters ) ); - state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ) ); - state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ) ); -#endif - return( sxe::move( state_machine ) ); -} - - -void downcast_event() -{ - state_machine_uptr state_machine = setup_state_machine( "downcast_event_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->halt(); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "downcast_event.hpp" + +#include + +#include "events.hpp" + + +namespace +{ + +typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; + + +void do_something_event_2_parameters( const sxy::event& _event ) +{ + const examples::event_2* event_with_param = dynamic_cast< const examples::event_2* >( &_event ); + + if( event_with_param ) + { + std::cout << "Parameters of event " << event_with_param->get_name() << " are:\n" << + event_with_param->get_param_1() << "\n" << event_with_param->get_param_2() << std::endl; + } + else + { + std::cout << "No event parameter.\n"; + } +} + + +void do_something_event_1_parameter( const sxy::event& _event ) +{ + const examples::event_1* event_with_param = dynamic_cast< const examples::event_1* >( &_event ); + + if( event_with_param ) + { + std::cout << "Parameter of event " << event_with_param->get_name() << " is: " << event_with_param->get_param() << + std::endl; + } + else + { + SX_ASSERT( false, "No event parameter" ); + } +} + + +void do_something_event_0_parameters( const sxy::event& _event ) +{ + SX_UNUSED_PARAMETER( _event ); + std::cout << "Event with no parameters." << std::endl; +} + + +} + + +namespace examples +{ + + +state_machine_uptr setup_state_machine( const std::string& _name ) +{ + state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); +#ifdef SX_CPP03_BOOST + 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_BEHAVIOR_FUNCTION( do_something_event_1_parameter ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + Y_BEHAVIOR_FUNCTION( do_something_event_2_parameters ) ); +#else + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ) ); + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + Y_BEHAVIOR_FUNCTION2( do_something_event_0_parameters ) ); + state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ) ); +#endif + return( sxe::move( state_machine ) ); +} + + +void downcast_event() +{ + state_machine_uptr state_machine = setup_state_machine( "downcast_event_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->halt(); +} + + +} diff --git a/examples/events_with_parameters/downcast_event.hpp b/examples/events_with_parameters/downcast_event.hpp index fe3eebb..0b5359e 100644 --- a/examples/events_with_parameters/downcast_event.hpp +++ b/examples/events_with_parameters/downcast_event.hpp @@ -1,24 +1,24 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DOWNCAST_EVENT_59195EF3_F9F0_47C4_BF1F_67C3AC807C0B -#define DOWNCAST_EVENT_59195EF3_F9F0_47C4_BF1F_67C3AC807C0B - - -namespace examples -{ - - void downcast_event(); - -} - - +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DOWNCAST_EVENT_59195EF3_F9F0_47C4_BF1F_67C3AC807C0B +#define DOWNCAST_EVENT_59195EF3_F9F0_47C4_BF1F_67C3AC807C0B + + +namespace examples +{ + + void downcast_event(); + +} + + #endif \ No newline at end of file diff --git a/examples/events_with_parameters/events.hpp b/examples/events_with_parameters/events.hpp index d71d5db..521cbd8 100644 --- a/examples/events_with_parameters/events.hpp +++ b/examples/events_with_parameters/events.hpp @@ -1,43 +1,43 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENTS_21338320_A7F5_43B1_90D9_E0FBED2D211B -#define EVENTS_21338320_A7F5_43B1_90D9_E0FBED2D211B - - -#include "yasmine.hpp" - - -#if defined( SX_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 -{ - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - 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 ) -#else - Y_EVENT_CREATE( event_1, EVENT_1, std::string, get_param ) - Y_EVENT_CREATE( event_2, EVENT_2, int, get_param_1, double, get_param_2 ) -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENTS_21338320_A7F5_43B1_90D9_E0FBED2D211B +#define EVENTS_21338320_A7F5_43B1_90D9_E0FBED2D211B + + +#include "yasmine.hpp" + + +#if defined( SX_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 +{ + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + 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 ) +#else + Y_EVENT_CREATE( event_1, EVENT_1, std::string, get_param ) + Y_EVENT_CREATE( event_2, EVENT_2, int, get_param_1, double, get_param_2 ) +#endif + + +} + + +#endif diff --git a/examples/events_with_parameters/events_with_parameters.cpp b/examples/events_with_parameters/events_with_parameters.cpp index 0bc9860..1429d68 100644 --- a/examples/events_with_parameters/events_with_parameters.cpp +++ b/examples/events_with_parameters/events_with_parameters.cpp @@ -1,29 +1,29 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include - -#include "downcast_event.hpp" -#include "function_downcast.hpp" -#include "class_method_downcast.hpp" - - -int main() -{ - std::cout << "#1 Downcast event scenario:" << std::endl; - examples::downcast_event(); - - std::cout << "#2 Use function downcast scenario:" << std::endl; - examples::use_function_downcast(); - - std::cout << "#3 Use class method downcast scenario:" << std::endl; - examples::use_method_downcast(); - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +#include "downcast_event.hpp" +#include "function_downcast.hpp" +#include "class_method_downcast.hpp" + + +int main() +{ + std::cout << "#1 Downcast event scenario:" << std::endl; + examples::downcast_event(); + + std::cout << "#2 Use function downcast scenario:" << std::endl; + examples::use_function_downcast(); + + std::cout << "#3 Use class method downcast scenario:" << std::endl; + examples::use_method_downcast(); + +} diff --git a/examples/events_with_parameters/events_with_parameters.vcxproj b/examples/events_with_parameters/events_with_parameters.vcxproj index 1c51222..a3a8a2e 100644 --- a/examples/events_with_parameters/events_with_parameters.vcxproj +++ b/examples/events_with_parameters/events_with_parameters.vcxproj @@ -1,416 +1,416 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - VS 2013 - Win32 - - - Debug - VS 2013 - x64 - - - Debug - Win32 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - VS 2013 - Win32 - - - Release - VS 2013 - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - {44767840-E79D-4049-B97B-867D32783090} - events_with_parameters - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - MachineX64 - - - - - Level3 - Disabled - true - - - true - MachineX64 - - - - - Level3 - Disabled - true - - - true - MachineX64 - - - - - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - MachineX64 - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - VS 2013 + Win32 + + + Debug - VS 2013 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + {44767840-E79D-4049-B97B-867D32783090} + events_with_parameters + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + MachineX64 + + + + + Level3 + Disabled + true + + + true + MachineX64 + + + + + Level3 + Disabled + true + + + true + MachineX64 + + + + + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + \ No newline at end of file diff --git a/examples/events_with_parameters/events_with_parameters.vcxproj.filters b/examples/events_with_parameters/events_with_parameters.vcxproj.filters index 263a6d6..73b8696 100644 --- a/examples/events_with_parameters/events_with_parameters.vcxproj.filters +++ b/examples/events_with_parameters/events_with_parameters.vcxproj.filters @@ -1,51 +1,51 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {eb9689c5-df18-42e0-9405-7bb311feb1e6} - - - {c05790a3-ead9-4b41-b433-e57da004705b} - - - - - Source Files\Downcast - - - Source Files - - - Source Files\Downcast - - - Source Files\Downcast - - - - - Header Files\Downcast - - - Header Files\Downcast - - - Header Files\Downcast - - - Header Files\Downcast - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {eb9689c5-df18-42e0-9405-7bb311feb1e6} + + + {c05790a3-ead9-4b41-b433-e57da004705b} + + + + + Source Files\Downcast + + + Source Files + + + Source Files\Downcast + + + Source Files\Downcast + + + + + Header Files\Downcast + + + Header Files\Downcast + + + Header Files\Downcast + + + Header Files\Downcast + + \ No newline at end of file diff --git a/examples/events_with_parameters/function_downcast.cpp b/examples/events_with_parameters/function_downcast.cpp index 54912e7..3f55049 100644 --- a/examples/events_with_parameters/function_downcast.cpp +++ b/examples/events_with_parameters/function_downcast.cpp @@ -1,164 +1,164 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "function_downcast.hpp" - -#include - -#include "events.hpp" - - -namespace -{ - - -typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; - - -#ifndef SX_CPP03_BOOST -void do_something_event_0_parameters( const sxy::completion_event& _event, sxy::event_collector& _event_collector ) -{ - SX_UNUSED_PARAMETER( _event ); - SX_UNUSED_PARAMETER( _event_collector ); - std::cout << "Completion event has no parameters." << std::endl; -} -#else -void do_something_event_0_parameters( const sxy::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; - } - else - { - throw sxe::exception( "Invalid event type!" ); - } -} -#endif - - -#ifndef SX_CPP03_BOOST -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 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; - } - else - { - throw sxe::exception( "Invalid event type!" ); - } -} -#endif - - -#ifndef SX_CPP03_BOOST -void do_something_event_2_parameters( const examples::event_2& _event, sxy::event_collector& _event_collector ) -{ - SX_UNUSED_PARAMETER( _event_collector ); - std::cout << "Parameters of event " << _event.get_name() << " are:\n" << _event.get_param_1() << "\n" << - _event.get_param_2() << std::endl; -} -#else -void do_something_event_2_parameters( const sxy::event& _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; - } - else - { - const sxy::completion_event* specialized_event2 = dynamic_cast< const sxy::completion_event* >( &_event ); - if( specialized_event2 ) - { - do_something_event_0_parameters( _event ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } -} -#endif - - -state_machine_uptr setup_state_machine2( const std::string& _name ) -{ - state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); -#ifndef SX_CPP03_BOOST - sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - Y_BEHAVIOR_FUNCTION2( &do_something_event_0_parameters, &do_something_event_2_parameters ), - Y_BEHAVIOR_FUNCTION2( &do_something_event_0_parameters, &do_something_event_2_parameters ), - Y_BEHAVIOR_FUNCTION2( &do_something_event_1_parameter ) ); - sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - Y_BEHAVIOR_FUNCTION2( &do_something_event_1_parameter ), - Y_BEHAVIOR_FUNCTION2( &do_something_event_1_parameter ), - Y_BEHAVIOR_FUNCTION2( &do_something_event_2_parameters ) ); - - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - Y_BEHAVIOR_FUNCTION2( &do_something_event_0_parameters ) ); - state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - Y_BEHAVIOR_FUNCTION2( &do_something_event_1_parameter ) ); - state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - Y_BEHAVIOR_FUNCTION2( &do_something_event_2_parameters ) ); -#else - sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", - sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ) ); - sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", - sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ), - sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ) ); - - state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, - sxy::behavior_function( sxe::bind( &do_something_event_0_parameters, sxe::_1 ) ) ); - state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, - sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ) ); - state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, - sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ) ); -#endif - - - return( sxe::move( state_machine ) ); -} - - -} - - -namespace examples -{ - - -void use_function_downcast() -{ - state_machine_uptr state_machine = setup_state_machine2( "downcast_event_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->halt(); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "function_downcast.hpp" + +#include + +#include "events.hpp" + + +namespace +{ + + +typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; + + +#ifndef SX_CPP03_BOOST +void do_something_event_0_parameters( const sxy::completion_event& _event, sxy::event_collector& _event_collector ) +{ + SX_UNUSED_PARAMETER( _event ); + SX_UNUSED_PARAMETER( _event_collector ); + std::cout << "Completion event has no parameters." << std::endl; +} +#else +void do_something_event_0_parameters( const sxy::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; + } + else + { + throw sxe::exception( "Invalid event type!" ); + } +} +#endif + + +#ifndef SX_CPP03_BOOST +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 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; + } + else + { + throw sxe::exception( "Invalid event type!" ); + } +} +#endif + + +#ifndef SX_CPP03_BOOST +void do_something_event_2_parameters( const examples::event_2& _event, sxy::event_collector& _event_collector ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + std::cout << "Parameters of event " << _event.get_name() << " are:\n" << _event.get_param_1() << "\n" << + _event.get_param_2() << std::endl; +} +#else +void do_something_event_2_parameters( const sxy::event& _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; + } + else + { + const sxy::completion_event* specialized_event2 = dynamic_cast< const sxy::completion_event* >( &_event ); + if( specialized_event2 ) + { + do_something_event_0_parameters( _event ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } +} +#endif + + +state_machine_uptr setup_state_machine2( const std::string& _name ) +{ + state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); +#ifndef SX_CPP03_BOOST + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + Y_BEHAVIOR_FUNCTION2( do_something_event_0_parameters, do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION2( do_something_event_0_parameters, do_something_event_2_parameters ), + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ) ); + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ), + Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + Y_BEHAVIOR_FUNCTION2( do_something_event_0_parameters ) ); + state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, + Y_BEHAVIOR_FUNCTION2( do_something_event_1_parameter ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + Y_BEHAVIOR_FUNCTION2( do_something_event_2_parameters ) ); +#else + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "1", + sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ) ); + sxy::simple_state& simple_state_2 = main_region.add_simple_state( "2", + sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ), + sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ) ); + + state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, initial_pseudostate, simple_state_1, + sxy::behavior_function( sxe::bind( &do_something_event_0_parameters, sxe::_1 ) ) ); + state_machine->add_transition( EVENT_1, simple_state_1, simple_state_2, + sxy::behavior_function( sxe::bind( &do_something_event_1_parameter, sxe::_1 ) ) ); + state_machine->add_transition( EVENT_2, simple_state_2, simple_state_1, + sxy::behavior_function( sxe::bind( &do_something_event_2_parameters, sxe::_1 ) ) ); +#endif + + + return( sxe::move( state_machine ) ); +} + + +} + + +namespace examples +{ + + +void use_function_downcast() +{ + state_machine_uptr state_machine = setup_state_machine2( "downcast_event_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->halt(); +} + + +} diff --git a/examples/events_with_parameters/function_downcast.hpp b/examples/events_with_parameters/function_downcast.hpp index f89baae..8cbf98c 100644 --- a/examples/events_with_parameters/function_downcast.hpp +++ b/examples/events_with_parameters/function_downcast.hpp @@ -1,24 +1,24 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FUNCTION_DOWNCAST_F8097BC3_DB64_4220_B2F7_7113B069EB7D -#define FUNCTION_DOWNCAST_F8097BC3_DB64_4220_B2F7_7113B069EB7D - - -namespace examples -{ - - void use_function_downcast(); - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FUNCTION_DOWNCAST_F8097BC3_DB64_4220_B2F7_7113B069EB7D +#define FUNCTION_DOWNCAST_F8097BC3_DB64_4220_B2F7_7113B069EB7D + + +namespace examples +{ + + void use_function_downcast(); + +} + + +#endif diff --git a/examples/forty_two/forty_two.cpp b/examples/forty_two/forty_two.cpp index c6ca7f6..3e37029 100644 --- a/examples/forty_two/forty_two.cpp +++ b/examples/forty_two/forty_two.cpp @@ -1,418 +1,418 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "forty_two.hpp" - -#include -#include -#include - -#ifdef Y_PROFILER - #include "conversion.hpp" -#endif - -namespace examples -{ - -#ifdef SX_CPP03_BOOST - 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 ) -#else - Y_EVENT_CREATE( event_A, 1 ) - Y_EVENT_CREATE( event_B, 2 ) - Y_EVENT_CREATE( event_C, 3 ) - Y_EVENT_CREATE( event_D, 4 ) - Y_EVENT_CREATE( event_E, 5 ) - Y_EVENT_CREATE( event_F, 6 ) - Y_EVENT_CREATE( event_G, 7 ) - Y_EVENT_CREATE( event_H, 8 ) - Y_EVENT_CREATE( event_I, 9 ) - Y_EVENT_CREATE( event_J, 10 ) - Y_EVENT_CREATE( event_K, 11 ) - Y_EVENT_CREATE( event_L, 12 ) - Y_EVENT_CREATE( event_M, 13 ) - Y_EVENT_CREATE( event_N, 14 ) - Y_EVENT_CREATE( event_O, 15 ) - Y_EVENT_CREATE( event_P, 16 ) - Y_EVENT_CREATE( event_Q, 17 ) - Y_EVENT_CREATE( event_R, 18 ) - Y_EVENT_CREATE( event_S, 19 ) - Y_EVENT_CREATE( event_T, 20 ) -#endif - - -forty_two::forty_two( const sxe::uint32_t _max_iterations ) - : state_machine_( build_state_machine() ), - iterations_( 0 ), - max_iterations_( _max_iterations ) -{ - SX_ASSERT( check_state_machine(), "State machine has defects!" ); - run(); -} - - -forty_two::~forty_two() SX_NOEXCEPT -{ - // Nothing to do... -} - - -forty_two::state_machine_uptr forty_two::build_state_machine() -{ - sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > l_state_machine = - SX_MAKE_UNIQUE< sxy::sync_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 SX_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_METHOD2( this, &forty_two::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 SX_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_METHOD2( this, &forty_two::check_iterations_divided_by_2 ) ); -#endif - l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, choice1, junction1 ); - -#ifdef SX_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_METHOD2( this, &forty_two::check_iterations_divided_by_3 ) ); - l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s21, - Y_GUARD_METHOD2( this, &forty_two::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 SX_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_METHOD2( this, &forty_two::check_iterations_exceded ) ); -#endif - l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction2, s1 ); - return( sxe::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_; - SX_LOG( hermes::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 SX_NO_LOGGING - hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); - log_manager.set_log_level( hermes::log_level::LL_DEBUG ); - log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); - log_manager.run(); -#endif - - sxe::system_clock::time_point start = sxe::system_clock::now(); - - bool starting_success = state_machine_->run(); - SX_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 sxe::system_clock::time_point stop = sxe::system_clock::now(); - -#ifdef Y_PROFILER - SX_LOG( log_level::LL_INFO, "% events were fired.", - sxe::to_string( state_machine_->get_number_of_processed_events() ) ); -#endif - - state_machine_->halt(); - - SX_LOG( hermes::log_level::LL_INFO, "Run time: % seconds", - sxe::duration_cast< sxe::seconds >( stop - start ).count() ); - -#ifndef SX_NO_LOGGING - log_manager.halt_and_join(); -#endif - - std::cin.get(); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "forty_two.hpp" + +#include +#include +#include + +#ifdef Y_PROFILER + #include "conversion.hpp" +#endif + +namespace examples +{ + +#ifdef SX_CPP03_BOOST + 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 ) +#else + Y_EVENT_CREATE( event_A, 1 ) + Y_EVENT_CREATE( event_B, 2 ) + Y_EVENT_CREATE( event_C, 3 ) + Y_EVENT_CREATE( event_D, 4 ) + Y_EVENT_CREATE( event_E, 5 ) + Y_EVENT_CREATE( event_F, 6 ) + Y_EVENT_CREATE( event_G, 7 ) + Y_EVENT_CREATE( event_H, 8 ) + Y_EVENT_CREATE( event_I, 9 ) + Y_EVENT_CREATE( event_J, 10 ) + Y_EVENT_CREATE( event_K, 11 ) + Y_EVENT_CREATE( event_L, 12 ) + Y_EVENT_CREATE( event_M, 13 ) + Y_EVENT_CREATE( event_N, 14 ) + Y_EVENT_CREATE( event_O, 15 ) + Y_EVENT_CREATE( event_P, 16 ) + Y_EVENT_CREATE( event_Q, 17 ) + Y_EVENT_CREATE( event_R, 18 ) + Y_EVENT_CREATE( event_S, 19 ) + Y_EVENT_CREATE( event_T, 20 ) +#endif + + +forty_two::forty_two( const sxe::uint32_t _max_iterations ) + : state_machine_( build_state_machine() ), + iterations_( 0 ), + max_iterations_( _max_iterations ) +{ + SX_ASSERT( check_state_machine(), "State machine has defects!" ); + run(); +} + + +forty_two::~forty_two() SX_NOEXCEPT +{ + // Nothing to do... +} + + +forty_two::state_machine_uptr forty_two::build_state_machine() +{ + sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > l_state_machine = + SX_MAKE_UNIQUE< sxy::sync_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 SX_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_METHOD2( this, &forty_two::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 SX_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_METHOD2( this, &forty_two::check_iterations_divided_by_2 ) ); +#endif + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, choice1, junction1 ); + +#ifdef SX_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_METHOD2( this, &forty_two::check_iterations_divided_by_3 ) ); + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction1, s21, + Y_GUARD_METHOD2( this, &forty_two::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 SX_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_METHOD2( this, &forty_two::check_iterations_exceded ) ); +#endif + l_state_machine->add_transition( sxy::Y_COMPLETION_EVENT_ID, junction2, s1 ); + return( sxe::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_; + SX_LOG( hermes::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 SX_NO_LOGGING + hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); + log_manager.set_log_level( hermes::log_level::LL_DEBUG ); + log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); + log_manager.run(); +#endif + + sxe::system_clock::time_point start = sxe::system_clock::now(); + + bool starting_success = state_machine_->run(); + SX_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 sxe::system_clock::time_point stop = sxe::system_clock::now(); + +#ifdef Y_PROFILER + SX_LOG( log_level::LL_INFO, "% events were fired.", + sxe::to_string( state_machine_->get_number_of_processed_events() ) ); +#endif + + state_machine_->halt(); + + SX_LOG( hermes::log_level::LL_INFO, "Run time: % seconds", + sxe::duration_cast< sxe::seconds >( stop - start ).count() ); + +#ifndef SX_NO_LOGGING + log_manager.halt_and_join(); +#endif + + std::cin.get(); +} + + +} diff --git a/examples/forty_two/forty_two.hpp b/examples/forty_two/forty_two.hpp index c64eafb..f74eab2 100644 --- a/examples/forty_two/forty_two.hpp +++ b/examples/forty_two/forty_two.hpp @@ -1,56 +1,56 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FORTY_TWO_7FADB8D9_22B1_4505_AF48_2E655055D7E3 -#define FORTY_TWO_7FADB8D9_22B1_4505_AF48_2E655055D7E3 - - -#include - -#include "yasmine.hpp" - - -namespace examples -{ - - -class forty_two SX_FINAL -{ -public: - - typedef sxe::SX_UNIQUE_PTR state_machine_uptr; - - - explicit forty_two( const sxe::uint32_t _max_iterations ); - ~forty_two() SX_NOEXCEPT; - -private: - state_machine_uptr build_state_machine(); - bool check_state_machine() const; - void increment_iterations(); - bool check_iterations_divided_by_2() const; - bool check_iterations_divided_by_3() const; - bool check_iterations_divided_by_5() const; - bool check_iterations_exceded() const; - void run(); - - - state_machine_uptr state_machine_; - uint32_t iterations_; - uint32_t max_iterations_; - - -}; - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORTY_TWO_7FADB8D9_22B1_4505_AF48_2E655055D7E3 +#define FORTY_TWO_7FADB8D9_22B1_4505_AF48_2E655055D7E3 + + +#include + +#include "yasmine.hpp" + + +namespace examples +{ + + +class forty_two SX_FINAL +{ +public: + + typedef sxe::SX_UNIQUE_PTR state_machine_uptr; + + + explicit forty_two( const sxe::uint32_t _max_iterations ); + ~forty_two() SX_NOEXCEPT; + +private: + state_machine_uptr build_state_machine(); + bool check_state_machine() const; + void increment_iterations(); + bool check_iterations_divided_by_2() const; + bool check_iterations_divided_by_3() const; + bool check_iterations_divided_by_5() const; + bool check_iterations_exceded() const; + void run(); + + + state_machine_uptr state_machine_; + uint32_t iterations_; + uint32_t max_iterations_; + + +}; + + +} + +#endif diff --git a/examples/forty_two/forty_two.vcxproj b/examples/forty_two/forty_two.vcxproj index f78408a..a611431 100644 --- a/examples/forty_two/forty_two.vcxproj +++ b/examples/forty_two/forty_two.vcxproj @@ -1,389 +1,389 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - VS 2013 - Win32 - - - Debug - VS 2013 - x64 - - - Debug - Win32 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - VS 2013 - Win32 - - - Release - VS 2013 - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA} - forty_two - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - - - - - - - - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - VS 2013 + Win32 + + + Debug - VS 2013 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA} + forty_two + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/forty_two/forty_two.vcxproj.filters b/examples/forty_two/forty_two.vcxproj.filters index acfd33e..9709a06 100644 --- a/examples/forty_two/forty_two.vcxproj.filters +++ b/examples/forty_two/forty_two.vcxproj.filters @@ -1,30 +1,30 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - - - Header Files - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + diff --git a/examples/forty_two/main.cpp b/examples/forty_two/main.cpp index 098d57f..f818412 100644 --- a/examples/forty_two/main.cpp +++ b/examples/forty_two/main.cpp @@ -1,18 +1,18 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "forty_two.hpp" - - -int main() -{ - examples::forty_two _42( 100000 ); +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "forty_two.hpp" + + +int main() +{ + examples::forty_two _42( 100000 ); } \ No newline at end of file diff --git a/examples/generator_example/CMakeLists.txt b/examples/generator_example/CMakeLists.txt new file mode 100644 index 0000000..8878dea --- /dev/null +++ b/examples/generator_example/CMakeLists.txt @@ -0,0 +1,181 @@ +cmake_minimum_required(VERSION 3.5) + +project(generator_example) + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") +file(GLOB generator_example_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() + + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") + + # 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("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") + if( "${SX_NO_LOGGING}" ) + set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") + endif() + + option("SX_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( "${SX_NO_STD_MAKE_UNIQUE}" ) + set(extra_flags "${extra_flags} -D \"SX_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("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") + if( "${SX_NO_LOGGING}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") + endif() + + option("SX_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( "${SX_NO_STD_MAKE_UNIQUE}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_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(generator_example ${generator_example_SRC}) +include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/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 (generator_example LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) + else() + target_link_libraries (generator_example LINK_PUBLIC libyasmine pthread) + endif() +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_link_libraries (generator_example 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(generator_example LINK_PUBLIC ${Boost_LIBRARIES}) + endif() +endif() + +install(TARGETS generator_example DESTINATION bin) diff --git a/examples/generator_example/generator_example.vcxproj b/examples/generator_example/generator_example.vcxproj new file mode 100644 index 0000000..7ccd6c4 --- /dev/null +++ b/examples/generator_example/generator_example.vcxproj @@ -0,0 +1,280 @@ + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68} + generator_example + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/generator_example/generator_example.vcxproj.filters b/examples/generator_example/generator_example.vcxproj.filters new file mode 100644 index 0000000..c1a0333 --- /dev/null +++ b/examples/generator_example/generator_example.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/examples/generator_example/logic.cpp b/examples/generator_example/logic.cpp new file mode 100644 index 0000000..6a196ba --- /dev/null +++ b/examples/generator_example/logic.cpp @@ -0,0 +1,149 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex generator (http://generator.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://generator.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "logic.hpp" + +#include + + +namespace examples +{ + +logic::logic() +{ + // Nothing to do... +} + + +logic::~logic() +{ + // Nothing to do... +} + + +void logic::behavior_enter_state_3() +{ + std::cout << "Enter State3. Static class method as behavior." << std::endl; +} + + +void logic::behavior_transition() +{ + std::cout << "Static class method as behavior for transition." << std::endl; +} + + +void logic::behavior_exit_state_3() const +{ + std::cout << "Exit State3. Class method as behavior." << std::endl; +} + + +void logic::behavior_enter_state_1() const +{ + std::cout << "Enter State1. Class method as behavior." << std::endl; +} + + +void logic::behavior_exit_state_1() const +{ + std::cout << "Exit State1. Class method as behavior." << std::endl; +} + + +void logic::behavior_do_state_4a() const +{ + std::cout << "Do behavior State4a. Class method as behavior." << std::endl; +} + + +void logic::behavior_enter_state_4a() const +{ + std::cout << "Enter behavior State4a. Class method as behavior." << std::endl; +} + + +void logic::behavior_do_state_4b() const +{ + std::cout << "Do behavior State4b. Class method as behavior." << std::endl; +} + + +void logic::behavior_enter_state_5() const +{ + std::cout << "Enter State5. Class method as behavior." << std::endl; +} + + +void logic::behavior_exit_state_5() const +{ + std::cout << "Exit State5. Class method as behavior." << std::endl; +} + +void logic::behavior_enter_state_8() const +{ + std::cout << "Enter State8. Class method as behavior." << std::endl; +} + + +void logic::behavior_exit_state_8() const +{ + std::cout << "Exit State8. Class method as behavior." << std::endl; +} + + +void logic::behavior_do_state_11() const +{ + std::cout << "Do behavior State11. Class method as behavior." << std::endl; +} + + +void logic::behavior_do_state_12() const +{ + std::cout << "Do behavior State12. Class method as behavior." << std::endl; +} + + +void logic::behavior_do_state_13() const +{ + std::cout << "Do behavior State13. Class method as behavior." << std::endl; +} + + +void logic::behavior_enter_state_7() +{ + std::cout << "Enter behavior State7. Static class method as behavior." << std::endl; +} + + +void logic::behavior_exit_state_7() +{ + std::cout << "Exit behavior State7. Static class method as behavior." << std::endl; +} + + +void behavior_do_state_3() +{ + std::cout << "Behavior do State3: Free function as behavior." << std::endl; +} + + +void behavior_do_state_9() +{ + std::cout << "Behavior do State9: Free function as behavior." << std::endl; +} + + +void behavior_function_transition() +{ + std::cout << "Behavior of transition: Free function as behavior." << std::endl; +} + +} + diff --git a/examples/generator_example/logic.hpp b/examples/generator_example/logic.hpp new file mode 100644 index 0000000..b54fc16 --- /dev/null +++ b/examples/generator_example/logic.hpp @@ -0,0 +1,55 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex generator(http://generator.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://generator.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GENESIS_IMPL_D878BF81_EC04_4B08_B920_240704E648CC +#define GENESIS_IMPL_D878BF81_EC04_4B08_B920_240704E648CC + + +#include "essentials/non_copyable.hpp" + + +namespace examples +{ + + +class logic +{ +public: + logic(); + ~logic(); + SX_NO_COPY( logic ) + static void behavior_enter_state_3(); + static void behavior_transition(); + void behavior_exit_state_3() const; + void behavior_enter_state_1() const; + void behavior_exit_state_1() const; + void behavior_do_state_4a() const; + void behavior_enter_state_4a() const; + void behavior_do_state_4b() const; + void behavior_enter_state_5() const; + void behavior_exit_state_5() const; + void behavior_enter_state_8() const; + void behavior_exit_state_8() const; + void behavior_do_state_11() const; + void behavior_do_state_12() const; + void behavior_do_state_13() const; + static void behavior_enter_state_7(); + static void behavior_exit_state_7(); +}; + + +void behavior_do_state_3(); +void behavior_do_state_9(); +void behavior_function_transition(); + + +} + + +#endif diff --git a/examples/generator_example/main.cpp b/examples/generator_example/main.cpp new file mode 100644 index 0000000..fdf799a --- /dev/null +++ b/examples/generator_example/main.cpp @@ -0,0 +1,16 @@ +#include "state_machine_creator.hpp" +#include "logic.hpp" + +int main() +{ + examples::logic behaviors; + examples::state_machine_uptr sm = create_state_machine( "Generated state machine", behaviors ); + sm->run(); + sm->fire_event( examples::E1::create() ); + sm->fire_event( examples::E2::create() ); + sm->fire_event( examples::E4::create() ); + sm->fire_event( examples::E6::create() ); + sm->fire_event( examples::E7::create() ); + sm->halt(); + return ( 0 ); +} \ No newline at end of file diff --git a/examples/generator_example/state_machine_creator.cpp b/examples/generator_example/state_machine_creator.cpp new file mode 100644 index 0000000..1a5a4ef --- /dev/null +++ b/examples/generator_example/state_machine_creator.cpp @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file was generated by yasmine's ygen @ 2017/04/20 14:03:35. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "state_machine_creator.hpp" +#include + +namespace examples +{ + + +state_machine_uptr create_state_machine(const std::string& _name, examples::logic& _logic ) +{ + state_machine_uptr the_state_machine = SX_MAKE_UNIQUE< sxy::sync_state_machine >( _name ); + + // vertices { + sxy::composite_state& root = the_state_machine->get_root_state(); + sxy::region& main_region = root.add_region("main_region"); + sxy::composite_state& State1 = main_region.add_composite_state("State1", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_enter_state_1 ), Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_exit_state_1 )); + sxy::region& region2S1 = State1.add_region("region2S1"); + sxy::simple_state& State4a = region2S1.add_simple_state("State4a", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_do_state_4a ), Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_enter_state_4a ), Y_EMPTY_BEHAVIOR); + sxy::simple_state& State4b = region2S1.add_simple_state("State4b", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_do_state_4b ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::region& region1S1 = State1.add_region("region1S1"); + sxy::simple_state& State2 = region1S1.add_simple_state("State2", Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::simple_state& State3 = region1S1.add_simple_state("State3", Y_BEHAVIOR_FUNCTION2( behavior_do_state_3 ), Y_BEHAVIOR_FUNCTION2( logic::behavior_enter_state_3 ), Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_exit_state_3 )); + sxy::initial_pseudostate& InitialS1r1 = region1S1.add_initial_pseudostate("InitialS1r1"); + sxy::composite_state& State5 = main_region.add_composite_state("State5", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_enter_state_5 ), Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_exit_state_5 )); + sxy::region& region1S5 = State5.add_region("region1S5"); + sxy::composite_state& State6 = region1S5.add_composite_state("State6", Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::region& region1S6 = State6.add_region("region1S6"); + sxy::composite_state& State8 = region1S6.add_composite_state("State8", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_enter_state_8 ), Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_exit_state_8 )); + sxy::region& region1S8 = State8.add_region("region1S8"); + sxy::simple_state& State9 = region1S8.add_simple_state("State9", Y_BEHAVIOR_FUNCTION2( behavior_do_state_9 ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::initial_pseudostate& InitialS8 = region1S8.add_initial_pseudostate("InitialS8"); + sxy::initial_pseudostate& InitialS6r1 = region1S6.add_initial_pseudostate("InitialS6r1"); + sxy::region& region2S6 = State6.add_region("region2S6"); + sxy::simple_state& State10 = region2S6.add_simple_state("State10", Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::simple_state& State11 = region2S6.add_simple_state("State11", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_do_state_11 ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::simple_state& State12 = region2S6.add_simple_state("State12", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_do_state_12 ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::simple_state& State13 = region2S6.add_simple_state("State13", Y_BEHAVIOR_METHOD2( &_logic, &logic::behavior_do_state_13 ), Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::initial_pseudostate& InitialS6r2 = region2S6.add_initial_pseudostate("InitialS6r2"); + sxy::region& region3S6 = State6.add_region("region3S6"); + sxy::simple_state& State14 = region3S6.add_simple_state("State14", Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR, Y_EMPTY_BEHAVIOR); + sxy::initial_pseudostate& InitialS6r3 = region3S6.add_initial_pseudostate("InitialS6r3"); + sxy::simple_state& State7 = region1S5.add_simple_state("State7", Y_EMPTY_BEHAVIOR, Y_BEHAVIOR_FUNCTION2( logic::behavior_enter_state_7 ), Y_BEHAVIOR_FUNCTION2( logic::behavior_exit_state_7 )); + sxy::initial_pseudostate& InitialS5 = region1S5.add_initial_pseudostate("InitialS5"); + sxy::initial_pseudostate& Initial = main_region.add_initial_pseudostate("Initial"); + sxy::terminate_pseudostate& Terminate = main_region.add_terminate_pseudostate("Terminate"); + sxy::join& Join1 = main_region.add_join("Join1"); + // } vertices + + + // transitions { + the_state_machine->add_transition({2}, State5, State1, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, Initial, State1, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_BEHAVIOR_FUNCTION2( behavior_function_transition )); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, InitialS1r1, State2, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({2}, State2, State3, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({1}, State1, State4a, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({2}, State4a, State4b, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_BEHAVIOR_FUNCTION2( logic::behavior_transition )); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, State3, Join1, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, State4b, Join1, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, Join1, State5, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, InitialS6r1, State8, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, InitialS8, State9, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, InitialS6r2, State10, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({3}, State10, State11, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({4}, State10, State12, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({5}, State10, State13, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, InitialS6r3, State14, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({6}, State6, State7, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition({7}, State5, Terminate, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + the_state_machine->add_transition(sxy::Y_COMPLETION_EVENT_ID, InitialS5, State6, sxy::transition_kind::EXTERNAL, Y_EMPTY_GUARD, Y_EMPTY_BEHAVIOR); + // } transitions + + return(sxe::move(the_state_machine)); +} + +} + diff --git a/examples/generator_example/state_machine_creator.hpp b/examples/generator_example/state_machine_creator.hpp new file mode 100644 index 0000000..8677b01 --- /dev/null +++ b/examples/generator_example/state_machine_creator.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file was generated by yasmine's ygen @ 2017/04/20 14:03:35. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MACHINE_CREATOR_HPP_ +#define STATE_MACHINE_CREATOR_HPP_ + +#include "yasmine.hpp" +#include "logic.hpp" + +namespace examples +{ + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) +Y_EVENT_WITH_ID( E1, 1 ) +Y_EVENT_WITH_ID( E2, 2 ) +Y_EVENT_WITH_ID( E3, 3 ) +Y_EVENT_WITH_ID( E4, 4 ) +Y_EVENT_WITH_ID( E5, 5 ) +Y_EVENT_WITH_ID( E6, 6 ) +Y_EVENT_WITH_ID( E7, 7 ) +#else +Y_EVENT_CREATE(E1, 1) +Y_EVENT_CREATE(E2, 2) +Y_EVENT_CREATE(E3, 3) +Y_EVENT_CREATE(E4, 4) +Y_EVENT_CREATE(E5, 5) +Y_EVENT_CREATE(E6, 6) +Y_EVENT_CREATE(E7, 7) +#endif + +typedef sxe::SX_UNIQUE_PTR state_machine_uptr; + +state_machine_uptr create_state_machine(const std::string& _name, examples::logic& _logic ); + +} + + +#endif diff --git a/examples/hello_yasmine/hello_yasmine.cpp b/examples/hello_yasmine/hello_yasmine.cpp index 2ce9c08..078d8f6 100644 --- a/examples/hello_yasmine/hello_yasmine.cpp +++ b/examples/hello_yasmine/hello_yasmine.cpp @@ -1,108 +1,108 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include - -#include "yasmine.hpp" - - -const sxy::event_id HELLO_EVENT = 1; -typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; - - - -void reply() -{ - std::cout << "Hello, yasmine!" << std::endl; -} - - -void wait() -{ - std::cout << "waiting" << std::endl; -} - - -state_machine_uptr setup_state_machine( const std::string& _name ) -{ - state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); -#ifdef SX_CPP03_BOOST - 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 ) ); -#else - sxy::simple_state& simple_state_waiting = main_region.add_simple_state( "waiting", Y_BEHAVIOR_FUNCTION2( wait ) ); - sxy::simple_state& simple_state_replying = main_region.add_simple_state( "replying", Y_BEHAVIOR_FUNCTION2( reply ) ); -#endif - 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 ); - - return( sxe::move( state_machine ) ); -} - - -bool check_state_machine_for_defects( const sxy::sync_state_machine& _state_machine ) -{ - sxy::state_machine_defects defects; - const bool state_machine_has_no_defects = _state_machine.check( defects ); - if( !state_machine_has_no_defects ) - { - sxy::write_defects_to_log( defects ); - } - - return( state_machine_has_no_defects ); -} - - -int main() -{ - int error_code = 0; - - hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); - log_manager.set_log_level( hermes::log_level::LL_FATAL ); - log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); - 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->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->halt(); - } - catch( const std::exception& exception ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); - error_code = 1; - } - catch( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); - error_code = 2; - } - } - else - { - error_code = 3; - } - - log_manager.halt_and_join(); - - return( error_code ); -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include + +#include "yasmine.hpp" + + +const sxy::event_id HELLO_EVENT = 1; +typedef sxe::SX_UNIQUE_PTR< sxy::sync_state_machine > state_machine_uptr; + + + +void reply() +{ + std::cout << "Hello, yasmine!" << std::endl; +} + + +void wait() +{ + std::cout << "waiting" << std::endl; +} + + +state_machine_uptr setup_state_machine( const std::string& _name ) +{ + state_machine_uptr state_machine = SX_MAKE_UNIQUE< sxy::sync_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" ); +#ifdef SX_CPP03_BOOST + 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 ) ); +#else + sxy::simple_state& simple_state_waiting = main_region.add_simple_state( "waiting", Y_BEHAVIOR_FUNCTION2( wait ) ); + sxy::simple_state& simple_state_replying = main_region.add_simple_state( "replying", Y_BEHAVIOR_FUNCTION2( reply ) ); +#endif + 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 ); + + return( sxe::move( state_machine ) ); +} + + +bool check_state_machine_for_defects( const sxy::sync_state_machine& _state_machine ) +{ + sxy::state_machine_defects defects; + const bool state_machine_has_no_defects = _state_machine.check( defects ); + if( !state_machine_has_no_defects ) + { + sxy::write_defects_to_log( defects ); + } + + return( state_machine_has_no_defects ); +} + + +int main() +{ + int error_code = 0; + + hermes::log_manager_template& log_manager = hermes::log_manager::get_instance(); + log_manager.set_log_level( hermes::log_level::LL_FATAL ); + log_manager.add_logger( SX_MAKE_UNIQUE< hermes::cout_logger >() ); + 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->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->halt(); + } + catch( const std::exception& exception ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); + error_code = 1; + } + catch( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); + error_code = 2; + } + } + else + { + error_code = 3; + } + + log_manager.halt_and_join(); + + return( error_code ); +} diff --git a/examples/hello_yasmine/hello_yasmine.vcxproj b/examples/hello_yasmine/hello_yasmine.vcxproj index c45879e..9eaee09 100644 --- a/examples/hello_yasmine/hello_yasmine.vcxproj +++ b/examples/hello_yasmine/hello_yasmine.vcxproj @@ -1,385 +1,385 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - VS 2013 - Win32 - - - Debug - VS 2013 - x64 - - - Debug - Win32 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - VS 2013 - Win32 - - - Release - VS 2013 - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {C231C585-F237-4F08-8BF5-8DC7106599D4} - hello_yasmine - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Disabled - true - - - MachineX86 - - - - - Level3 - Disabled - true - - - - - Level3 - Disabled - true - - - - - Level3 - Disabled - true - - - - - MachineX64 - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - Level3 - Disabled - true - - - MachineX64 - - - - - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - No - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - No - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - MachineX64 - No - - - - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - VS 2013 + Win32 + + + Debug - VS 2013 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {C231C585-F237-4F08-8BF5-8DC7106599D4} + hello_yasmine + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + true + + + MachineX86 + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + MachineX64 + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + Level3 + Disabled + true + + + MachineX64 + + + + + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + No + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + No + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + MachineX64 + No + + + + + + + + \ No newline at end of file diff --git a/examples/hello_yasmine/hello_yasmine.vcxproj.filters b/examples/hello_yasmine/hello_yasmine.vcxproj.filters index 6766117..9d3d2b4 100644 --- a/examples/hello_yasmine/hello_yasmine.vcxproj.filters +++ b/examples/hello_yasmine/hello_yasmine.vcxproj.filters @@ -1,22 +1,22 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + \ No newline at end of file diff --git a/examples/substatemachines_and_variables/events.hpp b/examples/substatemachines_and_variables/events.hpp index 59b2d8f..890e68a 100644 --- a/examples/substatemachines_and_variables/events.hpp +++ b/examples/substatemachines_and_variables/events.hpp @@ -1,60 +1,60 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENTS_9579372F_23DD_4365_927A_48C94C0A2585 -#define EVENTS_9579372F_23DD_4365_927A_48C94C0A2585 - - -#include "yasmine.hpp" - - -namespace -{ - - -#if defined( SX_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 - - -} - - -namespace examples -{ - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - 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 ) -#else - Y_EVENT_CREATE( event_1, EVENT_1 ) - Y_EVENT_CREATE( event_2, EVENT_2 ) - Y_EVENT_CREATE( event_3, EVENT_3 ) - Y_EVENT_CREATE( event_4, EVENT_4 ) - Y_EVENT_CREATE( event_5, EVENT_5, std::string, get_param ) -#endif - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENTS_9579372F_23DD_4365_927A_48C94C0A2585 +#define EVENTS_9579372F_23DD_4365_927A_48C94C0A2585 + + +#include "yasmine.hpp" + + +namespace +{ + + +#if defined( SX_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 + + +} + + +namespace examples +{ + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + 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 ) +#else + Y_EVENT_CREATE( event_1, EVENT_1 ) + Y_EVENT_CREATE( event_2, EVENT_2 ) + Y_EVENT_CREATE( event_3, EVENT_3 ) + Y_EVENT_CREATE( event_4, EVENT_4 ) + Y_EVENT_CREATE( event_5, EVENT_5, std::string, get_param ) +#endif + +} + +#endif diff --git a/examples/substatemachines_and_variables/main.cpp b/examples/substatemachines_and_variables/main.cpp index 3576ca3..272e2df 100644 --- a/examples/substatemachines_and_variables/main.cpp +++ b/examples/substatemachines_and_variables/main.cpp @@ -1,20 +1,20 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_machine_with_submachines.hpp" - - -int main() -{ - examples::state_machine_with_submachines state_machine_with_submachines; - state_machine_with_submachines.create(); - state_machine_with_submachines.run(); -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_with_submachines.hpp" + + +int main() +{ + examples::state_machine_with_submachines state_machine_with_submachines; + state_machine_with_submachines.create(); + state_machine_with_submachines.run(); +} diff --git a/examples/substatemachines_and_variables/state_machine_with_submachines.cpp b/examples/substatemachines_and_variables/state_machine_with_submachines.cpp index 561c85c..c94f9ac 100644 --- a/examples/substatemachines_and_variables/state_machine_with_submachines.cpp +++ b/examples/substatemachines_and_variables/state_machine_with_submachines.cpp @@ -1,71 +1,71 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_machine_with_submachines.hpp" - - -namespace examples -{ - - -state_machine_with_submachines::state_machine_with_submachines() - : state_machine_( SX_MAKE_UNIQUE( "sub state machines and variables" ) ), - submachine1_(), - submachine2_() -{ - // Nothing to do... -} - - -state_machine_with_submachines::~state_machine_with_submachines() SX_NOEXCEPT -{ - // Nothing to do... -} - - - -void state_machine_with_submachines::create() -{ - 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 pseudostate" ); - sxy::simple_state& simple_state_1 = main_region.add_simple_state( "simple_state_1" ); - - submachine1_ = SX_MAKE_UNIQUE( sxe::ref( *state_machine_ ), sxe::ref( main_region ) ); - submachine2_ = SX_MAKE_UNIQUE( sxe::ref( *state_machine_ ), sxe::ref( main_region ) ); - - sxy::final_state& final_state = main_region.add_final_state( "final state" ); - - 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() ); - state_machine_->add_transition( EVENT_4, submachine2_->get_submachine_root_state(), final_state ); -} - - -void state_machine_with_submachines::run() -{ - 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" ) ); - state_machine_->fire_event( event_2::create() ); - state_machine_->fire_event( event_3::create() ); - state_machine_->fire_event( event_5::create( "abc" ) ); - 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_->halt(); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_with_submachines.hpp" + + +namespace examples +{ + + +state_machine_with_submachines::state_machine_with_submachines() + : state_machine_( SX_MAKE_UNIQUE( "sub state machines and variables" ) ), + submachine1_(), + submachine2_() +{ + // Nothing to do... +} + + +state_machine_with_submachines::~state_machine_with_submachines() SX_NOEXCEPT +{ + // Nothing to do... +} + + + +void state_machine_with_submachines::create() +{ + 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 pseudostate" ); + sxy::simple_state& simple_state_1 = main_region.add_simple_state( "simple_state_1" ); + + submachine1_ = SX_MAKE_UNIQUE( sxe::ref( *state_machine_ ), sxe::ref( main_region ) ); + submachine2_ = SX_MAKE_UNIQUE( sxe::ref( *state_machine_ ), sxe::ref( main_region ) ); + + sxy::final_state& final_state = main_region.add_final_state( "final state" ); + + 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() ); + state_machine_->add_transition( EVENT_4, submachine2_->get_submachine_root_state(), final_state ); +} + + +void state_machine_with_submachines::run() +{ + 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" ) ); + state_machine_->fire_event( event_2::create() ); + state_machine_->fire_event( event_3::create() ); + state_machine_->fire_event( event_5::create( "abc" ) ); + 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_->halt(); +} + + +} diff --git a/examples/substatemachines_and_variables/state_machine_with_submachines.hpp b/examples/substatemachines_and_variables/state_machine_with_submachines.hpp index 65b4a1c..484115e 100644 --- a/examples/substatemachines_and_variables/state_machine_with_submachines.hpp +++ b/examples/substatemachines_and_variables/state_machine_with_submachines.hpp @@ -1,51 +1,51 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_WITH_SUBMACHINES_2ED377F2_0917_4082_8323_1756EFEFFEE2 -#define STATE_MACHINE_WITH_SUBMACHINES_2ED377F2_0917_4082_8323_1756EFEFFEE2 - - -#include "submachine.hpp" -#include "events.hpp" - - -namespace examples -{ - - -class state_machine_with_submachines SX_FINAL -{ - - -typedef sxe::SX_UNIQUE_PTR state_machine_uptr; -typedef sxe::SX_UNIQUE_PTR submachine_uptr; - - -public: - state_machine_with_submachines(); - ~state_machine_with_submachines() SX_NOEXCEPT; - SX_NO_COPY( state_machine_with_submachines ) - void create(); - void run(); - - -private: - state_machine_uptr state_machine_; - submachine_uptr submachine1_; - submachine_uptr submachine2_; - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_WITH_SUBMACHINES_2ED377F2_0917_4082_8323_1756EFEFFEE2 +#define STATE_MACHINE_WITH_SUBMACHINES_2ED377F2_0917_4082_8323_1756EFEFFEE2 + + +#include "submachine.hpp" +#include "events.hpp" + + +namespace examples +{ + + +class state_machine_with_submachines SX_FINAL +{ + + +typedef sxe::SX_UNIQUE_PTR state_machine_uptr; +typedef sxe::SX_UNIQUE_PTR submachine_uptr; + + +public: + state_machine_with_submachines(); + ~state_machine_with_submachines() SX_NOEXCEPT; + SX_NO_COPY( state_machine_with_submachines ) + void create(); + void run(); + + +private: + state_machine_uptr state_machine_; + submachine_uptr submachine1_; + submachine_uptr submachine2_; + +}; + + +} + + +#endif diff --git a/examples/substatemachines_and_variables/submachine.cpp b/examples/substatemachines_and_variables/submachine.cpp index 452f470..cfa5689 100644 --- a/examples/substatemachines_and_variables/submachine.cpp +++ b/examples/substatemachines_and_variables/submachine.cpp @@ -1,108 +1,108 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "submachine.hpp" - -#include - -#include "sync_state_machine.hpp" -#include "region.hpp" - -#include "events.hpp" - - -namespace examples -{ - - -submachine::submachine( sxy::sync_state_machine& _parent_state_machine, sxy::region& _parent_region ) -: -#ifndef SX_CPP03_BOOST - submachine_( _parent_region.add_composite_state( "submachine", - Y_BEHAVIOR_METHOD2( this, &submachine::reset_members ) ) ), -#else - submachine_( _parent_region.add_composite_state( "submachine", - Y_BEHAVIOR_METHOD_NO_EVENT( submachine, reset_members ) ) ), -#endif - i_(), - s_() -{ - sxy::region& submachine_region = submachine_.add_region( "submachine region" ); - sxy::initial_pseudostate& submachine_initial_pseudostate = submachine_region.add_initial_pseudostate( - "submachine_initial_pseudostate" ); -#ifndef SX_CPP03_BOOST - sxy::simple_state& submachine_simple_state_1 = submachine_region.add_simple_state( "submachine simple_state_1", - Y_BEHAVIOR_METHOD2( this, &submachine::print_members ) ); - sxy::simple_state& submachine_simple_state_2 = submachine_region.add_simple_state( "submachine simple_state_2", - Y_BEHAVIOR_METHOD2( this, &submachine::change_members ) ); -#else - 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", - Y_BEHAVIOR_METHOD( submachine, change_members ) ); -#endif - - _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( sxy::Y_COMPLETION_EVENT_ID, submachine_simple_state_2, submachine_simple_state_1 ); -} - - -submachine::~submachine() SX_NOEXCEPT -{ - // Nothing to do... -} - - -sxy::composite_state& submachine::get_submachine_root_state() const -{ - return( submachine_ ); -} - - -void submachine::reset_members() -{ - i_ = 0; - s_ = ""; -} - - -void submachine::print_members() const -{ - std::cout << i_ << " " << s_ << std::endl; -} - - -#ifndef SX_CPP03_BOOST -void submachine::change_members( const event_5& _event) -#else -void submachine::change_members( const sxy::event& _event ) -#endif -{ - ++i_; -#ifndef SX_CPP03_BOOST - s_ = _event.get_param(); -#else - const event_5* event_with_param = dynamic_cast< const event_5* >( &_event ); - - if( event_with_param ) - { - s_ = event_with_param->get_param(); - } - else - { - s_ = ""; - } -#endif -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "submachine.hpp" + +#include + +#include "sync_state_machine.hpp" +#include "region.hpp" + +#include "events.hpp" + + +namespace examples +{ + + +submachine::submachine( sxy::sync_state_machine& _parent_state_machine, sxy::region& _parent_region ) +: +#ifndef SX_CPP03_BOOST + submachine_( _parent_region.add_composite_state( "submachine", + Y_BEHAVIOR_METHOD2( this, &submachine::reset_members ) ) ), +#else + submachine_( _parent_region.add_composite_state( "submachine", + Y_BEHAVIOR_METHOD_NO_EVENT( submachine, reset_members ) ) ), +#endif + i_(), + s_() +{ + sxy::region& submachine_region = submachine_.add_region( "submachine region" ); + sxy::initial_pseudostate& submachine_initial_pseudostate = submachine_region.add_initial_pseudostate( + "submachine_initial_pseudostate" ); +#ifndef SX_CPP03_BOOST + sxy::simple_state& submachine_simple_state_1 = submachine_region.add_simple_state( "submachine simple_state_1", + Y_BEHAVIOR_METHOD2( this, &submachine::print_members ) ); + sxy::simple_state& submachine_simple_state_2 = submachine_region.add_simple_state( "submachine simple_state_2", + Y_BEHAVIOR_METHOD2( this, &submachine::change_members ) ); +#else + 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", + Y_BEHAVIOR_METHOD( submachine, change_members ) ); +#endif + + _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( sxy::Y_COMPLETION_EVENT_ID, submachine_simple_state_2, submachine_simple_state_1 ); +} + + +submachine::~submachine() SX_NOEXCEPT +{ + // Nothing to do... +} + + +sxy::composite_state& submachine::get_submachine_root_state() const +{ + return( submachine_ ); +} + + +void submachine::reset_members() +{ + i_ = 0; + s_ = ""; +} + + +void submachine::print_members() const +{ + std::cout << i_ << " " << s_ << std::endl; +} + + +#ifndef SX_CPP03_BOOST +void submachine::change_members( const event_5& _event) +#else +void submachine::change_members( const sxy::event& _event ) +#endif +{ + ++i_; +#ifndef SX_CPP03_BOOST + s_ = _event.get_param(); +#else + const event_5* event_with_param = dynamic_cast< const event_5* >( &_event ); + + if( event_with_param ) + { + s_ = event_with_param->get_param(); + } + else + { + s_ = ""; + } +#endif +} + + +} diff --git a/examples/substatemachines_and_variables/submachine.hpp b/examples/substatemachines_and_variables/submachine.hpp index 04f1f4c..e121762 100644 --- a/examples/substatemachines_and_variables/submachine.hpp +++ b/examples/substatemachines_and_variables/submachine.hpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SUBMACHINE_731C5BC9_5AEA_4C88_BD3A_770355BF17D3 -#define SUBMACHINE_731C5BC9_5AEA_4C88_BD3A_770355BF17D3 - - -#include "essentials/non_copyable.hpp" -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - - class sync_state_machine; - class region; - class composite_state; - - -} - - -#ifndef SX_CPP03_BOOST -namespace examples{ class event_5; } -#else -namespace sxy { class event; } -#endif - - -namespace examples -{ - - -class submachine SX_FINAL -{ -public: - submachine( sxy::sync_state_machine& _parent_state_machine, sxy::region& _parent_region ); - ~submachine() SX_NOEXCEPT; - SX_NO_COPY( submachine ) - sxy::composite_state& get_submachine_root_state() const; - - -private: - void reset_members(); - void print_members() const; -#ifndef SX_CPP03_BOOST - void change_members( const event_5& _event ); -#else - void change_members( const sxy::event& _event ); -#endif - - sxy::composite_state& submachine_; - int i_; - std::string s_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SUBMACHINE_731C5BC9_5AEA_4C88_BD3A_770355BF17D3 +#define SUBMACHINE_731C5BC9_5AEA_4C88_BD3A_770355BF17D3 + + +#include "essentials/non_copyable.hpp" +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + + class sync_state_machine; + class region; + class composite_state; + + +} + + +#ifndef SX_CPP03_BOOST +namespace examples{ class event_5; } +#else +namespace sxy { class event; } +#endif + + +namespace examples +{ + + +class submachine SX_FINAL +{ +public: + submachine( sxy::sync_state_machine& _parent_state_machine, sxy::region& _parent_region ); + ~submachine() SX_NOEXCEPT; + SX_NO_COPY( submachine ) + sxy::composite_state& get_submachine_root_state() const; + + +private: + void reset_members(); + void print_members() const; +#ifndef SX_CPP03_BOOST + void change_members( const event_5& _event ); +#else + void change_members( const sxy::event& _event ); +#endif + + sxy::composite_state& submachine_; + int i_; + std::string s_; +}; + + +} + + +#endif diff --git a/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj index 4acfb4a..18f40d7 100644 --- a/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj +++ b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj @@ -1,403 +1,403 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - VS 2013 - Win32 - - - Debug - VS 2013 - x64 - - - Debug - Win32 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - VS 2013 - Win32 - - - Release - VS 2013 - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {E27E791D-29D2-4FAA-A683-D58228818F67} - substatemachines_and_variables - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - Level3 - Disabled - true - - - true - - - - - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - MachineX64 - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - true - - - - - - - - - - - - - - - - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - VS 2013 + Win32 + + + Debug - VS 2013 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {E27E791D-29D2-4FAA-A683-D58228818F67} + substatemachines_and_variables + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters index de96e89..2e21916 100644 --- a/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters +++ b/examples/substatemachines_and_variables/substatemachines_and_variables.vcxproj.filters @@ -1,41 +1,41 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Header Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Header Files + + \ No newline at end of file diff --git a/externals/essentials/include/essentials/base.hpp b/externals/essentials/include/essentials/base.hpp index 4a44311..e360481 100644 --- a/externals/essentials/include/essentials/base.hpp +++ b/externals/essentials/include/essentials/base.hpp @@ -1,36 +1,36 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BASE_0C97CC9D_8A5B_4696_9964_49819CD9233A -#define BASE_0C97CC9D_8A5B_4696_9964_49819CD9233A - - -//!\def SX_ASSERT( _condition, _message ) -//!\brief Assert a given condition. Adds the message to the assert for better diagnostics when the assert is triggered. -#define SX_ASSERT( _condition, _message ) \ - do \ - { \ - assert( ( _condition ) && _message ); \ - } \ - while( 0 ) - -//!\def SX_ASSERTED( _x ) -//!\brief Suppress warnings for variables that are only used within asserts. -#define SX_ASSERTED( _x ) static_cast< void >( _x ); - -//!\def SX_UNUSED_PARAMETER( _x ) -//!\brief Suppress warnings for unreferenced parameters. -#define SX_UNUSED_PARAMETER( _x ) static_cast( _x ) - - -#include - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BASE_0C97CC9D_8A5B_4696_9964_49819CD9233A +#define BASE_0C97CC9D_8A5B_4696_9964_49819CD9233A + + +//!\def SX_ASSERT( _condition, _message ) +//!\brief Assert a given condition. Adds the message to the assert for better diagnostics when the assert is triggered. +#define SX_ASSERT( _condition, _message ) \ + do \ + { \ + assert( ( _condition ) && _message ); \ + } \ + while( 0 ) + +//!\def SX_ASSERTED( _x ) +//!\brief Suppress warnings for variables that are only used within asserts. +#define SX_ASSERTED( _x ) static_cast< void >( _x ); + +//!\def SX_UNUSED_PARAMETER( _x ) +//!\brief Suppress warnings for unreferenced parameters. +#define SX_UNUSED_PARAMETER( _x ) static_cast( _x ) + + +#include + + +#endif diff --git a/externals/essentials/include/essentials/build_number.hpp b/externals/essentials/include/essentials/build_number.hpp index 9006dff..0e18bab 100644 --- a/externals/essentials/include/essentials/build_number.hpp +++ b/externals/essentials/include/essentials/build_number.hpp @@ -1,35 +1,35 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BUILD_NUMBER_0A2C7A7F_B3EC_443A_BDD8_652E7DEFC433 -#define BUILD_NUMBER_0A2C7A7F_B3EC_443A_BDD8_652E7DEFC433 - - -#include "compatibility/compatibility.hpp" - - -namespace sxe -{ - - -namespace version -{ - - - const sxe::uint16_t BUILD_NUMBER( 56 ); - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_NUMBER_0A2C7A7F_B3EC_443A_BDD8_652E7DEFC433 +#define BUILD_NUMBER_0A2C7A7F_B3EC_443A_BDD8_652E7DEFC433 + + +#include "compatibility/compatibility.hpp" + + +namespace sxe +{ + + +namespace version +{ + + + const sxe::uint16_t BUILD_NUMBER( 60 ); + + +} + + +} + + +#endif diff --git a/externals/essentials/include/essentials/compatibility/chrono.hpp b/externals/essentials/include/essentials/compatibility/chrono.hpp index 1946dc4..b53e1fd 100644 --- a/externals/essentials/include/essentials/compatibility/chrono.hpp +++ b/externals/essentials/include/essentials/compatibility/chrono.hpp @@ -1,59 +1,59 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CHRONO_2625645C_6611_46F7_AA2F_6F3B256839F3 -#define CHRONO_2625645C_6611_46F7_AA2F_6F3B256839F3 - - -#ifdef SX_CPP03_BOOST - -#include - -#else - -#include - -#endif - - -namespace sxe -{ - - -#ifdef SX_CPP03_BOOST // C++03 compatibility - - using boost::chrono::time_point; - using boost::chrono::system_clock; - using boost::chrono::steady_clock; - using boost::chrono::seconds; - using boost::chrono::milliseconds; - using boost::chrono::duration_cast; - using boost::chrono::time_point; - - -#else // C++11 compatibility - - - using std::chrono::time_point; - using std::chrono::system_clock; - using std::chrono::steady_clock; - using std::chrono::milliseconds; - using std::chrono::seconds; - using std::chrono::duration_cast; - using std::chrono::time_point; - - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHRONO_2625645C_6611_46F7_AA2F_6F3B256839F3 +#define CHRONO_2625645C_6611_46F7_AA2F_6F3B256839F3 + + +#ifdef SX_CPP03_BOOST + +#include + +#else + +#include + +#endif + + +namespace sxe +{ + + +#ifdef SX_CPP03_BOOST // C++03 compatibility + + using boost::chrono::time_point; + using boost::chrono::system_clock; + using boost::chrono::steady_clock; + using boost::chrono::seconds; + using boost::chrono::milliseconds; + using boost::chrono::duration_cast; + using boost::chrono::time_point; + + +#else // C++11 compatibility + + + using std::chrono::time_point; + using std::chrono::system_clock; + using std::chrono::steady_clock; + using std::chrono::milliseconds; + using std::chrono::seconds; + using std::chrono::duration_cast; + using std::chrono::time_point; + + +#endif + + +} + + +#endif diff --git a/externals/essentials/include/essentials/compatibility/compatibility.hpp b/externals/essentials/include/essentials/compatibility/compatibility.hpp index b0820fb..90ddb19 100644 --- a/externals/essentials/include/essentials/compatibility/compatibility.hpp +++ b/externals/essentials/include/essentials/compatibility/compatibility.hpp @@ -1,183 +1,181 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPATIBILITY_63A35CFD_26BC_42BE_9F09_D559349FFE63 -#define COMPATIBILITY_63A35CFD_26BC_42BE_9F09_D559349FFE63 - - -#ifdef SX_CPP03_BOOST -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4456 ) -#pragma warning( disable : 4996 ) -#endif - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning( pop ) -#endif - -#else -#include -#include -#include -#include -#include -#endif - - -namespace sxe -{ - - -#ifdef SX_CPP03_BOOST // C++03 compatibility - - #define SX_OVERRIDE - #define SX_FINAL - #define SX_DELETE - #define SX_NULLPTR NULL - - #define SX_FOR(_variable, _container) BOOST_FOREACH( _variable, _container ) - - #define SX_CONSTEXPR const - - #define SX_NOEXCEPT throw() - - - using boost::shared_ptr; - #define SX_UNIQUE_PTR shared_ptr - - #define SX_MAKE_SHARED boost::make_shared - #define SX_MAKE_UNIQUE boost::make_shared - - template - _type& move(_type& _t) - { - return( _t ); - } - - using boost::int8_t; - using boost::int16_t; - using boost::int32_t; - using boost::int64_t; - using boost::uint8_t; - using boost::uint16_t; - using boost::uint32_t; - using boost::uint64_t; - - - using boost::bind; - using boost::ref; - using boost::cref; - using boost::placeholders::_1; - using boost::placeholders::_2; - - using boost::function; - - using boost::remove_reference; - using boost::remove_const; - - using boost::random_device; - - -#else // C++11 compatibility - - #ifdef SX_NO_STD_MAKE_UNIQUE - - template< typename t, typename ... args > - std::unique_ptr< t > make_unique(args&& ... _args) - { - return( std::unique_ptr< t >(new t(std::forward< args >(_args)...)) ); - } - - #else - - using std::make_unique; - - #endif - - #define SX_OVERRIDE override - #define SX_FINAL final - #define SX_DELETE = delete - #define SX_NULLPTR nullptr - - #define SX_FOR(_variable, _container) for( _variable : _container ) - - #ifdef _MSC_VER - #if _MSC_VER <= 1800 - #define SX_CONSTEXPR const - #endif - #endif - - #ifndef SX_CONSTEXPR - #define SX_CONSTEXPR constexpr - #endif - -#ifdef _MSC_VER - #if _MSC_VER <= 1800 - #define SX_NOEXCEPT throw() - #else - #define SX_NOEXCEPT noexcept - #endif -#else - #define SX_NOEXCEPT noexcept -#endif - - using std::shared_ptr; - template - using SX_UNIQUE_PTR = std::unique_ptr<_pointee>; - - #define SX_MAKE_SHARED std::make_shared - #define SX_MAKE_UNIQUE sxe::make_unique - - using std::move; - - - using std::int8_t; - using std::int16_t; - using std::int32_t; - using std::int64_t; - using std::uint8_t; - using std::uint16_t; - using std::uint32_t; - using std::uint64_t; - - - using std::bind; - using std::ref; - using std::cref; - using std::placeholders::_1; - using std::placeholders::_2; - - using std::function; - - using std::remove_reference; - using std::remove_const; - - using std::random_device; - - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPATIBILITY_63A35CFD_26BC_42BE_9F09_D559349FFE63 +#define COMPATIBILITY_63A35CFD_26BC_42BE_9F09_D559349FFE63 + + +#ifdef SX_CPP03_BOOST +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4456 ) +#pragma warning( disable : 4996 ) +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#else +#include +#include +#include +#include +#include +#endif + + +namespace sxe +{ + + +#ifdef SX_CPP03_BOOST // C++03 compatibility + + #define SX_OVERRIDE + #define SX_FINAL + #define SX_DELETE + #define SX_NULLPTR NULL + + #define SX_FOR(_variable, _container) BOOST_FOREACH( _variable, _container ) + + #define SX_CONSTEXPR const + + #define SX_NOEXCEPT throw() + + + using boost::shared_ptr; + #define SX_UNIQUE_PTR shared_ptr + + #define SX_MAKE_SHARED boost::make_shared + #define SX_MAKE_UNIQUE boost::make_shared + + template + _type& move(_type& _t) + { + return( _t ); + } + + using boost::int8_t; + using boost::int16_t; + using boost::int32_t; + using boost::int64_t; + using boost::uint8_t; + using boost::uint16_t; + using boost::uint32_t; + using boost::uint64_t; + + using boost::bind; + using boost::ref; + using boost::cref; + using boost::placeholders::_1; + using boost::placeholders::_2; + + using boost::function; + + using boost::remove_reference; + using boost::remove_const; + + using boost::random_device; + + +#else // C++11 compatibility + + #ifdef SX_NO_STD_MAKE_UNIQUE + + template< typename t, typename ... args > + std::unique_ptr< t > make_unique(args&& ... _args) + { + return( std::unique_ptr< t >(new t(std::forward< args >(_args)...)) ); + } + + #else + + using std::make_unique; + + #endif + + #define SX_OVERRIDE override + #define SX_FINAL final + #define SX_DELETE = delete + #define SX_NULLPTR nullptr + + #define SX_FOR(_variable, _container) for( _variable : _container ) + + #ifdef _MSC_VER + #if _MSC_VER <= 1800 + #define SX_CONSTEXPR const + #endif + #endif + + #ifndef SX_CONSTEXPR + #define SX_CONSTEXPR constexpr + #endif + +#ifdef _MSC_VER + #if _MSC_VER <= 1800 + #define SX_NOEXCEPT throw() + #else + #define SX_NOEXCEPT noexcept + #endif +#else + #define SX_NOEXCEPT noexcept +#endif + + using std::shared_ptr; + template + using SX_UNIQUE_PTR = std::unique_ptr<_pointee>; + + #define SX_MAKE_SHARED std::make_shared + #define SX_MAKE_UNIQUE sxe::make_unique + + using std::move; + + + using std::int8_t; + using std::int16_t; + using std::int32_t; + using std::int64_t; + using std::uint8_t; + using std::uint16_t; + using std::uint32_t; + using std::uint64_t; + + using std::bind; + using std::ref; + using std::cref; + using std::placeholders::_1; + using std::placeholders::_2; + + using std::function; + + using std::remove_reference; + using std::remove_const; + + using std::random_device; + + +#endif + + +} + + +#endif diff --git a/externals/essentials/include/essentials/compatibility/thread.hpp b/externals/essentials/include/essentials/compatibility/thread.hpp index 2381481..3cdb3c3 100644 --- a/externals/essentials/include/essentials/compatibility/thread.hpp +++ b/externals/essentials/include/essentials/compatibility/thread.hpp @@ -1,63 +1,63 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef THREAD_A43220E4_F5F8_42D5_9B31_749D813922CF -#define THREAD_A43220E4_F5F8_42D5_9B31_749D813922CF - - -#ifdef SX_CPP03_BOOST - -#include -#include - -#else - -#include -#include -#include -#include - -#endif - - - -namespace sxe -{ - - -#ifdef SX_CPP03_BOOST // C++03 compatibility - - using boost::thread; - using boost::unique_lock; - using boost::mutex; - using boost::lock_guard; - using boost::condition_variable; - using boost::this_thread::sleep_for; - using boost::atomic; - - -#else // C++11 compatibility - - - using std::thread; - using std::unique_lock; - using std::mutex; - using std::lock_guard; - using std::condition_variable; - using std::this_thread::sleep_for; - using std::atomic; - - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef THREAD_A43220E4_F5F8_42D5_9B31_749D813922CF +#define THREAD_A43220E4_F5F8_42D5_9B31_749D813922CF + + +#ifdef SX_CPP03_BOOST + +#include +#include + +#else + +#include +#include +#include +#include + +#endif + + + +namespace sxe +{ + + +#ifdef SX_CPP03_BOOST // C++03 compatibility + + using boost::thread; + using boost::unique_lock; + using boost::mutex; + using boost::lock_guard; + using boost::condition_variable; + using boost::this_thread::sleep_for; + using boost::atomic; + + +#else // C++11 compatibility + + + using std::thread; + using std::unique_lock; + using std::mutex; + using std::lock_guard; + using std::condition_variable; + using std::this_thread::sleep_for; + using std::atomic; + + +#endif + + +} + + +#endif diff --git a/externals/essentials/include/essentials/conversion.hpp b/externals/essentials/include/essentials/conversion.hpp index a93c9fb..8d73274 100644 --- a/externals/essentials/include/essentials/conversion.hpp +++ b/externals/essentials/include/essentials/conversion.hpp @@ -1,42 +1,53 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CONVERSION_99CAC61B_DD8A_43E2_8612_0F42873A5741 -#define CONVERSION_99CAC61B_DD8A_43E2_8612_0F42873A5741 - - -#include "compatibility/compatibility.hpp" - - -namespace sxe -{ - - -//!\brief Converts a number from string to int. -//!\param _int_as_string Number in string format. -//!\param _result Variable where the result will be stored. -//!\return True on success, false otherwise. -bool string_to_int( const char* const _int_as_string, int& _result ); - -//!\brief Converts a number from unsigned int 32 to string. -//!\param _value Number to be converted. -//!\return Number as string. -std::string to_string( const sxe::uint32_t _value ); - -//!\brief Converts a number from int to string. -//!\param _value Number to be converted. -//!\return Number as string. -std::string to_string( const int _value ); - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONVERSION_99CAC61B_DD8A_43E2_8612_0F42873A5741 +#define CONVERSION_99CAC61B_DD8A_43E2_8612_0F42873A5741 + + +#include "compatibility/compatibility.hpp" + + +namespace sxe +{ + + + //!\brief Converts a number from string to int. + //!\param _int_as_string Number in string format. + //!\param _result Variable where the result will be stored. + //!\return True on success, false otherwise. + bool string_to_int( const char* const _int_as_string, int& _result ); + + //!\brief Converts a number from unsigned int 32 to string. + //!\param _value Number to be converted. + //!\return Number as string. + std::string to_string( const sxe::uint32_t _value ); + + //!\brief Converts a number from int to string. + //!\param _value Number to be converted. + //!\return Number as string. + std::string to_string( const int _value ); + + //!\brief Converts a string to uppercase. + //!\param _value String to be converted. + //!\return String in uppercase format. + //!\sa to_lower + std::string to_upper( const std::string& _value ); + + //!\brief Converts a string to lowercase. + //!\param _value String to be converted. + //!\return String in lowercase format. + //!\sa to_upper + std::string to_lower( const std::string& _value ); + +} + + +#endif diff --git a/externals/essentials/include/essentials/essentials_version.hpp b/externals/essentials/include/essentials/essentials_version.hpp index 96d967f..b652986 100644 --- a/externals/essentials/include/essentials/essentials_version.hpp +++ b/externals/essentials/include/essentials/essentials_version.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E -#define VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E - - -#include "compatibility/compatibility.hpp" - - -namespace sxe -{ - - -namespace version -{ - - -void log_version(); - - -sxe::uint16_t get_major_version(); -sxe::uint16_t get_minor_version(); -sxe::uint16_t get_patch_version(); -sxe::uint16_t get_build_number(); - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E +#define VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E + + +#include "compatibility/compatibility.hpp" + + +namespace sxe +{ + + +namespace version +{ + + +void log_version(); + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +#endif diff --git a/externals/essentials/include/essentials/exception.hpp b/externals/essentials/include/essentials/exception.hpp index 76ad4b8..2e357f8 100644 --- a/externals/essentials/include/essentials/exception.hpp +++ b/externals/essentials/include/essentials/exception.hpp @@ -1,30 +1,30 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXCEPTION_B675DC28_13E9_4827_9916_4649C36BD407 -#define EXCEPTION_B675DC28_13E9_4827_9916_4649C36BD407 - - -#include "exception_template.hpp" - - -namespace sxe -{ - - -//!\def SX_EXCEPTION( exception ) -//!\brief The Seadex essentials exception class. -SX_EXCEPTION( exception ) - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXCEPTION_B675DC28_13E9_4827_9916_4649C36BD407 +#define EXCEPTION_B675DC28_13E9_4827_9916_4649C36BD407 + + +#include "exception_template.hpp" + + +namespace sxe +{ + + +//!\def SX_EXCEPTION( exception ) +//!\brief The Seadex essentials exception class. +SX_EXCEPTION( exception ) + + +} + + +#endif diff --git a/externals/essentials/include/essentials/exception_template.hpp b/externals/essentials/include/essentials/exception_template.hpp index 2415a7d..749894f 100644 --- a/externals/essentials/include/essentials/exception_template.hpp +++ b/externals/essentials/include/essentials/exception_template.hpp @@ -1,160 +1,160 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXCEPTION_TEMPLATE_6EFED438_B578_4EF6_B02A_53DC49B89A0D -#define EXCEPTION_TEMPLATE_6EFED438_B578_4EF6_B02A_53DC49B89A0D - - -#include - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/sxprintf.hpp" - - -#ifndef SX_CPP03_BOOST - - -//!\def SX_EXCEPTION( _name ) -//!\brief Create an exception class inheriting std::exception with the given name. It also supports -//! creating messages with placeholders by calling sxprintf. -//!\sa sxprintf -#define SX_EXCEPTION( _name ) \ -class _name: public std::exception \ -{ \ -public: \ - template< typename ... args > \ - _name(const std::string & _what, args ... _args ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _args ... ) ) \ - { \ - } \ -\ -\ - virtual ~_name () SX_NOEXCEPT SX_OVERRIDE {}\ -\ -\ - virtual const char* what() const throw () SX_OVERRIDE \ - { \ - return ( what_.c_str() ); \ - } \ -\ -\ -private: \ - std::string what_; \ -\ -\ -}; - - -#else - - -#define SX_EXCEPTION( _name ) \ -class _name: public std::exception \ -{ \ -public: \ - explicit _name(const std::string & _what ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str() ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6 ) ) \ - { \ - } \ -\ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, const sxe::value_type& _value8 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, const sxe::value_type& _value8, const sxe::value_type& _value9 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ) \ - { \ - } \ -\ -\ - explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10 ):\ - std::exception(), \ - what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ) \ - { \ - } \ -\ -\ - virtual ~_name () SX_NOEXCEPT SX_OVERRIDE {}\ -\ -\ - virtual const char* what() const throw () SX_OVERRIDE \ - { \ - return ( what_.c_str() ); \ - } \ -\ -\ -private: \ - std::string what_; \ -\ -\ -}; - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXCEPTION_TEMPLATE_6EFED438_B578_4EF6_B02A_53DC49B89A0D +#define EXCEPTION_TEMPLATE_6EFED438_B578_4EF6_B02A_53DC49B89A0D + + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/sxprintf.hpp" + + +#ifndef SX_CPP03_BOOST + + +//!\def SX_EXCEPTION( _name ) +//!\brief Create an exception class inheriting std::exception with the given name. It also supports +//! creating messages with placeholders by calling sxprintf. +//!\sa sxprintf +#define SX_EXCEPTION( _name ) \ +class _name: public std::exception \ +{ \ +public: \ + template< typename ... args > \ + _name(const std::string & _what, args ... _args ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _args ... ) ) \ + { \ + } \ +\ +\ + virtual ~_name () SX_NOEXCEPT SX_OVERRIDE {}\ +\ +\ + virtual const char* what() const throw () SX_OVERRIDE \ + { \ + return ( what_.c_str() ); \ + } \ +\ +\ +private: \ + std::string what_; \ +\ +\ +}; + + +#else + + +#define SX_EXCEPTION( _name ) \ +class _name: public std::exception \ +{ \ +public: \ + explicit _name(const std::string & _what ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str() ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6 ) ) \ + { \ + } \ +\ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, const sxe::value_type& _value8 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, const sxe::value_type& _value8, const sxe::value_type& _value9 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ) \ + { \ + } \ +\ +\ + explicit _name(const std::string & _what, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10 ):\ + std::exception(), \ + what_( sxe::sxprintf( _what.c_str(), _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ) \ + { \ + } \ +\ +\ + virtual ~_name () SX_NOEXCEPT SX_OVERRIDE {}\ +\ +\ + virtual const char* what() const throw () SX_OVERRIDE \ + { \ + return ( what_.c_str() ); \ + } \ +\ +\ +private: \ + std::string what_; \ +\ +\ +}; + + +#endif + + +#endif diff --git a/externals/essentials/include/essentials/format_settings.hpp b/externals/essentials/include/essentials/format_settings.hpp index 6344081..798c83e 100644 --- a/externals/essentials/include/essentials/format_settings.hpp +++ b/externals/essentials/include/essentials/format_settings.hpp @@ -1,45 +1,45 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FORMAT_SETTINGS_1D24A599_70E3_42BB_BFE6_46BD94217FAB -#define FORMAT_SETTINGS_1D24A599_70E3_42BB_BFE6_46BD94217FAB - - -#include - -#include "compatibility/compatibility.hpp" - - -namespace sxe -{ - -//!\struct format_settings -//!\brief Structure containing information for formatting the output of sxprintf. -struct format_settings SX_FINAL -{ - //!\brief Constructor of the structure. - format_settings(); - - - std::string format_string_; - bool missing_closing_bracket_; - bool correct_; - bool hex_; - bool pad_zeros_; - bool places_set_; - int places_; - bool decimal_places_set_; - int decimal_places_; -}; - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORMAT_SETTINGS_1D24A599_70E3_42BB_BFE6_46BD94217FAB +#define FORMAT_SETTINGS_1D24A599_70E3_42BB_BFE6_46BD94217FAB + + +#include + +#include "compatibility/compatibility.hpp" + + +namespace sxe +{ + +//!\struct format_settings +//!\brief Structure containing information for formatting the output of sxprintf. +struct format_settings SX_FINAL +{ + //!\brief Constructor. + format_settings(); + + + std::string format_string_; + bool missing_closing_bracket_; + bool correct_; + bool hex_; + bool pad_zeros_; + bool places_set_; + int places_; + bool decimal_places_set_; + int decimal_places_; +}; + +} + + +#endif diff --git a/externals/essentials/include/essentials/macro_helpers.hpp b/externals/essentials/include/essentials/macro_helpers.hpp index b0777eb..46609e4 100644 --- a/externals/essentials/include/essentials/macro_helpers.hpp +++ b/externals/essentials/include/essentials/macro_helpers.hpp @@ -1,46 +1,46 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef MACRO_HELPERS_D52C3077_E0EF_4C4E_B451_1472DEE602E8 -#define MACRO_HELPERS_D52C3077_E0EF_4C4E_B451_1472DEE602E8 - - -#ifndef SX_NO_VARIADIC_MACRO - - -//!\def EXPAND( x ) -//!\brief Helper to work around some Visual C++ compiler quirk dealing with variadic macros. -#define EXPAND( x ) x - -//!\def CAT( A, B ) -//!\brief Concatenate two tokens. -#define CAT( A, B ) A ## B - -//!\def SELECT( NAME, NUM ) -//!\brief Creating a name from a base name and a number with underscore between them. -#define SELECT( NAME, NUM ) CAT( NAME ## _, NUM ) - -//!\def GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, COUNT, ... ) -//!\brief Helper for counting the number of parameters of a macro. -#define GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, COUNT, ... ) COUNT - -//!\def VA_SIZE( ... ) -//!\brief Count the number of parameters of a macro. -#define VA_SIZE( ... ) EXPAND( GET_COUNT( __VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1 ) ) - -//!\def VA_SELECT( NAME, ... ) -//!\brief Selects the correct overloaded macro based on the number of parameters. -#define VA_SELECT( NAME, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__) ) - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef MACRO_HELPERS_D52C3077_E0EF_4C4E_B451_1472DEE602E8 +#define MACRO_HELPERS_D52C3077_E0EF_4C4E_B451_1472DEE602E8 + + +#ifndef SX_NO_VARIADIC_MACRO + + +//!\def EXPAND( x ) +//!\brief Helper to work around some Visual C++ compiler quirk dealing with variadic macros. +#define EXPAND( x ) x + +//!\def CAT( A, B ) +//!\brief Concatenate two tokens. +#define CAT( A, B ) A ## B + +//!\def SELECT( NAME, NUM ) +//!\brief Creating a name from a base name and a number with underscore between them. +#define SELECT( NAME, NUM ) CAT( NAME ## _, NUM ) + +//!\def GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, COUNT, ... ) +//!\brief Helper for counting the number of parameters of a macro. +#define GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, COUNT, ... ) COUNT + +//!\def VA_SIZE( ... ) +//!\brief Count the number of parameters of a macro. +#define VA_SIZE( ... ) EXPAND( GET_COUNT( __VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1 ) ) + +//!\def VA_SELECT( NAME, ... ) +//!\brief Selects the correct overloaded macro based on the number of parameters. +#define VA_SELECT( NAME, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__) ) + + +#endif + + +#endif diff --git a/externals/essentials/include/essentials/non_copyable.hpp b/externals/essentials/include/essentials/non_copyable.hpp index b93fff3..d9f85b4 100644 --- a/externals/essentials/include/essentials/non_copyable.hpp +++ b/externals/essentials/include/essentials/non_copyable.hpp @@ -1,68 +1,68 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef NON_COPYABLE_D2C5BF6C_4B43_42AF_9E42_1AAE2B5C49C8 -#define NON_COPYABLE_D2C5BF6C_4B43_42AF_9E42_1AAE2B5C49C8 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxe -{ - - -#ifdef SX_CPP03_BOOST - - -//!\def SX_NO_COPY(_class_name) -//!\brief Delete the copy constructor and assignment operator of the given class. -#define SX_NO_COPY(_class_name)\ -private:\ - _class_name(const _class_name&) SX_DELETE;\ - _class_name& operator=(const _class_name&) SX_DELETE;\ -public:\ -\ - - -//!\def SX_NO_ASSIGNMENT_OPERATOR(_class_name) -//!\brief Delete the assignment operator of the given class. -#define SX_NO_ASSIGNMENT_OPERATOR(_class_name)\ -private:\ - _class_name& operator=( const _class_name& ) SX_DELETE;\ -public:\ -\ - - -#else - - -//!\def SX_NO_COPY(_class_name) -//!\brief Delete the copy constructor and assignment operator of the given class. -#define SX_NO_COPY(_class_name)\ - _class_name(const _class_name&) SX_DELETE;\ - _class_name& operator=(const _class_name&) SX_DELETE;\ -\ - - -//!\def SX_NO_ASSIGNMENT_OPERATOR(_class_name) -//!\brief Delete the assignment operator of the given class. -#define SX_NO_ASSIGNMENT_OPERATOR(_class_name)\ - _class_name& operator=( const _class_name& ) SX_DELETE;\ -\ - - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef NON_COPYABLE_D2C5BF6C_4B43_42AF_9E42_1AAE2B5C49C8 +#define NON_COPYABLE_D2C5BF6C_4B43_42AF_9E42_1AAE2B5C49C8 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxe +{ + + +#ifdef SX_CPP03_BOOST + + +//!\def SX_NO_COPY(_class_name) +//!\brief Delete the copy constructor and assignment operator of the given class. +#define SX_NO_COPY(_class_name)\ +private:\ + _class_name(const _class_name&) SX_DELETE;\ + _class_name& operator=(const _class_name&) SX_DELETE;\ +public:\ +\ + + +//!\def SX_NO_ASSIGNMENT_OPERATOR(_class_name) +//!\brief Delete the assignment operator of the given class. +#define SX_NO_ASSIGNMENT_OPERATOR(_class_name)\ +private:\ + _class_name& operator=( const _class_name& ) SX_DELETE;\ +public:\ +\ + + +#else + + +//!\def SX_NO_COPY(_class_name) +//!\brief Delete the copy constructor and assignment operator of the given class. +#define SX_NO_COPY(_class_name)\ + _class_name(const _class_name&) SX_DELETE;\ + _class_name& operator=(const _class_name&) SX_DELETE;\ +\ + + +//!\def SX_NO_ASSIGNMENT_OPERATOR(_class_name) +//!\brief Delete the assignment operator of the given class. +#define SX_NO_ASSIGNMENT_OPERATOR(_class_name)\ + _class_name& operator=( const _class_name& ) SX_DELETE;\ +\ + + +#endif + + +} + + +#endif diff --git a/externals/essentials/include/essentials/sxprintf.hpp b/externals/essentials/include/essentials/sxprintf.hpp index d1c67a5..f6c4d72 100644 --- a/externals/essentials/include/essentials/sxprintf.hpp +++ b/externals/essentials/include/essentials/sxprintf.hpp @@ -1,242 +1,242 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef PRINTF_2B6FD3F2_C084_486B_805B_5F0E05B743E4 -#define PRINTF_2B6FD3F2_C084_486B_805B_5F0E05B743E4 - - -#include -#include - - -#ifdef SX_CPP03_BOOST - #include - #include -#endif - -#include "compatibility/compatibility.hpp" -#include "format_settings.hpp" - - -namespace sxe -{ - - -#ifdef SX_CPP03_BOOST - typedef boost::variant< bool, int, unsigned int, sxe::int8_t, sxe::uint8_t, sxe::uint16_t, sxe::uint32_t, - std::string, std::size_t, const char*, int_least64_t, double > value_type; - typedef std::vector< value_type > value_types; -#endif - - -extern const char PLACE_HOLDER; -extern const char* const SUPERFLUOUS_PARAMETER_START; -extern const char SUPERFLUOUS_PARAMETER_END; -extern const char OPENING_SQUARE_BRACKET; -extern const char CLOSING_SQUARE_BRACKET; - - -template< typename value > -struct stream_writer -{ - static void print( std::ostream& _os, const value& _value ) - { - _os << _value; - } -}; - - -template< > -struct stream_writer< sxe::uint8_t > -{ - static void print(std::ostream& _os, const sxe::uint8_t& _value) - { - _os << static_cast( _value ); - } -}; - - -// cppcheck-suppress unusedFunction -std::ostream& operator<<( std::ostream& _os, const sxe::format_settings& _format ); -sxe::format_settings parse_format_string( const char** const _format ); - - -#ifdef SX_CPP03_BOOST - -void print_value_type_value( std::ostream& _os, const value_type& _value ); - - -#endif - - -template< typename value > -void print_superfluous_parameters( std::ostream& _os, const value& _value ) -{ - _os << SUPERFLUOUS_PARAMETER_START; -#ifndef SX_CPP03_BOOST - stream_writer< value >::print( _os, _value ); -#else - print_value_type_value( _os, _value ); -#endif - _os << SUPERFLUOUS_PARAMETER_END; -} - - -#ifndef SX_CPP03_BOOST - - -template< typename value, typename ... args > -void print_superfluous_parameters( std::ostream& _os, - const value& _value, args ... _args ) -{ - _os << SUPERFLUOUS_PARAMETER_START; - stream_writer< value >::print( _os, _value ); - _os << SUPERFLUOUS_PARAMETER_END; - print_superfluous_parameters( _os, _args ... ); -} - - -#else - - -#endif - - -void sxprintf( std::ostream& _os, const char* _format ); - -#ifndef SX_CPP03_BOOST -template< typename value, typename ... args > -void sxprintf( std::ostream& _os, const char* _format, const value& _value, args ... _args ) -{ - while( *_format ) - { - if( PLACE_HOLDER == *_format ) - { - if( PLACE_HOLDER == *( _format + 1 ) ) - { - ++_format; // skip first place holder - _os << *_format++; // output of the second place holder - } - else - { - if( OPENING_SQUARE_BRACKET == *( _format + 1 ) ) - { - ++_format; - const sxe::format_settings format_settings = sxe::parse_format_string( &_format ); - const std::ios_base::fmtflags stream_flags = _os.flags(); - const char streafill_ = _os.fill(); - if( format_settings.correct_ ) - { - _os << format_settings; - stream_writer< value >::print( _os, _value ); - } - else - { - while( CLOSING_SQUARE_BRACKET != *( _format ) ) - { - ++_format; - } - stream_writer< value >::print( _os, _value ); - _os << format_settings; - } - _os.flags( stream_flags ); - _os.fill( streafill_ ); - } - else - { - stream_writer< value >::print( _os, _value ); - } - - sxprintf( _os, _format + 1, _args ... ); - return; - } - } - else - { - _os << *_format++; - } - } - - print_superfluous_parameters( _os, _value, _args ... ); -} - - -//!\brief Creates a formatted message. The format string can contain placeholders ('%'s) that will be replaced with -//!the parameters by this function. To emit a '%' use two percent signs ("%%"). -//!\param _format The format string in which will the placeholders will be replaced (if there are any). -//!\param _args The arguments that will replace the placeholders in the format string. The number of parameters in -//!_args has to be equal to the number of placeholders in the format string. If you pass too few or too many -//!arguments, the resulting string will contain diagnostics in the resulting string -//!([Missing parameter!] or [Superfluous parameter: x]). -//!\return String containing the complete formatted message. -template< typename ... args > -std::string sxprintf(const char* const _format, args ... _args) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _args ...); - return( target_string_stream.str() ); -} - -#else - -std::string sxprintf(const char* const _format); -std::string sxprintf(const char* const _format, const value_type& _value1); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, - const value_type& _value9); -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, - const value_type& _value9, const value_type& _value10); - - -void sxprintf(std::ostream& _os, const char* const _format); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8, const value_type& _value9); -void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8, const value_type& _value9, const value_type& _value10); - - void sxprintf(std::ostream& _os, const char* const _format, const value_types& _values); - -#endif - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PRINTF_2B6FD3F2_C084_486B_805B_5F0E05B743E4 +#define PRINTF_2B6FD3F2_C084_486B_805B_5F0E05B743E4 + + +#include +#include + + +#ifdef SX_CPP03_BOOST + #include + #include +#endif + +#include "compatibility/compatibility.hpp" +#include "format_settings.hpp" + + +namespace sxe +{ + + +#ifdef SX_CPP03_BOOST + typedef boost::variant< bool, int, unsigned int, sxe::int8_t, sxe::uint8_t, sxe::uint16_t, sxe::uint32_t, + std::string, std::size_t, const char*, int_least64_t, double > value_type; + typedef std::vector< value_type > value_types; +#endif + + +extern const char PLACE_HOLDER; +extern const char* const SUPERFLUOUS_PARAMETER_START; +extern const char SUPERFLUOUS_PARAMETER_END; +extern const char OPENING_SQUARE_BRACKET; +extern const char CLOSING_SQUARE_BRACKET; + + +template< typename value > +struct stream_writer +{ + static void print( std::ostream& _os, const value& _value ) + { + _os << _value; + } +}; + + +template< > +struct stream_writer< sxe::uint8_t > +{ + static void print(std::ostream& _os, const sxe::uint8_t& _value) + { + _os << static_cast( _value ); + } +}; + + +// cppcheck-suppress unusedFunction +std::ostream& operator<<( std::ostream& _os, const sxe::format_settings& _format ); +sxe::format_settings parse_format_string( const char** const _format ); + + +#ifdef SX_CPP03_BOOST + +void print_value_type_value( std::ostream& _os, const value_type& _value ); + + +#endif + + +template< typename value > +void print_superfluous_parameters( std::ostream& _os, const value& _value ) +{ + _os << SUPERFLUOUS_PARAMETER_START; +#ifndef SX_CPP03_BOOST + stream_writer< value >::print( _os, _value ); +#else + print_value_type_value( _os, _value ); +#endif + _os << SUPERFLUOUS_PARAMETER_END; +} + + +#ifndef SX_CPP03_BOOST + + +template< typename value, typename ... args > +void print_superfluous_parameters( std::ostream& _os, + const value& _value, args ... _args ) +{ + _os << SUPERFLUOUS_PARAMETER_START; + stream_writer< value >::print( _os, _value ); + _os << SUPERFLUOUS_PARAMETER_END; + print_superfluous_parameters( _os, _args ... ); +} + + +#else + + +#endif + + +void sxprintf( std::ostream& _os, const char* _format ); + +#ifndef SX_CPP03_BOOST +template< typename value, typename ... args > +void sxprintf( std::ostream& _os, const char* _format, const value& _value, args ... _args ) +{ + while( *_format ) + { + if( PLACE_HOLDER == *_format ) + { + if( PLACE_HOLDER == *( _format + 1 ) ) + { + ++_format; // skip first place holder + _os << *_format++; // output of the second place holder + } + else + { + if( OPENING_SQUARE_BRACKET == *( _format + 1 ) ) + { + ++_format; + const sxe::format_settings format_settings = sxe::parse_format_string( &_format ); + const std::ios_base::fmtflags stream_flags = _os.flags(); + const char streafill_ = _os.fill(); + if( format_settings.correct_ ) + { + _os << format_settings; + stream_writer< value >::print( _os, _value ); + } + else + { + while( CLOSING_SQUARE_BRACKET != *( _format ) ) + { + ++_format; + } + stream_writer< value >::print( _os, _value ); + _os << format_settings; + } + _os.flags( stream_flags ); + _os.fill( streafill_ ); + } + else + { + stream_writer< value >::print( _os, _value ); + } + + sxprintf( _os, _format + 1, _args ... ); + return; + } + } + else + { + _os << *_format++; + } + } + + print_superfluous_parameters( _os, _value, _args ... ); +} + + +//!\brief Creates a formatted message. The format string can contain placeholders ('%'s) that will be replaced with +//!the parameters by this function. To emit a '%' use two percent signs ("%%"). +//!\param _format The format string in which will the placeholders will be replaced (if there are any). +//!\param _args The arguments that will replace the placeholders in the format string. The number of parameters in +//!_args has to be equal to the number of placeholders in the format string. If you pass too few or too many +//!arguments, the resulting string will contain diagnostics in the resulting string +//!([Missing parameter!] or [Superfluous parameter: x]). +//!\return String containing the complete formatted message. +template< typename ... args > +std::string sxprintf(const char* const _format, args ... _args) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _args ...); + return( target_string_stream.str() ); +} + +#else + +std::string sxprintf(const char* const _format); +std::string sxprintf(const char* const _format, const value_type& _value1); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, + const value_type& _value9); +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, + const value_type& _value9, const value_type& _value10); + + +void sxprintf(std::ostream& _os, const char* const _format); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8, const value_type& _value9); +void sxprintf(std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8, const value_type& _value9, const value_type& _value10); + + void sxprintf(std::ostream& _os, const char* const _format, const value_types& _values); + +#endif + + +} + +#endif diff --git a/libyasmine/include/uri.hpp b/externals/essentials/include/essentials/uri.hpp similarity index 70% rename from libyasmine/include/uri.hpp rename to externals/essentials/include/essentials/uri.hpp index ff6fe3d..5a0a0bb 100644 --- a/libyasmine/include/uri.hpp +++ b/externals/essentials/include/essentials/uri.hpp @@ -1,53 +1,55 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef URI_84775A3E_75EA_4F0A_86CF_E7CF5780ACD1 -#define URI_84775A3E_75EA_4F0A_86CF_E7CF5780ACD1 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class uri SX_FINAL -{ -public: - explicit uri( const std::string& _uri = "" ); - ~uri() SX_NOEXCEPT; - bool is_empty() const; - const std::string to_string() const; - const std::string& get_front() const; - const std::string& get_back(); - void push_front( const std::string& _segment ); - void push_back( const std::string& _segment ); - void pop_front(); - void pop_back(); - size_t size() const; - - -private: - const std::string build_uri() const; - void split_string_to_uri_segments( const std::string& _uri ); - - - std::deque< std::string > uri_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef URI_72CBB6C3_57D9_443A_99F0_9EDE9A2BC07D +#define URI_72CBB6C3_57D9_443A_99F0_9EDE9A2BC07D + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxe +{ + + +const char URI_DELIMITER = '/'; + + +class uri SX_FINAL +{ +public: + explicit uri( const std::string& _uri = "" ); + ~uri() SX_NOEXCEPT; + bool is_empty() const; + const std::string to_string() const; + const std::string& get_front() const; + const std::string& get_back(); + void push_front( const std::string& _segment ); + void push_back( const std::string& _segment ); + void pop_front(); + void pop_back(); + size_t size() const; + + +private: + const std::string build_uri() const; + void split_string_to_uri_segments( const std::string& _uri ); + + + std::deque< std::string > uri_; +}; + + +} + + +#endif diff --git a/externals/essentials/source/conversion.cpp b/externals/essentials/source/conversion.cpp index db5ad18..21ee550 100644 --- a/externals/essentials/source/conversion.cpp +++ b/externals/essentials/source/conversion.cpp @@ -1,83 +1,102 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "essentials/conversion.hpp" - -#include - -#ifndef SX_CPP03_BOOST - #include -#else - #include -#endif - - -namespace sxe -{ - - -bool string_to_int( const char* const _int_as_string, int& _result ) -{ - bool success = false; - try - { -#ifndef SX_CPP03_BOOST - _result = std::stoi( std::string( _int_as_string ) ); - success = true; -#else - std::istringstream is( _int_as_string ); - if (is >> _result) - { - success = true; - } - else - { - success = false; - } -#endif - - } - catch ( const std::invalid_argument& ) - { - success = false; - } - catch ( const std::out_of_range& ) - { - success = false; - } - return( success ); -} - - -std::string to_string( const sxe::uint32_t _value ) -{ -#ifndef SX_CPP03_BOOST - return( std::to_string( _value ) ); -#else - std::ostringstream ostr; - ostr << _value; - return( ostr.str() ); -#endif -} - - -std::string to_string( const int _value ) -{ -#ifndef SX_CPP03_BOOST - return( std::to_string( _value ) ); -#else - std::ostringstream ostr; - ostr << _value; - return( ostr.str() ); -#endif -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "essentials/conversion.hpp" + +#include +#include + +#ifndef SX_CPP03_BOOST + #include +#else + #include +#endif + + +namespace sxe +{ + + +bool string_to_int( const char* const _int_as_string, int& _result ) +{ + bool success = false; + try + { +#ifndef SX_CPP03_BOOST + _result = std::stoi( std::string( _int_as_string ) ); + success = true; +#else + std::istringstream is( _int_as_string ); + if (is >> _result) + { + success = true; + } + else + { + success = false; + } +#endif + + } + catch ( const std::invalid_argument& ) + { + success = false; + } + catch ( const std::out_of_range& ) + { + success = false; + } + return( success ); +} + + +std::string to_string( const sxe::uint32_t _value ) +{ +#ifndef SX_CPP03_BOOST + return( std::to_string( _value ) ); +#else + std::ostringstream ostr; + ostr << _value; + return( ostr.str() ); +#endif +} + + +std::string to_string( const int _value ) +{ +#ifndef SX_CPP03_BOOST + return( std::to_string( _value ) ); +#else + std::ostringstream ostr; + ostr << _value; + return( ostr.str() ); +#endif +} + + +// cppcheck-suppress unusedFunction +std::string to_upper( const std::string& _value ) +{ + std::string value_caps = _value; + std::transform( value_caps.begin(), value_caps.end(), value_caps.begin(), ::toupper ); + return( value_caps ); +} + + +// cppcheck-suppress unusedFunction +std::string to_lower( const std::string& _value ) +{ + std::string value_to_lower = _value; + std::transform( value_to_lower.begin(), value_to_lower.end(), value_to_lower.begin(), ::tolower ); + return( value_to_lower ); +} + + +} diff --git a/externals/essentials/source/essentials_version.cpp b/externals/essentials/source/essentials_version.cpp index 4abfe29..1d851f7 100644 --- a/externals/essentials/source/essentials_version.cpp +++ b/externals/essentials/source/essentials_version.cpp @@ -1,74 +1,74 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "essentials/essentials_version.hpp" - -#include - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/build_number.hpp" -#include "essentials/sxprintf.hpp" - - -namespace sxe -{ - - -namespace version -{ - - -namespace -{ - - -const sxe::uint16_t VERSION_MAJOR( 1 ); -const sxe::uint16_t VERSION_MINOR( 0 ); -const sxe::uint16_t VERSION_PATCH( 1 ); - - -} - - -// cppcheck-suppress unusedFunction -void log_version() -{ - std::cout << sxe::sxprintf( "essentials library version %.%.%.%.", get_major_version(), - get_minor_version(), get_patch_version(), get_build_number() ) << std::endl; -} - - -sxe::uint16_t get_major_version() -{ - return( VERSION_MAJOR ); -} - - -sxe::uint16_t get_minor_version() -{ - return( VERSION_MINOR ); -} - - -sxe::uint16_t get_patch_version() -{ - return( VERSION_PATCH ); -} - - -sxe::uint16_t get_build_number() -{ - return( BUILD_NUMBER ); -} - - -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "essentials/essentials_version.hpp" + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/build_number.hpp" +#include "essentials/sxprintf.hpp" + + +namespace sxe +{ + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 1 ); +const sxe::uint16_t VERSION_MINOR( 2 ); +const sxe::uint16_t VERSION_PATCH( 0 ); + + +} + + +// cppcheck-suppress unusedFunction +void log_version() +{ + std::cout << sxe::sxprintf( "essentials library version %.%.%.%.", get_major_version(), + get_minor_version(), get_patch_version(), get_build_number() ) << std::endl; +} + + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( BUILD_NUMBER ); +} + + +} + + +} diff --git a/externals/essentials/source/format_settings.cpp b/externals/essentials/source/format_settings.cpp index 0417c8a..768379a 100644 --- a/externals/essentials/source/format_settings.cpp +++ b/externals/essentials/source/format_settings.cpp @@ -1,32 +1,32 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "essentials/format_settings.hpp" - - -namespace sxe -{ - - -format_settings::format_settings(): - format_string_(), - missing_closing_bracket_( false ), - correct_( false ), - hex_( false ), - pad_zeros_( false ), - places_set_( false ), - places_( 0 ), - decimal_places_set_( false ), - decimal_places_( 0 ) -{ - // Nothing to do... -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "essentials/format_settings.hpp" + + +namespace sxe +{ + + +format_settings::format_settings(): + format_string_(), + missing_closing_bracket_( false ), + correct_( false ), + hex_( false ), + pad_zeros_( false ), + places_set_( false ), + places_( 0 ), + decimal_places_set_( false ), + decimal_places_( 0 ) +{ + // Nothing to do... +} + + +} diff --git a/externals/essentials/source/sxprintf.cpp b/externals/essentials/source/sxprintf.cpp index b2c41b5..e5fc6b5 100644 --- a/externals/essentials/source/sxprintf.cpp +++ b/externals/essentials/source/sxprintf.cpp @@ -1,628 +1,628 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex essentials library (http://essentials.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://essentials.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "essentials/sxprintf.hpp" - -#include - -#include "essentials/base.hpp" -#include "essentials/conversion.hpp" - - -namespace sxe -{ - - -namespace -{ - - - const char MISSING_PARAMETERS_MESSAGE[] = "[Missing parameter!]"; - const char MISSING_TERMINATOR[] = "[Missing output modifier terminator!]"; - const char ILLEGAL_MODIFIER[] = "[Illegal output modifier!]"; - const char POINT = '.'; - const char ZERO = '0'; - const char X = 'x'; - const char CAPS_X = 'X'; - - -} - - -const char PLACE_HOLDER = '%'; -const char* const SUPERFLUOUS_PARAMETER_START = "[Superfluous parameter: "; -const char SUPERFLUOUS_PARAMETER_END = ']'; -const char OPENING_SQUARE_BRACKET = '['; -const char CLOSING_SQUARE_BRACKET = ']'; - - -// cppcheck-suppress unusedFunction -std::ostream& operator<<( std::ostream& _os, const sxe::format_settings& _format ) -{ - if( !_format.correct_ ) - { - _os << ILLEGAL_MODIFIER; - } - else if( _format.missing_closing_bracket_ ) - { - _os << MISSING_TERMINATOR; - } - else - { - if( _format.hex_ ) - { - _os << std::hex; - _os << std::showbase; - _os.fill( '0' ); - } - else - { - if( _format.pad_zeros_ ) - { - _os.fill( '0' ); - } - - if( _format.places_set_ ) - { - _os.width( _format.places_ ); - } - - if( _format.decimal_places_set_ ) - { - _os.precision( _format.decimal_places_ ); - } - } - } - - return( _os ); -} - - -bool is_allowed_char( const char _char ) -{ - const bool success = ( std::isdigit( _char ) || ( X == _char ) || ( CAPS_X == _char ) ); - return( success ); -} - - -sxe::format_settings parse_format_string( const char** const _format ) -{ - sxe::format_settings format_settings; - format_settings.correct_ = true; - SX_ASSERT( ( OPENING_SQUARE_BRACKET == **_format ), "Format string to parse doesn't start with [." ); - ++*_format; - format_settings.missing_closing_bracket_ = true; - bool point_found = false; - const char* text_before_point = *_format; - std::size_t text_before_point_size = 0; - const char* text_after_point = SX_NULLPTR; - std::size_t text_after_point_size = 0; - while( **_format ) - { - if( CLOSING_SQUARE_BRACKET == **_format ) - { - format_settings.missing_closing_bracket_ = false; - break; - } - else - if( POINT == **_format ) - { - if( point_found ) - { - format_settings.correct_ = false; - break; - } - else - { - point_found = true; - text_after_point = ( *_format ) + 1; - text_after_point_size = 0; - } - } - else - { - const char _text_char = **_format; - if( is_allowed_char( _text_char ) ) - { - if( point_found ) - { - ++text_after_point_size; - } - else - { - ++text_before_point_size; - } - } - else - { - format_settings.correct_ = false; - break; - } - } - - ++( *_format ); - } - - SX_ASSERT( text_before_point, "Logic error parsing format string!" ); - if( ( 0 == text_before_point_size ) && ( 0 == text_after_point_size ) ) - { - format_settings.correct_ = false; - } - - if( ( !format_settings.missing_closing_bracket_ ) && format_settings.correct_ ) - { - if( ( 0 < text_before_point_size ) && ( ( X == text_before_point[ 0 ] ) || ( CAPS_X == text_before_point[ 0 ] ) ) ) - { - format_settings.hex_ = true; - ++text_before_point; - --text_before_point_size; - } - - if( ( 0 < text_before_point_size ) && ( ZERO == text_before_point[ 0 ] ) ) - { - format_settings.pad_zeros_ = true; - ++text_before_point; - --text_before_point_size; - } - - if( 0 < text_before_point_size ) - { - format_settings.places_set_ = true; - if( !string_to_int( text_before_point, format_settings.places_ ) ) - { - format_settings.correct_ = false; - } - } - - if( 0 < text_after_point_size ) - { - SX_ASSERT( text_after_point, "Logic error parsing format string!" ); - format_settings.decimal_places_set_ = true; - if( !string_to_int( text_after_point, format_settings.decimal_places_ ) ) - { - format_settings.correct_ = false; - } - } - } - - return( format_settings ); -} - - -#ifdef SX_CPP03_BOOST - - -void print_superfluous_parameters( std::ostream& _os, const value_types& _values, value_types::const_iterator& _position ) -{ - while( _position != _values.end() ) - { - print_superfluous_parameters( _os, *_position ); - ++_position; - } -} - - -#endif - - -void sxprintf( std::ostream& _os, const char* _format ) -{ - while( *_format ) - { - if( PLACE_HOLDER == *_format ) - { - if( PLACE_HOLDER == *( _format + 1 ) ) - { - ++_format; - } - else - { - _os << MISSING_PARAMETERS_MESSAGE; - } - } - _os << *_format++; - } -} - - -#ifdef SX_CPP03_BOOST - - -std::string sxprintf(const char* const _format) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, - const value_type& _value9) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9); - return( target_string_stream.str() ); -} - - -std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, - const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, - const value_type& _value9, const value_type& _value10) -{ - std::stringstream target_string_stream; - sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10); - return( target_string_stream.str() ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1 ) -{ - value_types values; - values.push_back( _value1 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - values.push_back( _value5 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - values.push_back( _value5 ); - values.push_back( _value6 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - values.push_back( _value5 ); - values.push_back( _value6 ); - values.push_back( _value7 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - values.push_back( _value5 ); - values.push_back( _value6 ); - values.push_back( _value7 ); - values.push_back( _value8 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8, const value_type& _value9 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - values.push_back( _value5 ); - values.push_back( _value6 ); - values.push_back( _value7 ); - values.push_back( _value8 ); - values.push_back( _value9 ); - sxprintf( _os, _format, values ); -} - - -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8, const value_type& _value9, const value_type& _value10 ) -{ - value_types values; - values.push_back( _value1 ); - values.push_back( _value2 ); - values.push_back( _value3 ); - values.push_back( _value4 ); - values.push_back( _value5 ); - values.push_back( _value6 ); - values.push_back( _value7 ); - values.push_back( _value8 ); - values.push_back( _value9 ); - values.push_back( _value10 ); - sxprintf( _os, _format, values ); -} - - -const char* sxprintf_impl( std::ostream& _os, const char* _format, value_types::const_iterator& _position, - const value_types::const_iterator _end, bool& printed ) -{ - while (*_format) - { - if (PLACE_HOLDER == *_format) - { - if (PLACE_HOLDER == *( _format + 1 )) - { - ++_format; // skip first place holder - _os << *_format++; // output of the second place holder - } - else - { - if (OPENING_SQUARE_BRACKET == *( _format + 1 )) - { - ++_format; - const sxe::format_settings format_settings = sxe::parse_format_string(&_format); - const std::ios_base::fmtflags stream_flags = _os.flags(); - const char streafill_ = _os.fill(); - _os << format_settings; - print_value_type_value( _os, *_position ); - _os.flags(stream_flags); - _os.fill(streafill_); - printed = true; - if( !format_settings.missing_closing_bracket_ ) - { - if( CLOSING_SQUARE_BRACKET == *( _format ) ) - { - ++_format; - } - } - else - { - if( !format_settings.correct_ ) - { - ++_format; - } - } - } - else - { - print_value_type_value( _os, *_position ); - printed = true; - ++_format; - break; - } - - if( _position + 1 != _end ) - { - if( *_format != '\0' ) - { - ++_position; - _format = sxprintf_impl( _os, _format, _position, _end, printed ); - } - } - return( _format ); - } - } - else - { - _os << *_format++; - } - } - return ( _format ); -} - - -void sxprintf( std::ostream& _os, const char * const _format, const value_types& _values ) -{ - SX_ASSERT( _format, "No format string to parse was passed!" ); - const char* current_position = _format; - - value_types::const_iterator _end = _values.end(); - value_types::const_iterator _position = _values.begin(); - while( _position != _end ) - { - bool printed = false; - current_position = sxprintf_impl( _os, current_position, _position, _end, printed ); - if( printed ) - { - ++_position; - } - if( current_position[0] == '\0' ) - { - break; - } - } - - sxprintf( _os, current_position ); - - if( _position != _end ) - { - print_superfluous_parameters( _os, _values, _position ); - } -} - - -void print_value_type_value( std::ostream& _os, const value_type& _value ) -{ - const std::type_info& type_info = _value.type(); - - if( type_info == typeid ( bool ) ) - { - stream_writer< bool >::print( _os, boost::get< bool >( _value ) ); - } - else if( type_info == typeid ( int ) ) - { - stream_writer< int >::print( _os, boost::get< int >( _value ) ); - } - else if( type_info == typeid ( unsigned int ) ) - { - stream_writer< unsigned int >::print( _os, boost::get< unsigned int >( _value ) ); - } - else if( type_info == typeid ( sxe::int8_t ) ) - { - stream_writer< sxe::int8_t >::print( _os, boost::get< sxe::int8_t >( _value ) ); - } - else if (type_info == typeid ( sxe::uint8_t )) - { - stream_writer< sxe::uint8_t >::print(_os, boost::get< sxe::uint8_t >(_value)); - } - else if( type_info == typeid ( sxe::uint16_t ) ) - { - stream_writer< sxe::uint16_t >::print( _os, boost::get< sxe::uint16_t >( _value ) ); - } - else if( type_info == typeid ( sxe::uint32_t ) ) - { - stream_writer< sxe::uint32_t >::print( _os, boost::get< sxe::uint32_t >( _value ) ); - } - else if( type_info == typeid ( std::string ) ) - { - stream_writer< std::string >::print( _os, boost::get< std::string >( _value ) ); - } - else if( type_info == typeid ( std::size_t ) ) - { - stream_writer< std::size_t >::print( _os, boost::get< std::size_t >( _value ) ); - } - else if( type_info == typeid ( const char* ) ) - { - stream_writer< const char* >::print( _os, boost::get< const char* >( _value ) ); - } - else if( type_info == typeid ( int_least64_t ) ) - { - stream_writer< int_least64_t >::print( _os, boost::get< int_least64_t >( _value ) ); - } - else if( type_info == typeid ( double ) ) - { - stream_writer< double >::print( _os, boost::get< double >( _value ) ); - } -} - - -#endif - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "essentials/sxprintf.hpp" + +#include + +#include "essentials/base.hpp" +#include "essentials/conversion.hpp" + + +namespace sxe +{ + + +namespace +{ + + + const char MISSING_PARAMETERS_MESSAGE[] = "[Missing parameter!]"; + const char MISSING_TERMINATOR[] = "[Missing output modifier terminator!]"; + const char ILLEGAL_MODIFIER[] = "[Illegal output modifier!]"; + const char POINT = '.'; + const char ZERO = '0'; + const char X = 'x'; + const char CAPS_X = 'X'; + + +} + + +const char PLACE_HOLDER = '%'; +const char* const SUPERFLUOUS_PARAMETER_START = "[Superfluous parameter: "; +const char SUPERFLUOUS_PARAMETER_END = ']'; +const char OPENING_SQUARE_BRACKET = '['; +const char CLOSING_SQUARE_BRACKET = ']'; + + +// cppcheck-suppress unusedFunction +std::ostream& operator<<( std::ostream& _os, const sxe::format_settings& _format ) +{ + if( !_format.correct_ ) + { + _os << ILLEGAL_MODIFIER; + } + else if( _format.missing_closing_bracket_ ) + { + _os << MISSING_TERMINATOR; + } + else + { + if( _format.hex_ ) + { + _os << std::hex; + _os << std::showbase; + _os.fill( '0' ); + } + else + { + if( _format.pad_zeros_ ) + { + _os.fill( '0' ); + } + + if( _format.places_set_ ) + { + _os.width( _format.places_ ); + } + + if( _format.decimal_places_set_ ) + { + _os.precision( _format.decimal_places_ ); + } + } + } + + return( _os ); +} + + +bool is_allowed_char( const char _char ) +{ + const bool success = ( std::isdigit( _char ) || ( X == _char ) || ( CAPS_X == _char ) ); + return( success ); +} + + +sxe::format_settings parse_format_string( const char** const _format ) +{ + sxe::format_settings format_settings; + format_settings.correct_ = true; + SX_ASSERT( ( OPENING_SQUARE_BRACKET == **_format ), "Format string to parse doesn't start with [." ); + ++*_format; + format_settings.missing_closing_bracket_ = true; + bool point_found = false; + const char* text_before_point = *_format; + std::size_t text_before_point_size = 0; + const char* text_after_point = SX_NULLPTR; + std::size_t text_after_point_size = 0; + while( **_format ) + { + if( CLOSING_SQUARE_BRACKET == **_format ) + { + format_settings.missing_closing_bracket_ = false; + break; + } + else + if( POINT == **_format ) + { + if( point_found ) + { + format_settings.correct_ = false; + break; + } + else + { + point_found = true; + text_after_point = ( *_format ) + 1; + text_after_point_size = 0; + } + } + else + { + const char _text_char = **_format; + if( is_allowed_char( _text_char ) ) + { + if( point_found ) + { + ++text_after_point_size; + } + else + { + ++text_before_point_size; + } + } + else + { + format_settings.correct_ = false; + break; + } + } + + ++( *_format ); + } + + SX_ASSERT( text_before_point, "Logic error parsing format string!" ); + if( ( 0 == text_before_point_size ) && ( 0 == text_after_point_size ) ) + { + format_settings.correct_ = false; + } + + if( ( !format_settings.missing_closing_bracket_ ) && format_settings.correct_ ) + { + if( ( 0 < text_before_point_size ) && ( ( X == text_before_point[ 0 ] ) || ( CAPS_X == text_before_point[ 0 ] ) ) ) + { + format_settings.hex_ = true; + ++text_before_point; + --text_before_point_size; + } + + if( ( 0 < text_before_point_size ) && ( ZERO == text_before_point[ 0 ] ) ) + { + format_settings.pad_zeros_ = true; + ++text_before_point; + --text_before_point_size; + } + + if( 0 < text_before_point_size ) + { + format_settings.places_set_ = true; + if( !string_to_int( text_before_point, format_settings.places_ ) ) + { + format_settings.correct_ = false; + } + } + + if( 0 < text_after_point_size ) + { + SX_ASSERT( text_after_point, "Logic error parsing format string!" ); + format_settings.decimal_places_set_ = true; + if( !string_to_int( text_after_point, format_settings.decimal_places_ ) ) + { + format_settings.correct_ = false; + } + } + } + + return( format_settings ); +} + + +#ifdef SX_CPP03_BOOST + + +void print_superfluous_parameters( std::ostream& _os, const value_types& _values, value_types::const_iterator& _position ) +{ + while( _position != _values.end() ) + { + print_superfluous_parameters( _os, *_position ); + ++_position; + } +} + + +#endif + + +void sxprintf( std::ostream& _os, const char* _format ) +{ + while( *_format ) + { + if( PLACE_HOLDER == *_format ) + { + if( PLACE_HOLDER == *( _format + 1 ) ) + { + ++_format; + } + else + { + _os << MISSING_PARAMETERS_MESSAGE; + } + } + _os << *_format++; + } +} + + +#ifdef SX_CPP03_BOOST + + +std::string sxprintf(const char* const _format) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, + const value_type& _value9) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9); + return( target_string_stream.str() ); +} + + +std::string sxprintf(const char* const _format, const value_type& _value1, const value_type& _value2, const value_type& _value3, + const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7, const value_type& _value8, + const value_type& _value9, const value_type& _value10) +{ + std::stringstream target_string_stream; + sxprintf(target_string_stream, _format, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10); + return( target_string_stream.str() ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1 ) +{ + value_types values; + values.push_back( _value1 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + values.push_back( _value5 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + values.push_back( _value5 ); + values.push_back( _value6 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + values.push_back( _value5 ); + values.push_back( _value6 ); + values.push_back( _value7 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + values.push_back( _value5 ); + values.push_back( _value6 ); + values.push_back( _value7 ); + values.push_back( _value8 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8, const value_type& _value9 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + values.push_back( _value5 ); + values.push_back( _value6 ); + values.push_back( _value7 ); + values.push_back( _value8 ); + values.push_back( _value9 ); + sxprintf( _os, _format, values ); +} + + +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8, const value_type& _value9, const value_type& _value10 ) +{ + value_types values; + values.push_back( _value1 ); + values.push_back( _value2 ); + values.push_back( _value3 ); + values.push_back( _value4 ); + values.push_back( _value5 ); + values.push_back( _value6 ); + values.push_back( _value7 ); + values.push_back( _value8 ); + values.push_back( _value9 ); + values.push_back( _value10 ); + sxprintf( _os, _format, values ); +} + + +const char* sxprintf_impl( std::ostream& _os, const char* _format, value_types::const_iterator& _position, + const value_types::const_iterator _end, bool& printed ) +{ + while (*_format) + { + if (PLACE_HOLDER == *_format) + { + if (PLACE_HOLDER == *( _format + 1 )) + { + ++_format; // skip first place holder + _os << *_format++; // output of the second place holder + } + else + { + if (OPENING_SQUARE_BRACKET == *( _format + 1 )) + { + ++_format; + const sxe::format_settings format_settings = sxe::parse_format_string(&_format); + const std::ios_base::fmtflags stream_flags = _os.flags(); + const char streafill_ = _os.fill(); + _os << format_settings; + print_value_type_value( _os, *_position ); + _os.flags(stream_flags); + _os.fill(streafill_); + printed = true; + if( !format_settings.missing_closing_bracket_ ) + { + if( CLOSING_SQUARE_BRACKET == *( _format ) ) + { + ++_format; + } + } + else + { + if( !format_settings.correct_ ) + { + ++_format; + } + } + } + else + { + print_value_type_value( _os, *_position ); + printed = true; + ++_format; + break; + } + + if( _position + 1 != _end ) + { + if( *_format != '\0' ) + { + ++_position; + _format = sxprintf_impl( _os, _format, _position, _end, printed ); + } + } + return( _format ); + } + } + else + { + _os << *_format++; + } + } + return ( _format ); +} + + +void sxprintf( std::ostream& _os, const char * const _format, const value_types& _values ) +{ + SX_ASSERT( _format, "No format string to parse was passed!" ); + const char* current_position = _format; + + value_types::const_iterator _end = _values.end(); + value_types::const_iterator _position = _values.begin(); + while( _position != _end ) + { + bool printed = false; + current_position = sxprintf_impl( _os, current_position, _position, _end, printed ); + if( printed ) + { + ++_position; + } + if( current_position[0] == '\0' ) + { + break; + } + } + + sxprintf( _os, current_position ); + + if( _position != _end ) + { + print_superfluous_parameters( _os, _values, _position ); + } +} + + +void print_value_type_value( std::ostream& _os, const value_type& _value ) +{ + const std::type_info& type_info = _value.type(); + + if( type_info == typeid ( bool ) ) + { + stream_writer< bool >::print( _os, boost::get< bool >( _value ) ); + } + else if( type_info == typeid ( int ) ) + { + stream_writer< int >::print( _os, boost::get< int >( _value ) ); + } + else if( type_info == typeid ( unsigned int ) ) + { + stream_writer< unsigned int >::print( _os, boost::get< unsigned int >( _value ) ); + } + else if( type_info == typeid ( sxe::int8_t ) ) + { + stream_writer< sxe::int8_t >::print( _os, boost::get< sxe::int8_t >( _value ) ); + } + else if (type_info == typeid ( sxe::uint8_t )) + { + stream_writer< sxe::uint8_t >::print(_os, boost::get< sxe::uint8_t >(_value)); + } + else if( type_info == typeid ( sxe::uint16_t ) ) + { + stream_writer< sxe::uint16_t >::print( _os, boost::get< sxe::uint16_t >( _value ) ); + } + else if( type_info == typeid ( sxe::uint32_t ) ) + { + stream_writer< sxe::uint32_t >::print( _os, boost::get< sxe::uint32_t >( _value ) ); + } + else if( type_info == typeid ( std::string ) ) + { + stream_writer< std::string >::print( _os, boost::get< std::string >( _value ) ); + } + else if( type_info == typeid ( std::size_t ) ) + { + stream_writer< std::size_t >::print( _os, boost::get< std::size_t >( _value ) ); + } + else if( type_info == typeid ( const char* ) ) + { + stream_writer< const char* >::print( _os, boost::get< const char* >( _value ) ); + } + else if( type_info == typeid ( int_least64_t ) ) + { + stream_writer< int_least64_t >::print( _os, boost::get< int_least64_t >( _value ) ); + } + else if( type_info == typeid ( double ) ) + { + stream_writer< double >::print( _os, boost::get< double >( _value ) ); + } +} + + +#endif + + +} diff --git a/libyasmine/source/uri.cpp b/externals/essentials/source/uri.cpp similarity index 75% rename from libyasmine/source/uri.cpp rename to externals/essentials/source/uri.cpp index 2d04f57..9926a9a 100644 --- a/libyasmine/source/uri.cpp +++ b/externals/essentials/source/uri.cpp @@ -1,138 +1,136 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "uri.hpp" - -#include -#include - -#include "essentials/base.hpp" -#include "hermes/globals.hpp" - - -namespace sxy -{ - - -uri::uri( const std::string& _uri ) - : uri_() -{ - split_string_to_uri_segments( _uri ); -} - - -uri::~uri() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool uri::is_empty() const -{ - return( uri_.empty() ); -} - - -const std::string uri::to_string() const -{ - return( build_uri() ); -} - - -const std::string& uri::get_front() const -{ - SX_ASSERT( !uri_.empty(), "Uri is empty!" ); - return( uri_.front() ); -} - - -const std::string& uri::get_back() -{ - SX_ASSERT( !uri_.empty(), "Uri is empty!" ); - return( uri_.back() ); -} - - -void uri::push_front( const std::string& _segment ) -{ - uri_.push_front( _segment ); -} - - -void uri::push_back( const std::string& _segment ) -{ - uri_.push_back( _segment ); -} - - -void uri::pop_front() -{ - SX_ASSERT( !uri_.empty(), "Uri is empty!" ); - uri_.pop_front(); -} - - -void uri::pop_back() -{ - SX_ASSERT( !uri_.empty(), "Uri is empty!" ); - uri_.pop_back(); -} - - -size_t uri::size() const -{ - return( uri_.size() ); -} - - -const std::string uri::build_uri() const -{ - std::stringstream uri; - - SX_FOR( const std::string& uri_element, uri_ ) - { - uri << hermes::URI_DELIMITER << uri_element; - } - - return( uri.str() ); -} - - -void uri::split_string_to_uri_segments( const std::string& _uri ) -{ - std::string uri = _uri; - if( !_uri.empty() ) - { - if( hermes::URI_DELIMITER == _uri[ 0 ] ) - { - uri = _uri.substr( 1 ); - } - - std::string::size_type start = 0; - std::string::size_type end = uri.find( hermes::URI_DELIMITER ); - while( end != std::string::npos ) - { - const std::string& segment = uri.substr( start, end - start ); - uri_.push_back( segment ); - start = ++end; - end = uri.find( hermes::URI_DELIMITER, end ); - } - - const std::string& last_segment = uri.substr( start ); - if( last_segment[ 0 ] != hermes::URI_DELIMITER ) - { - uri_.push_back( last_segment ); - } - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "essentials/uri.hpp" + +#include +#include + +#include "essentials/base.hpp" + + +namespace sxe +{ + + +uri::uri( const std::string& _uri ) + : uri_() +{ + split_string_to_uri_segments( _uri ); +} + + +uri::~uri() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool uri::is_empty() const +{ + return( uri_.empty() ); +} + + +const std::string uri::to_string() const +{ + return( build_uri() ); +} + + +const std::string& uri::get_front() const +{ + SX_ASSERT( !uri_.empty(), "Uri is empty!" ); + return( uri_.front() ); +} + + +const std::string& uri::get_back() +{ + SX_ASSERT( !uri_.empty(), "Uri is empty!" ); + return( uri_.back() ); +} + + +void uri::push_front( const std::string& _segment ) +{ + uri_.push_front( _segment ); +} + + +void uri::push_back( const std::string& _segment ) +{ + uri_.push_back( _segment ); +} + + +void uri::pop_front() +{ + SX_ASSERT( !uri_.empty(), "Uri is empty!" ); + uri_.pop_front(); +} + + +void uri::pop_back() +{ + SX_ASSERT( !uri_.empty(), "Uri is empty!" ); + uri_.pop_back(); +} + + +size_t uri::size() const +{ + return( uri_.size() ); +} + + +const std::string uri::build_uri() const +{ + std::stringstream uri; + + SX_FOR( const std::string& uri_element, uri_ ) + { + uri << URI_DELIMITER << uri_element; + } + + return( uri.str() ); +} + + +void uri::split_string_to_uri_segments( const std::string& _uri ) +{ + std::string uri = _uri; + if( !_uri.empty() ) + { + if( URI_DELIMITER == _uri[ 0 ] ) + { + uri = _uri.substr( 1 ); + } + + std::string::size_type start = 0; + std::string::size_type end = uri.find( URI_DELIMITER ); + while( end != std::string::npos ) + { + const std::string& segment = uri.substr( start, end - start ); + uri_.push_back( segment ); + start = ++end; + end = uri.find( URI_DELIMITER, end ); + } + + const std::string& last_segment = uri.substr( start ); + if( last_segment[ 0 ] != URI_DELIMITER ) + { + uri_.push_back( last_segment ); + } + } +} + + +} diff --git a/externals/hermes/include/hermes/build_number.hpp b/externals/hermes/include/hermes/build_number.hpp index eafc9c9..61892f9 100644 --- a/externals/hermes/include/hermes/build_number.hpp +++ b/externals/hermes/include/hermes/build_number.hpp @@ -1,35 +1,35 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BUILD_NUMBER_D6FF600D_5F67_43E8_A8CD_7BEE789F3AD4 -#define BUILD_NUMBER_D6FF600D_5F67_43E8_A8CD_7BEE789F3AD4 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace hermes -{ - - -namespace version -{ - - - const sxe::uint16_t BUILD_NUMBER( 66 ); - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_NUMBER_D6FF600D_5F67_43E8_A8CD_7BEE789F3AD4 +#define BUILD_NUMBER_D6FF600D_5F67_43E8_A8CD_7BEE789F3AD4 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace hermes +{ + + +namespace version +{ + + + const sxe::uint16_t BUILD_NUMBER( 66 ); + + +} + + +} + + +#endif diff --git a/externals/hermes/include/hermes/color.hpp b/externals/hermes/include/hermes/color.hpp index 6453cbc..54a7248 100644 --- a/externals/hermes/include/hermes/color.hpp +++ b/externals/hermes/include/hermes/color.hpp @@ -1,94 +1,94 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef COLOR_63B5B1DB_D383_404D_93EF_AB2BC3A0D286 -#define COLOR_63B5B1DB_D383_404D_93EF_AB2BC3A0D286 - - -namespace hermes -{ - - -#ifndef SX_CPP03_BOOST - - - //!\enum color - //!\brief Enumeration for predefined colors. - enum class color - { - C_BLACK = 0, C_WHITE = 15, C_DARK_WHITE = 7, C_BLUE = 9, C_DARK_BLUE = 1, C_GREEN = 10, C_DARK_GREEN = 2, C_RED = 12, - C_DARK_RED = 4, C_YELLOW = 14, C_DARK_YELLOW = 6, C_AQUA = 3, C_GRAY = 8, C_MAGENTA = 13, C_CYAN = 11 - }; - - -#else - - - //!\struct color - //!\brief Structure representing a predefined color (enum wrapper for C++11 enum class like behavior). - struct color - { - //!\enum color - //!\brief Enumeration for predefined colors. - enum inner - { - C_BLACK = 0, C_WHITE = 15, C_DARK_WHITE = 7, C_BLUE = 9, C_DARK_BLUE = 1, C_GREEN = 10, C_DARK_GREEN = 2, C_RED = 12, - C_DARK_RED = 4, C_YELLOW = 14, C_DARK_YELLOW = 6, C_AQUA = 3, C_GRAY = 8, C_MAGENTA = 13, C_CYAN = 11 - }; - - - //!\brief Constructor. Default value is white. - color() : value_( C_WHITE ) - { - // Nothing to do... - } - - - //!\brief Constructor - //!\param _value Given color value that is represented by the structure. - color( const inner _value ) : value_( _value ) - { - // Nothing to do... - } - - - //!\brief Constructor - //!\param _color Given color structure containing the color that is represented by the structure. - color( const color& _color ) : value_( _color.value_ ) - { - // Nothing to do... - } - - - //!\brief Get the color value represented by the structure. - operator inner() const - { - return ( value_ ); - } - - - //!\brief Color represented by the structure. - inner value_; - - }; - - -#endif - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef COLOR_63B5B1DB_D383_404D_93EF_AB2BC3A0D286 +#define COLOR_63B5B1DB_D383_404D_93EF_AB2BC3A0D286 + + +namespace hermes +{ + + +#ifndef SX_CPP03_BOOST + + + //!\enum color + //!\brief Enumeration for predefined colors. + enum class color + { + C_BLACK = 0, C_WHITE = 15, C_DARK_WHITE = 7, C_BLUE = 9, C_DARK_BLUE = 1, C_GREEN = 10, C_DARK_GREEN = 2, C_RED = 12, + C_DARK_RED = 4, C_YELLOW = 14, C_DARK_YELLOW = 6, C_AQUA = 3, C_GRAY = 8, C_MAGENTA = 13, C_CYAN = 11 + }; + + +#else + + + //!\struct color + //!\brief Structure representing a predefined color (enum wrapper for C++11 enum class like behavior). + struct color + { + //!\enum color + //!\brief Enumeration for predefined colors. + enum inner + { + C_BLACK = 0, C_WHITE = 15, C_DARK_WHITE = 7, C_BLUE = 9, C_DARK_BLUE = 1, C_GREEN = 10, C_DARK_GREEN = 2, C_RED = 12, + C_DARK_RED = 4, C_YELLOW = 14, C_DARK_YELLOW = 6, C_AQUA = 3, C_GRAY = 8, C_MAGENTA = 13, C_CYAN = 11 + }; + + + //!\brief Constructor. Default value is white. + color() : value_( C_WHITE ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _value Given color value that is represented by the structure. + color( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _color Given color structure containing the color that is represented by the structure. + color( const color& _color ) : value_( _color.value_ ) + { + // Nothing to do... + } + + + //!\brief Get the color value represented by the structure. + operator inner() const + { + return ( value_ ); + } + + + //!\brief Color represented by the structure. + inner value_; + + }; + + +#endif + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/color_mapping.hpp b/externals/hermes/include/hermes/color_mapping.hpp index 549da7f..229e883 100644 --- a/externals/hermes/include/hermes/color_mapping.hpp +++ b/externals/hermes/include/hermes/color_mapping.hpp @@ -1,59 +1,59 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef COLOR_MAPPING_A8F877D1_966B_463B_AE26_BD54CB2FEC35 -#define COLOR_MAPPING_A8F877D1_966B_463B_AE26_BD54CB2FEC35 - - -#include - -#include "essentials/non_copyable.hpp" -#include "color.hpp" -#include "log_level.hpp" - - -namespace hermes -{ - - -//!\class color_mapping -//!\brief Class for mapping colors to log levels. -class color_mapping SX_FINAL -{ -public: - //!\typedef color_map - //!\brief Alias for the map of log levels to colors. - typedef std::map< log_level, color > color_map; - - //!\brief Constructor of the class. - color_mapping(); - ~color_mapping() SX_NOEXCEPT; - SX_NO_COPY(color_mapping) - - //!\brief Method for getting the color associated with the given log level. - //!\param _log_level The log level for which the color is requested. - //!\return Color value associated with the given log level. - color get_color( const log_level _log_level ) const; - - -private: - color_map color_map_; -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef COLOR_MAPPING_A8F877D1_966B_463B_AE26_BD54CB2FEC35 +#define COLOR_MAPPING_A8F877D1_966B_463B_AE26_BD54CB2FEC35 + + +#include + +#include "essentials/non_copyable.hpp" +#include "color.hpp" +#include "log_level.hpp" + + +namespace hermes +{ + + +//!\class color_mapping +//!\brief Class for mapping colors to log levels. +class color_mapping SX_FINAL +{ +public: + //!\typedef color_map + //!\brief Alias for the map of log levels to colors. + typedef std::map< log_level, color > color_map; + + //!\brief Constructor. + color_mapping(); + ~color_mapping() SX_NOEXCEPT; + SX_NO_COPY(color_mapping) + + //!\brief Method for getting the color associated with the given log level. + //!\param _log_level The log level for which the color is requested. + //!\return Color value associated with the given log level. + color get_color( const log_level _log_level ) const; + + +private: + color_map color_map_; +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/cout_logger.hpp b/externals/hermes/include/hermes/cout_logger.hpp index 018eb71..9dc5508 100644 --- a/externals/hermes/include/hermes/cout_logger.hpp +++ b/externals/hermes/include/hermes/cout_logger.hpp @@ -1,60 +1,60 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef COUT_LOGGER_170B8470_DB09_43CF_A547_D6C928D5121F -#define COUT_LOGGER_170B8470_DB09_43CF_A547_D6C928D5121F - - -#include "logger.hpp" -#include "color_mapping.hpp" - - -namespace hermes -{ - - -//!\class cout_logger -//!\brief Class for printing messages in the console via cout. -class cout_logger: - public logger -{ -public: - //!\brief Constructor - cout_logger(); - virtual ~cout_logger() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(cout_logger) - - //!\brief Prints the message. - //!\param _log_message Log message that will be printed. - //!\return void - virtual void log( const log_message& _log_message ) SX_OVERRIDE; - - -private: - void log_level_as_message( const hermes::log_level _log_level ) const; - - color_mapping color_mapping_; -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef COUT_LOGGER_170B8470_DB09_43CF_A547_D6C928D5121F +#define COUT_LOGGER_170B8470_DB09_43CF_A547_D6C928D5121F + + +#include "logger.hpp" +#include "color_mapping.hpp" + + +namespace hermes +{ + + +//!\class cout_logger +//!\brief Class for printing messages in the console via cout. +class cout_logger: + public logger +{ +public: + //!\brief Constructor + cout_logger(); + virtual ~cout_logger() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(cout_logger) + + //!\brief Prints the message. + //!\param _log_message Log message that will be printed. + //!\return void + virtual void log( const log_message& _log_message ) SX_OVERRIDE; + + +private: + void log_level_as_message( const hermes::log_level _log_level ) const; + + color_mapping color_mapping_; +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/file_logger.hpp b/externals/hermes/include/hermes/file_logger.hpp index 7f0f726..d0df092 100644 --- a/externals/hermes/include/hermes/file_logger.hpp +++ b/externals/hermes/include/hermes/file_logger.hpp @@ -1,80 +1,80 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 -#define FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 - - -#include "logger.hpp" -#include "essentials/exception_template.hpp" - - -namespace hermes -{ - - -//!\class file_logger -//!\brief Class for writing messages to a log file. It rotates the log file if a certain size limit is met. Naming and -//!location of the log files can be customized. Also the number of log files in rotation can be set. -class file_logger: - public logger -{ -public: - //!\brief Exception class of the file_logger. - SX_EXCEPTION( exception ) - - //!\brief Constructor - //!\param _max_file_size_in_bytes Maximum size of a log file in bytes. - //!\param _log_files_directory Folder where the log files are stored. - //!\param _name_suffix The suffix for the log files. - //!\param _name_extension The extension of the log files. - //!\param _max_file_number The maximum number of log files. - //!\param _throw_on_error Flag for throwing an exception on error. Default is true. - explicit file_logger( const size_t _max_file_size_in_bytes, const std::string& _log_files_directory, - const std::string& _name_suffix, const std::string& _name_extension, const unsigned _max_file_number, - const bool _throw_on_error = true ); - virtual ~file_logger() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(file_logger) - - //!\brief Writes the message. - //!\param _log_message Log message that will be written. - //!\return void - virtual void log( const log_message& _log_message ) SX_OVERRIDE; - - -private: - std::string get_log_file_name_with_index( const unsigned _index ) const; - std::string get_working_log_file_name() const; - void log_into_file( const std::string& _message ) const; - void rotate_if_necessary() const; - void rename_files() const; - void rename_file_if_exists( const std::string& _old_name, const std::string& _new_name ) const; - void delete_file( const std::string& _file_name ) const; - - - const size_t max_file_size_in_bytes_; - const std::string log_files_directory_; - const std::string name_sufix_; - const std::string name_extension_; - const unsigned max_file_number_; - const bool throw_on_error_; - std::string working_file_; -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 +#define FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 + + +#include "logger.hpp" +#include "essentials/exception_template.hpp" + + +namespace hermes +{ + + +//!\class file_logger +//!\brief Class for writing messages to a log file. It rotates the log file if a certain size limit is met. Naming and +//!location of the log files can be customized. Also the number of log files in rotation can be set. +class file_logger: + public logger +{ +public: + //!\brief Exception class of the file_logger. + SX_EXCEPTION( exception ) + + //!\brief Constructor + //!\param _max_file_size_in_bytes Maximum size of a log file in bytes. + //!\param _log_files_directory Folder where the log files are stored. + //!\param _name_suffix The suffix for the log files. + //!\param _name_extension The extension of the log files. + //!\param _max_file_number The maximum number of log files. + //!\param _throw_on_error Flag for throwing an exception on error. Default is true. + explicit file_logger( const size_t _max_file_size_in_bytes, const std::string& _log_files_directory, + const std::string& _name_suffix, const std::string& _name_extension, const unsigned _max_file_number, + const bool _throw_on_error = true ); + virtual ~file_logger() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(file_logger) + + //!\brief Writes the message. + //!\param _log_message Log message that will be written. + //!\return void + virtual void log( const log_message& _log_message ) SX_OVERRIDE; + + +private: + std::string get_log_file_name_with_index( const unsigned _index ) const; + std::string get_working_log_file_name() const; + void log_into_file( const std::string& _message ) const; + void rotate_if_necessary() const; + void rename_files() const; + void rename_file_if_exists( const std::string& _old_name, const std::string& _new_name ) const; + void delete_file( const std::string& _file_name ) const; + + + const size_t max_file_size_in_bytes_; + const std::string log_files_directory_; + const std::string name_sufix_; + const std::string name_extension_; + const unsigned max_file_number_; + const bool throw_on_error_; + std::string working_file_; +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/file_system.hpp b/externals/hermes/include/hermes/file_system.hpp index 3b4dd1e..2ec9753 100644 --- a/externals/hermes/include/hermes/file_system.hpp +++ b/externals/hermes/include/hermes/file_system.hpp @@ -1,45 +1,45 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FILE_SYSTEM_E5395B2B_BD8A_46B9_831A_B9A24E8CEDC2 -#define FILE_SYSTEM_E5395B2B_BD8A_46B9_831A_B9A24E8CEDC2 - - -#include -#include - - -namespace hermes -{ - - -//!\fn get_file_size -//!\brief Get the size of the file with the given name. -//!\param _file_name Name of file for which the size is requested. -//!\return Size of the given file. -size_t get_file_size( const std::string& _file_name ); - -//!\fn does_file_exist -//!\brief Checks if the file with the given name exists. -//!\param _file_name Name of the file to be checked. -//!\return True if the given file exists, false otherwise. -bool does_file_exist( const std::string& _file_name ); - -//!\fn add_trailing_slash_to_directory_path -//!\brief Add trailing slash to the given path. -//!\param _path Path to which the trailing slash is added. -//!\return Path with trailing slash at the end. -std::string add_trailing_slash_to_directory_path( const std::string& _path ); - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FILE_SYSTEM_E5395B2B_BD8A_46B9_831A_B9A24E8CEDC2 +#define FILE_SYSTEM_E5395B2B_BD8A_46B9_831A_B9A24E8CEDC2 + + +#include +#include + + +namespace hermes +{ + + +//!\fn get_file_size +//!\brief Get the size of the file with the given name. +//!\param _file_name Name of file for which the size is requested. +//!\return Size of the given file. +size_t get_file_size( const std::string& _file_name ); + +//!\fn does_file_exist +//!\brief Checks if the file with the given name exists. +//!\param _file_name Name of the file to be checked. +//!\return True if the given file exists, false otherwise. +bool does_file_exist( const std::string& _file_name ); + +//!\fn add_trailing_slash_to_directory_path +//!\brief Add trailing slash to the given path. +//!\param _path Path to which the trailing slash is added. +//!\return Path with trailing slash at the end. +std::string add_trailing_slash_to_directory_path( const std::string& _path ); + + +} + + +#endif diff --git a/externals/hermes/include/hermes/globals.hpp b/externals/hermes/include/hermes/globals.hpp index eab7b77..74ac1d4 100644 --- a/externals/hermes/include/hermes/globals.hpp +++ b/externals/hermes/include/hermes/globals.hpp @@ -1,29 +1,26 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef GLOBALS_A818BE8A_F8B8_44CA_9596_D6F248E8A175 -#define GLOBALS_A818BE8A_F8B8_44CA_9596_D6F248E8A175 - - -namespace hermes -{ - - -//!\brief Constant for width of the log level block. The log level block has a fixed width for better readability. -extern const int LOG_LEVEL_BLOCK_WIDTH; - -//!\brief Constant URI delimiter character -extern const char URI_DELIMITER; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef GLOBALS_A818BE8A_F8B8_44CA_9596_D6F248E8A175 +#define GLOBALS_A818BE8A_F8B8_44CA_9596_D6F248E8A175 + + +namespace hermes +{ + + +//!\brief Constant for width of the log level block. The log level block has a fixed width for better readability. +extern const int LOG_LEVEL_BLOCK_WIDTH; + + +} + + +#endif diff --git a/externals/hermes/include/hermes/hermes_version.hpp b/externals/hermes/include/hermes/hermes_version.hpp index 1192482..fb0ec05 100644 --- a/externals/hermes/include/hermes/hermes_version.hpp +++ b/externals/hermes/include/hermes/hermes_version.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERSION_3B8BFD66_4CAA_4921_88C4_D49899FE2C59 -#define VERSION_3B8BFD66_4CAA_4921_88C4_D49899FE2C59 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace hermes -{ - - -namespace version -{ - - -void log_version(); - - -sxe::uint16_t get_major_version(); -sxe::uint16_t get_minor_version(); -sxe::uint16_t get_patch_version(); -sxe::uint16_t get_build_number(); - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERSION_3B8BFD66_4CAA_4921_88C4_D49899FE2C59 +#define VERSION_3B8BFD66_4CAA_4921_88C4_D49899FE2C59 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace hermes +{ + + +namespace version +{ + + +void log_version(); + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +#endif diff --git a/externals/hermes/include/hermes/log.hpp b/externals/hermes/include/hermes/log.hpp index 02ac66a..5de53e2 100644 --- a/externals/hermes/include/hermes/log.hpp +++ b/externals/hermes/include/hermes/log.hpp @@ -1,150 +1,150 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef LOG_5AD3F1F5_0FC9_4D0E_8101_D9D70B8B1486 -#define LOG_5AD3F1F5_0FC9_4D0E_8101_D9D70B8B1486 - - -#ifdef SX_NO_LOGGING - - -inline void parameter_muncher() -{ - // Nothing to do... -} - - -template< typename T, typename ... args > -void parameter_muncher( T, args ... _args ) -{ - parameter_muncher( _args... ); -} - - -//!\brief Macro that is used when SX_NO_LOGGING is defined and thus there should be no logging. Consumes all parameters -//!so no warnings occur because of unused parameters. The code does nothing and can (will) be removed by the optimizer. -//!\sa sxprintf -#define SX_LOG( _dummy, ... ) \ - do \ - { \ - parameter_muncher( __VA_ARGS__ ); \ - } \ - while( false ) - - -//!\brief Macro that is used when SX_NO_LOGGING is defined and thus there should be no logging. Consumes all parameters -//!so no warnings occur because of unused parameters. The code does nothing and can (will) be removed by the optimizer. -//!\sa sxprintf -#define SX_LOG_HEX( _dummy, ... ) \ - do \ - { \ - parameter_muncher( __VA_ARGS__ ); \ - } \ - while( false ) - - -#else - - -#ifndef SX_CPP03_BOOST - -//!\brief Create a log message. -//!\param _level The log level of the message. -//!\param ... Parameters that are inserted into the message. -//!\sa sxprintf -#define SX_LOG( _level, ... ) \ - do \ - { \ - hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); \ - if( _level <= l_log_manager.get_log_level() ) \ - { \ - l_log_manager.log( _level, hermes::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, __VA_ARGS__ ); \ - } \ - } \ - while( false ) - - -//!\brief Create a hex log message. -//!\param _level The log level of the message. -//!\param _heading The heading of the message. -//!\param _data The message of the log. -//!\param ... Parameters that are inserted into the message. -//!\sa sxprintf -#define SX_LOG_HEX( _level, _heading, _data, ... ) \ - do \ - { \ - hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); \ - if( _level <= l_log_manager.get_log_level() ) \ - { \ - const std::string l_heading(_heading);\ - const std::string l_data(_data);\ - const std::string l_message = l_heading + "\n" + l_data;\ - l_log_manager.log( _level, hermes::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, l_message, __VA_ARGS__ ); \ - } \ - } \ - while( false ) - - -//!\brief 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 sxprintf -#define SX_LOG_AND_WAIT( _level, ... ) \ - do \ - { \ - hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); \ - if( _level <= l_log_manager.get_log_level() ) \ - { \ - l_log_manager.log_and_wait( _level, hermes::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, __VA_ARGS__ ); \ - } \ - } \ - while( false ) - - -#else - - -#define SX_LOG hermes::log_helper( __FILE__, __LINE__).log -#define SX_LOG_AND_WAIT hermes::log_helper( __FILE__, __LINE__).log_and_wait - - -#endif - - -#endif - - -#ifndef SX_NO_LOGGING - - -#include "log_manager_template.hpp" -#include "std_timestamp_policy.hpp" - - -namespace hermes -{ - - -//!\brief An alias-declaration for the log manager template. -typedef hermes::log_manager_template< hermes::std_timestamp_policy > log_manager; - - -} - - -#ifdef SX_CPP03_BOOST -#include "log_helper.hpp" -#endif - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LOG_5AD3F1F5_0FC9_4D0E_8101_D9D70B8B1486 +#define LOG_5AD3F1F5_0FC9_4D0E_8101_D9D70B8B1486 + + +#ifdef SX_NO_LOGGING + + +inline void parameter_muncher() +{ + // Nothing to do... +} + + +template< typename T, typename ... args > +void parameter_muncher( T, args ... _args ) +{ + parameter_muncher( _args... ); +} + + +//!\brief Macro that is used when SX_NO_LOGGING is defined and thus there should be no logging. Consumes all parameters +//!so no warnings occur because of unused parameters. The code does nothing and can (will) be removed by the optimizer. +//!\sa sxprintf +#define SX_LOG( _dummy, ... ) \ + do \ + { \ + parameter_muncher( __VA_ARGS__ ); \ + } \ + while( false ) + + +//!\brief Macro that is used when SX_NO_LOGGING is defined and thus there should be no logging. Consumes all parameters +//!so no warnings occur because of unused parameters. The code does nothing and can (will) be removed by the optimizer. +//!\sa sxprintf +#define SX_LOG_HEX( _dummy, ... ) \ + do \ + { \ + parameter_muncher( __VA_ARGS__ ); \ + } \ + while( false ) + + +#else + + +#ifndef SX_CPP03_BOOST + +//!\brief Create a log message. +//!\param _level The log level of the message. +//!\param ... Parameters that are inserted into the message. +//!\sa sxprintf +#define SX_LOG( _level, ... ) \ + do \ + { \ + hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); \ + if( _level <= l_log_manager.get_log_level() ) \ + { \ + l_log_manager.log( _level, hermes::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, __VA_ARGS__ ); \ + } \ + } \ + while( false ) + + +//!\brief Create a hex log message. +//!\param _level The log level of the message. +//!\param _heading The heading of the message. +//!\param _data The message of the log. +//!\param ... Parameters that are inserted into the message. +//!\sa sxprintf +#define SX_LOG_HEX( _level, _heading, _data, ... ) \ + do \ + { \ + hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); \ + if( _level <= l_log_manager.get_log_level() ) \ + { \ + const std::string l_heading(_heading);\ + const std::string l_data(_data);\ + const std::string l_message = l_heading + "\n" + l_data;\ + l_log_manager.log( _level, hermes::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, l_message, __VA_ARGS__ ); \ + } \ + } \ + while( false ) + + +//!\brief 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 sxprintf +#define SX_LOG_AND_WAIT( _level, ... ) \ + do \ + { \ + hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); \ + if( _level <= l_log_manager.get_log_level() ) \ + { \ + l_log_manager.log_and_wait( _level, hermes::log_manager::get_instance().get_timestamp(), __FILE__, __LINE__, __VA_ARGS__ ); \ + } \ + } \ + while( false ) + + +#else + + +#define SX_LOG hermes::log_helper( __FILE__, __LINE__).log +#define SX_LOG_AND_WAIT hermes::log_helper( __FILE__, __LINE__).log_and_wait + + +#endif + + +#endif + + +#ifndef SX_NO_LOGGING + + +#include "log_manager_template.hpp" +#include "std_timestamp_policy.hpp" + + +namespace hermes +{ + + +//!\brief An alias-declaration for the log manager template. +typedef hermes::log_manager_template< hermes::std_timestamp_policy > log_manager; + + +} + + +#ifdef SX_CPP03_BOOST +#include "log_helper.hpp" +#endif + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/log_and_throw.hpp b/externals/hermes/include/hermes/log_and_throw.hpp index 0c9f74a..049507b 100644 --- a/externals/hermes/include/hermes/log_and_throw.hpp +++ b/externals/hermes/include/hermes/log_and_throw.hpp @@ -1,124 +1,124 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef LOG_AND_THROW_A0ED92EB_7368_43EA_BB73_822E62AB4E66 -#define LOG_AND_THROW_A0ED92EB_7368_43EA_BB73_822E62AB4E66 - - -#include "log.hpp" -#include "essentials/exception.hpp" - - -#ifdef SX_CPP03_BOOST - #ifdef SX_NO_VARIADIC_MACRO - #include "log_and_throw_helper.hpp" - #else - #include "essentials/macro_helpers.hpp" - #endif -#endif - - -namespace hermes -{ - - -#ifndef SX_CPP03_BOOST - - -//!\def LOG_AND_THROW( _log_level, ... ) -//!\brief Log a message and then throw an exception with the same message. -#define LOG_AND_THROW( _log_level, ... ) \ - SX_LOG( _log_level, __VA_ARGS__ ); \ - throw sxe::exception( __VA_ARGS__ ); - - -#else - - -#ifndef SX_NO_VARIADIC_MACRO - -#define HERMES_VA_SELECT( NAME, _level, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )( _level, __VA_ARGS__) ) - -//!\def LOG_AND_THROW( _level, ... ) -//!\brief Log a message and then throw an exception with the same message. -#define LOG_AND_THROW( _level, ... ) HEMRES_EXPAND( HERMES_VA_SELECT( LOG_AND_THROW_PARAM, _level, __VA_ARGS__ ) ) - - -#define LOG_AND_THROW_PARAM_1( _log_level, _what ) \ - SX_LOG( _log_level, _what ); \ - throw sxe::exception( _what ); - - -#define LOG_AND_THROW_PARAM_2( _log_level, _what, _value ) \ - SX_LOG( _log_level, _what, _value ); \ - throw sxe::exception( _what, _value ); - - -#define LOG_AND_THROW_PARAM_3( _log_level, _what, _value1, _value2 ) \ - SX_LOG( _log_level, _what, _value1, _value2 ); \ - throw sxe::exception( _what, _value1, _value2 ); - - -#define LOG_AND_THROW_PARAM_4( _log_level, _what, _value1, _value2, _value3 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3 ); \ - throw sxe::exception( _what, _value1, _value2, _value3 ); - - -#define LOG_AND_THROW_PARAM_5( _log_level, _what, _value1, _value2, _value3, _value4 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4 ); \ - throw sxe::exception( _what, _value1, _value2, _value3, _value4 ); - - -#define LOG_AND_THROW_PARAM_6( _log_level, _what, _value1, _value2, _value3, _value4, _value5 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5 ); \ - throw sxe::exception( _what, _value1, _value2, _value3, _value4, _value5 ); - - -#define LOG_AND_THROW_PARAM_7( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6 ); \ - throw sxe::exception( _what, _value1, _value2, _value3, _value4, _value5, _value6 ); - - -#define LOG_AND_THROW_PARAM_8( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); \ - throw sxe::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 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); \ - throw sxe::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 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); \ - throw sxe::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 ) \ - SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); \ - throw sxe::exception( _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); - - -#else - - -#define LOG_AND_THROW hermes::log_and_throw_helper( __FILE__, __LINE__ ).log - - -#endif - - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LOG_AND_THROW_A0ED92EB_7368_43EA_BB73_822E62AB4E66 +#define LOG_AND_THROW_A0ED92EB_7368_43EA_BB73_822E62AB4E66 + + +#include "log.hpp" +#include "essentials/exception.hpp" + + +#ifdef SX_CPP03_BOOST + #ifdef SX_NO_VARIADIC_MACRO + #include "log_and_throw_helper.hpp" + #else + #include "essentials/macro_helpers.hpp" + #endif +#endif + + +namespace hermes +{ + + +#ifndef SX_CPP03_BOOST + + +//!\def LOG_AND_THROW( _log_level, ... ) +//!\brief Log a message and then throw an exception with the same message. +#define LOG_AND_THROW( _log_level, ... ) \ + SX_LOG( _log_level, __VA_ARGS__ ); \ + throw sxe::exception( __VA_ARGS__ ); + + +#else + + +#ifndef SX_NO_VARIADIC_MACRO + +#define HERMES_VA_SELECT( NAME, _level, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )( _level, __VA_ARGS__) ) + +//!\def LOG_AND_THROW( _level, ... ) +//!\brief Log a message and then throw an exception with the same message. +#define LOG_AND_THROW( _level, ... ) HEMRES_EXPAND( HERMES_VA_SELECT( LOG_AND_THROW_PARAM, _level, __VA_ARGS__ ) ) + + +#define LOG_AND_THROW_PARAM_1( _log_level, _what ) \ + SX_LOG( _log_level, _what ); \ + throw sxe::exception( _what ); + + +#define LOG_AND_THROW_PARAM_2( _log_level, _what, _value ) \ + SX_LOG( _log_level, _what, _value ); \ + throw sxe::exception( _what, _value ); + + +#define LOG_AND_THROW_PARAM_3( _log_level, _what, _value1, _value2 ) \ + SX_LOG( _log_level, _what, _value1, _value2 ); \ + throw sxe::exception( _what, _value1, _value2 ); + + +#define LOG_AND_THROW_PARAM_4( _log_level, _what, _value1, _value2, _value3 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3 ); \ + throw sxe::exception( _what, _value1, _value2, _value3 ); + + +#define LOG_AND_THROW_PARAM_5( _log_level, _what, _value1, _value2, _value3, _value4 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4 ); \ + throw sxe::exception( _what, _value1, _value2, _value3, _value4 ); + + +#define LOG_AND_THROW_PARAM_6( _log_level, _what, _value1, _value2, _value3, _value4, _value5 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5 ); \ + throw sxe::exception( _what, _value1, _value2, _value3, _value4, _value5 ); + + +#define LOG_AND_THROW_PARAM_7( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6 ); \ + throw sxe::exception( _what, _value1, _value2, _value3, _value4, _value5, _value6 ); + + +#define LOG_AND_THROW_PARAM_8( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); \ + throw sxe::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 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); \ + throw sxe::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 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); \ + throw sxe::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 ) \ + SX_LOG( _log_level, _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); \ + throw sxe::exception( _what, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); + + +#else + + +#define LOG_AND_THROW hermes::log_and_throw_helper( __FILE__, __LINE__ ).log + + +#endif + + +#endif + + +} + + +#endif diff --git a/externals/hermes/include/hermes/log_and_throw_helper.hpp b/externals/hermes/include/hermes/log_and_throw_helper.hpp index 9cd04b3..898ab1e 100644 --- a/externals/hermes/include/hermes/log_and_throw_helper.hpp +++ b/externals/hermes/include/hermes/log_and_throw_helper.hpp @@ -1,210 +1,210 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef LOG_AND_THROW_HELPER_048D9A04_8BD3_49F0_97EA_7DCB3D6E08FC -#define LOG_AND_THROW_HELPER_048D9A04_8BD3_49F0_97EA_7DCB3D6E08FC - - -#ifdef SX_CPP03_BOOST - - -#include - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/non_copyable.hpp" -#include "essentials/exception.hpp" -#include "log.hpp" - - -namespace hermes -{ - - - struct log_level; - - - class log_and_throw_helper SX_FINAL - { - public: - log_and_throw_helper( const std::string& _file_name, const int _line ); - ~log_and_throw_helper() SX_NOEXCEPT; - SX_NO_COPY( log_and_throw_helper ) - - void log( const log_level& _level, const std::string& _message ) const; - - template< typename _parameter_type1 > - void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1 ); - } - throw sxe::exception( _message, _value1 ); - } - - - template< typename _parameter_type1, typename _parameter_type2 > - void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, - _value2 ); - } - throw sxe::exception( _message, _value1, _value2 ); - } - - - template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3 > - void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, - _value2, _value3 ); - } - throw sxe::exception( _message, _value1, _value2, _value3 ); - } - - - template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, - typename _parameter_type4 > - void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, - _value2, _value3, _value4 ); - } - throw sxe::exception( _message, _value1, _value2, _value3, _value4 ); - } - - - template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, - typename _parameter_type4, typename _parameter_type5 > - void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1, _value2, _value3, _value4, _value5 ); - } - throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1, _value2, _value3, _value4, _value5, _value6 ); - } - throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); - } - throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, - _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); - } - throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); - } - throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); - } - throw sxe::exception( _message, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, - _value10 ); - } - - private: - const std::string& file_name_; - const int line_; - - - }; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LOG_AND_THROW_HELPER_048D9A04_8BD3_49F0_97EA_7DCB3D6E08FC +#define LOG_AND_THROW_HELPER_048D9A04_8BD3_49F0_97EA_7DCB3D6E08FC + + +#ifdef SX_CPP03_BOOST + + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/non_copyable.hpp" +#include "essentials/exception.hpp" +#include "log.hpp" + + +namespace hermes +{ + + + struct log_level; + + + class log_and_throw_helper SX_FINAL + { + public: + log_and_throw_helper( const std::string& _file_name, const int _line ); + ~log_and_throw_helper() SX_NOEXCEPT; + SX_NO_COPY( log_and_throw_helper ) + + void log( const log_level& _level, const std::string& _message ) const; + + template< typename _parameter_type1 > + void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1 ); + } + throw sxe::exception( _message, _value1 ); + } + + + template< typename _parameter_type1, typename _parameter_type2 > + void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, + _value2 ); + } + throw sxe::exception( _message, _value1, _value2 ); + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3 > + void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, + _value2, _value3 ); + } + throw sxe::exception( _message, _value1, _value2, _value3 ); + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, + typename _parameter_type4 > + void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, + _value2, _value3, _value4 ); + } + throw sxe::exception( _message, _value1, _value2, _value3, _value4 ); + } + + + template< typename _parameter_type1, typename _parameter_type2, typename _parameter_type3, + typename _parameter_type4, typename _parameter_type5 > + void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5 ); + } + throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6 ); + } + throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7 ); + } + throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, _value1, + _value2, _value3, _value4, _value5, _value6, _value7, _value8 ); + } + throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9 ); + } + throw sxe::exception( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); + } + throw sxe::exception( _message, _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, + _value10 ); + } + + private: + const std::string& file_name_; + const int line_; + + + }; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/log_callback.hpp b/externals/hermes/include/hermes/log_callback.hpp index 13012b4..4fd9f04 100644 --- a/externals/hermes/include/hermes/log_callback.hpp +++ b/externals/hermes/include/hermes/log_callback.hpp @@ -1,57 +1,57 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 -#define LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 - - -#include "essentials/compatibility/compatibility.hpp" - -namespace hermes -{ - - -//!\interface log_callback -//!\brief Interface that adds wait functionality to the class that implements it. -class log_callback -{ -public: - log_callback() - { - // Nothing to do... - } - - - virtual ~log_callback() SX_NOEXCEPT - { - // Nothing to do... - } - - - //!\brief Wait for a condition. - virtual void wait() = 0; - - //!\brief The thing we are waiting for is done. - virtual void done() = 0; - - //!\brief Checks the theing we are waiting for is done. - virtual bool is_done() = 0; -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 +#define LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 + + +#include "essentials/compatibility/compatibility.hpp" + +namespace hermes +{ + + +//!\interface log_callback +//!\brief Interface that adds wait functionality to the class that implements it. +class log_callback +{ +public: + log_callback() + { + // Nothing to do... + } + + + virtual ~log_callback() SX_NOEXCEPT + { + // Nothing to do... + } + + + //!\brief Wait for a condition. + virtual void wait() = 0; + + //!\brief The thing we are waiting for is done. + virtual void done() = 0; + + //!\brief Checks the theing we are waiting for is done. + virtual bool is_done() = 0; +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/log_helper.hpp b/externals/hermes/include/hermes/log_helper.hpp index efc8ef7..92623d1 100644 --- a/externals/hermes/include/hermes/log_helper.hpp +++ b/externals/hermes/include/hermes/log_helper.hpp @@ -1,342 +1,342 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef LOG_HELPER_F1630103_70EA_469C_B378_32955DA9A018 -#define LOG_HELPER_F1630103_70EA_469C_B378_32955DA9A018 - - -#ifdef SX_CPP03_BOOST - - -#include - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/non_copyable.hpp" -#include "log.hpp" - - -namespace hermes -{ - - -struct log_level; - - -class log_helper SX_FINAL -{ -public: - log_helper( const std::string& _file_name, const int _line ); - ~log_helper() SX_NOEXCEPT; - SX_NO_COPY( log_helper ) - - void log( const log_level& _level, const std::string& _message ) const; - - - template< typename _parameter_type1 > - void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1 ); - } - } - - - template< typename _parameter_type1, typename _parameter_type2 > - void log( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, - _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); - } - } - - - 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_; - - -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LOG_HELPER_F1630103_70EA_469C_B378_32955DA9A018 +#define LOG_HELPER_F1630103_70EA_469C_B378_32955DA9A018 + + +#ifdef SX_CPP03_BOOST + + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/non_copyable.hpp" +#include "log.hpp" + + +namespace hermes +{ + + +struct log_level; + + +class log_helper SX_FINAL +{ +public: + log_helper( const std::string& _file_name, const int _line ); + ~log_helper() SX_NOEXCEPT; + SX_NO_COPY( log_helper ) + + void log( const log_level& _level, const std::string& _message ) const; + + + template< typename _parameter_type1 > + void log( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1 ); + } + } + + + template< typename _parameter_type1, typename _parameter_type2 > + void log( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _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( 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( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message, + _value1, _value2, _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ); + } + } + + + 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_; + + +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/log_level.hpp b/externals/hermes/include/hermes/log_level.hpp index 983b0e1..c6da58b 100644 --- a/externals/hermes/include/hermes/log_level.hpp +++ b/externals/hermes/include/hermes/log_level.hpp @@ -1,117 +1,117 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SX_NO_LOGGING - - -#ifndef LOG_LEVEL_5059A1FA_DC2D_4C94_AA8B_49B750B30F07 -#define LOG_LEVEL_5059A1FA_DC2D_4C94_AA8B_49B750B30F07 - - -#include - - -namespace hermes -{ - - -#ifndef SX_CPP03_BOOST - - -//!\enum log_level -//!\brief The 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 -}; - - -#else - - -//!\struct log_level -//!\brief Structure representing a log level (enum wrapper for C++11 enum class like behavior). -struct log_level -{ - //!\enum log_level - //!\brief The log levels. - 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 - }; - - - //!\brief Constructor - //!\param _value Given log level value that is represented by the structure. - log_level( inner _value ) : value_( _value ) - { - // Nothing to do... - } - - - //!\brief Constructor. Default value is LL_OFF. - log_level() : value_( LL_OFF ) - { - // Nothing to do... - } - - - //!\brief Constructor - //!\param _color Given log level structure containing the log level value that is represented by the structure. - log_level(const log_level& _log_level) : value_(_log_level.value_) - { - // Nothing to do... - } - - - //!\brief Function returning the log level value represented by the structure. - operator inner() const - { - return ( value_ ); - } - - - //!\brief Log level value represented by the structure. - inner value_; - -}; - - -#endif - - - -//!\brief Convert the given log level to a string. -//!\param _log_level The log level. -//!\return The log level as string. -std::string log_level_to_string( const log_level _log_level ); - - - -#ifdef SX_CPP03_BOOST - - -bool operator==( const hermes::log_level& _lhs, const hermes::log_level::inner _rhs ); -bool operator==( const hermes::log_level::inner _lhs, const hermes::log_level& _rhs ); -bool operator<(const hermes::log_level _lhs, const hermes::log_level _rhs); -bool operator<=( const hermes::log_level _lhs, const hermes::log_level _rhs ); - - - -#endif - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SX_NO_LOGGING + + +#ifndef LOG_LEVEL_5059A1FA_DC2D_4C94_AA8B_49B750B30F07 +#define LOG_LEVEL_5059A1FA_DC2D_4C94_AA8B_49B750B30F07 + + +#include + + +namespace hermes +{ + + +#ifndef SX_CPP03_BOOST + + +//!\enum log_level +//!\brief The 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 +}; + + +#else + + +//!\struct log_level +//!\brief Structure representing a log level (enum wrapper for C++11 enum class like behavior). +struct log_level +{ + //!\enum log_level + //!\brief The log levels. + 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 + }; + + + //!\brief Constructor + //!\param _value Given log level value that is represented by the structure. + log_level( inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + //!\brief Constructor. Default value is LL_OFF. + log_level() : value_( LL_OFF ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _color Given log level structure containing the log level value that is represented by the structure. + log_level(const log_level& _log_level) : value_(_log_level.value_) + { + // Nothing to do... + } + + + //!\brief Function returning the log level value represented by the structure. + operator inner() const + { + return ( value_ ); + } + + + //!\brief Log level value represented by the structure. + inner value_; + +}; + + +#endif + + + +//!\brief Convert the given log level to a string. +//!\param _log_level The log level. +//!\return The log level as string. +std::string log_level_to_string( const log_level _log_level ); + + + +#ifdef SX_CPP03_BOOST + + +bool operator==( const hermes::log_level& _lhs, const hermes::log_level::inner _rhs ); +bool operator==( const hermes::log_level::inner _lhs, const hermes::log_level& _rhs ); +bool operator<(const hermes::log_level _lhs, const hermes::log_level _rhs); +bool operator<=( const hermes::log_level _lhs, const hermes::log_level _rhs ); + + + +#endif + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/log_manager_template.hpp b/externals/hermes/include/hermes/log_manager_template.hpp index 1fd2bd0..65dd14c 100644 --- a/externals/hermes/include/hermes/log_manager_template.hpp +++ b/externals/hermes/include/hermes/log_manager_template.hpp @@ -1,591 +1,591 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B -#define LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B - - -#include - -#include "essentials/base.hpp" -#include "logger.hpp" -#include "log_message.hpp" -#include "essentials/sxprintf.hpp" -#include "waiter.hpp" - - -namespace hermes -{ - - -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 SX_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 ); - } - - - SX_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 SX_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, SX_LOG(), sxprintf - 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( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _args ... ) ); - sxe::lock_guard< sxe::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, SX_LOG(), sxprintf - 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, sxe::sxprintf( _message.c_str(), _args ... ) ); - sxe::lock_guard< sxe::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( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str() ) ); - sxe::lock_guard< sxe::mutex > lock(mutex_); - messages_.push(message); - } - condition_.notify_one(); - } - - - void log(const hermes::log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, - const std::string& _message, const sxe::value_type& _value) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, - _value2) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3)); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4)); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5 ) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5)); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6)); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8, const sxe::value_type& _value9) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10) - { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10) ); - sxe::lock_guard< sxe::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, sxe::sxprintf( _message.c_str() ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4, _value5 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8, const sxe::value_type& _value9 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ); - sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, - const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10 ) - { - waiter waiter; - { - log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ); - sxe::lock_guard< sxe::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 ) - { - SX_ASSERT( stop_, "Logger cannot be added while running!" ); - sxe::lock_guard< sxe::mutex > lock( mutex_ ); - loggers_.push_back( sxe::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_ = sxe::thread( sxe::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() - { - { - sxe::lock_guard< sxe::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 ) - { - SX_ASSERT( !LOG_MANAGER_EXISTS, "Log manager already exists!" ); - LOG_MANAGER_EXISTS = true; - } - - - ~log_manager_template() - { - SX_ASSERT( 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; - { - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - condition_.wait( lock, sxe::bind( &log_manager_template::should_be_running, this ) ); - - if( finished() ) - { - break; - } - - message = messages_.front(); - messages_.pop(); - } - - SX_FOR(const logger_uptr& logger, loggers_) - { - logger->log( message ); - message.done(); - } - } - } - - - sxe::thread thread_; - sxe::mutex mutex_; - sxe::condition_variable condition_; - bool stop_; - loggers loggers_; - std::queue< log_message > messages_; - log_level log_level_; -}; - - -} - - -#endif - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B +#define LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B + + +#include + +#include "essentials/base.hpp" +#include "logger.hpp" +#include "log_message.hpp" +#include "essentials/sxprintf.hpp" +#include "waiter.hpp" + + +namespace hermes +{ + + +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 SX_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 ); + } + + + SX_NO_COPY(log_manager_template) + + //!\brief Get the currently set log level. + //!\return Current log level. + log_level get_log_level() const + { + return( log_level_ ); + } + + + //!\brief Set 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 SX_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, SX_LOG(), sxprintf + 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( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _args ... ) ); + sxe::lock_guard< sxe::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, SX_LOG(), sxprintf + 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, sxe::sxprintf( _message.c_str(), _args ... ) ); + sxe::lock_guard< sxe::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( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str() ) ); + sxe::lock_guard< sxe::mutex > lock(mutex_); + messages_.push(message); + } + condition_.notify_one(); + } + + + void log(const hermes::log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + const std::string& _message, const sxe::value_type& _value) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, + _value2) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3)); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4)); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5 ) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5)); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6)); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, + const sxe::value_type& _value8) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, + const sxe::value_type& _value8, const sxe::value_type& _value9) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, + const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10) + { + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10) ); + sxe::lock_guard< sxe::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, sxe::sxprintf( _message.c_str() ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, + const sxe::value_type& _value8 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, + const sxe::value_type& _value8, const sxe::value_type& _value9 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ); + sxe::lock_guard< sxe::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 sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, + const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, + const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10 ) + { + waiter waiter; + { + log_message message( &waiter, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ); + sxe::lock_guard< sxe::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 ) + { + SX_ASSERT( stop_, "Logger cannot be added while running!" ); + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + loggers_.push_back( sxe::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_ = sxe::thread( sxe::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() + { + { + sxe::lock_guard< sxe::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 Get 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 ) + { + SX_ASSERT( !LOG_MANAGER_EXISTS, "Log manager already exists!" ); + LOG_MANAGER_EXISTS = true; + } + + + ~log_manager_template() + { + SX_ASSERT( 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; + { + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + condition_.wait( lock, sxe::bind( &log_manager_template::should_be_running, this ) ); + + if( finished() ) + { + break; + } + + message = messages_.front(); + messages_.pop(); + } + + SX_FOR(const logger_uptr& logger, loggers_) + { + logger->log( message ); + message.done(); + } + } + } + + + sxe::thread thread_; + sxe::mutex mutex_; + sxe::condition_variable condition_; + bool stop_; + loggers loggers_; + std::queue< log_message > messages_; + log_level log_level_; +}; + + +} + + +#endif + +#endif diff --git a/externals/hermes/include/hermes/log_message.hpp b/externals/hermes/include/hermes/log_message.hpp index 0952d07..34159c2 100644 --- a/externals/hermes/include/hermes/log_message.hpp +++ b/externals/hermes/include/hermes/log_message.hpp @@ -1,63 +1,63 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 -#define LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 - - -#include "log_level.hpp" -#include "essentials/compatibility/compatibility.hpp" - - -namespace hermes -{ - - -class log_callback; - - -//!\struct log_message -//!\brief Structure of the message to be logged, containing all necessary elements: log callback (if it is used), -//!\log level, time stamp of the log, file and line where the log is generated and the message of the log. -struct log_message SX_FINAL -{ - //!\brief Constructor - log_message(); - - //!\brief Constructor - //!\param _log_callback Pointer to log callback. - //!\param _log_level Log level for this log message. - //!\param _time_stamp Time stamp of the log message. - //!\param _file File where the log message was generated. - //!\param _line Line of the file where the log message is generated. - //!\param _message The message of the log. - 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 ); - - //!\brief Function that notifies the log callback that we are done. - void done(); - - log_level log_level_; - std::string time_stamp_; - std::string file_; - int line_; - std::string message_; - log_callback* log_callback_; -}; - - -} - - -#endif - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 +#define LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 + + +#include "log_level.hpp" +#include "essentials/compatibility/compatibility.hpp" + + +namespace hermes +{ + + +class log_callback; + + +//!\struct log_message +//!\brief Structure of the message to be logged, containing all necessary elements: log callback (if it is used), +//!\log level, time stamp of the log, file and line where the log is generated and the message of the log. +struct log_message SX_FINAL +{ + //!\brief Constructor + log_message(); + + //!\brief Constructor + //!\param _log_callback Pointer to log callback. + //!\param _log_level Log level for this log message. + //!\param _time_stamp Time stamp of the log message. + //!\param _file File where the log message was generated. + //!\param _line Line of the file where the log message is generated. + //!\param _message The message of the log. + 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 ); + + //!\brief Function that notifies the log callback that we are done. + void done(); + + log_level log_level_; + std::string time_stamp_; + std::string file_; + int line_; + std::string message_; + log_callback* log_callback_; +}; + + +} + + +#endif + +#endif diff --git a/externals/hermes/include/hermes/logger.hpp b/externals/hermes/include/hermes/logger.hpp index c43f63a..b8e2267 100644 --- a/externals/hermes/include/hermes/logger.hpp +++ b/externals/hermes/include/hermes/logger.hpp @@ -1,61 +1,61 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef LOGGER_4207DA98_D8C1_41B4_B5B1_29E8C5A22DF3 -#define LOGGER_4207DA98_D8C1_41B4_B5B1_29E8C5A22DF3 - - -#include "logger_fwd.hpp" -#include "essentials/non_copyable.hpp" - - -namespace hermes -{ - - -struct log_message; - - -//!\interface logger -//!\brief Interface of the general logger. The specialized loggers derive from this interface. -class logger -{ -public: - //!\brief logger constructor. - logger() - { - // Nothing to do... - } - - - virtual ~logger() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(logger) - - //!\brief Log the message to the target medium. - //!\param _log_message Message to be logged. - //!\return void - virtual void log( const log_message& _log_message ) = 0; -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef LOGGER_4207DA98_D8C1_41B4_B5B1_29E8C5A22DF3 +#define LOGGER_4207DA98_D8C1_41B4_B5B1_29E8C5A22DF3 + + +#include "logger_fwd.hpp" +#include "essentials/non_copyable.hpp" + + +namespace hermes +{ + + +struct log_message; + + +//!\interface logger +//!\brief Interface of the general logger. The specialized loggers derive from this interface. +class logger +{ +public: + //!\brief logger constructor. + logger() + { + // Nothing to do... + } + + + virtual ~logger() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(logger) + + //!\brief Log the message to the target medium. + //!\param _log_message Message to be logged. + //!\return void + virtual void log( const log_message& _log_message ) = 0; +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/logger_fwd.hpp b/externals/hermes/include/hermes/logger_fwd.hpp index 237dc1a..3d86d91 100644 --- a/externals/hermes/include/hermes/logger_fwd.hpp +++ b/externals/hermes/include/hermes/logger_fwd.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef LOGGER_FWD_9F0DC46E_91EC_44AB_ADE0_7F223D30DE83 -#define LOGGER_FWD_9F0DC46E_91EC_44AB_ADE0_7F223D30DE83 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace hermes -{ - - -class logger; - -//!\typedef Alias for logger smart pointer. -typedef sxe::SX_UNIQUE_PTR< logger > logger_uptr; - -//!\typedef Alias for vector of logger smart pointers. -typedef std::vector< logger_uptr > loggers; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef LOGGER_FWD_9F0DC46E_91EC_44AB_ADE0_7F223D30DE83 +#define LOGGER_FWD_9F0DC46E_91EC_44AB_ADE0_7F223D30DE83 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace hermes +{ + + +class logger; + +//!\typedef Alias for logger smart pointer. +typedef sxe::SX_UNIQUE_PTR< logger > logger_uptr; + +//!\typedef Alias for vector of logger smart pointers. +typedef std::vector< logger_uptr > loggers; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/std_timestamp_policy.hpp b/externals/hermes/include/hermes/std_timestamp_policy.hpp index 6ac8697..9ebc2e4 100644 --- a/externals/hermes/include/hermes/std_timestamp_policy.hpp +++ b/externals/hermes/include/hermes/std_timestamp_policy.hpp @@ -1,44 +1,44 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#ifndef STD_TIMESTAMP_POLICY_A0D64C16_D7D3_4E06_B647_F949D14BBBAB -#define STD_TIMESTAMP_POLICY_A0D64C16_D7D3_4E06_B647_F949D14BBBAB - - -#include - -#include "essentials/non_copyable.hpp" - - -namespace hermes -{ - -//!\class std_timestamp_policy -//!\brief Provides time stamps for the logger. -class std_timestamp_policy SX_FINAL -{ -public: - SX_NO_COPY(std_timestamp_policy) - - //!\ Provides time stamp as string. - //!\return Time stamp as string. - static std::string get_timestamp(); -}; - - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#ifndef STD_TIMESTAMP_POLICY_A0D64C16_D7D3_4E06_B647_F949D14BBBAB +#define STD_TIMESTAMP_POLICY_A0D64C16_D7D3_4E06_B647_F949D14BBBAB + + +#include + +#include "essentials/non_copyable.hpp" + + +namespace hermes +{ + +//!\class std_timestamp_policy +//!\brief Provides time stamps for the logger. +class std_timestamp_policy SX_FINAL +{ +public: + SX_NO_COPY(std_timestamp_policy) + + //!\ Provides time stamp as string. + //!\return Time stamp as string. + static std::string get_timestamp(); +}; + + +} + + +#endif + + +#endif diff --git a/externals/hermes/include/hermes/waiter.hpp b/externals/hermes/include/hermes/waiter.hpp index c0575a9..04992ab 100644 --- a/externals/hermes/include/hermes/waiter.hpp +++ b/externals/hermes/include/hermes/waiter.hpp @@ -1,58 +1,58 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SX_NO_LOGGING - - -#ifndef WAITER_5E57D733_02DD_413D_A906_5047979A5DFD -#define WAITER_5E57D733_02DD_413D_A906_5047979A5DFD - - -#include "log_callback.hpp" -#include "essentials/compatibility/thread.hpp" - - -namespace hermes -{ - - //!\class waiter - //!\brief Class that implements the log callback and gives the logger the ability to wait for a message to be printed. This useful when - //!when we have to be sure writing a log message has definitely finished (e.g. before triggering an assert). - class waiter : public log_callback - { - public: - //!\brief Constructor - waiter(); - virtual ~waiter() SX_NOEXCEPT SX_OVERRIDE; - - //!\brief Wait for the process to finish. - virtual void wait() SX_OVERRIDE; - - //!\brief The thing we are waiting for is done. - virtual void done() SX_OVERRIDE; - - //!\brief Check if the thing we are waiting for is done. - //!\return True if it's done, false otherwise. - virtual bool is_done() SX_OVERRIDE; - - - private: - sxe::mutex done_mutex_; - sxe::condition_variable done_condition_variable_; - bool done_; - }; - -} - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SX_NO_LOGGING + + +#ifndef WAITER_5E57D733_02DD_413D_A906_5047979A5DFD +#define WAITER_5E57D733_02DD_413D_A906_5047979A5DFD + + +#include "log_callback.hpp" +#include "essentials/compatibility/thread.hpp" + + +namespace hermes +{ + + //!\class waiter + //!\brief Class that implements the log callback and gives the logger the ability to wait for a message to be printed. This useful when + //!when we have to be sure writing a log message has definitely finished (e.g. before triggering an assert). + class waiter : public log_callback + { + public: + //!\brief Constructor + waiter(); + virtual ~waiter() SX_NOEXCEPT SX_OVERRIDE; + + //!\brief Wait for the process to finish. + virtual void wait() SX_OVERRIDE; + + //!\brief The thing we are waiting for is done. + virtual void done() SX_OVERRIDE; + + //!\brief Check if the thing we are waiting for is done. + //!\return True if it's done, false otherwise. + virtual bool is_done() SX_OVERRIDE; + + + private: + sxe::mutex done_mutex_; + sxe::condition_variable done_condition_variable_; + bool done_; + }; + +} + + +#endif + + +#endif diff --git a/externals/hermes/source/color_mapping.cpp b/externals/hermes/source/color_mapping.cpp index 59f9adc..9e7a468 100644 --- a/externals/hermes/source/color_mapping.cpp +++ b/externals/hermes/source/color_mapping.cpp @@ -1,78 +1,78 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/color_mapping.hpp" - -#include -#include - - -namespace hermes -{ - -#ifndef SX_CPP03_BOOST - - -color_mapping::color_mapping() - : color_map_( - { - { 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 } - } ) -{ - // Nothing to do... -} - - -#else - - - color_mapping::color_mapping() - { - color_map_[ log_level::LL_FATAL ] = color::C_RED; - color_map_[ log_level::LL_ERROR ] = color::C_DARK_RED; - color_map_[ log_level::LL_ASSERT ] = color::C_DARK_RED; - color_map_[ log_level::LL_WARN ] = color::C_YELLOW; - color_map_[ log_level::LL_INFO ] = color::C_DARK_YELLOW; - 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; - } - - -#endif - - -color_mapping::~color_mapping() SX_NOEXCEPT -{ - // Nothing to do... -} - - -color color_mapping::get_color( const hermes::log_level _log_level ) const -{ - color color_to_use( color::C_WHITE ); - color_map::const_iterator search = color_map_.find( _log_level ); - if (search != color_map_.end()) - { - color_to_use = search->second; - } - return( color_to_use ); -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/color_mapping.hpp" + +#include +#include + + +namespace hermes +{ + +#ifndef SX_CPP03_BOOST + + +color_mapping::color_mapping() + : color_map_( + { + { 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 } + } ) +{ + // Nothing to do... +} + + +#else + + + color_mapping::color_mapping() + { + color_map_[ log_level::LL_FATAL ] = color::C_RED; + color_map_[ log_level::LL_ERROR ] = color::C_DARK_RED; + color_map_[ log_level::LL_ASSERT ] = color::C_DARK_RED; + color_map_[ log_level::LL_WARN ] = color::C_YELLOW; + color_map_[ log_level::LL_INFO ] = color::C_DARK_YELLOW; + 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; + } + + +#endif + + +color_mapping::~color_mapping() SX_NOEXCEPT +{ + // Nothing to do... +} + + +color color_mapping::get_color( const hermes::log_level _log_level ) const +{ + color color_to_use( color::C_WHITE ); + color_map::const_iterator search = color_map_.find( _log_level ); + if (search != color_map_.end()) + { + color_to_use = search->second; + } + return( color_to_use ); +} + + +} + + +#endif diff --git a/externals/hermes/source/cout_logger.cpp b/externals/hermes/source/cout_logger.cpp index 9c4fb80..23c6c03 100644 --- a/externals/hermes/source/cout_logger.cpp +++ b/externals/hermes/source/cout_logger.cpp @@ -1,96 +1,96 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/cout_logger.hpp" - -#include -#include -#include - -#include "essentials/conversion.hpp" - -#include "hermes/log_message.hpp" - - -#ifdef WIN32 - - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#ifndef SX_NO_WINDOWS_H - #include -#endif - - -#endif - -#include "hermes/globals.hpp" - - -namespace hermes -{ - - -cout_logger::cout_logger() - : logger(), - color_mapping_() -{ - // Nothing to do... -} - - -void cout_logger::log( const log_message& _log_message ) -{ - std::stringstream log_stream; - log_level_as_message( _log_message.log_level_ ); - log_stream << " " << _log_message.time_stamp_; - log_stream << " [" << _log_message.file_; - log_stream << "@" << sxe::to_string( _log_message.line_ ); - log_stream << "]: " << _log_message.message_; - std::cout << log_stream.str() << std::endl; -} - - -void cout_logger::log_level_as_message( const hermes::log_level _log_level ) const -{ - const std::string& log_level = log_level_to_string( _log_level ); - -#ifdef WIN32 - - CONSOLE_SCREEN_BUFFER_INFO console_screen_buffer_info; - HANDLE handle = GetStdHandle( STD_OUTPUT_HANDLE ); - GetConsoleScreenBufferInfo( handle, &console_screen_buffer_info ); - const color color_of_log_level = color_mapping_.get_color( _log_level ); -#ifndef SX_CPP03_BOOST - SetConsoleTextAttribute( handle, static_cast< WORD >( color_of_log_level ) ); -#else - SetConsoleTextAttribute(handle, static_cast< WORD >( color_of_log_level.value_ )); -#endif - std::cout << " " << std::setw( LOG_LEVEL_BLOCK_WIDTH ) << std::setfill( ' ' ) << std::left << log_level; - SetConsoleTextAttribute( handle, console_screen_buffer_info.wAttributes ); - -#else - - std::cout << " " << std::setw( LOG_LEVEL_BLOCK_WIDTH ) << std::setfill( ' ' ) << std::left << log_level; - -#endif - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/cout_logger.hpp" + +#include +#include +#include + +#include "essentials/conversion.hpp" + +#include "hermes/log_message.hpp" + + +#ifdef WIN32 + + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#ifndef SX_NO_WINDOWS_H + #include +#endif + + +#endif + +#include "hermes/globals.hpp" + + +namespace hermes +{ + + +cout_logger::cout_logger() + : logger(), + color_mapping_() +{ + // Nothing to do... +} + + +void cout_logger::log( const log_message& _log_message ) +{ + std::stringstream log_stream; + log_level_as_message( _log_message.log_level_ ); + log_stream << " " << _log_message.time_stamp_; + log_stream << " [" << _log_message.file_; + log_stream << "@" << sxe::to_string( _log_message.line_ ); + log_stream << "]: " << _log_message.message_; + std::cout << log_stream.str() << std::endl; +} + + +void cout_logger::log_level_as_message( const hermes::log_level _log_level ) const +{ + const std::string& log_level = log_level_to_string( _log_level ); + +#ifdef WIN32 + + CONSOLE_SCREEN_BUFFER_INFO console_screen_buffer_info; + HANDLE handle = GetStdHandle( STD_OUTPUT_HANDLE ); + GetConsoleScreenBufferInfo( handle, &console_screen_buffer_info ); + const color color_of_log_level = color_mapping_.get_color( _log_level ); +#ifndef SX_CPP03_BOOST + SetConsoleTextAttribute( handle, static_cast< WORD >( color_of_log_level ) ); +#else + SetConsoleTextAttribute(handle, static_cast< WORD >( color_of_log_level.value_ )); +#endif + std::cout << " " << std::setw( LOG_LEVEL_BLOCK_WIDTH ) << std::setfill( ' ' ) << std::left << log_level; + SetConsoleTextAttribute( handle, console_screen_buffer_info.wAttributes ); + +#else + + std::cout << " " << std::setw( LOG_LEVEL_BLOCK_WIDTH ) << std::setfill( ' ' ) << std::left << log_level; + +#endif + + +} + + +} + + +#endif diff --git a/externals/hermes/source/file_logger.cpp b/externals/hermes/source/file_logger.cpp index ea66d69..205bac0 100644 --- a/externals/hermes/source/file_logger.cpp +++ b/externals/hermes/source/file_logger.cpp @@ -1,186 +1,186 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/file_logger.hpp" - -#include -#include -#include - -#include "essentials/conversion.hpp" - -#include "hermes/file_system.hpp" -#include "hermes/globals.hpp" -#include "hermes/log_message.hpp" - - -namespace hermes -{ - - -file_logger::file_logger( const size_t _max_file_size_in_bytes, const std::string& _log_files_directory, - const std::string& _name_suffix, const std::string& _name_extension, const unsigned _max_file_number, - const bool _throw_on_error ) : - max_file_size_in_bytes_( _max_file_size_in_bytes ), - log_files_directory_( add_trailing_slash_to_directory_path( _log_files_directory ) ), - name_sufix_( _name_suffix ), - name_extension_( _name_extension ), - max_file_number_( _max_file_number ), - throw_on_error_( _throw_on_error ), - working_file_() -{ - // Set member here to avoid future trouble with initialization order. - working_file_ = get_working_log_file_name(); - rotate_if_necessary(); -} - - -file_logger::~file_logger() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void file_logger::log( const log_message& _log_message ) -{ - const std::string log_level = log_level_to_string( _log_message.log_level_ ); - std::stringstream log_message_stream; - log_message_stream << std::setw( LOG_LEVEL_BLOCK_WIDTH ) << std::setfill( ' ' ) << std::left << log_level << - " " << _log_message.time_stamp_ << " [" << _log_message.file_ << "@" << _log_message.line_ << - "]: " << _log_message.message_; - log_into_file( log_message_stream.str() ); - rotate_if_necessary(); -} - - -void file_logger::log_into_file( const std::string& _message ) const -{ - const bool append = does_file_exist( working_file_ ); - std::ios_base::openmode open_mode_flag; - if( append ) - { - open_mode_flag = std::ios::app; - } - else - { - open_mode_flag = std::ios::trunc; - } - -#ifndef SX_CPP03_BOOST - std::ofstream file( working_file_, open_mode_flag ); -#else - std::ofstream file( working_file_.c_str(), open_mode_flag ); -#endif - if( !file ) - { - const std::string error_message = sxe::sxprintf( "Failed to open file '%'.", working_file_ ); - if( throw_on_error_ ) - { - throw exception( error_message ); - } - else - { - std::cerr << error_message; - } - } - - file << _message << std::endl; - file.close(); -} - - -std::string file_logger::get_log_file_name_with_index( const unsigned _index ) const -{ - std::stringstream file_name_stream; - file_name_stream << log_files_directory_ << name_sufix_ << sxe::to_string( _index ) << "." << name_extension_; - return( file_name_stream.str() ); -} - - -std::string file_logger::get_working_log_file_name() const -{ - return( log_files_directory_ + name_sufix_ + "." + name_extension_ ); -} - - -void file_logger::rotate_if_necessary() const -{ - const size_t file_size = get_file_size( working_file_ ); - if( file_size > max_file_size_in_bytes_ ) - { - rename_files(); - } -} - - -void file_logger::rename_files() const -{ - for( unsigned i = max_file_number_ - 1; i > 0; --i ) - { - const std::string old_name = get_log_file_name_with_index( i - 1 ); - const std::string new_name = get_log_file_name_with_index( i ); - rename_file_if_exists( old_name, new_name ); - } - - // rename from foo.log to foo0.log - rename_file_if_exists( working_file_, get_log_file_name_with_index( 0 ) ); -} - - -void file_logger::rename_file_if_exists( const std::string& _old_name, const std::string& _new_name ) const -{ - if( does_file_exist( _old_name ) ) - { - if( does_file_exist( _new_name ) ) - { - delete_file( _new_name ); - } - - const int renamed = std::rename( _old_name.c_str(), _new_name.c_str() ); - if( renamed ) - { - const std::string error_message = sxe::sxprintf( "File '%' could not be renamed!", _old_name ); - if( throw_on_error_ ) - { - throw exception( error_message ); - } - else - { - std::cerr << error_message; - } - } - } -} - - -void file_logger::delete_file( const std::string& _file_name ) const -{ - const int removed = std::remove( _file_name.c_str() ); - if( removed > 0 ) - { - const std::string error_message = sxe::sxprintf( "File '%' could not be deleted!\n", _file_name ); - if( throw_on_error_ ) - { - throw exception( error_message ); - } - else - { - std::cerr << error_message; - } - } -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/file_logger.hpp" + +#include +#include +#include + +#include "essentials/conversion.hpp" + +#include "hermes/file_system.hpp" +#include "hermes/globals.hpp" +#include "hermes/log_message.hpp" + + +namespace hermes +{ + + +file_logger::file_logger( const size_t _max_file_size_in_bytes, const std::string& _log_files_directory, + const std::string& _name_suffix, const std::string& _name_extension, const unsigned _max_file_number, + const bool _throw_on_error ) : + max_file_size_in_bytes_( _max_file_size_in_bytes ), + log_files_directory_( add_trailing_slash_to_directory_path( _log_files_directory ) ), + name_sufix_( _name_suffix ), + name_extension_( _name_extension ), + max_file_number_( _max_file_number ), + throw_on_error_( _throw_on_error ), + working_file_() +{ + // Set member here to avoid future trouble with initialization order. + working_file_ = get_working_log_file_name(); + rotate_if_necessary(); +} + + +file_logger::~file_logger() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void file_logger::log( const log_message& _log_message ) +{ + const std::string log_level = log_level_to_string( _log_message.log_level_ ); + std::stringstream log_message_stream; + log_message_stream << std::setw( LOG_LEVEL_BLOCK_WIDTH ) << std::setfill( ' ' ) << std::left << log_level << + " " << _log_message.time_stamp_ << " [" << _log_message.file_ << "@" << _log_message.line_ << + "]: " << _log_message.message_; + log_into_file( log_message_stream.str() ); + rotate_if_necessary(); +} + + +void file_logger::log_into_file( const std::string& _message ) const +{ + const bool append = does_file_exist( working_file_ ); + std::ios_base::openmode open_mode_flag; + if( append ) + { + open_mode_flag = std::ios::app; + } + else + { + open_mode_flag = std::ios::trunc; + } + +#ifndef SX_CPP03_BOOST + std::ofstream file( working_file_, open_mode_flag ); +#else + std::ofstream file( working_file_.c_str(), open_mode_flag ); +#endif + if( !file ) + { + const std::string error_message = sxe::sxprintf( "Failed to open file '%'.", working_file_ ); + if( throw_on_error_ ) + { + throw exception( error_message ); + } + else + { + std::cerr << error_message; + } + } + + file << _message << std::endl; + file.close(); +} + + +std::string file_logger::get_log_file_name_with_index( const unsigned _index ) const +{ + std::stringstream file_name_stream; + file_name_stream << log_files_directory_ << name_sufix_ << sxe::to_string( _index ) << "." << name_extension_; + return( file_name_stream.str() ); +} + + +std::string file_logger::get_working_log_file_name() const +{ + return( log_files_directory_ + name_sufix_ + "." + name_extension_ ); +} + + +void file_logger::rotate_if_necessary() const +{ + const size_t file_size = get_file_size( working_file_ ); + if( file_size > max_file_size_in_bytes_ ) + { + rename_files(); + } +} + + +void file_logger::rename_files() const +{ + for( unsigned i = max_file_number_ - 1; i > 0; --i ) + { + const std::string old_name = get_log_file_name_with_index( i - 1 ); + const std::string new_name = get_log_file_name_with_index( i ); + rename_file_if_exists( old_name, new_name ); + } + + // rename from foo.log to foo0.log + rename_file_if_exists( working_file_, get_log_file_name_with_index( 0 ) ); +} + + +void file_logger::rename_file_if_exists( const std::string& _old_name, const std::string& _new_name ) const +{ + if( does_file_exist( _old_name ) ) + { + if( does_file_exist( _new_name ) ) + { + delete_file( _new_name ); + } + + const int renamed = std::rename( _old_name.c_str(), _new_name.c_str() ); + if( renamed ) + { + const std::string error_message = sxe::sxprintf( "File '%' could not be renamed!", _old_name ); + if( throw_on_error_ ) + { + throw exception( error_message ); + } + else + { + std::cerr << error_message; + } + } + } +} + + +void file_logger::delete_file( const std::string& _file_name ) const +{ + const int removed = std::remove( _file_name.c_str() ); + if( removed > 0 ) + { + const std::string error_message = sxe::sxprintf( "File '%' could not be deleted!\n", _file_name ); + if( throw_on_error_ ) + { + throw exception( error_message ); + } + else + { + std::cerr << error_message; + } + } +} + + +} + + +#endif diff --git a/externals/hermes/source/file_system.cpp b/externals/hermes/source/file_system.cpp index d4017f3..2e0022e 100644 --- a/externals/hermes/source/file_system.cpp +++ b/externals/hermes/source/file_system.cpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "hermes/file_system.hpp" - - -namespace hermes -{ - - -size_t get_file_size( const std::string& _file_name ) -{ -#ifndef SX_CPP03_BOOST - std::ifstream in( _file_name, std::ios::binary | std::ios::ate ); -#else - std::ifstream in( _file_name.c_str(), std::ios::binary | std::ios::ate ); -#endif - return( static_cast< size_t >( in.tellg() ) ); -} - - -bool does_file_exist( const std::string& _file_name ) -{ - bool file_exists = false; -#ifndef SX_CPP03_BOOST - std::ifstream in( _file_name ); -#else - std::ifstream in( _file_name.c_str() ); -#endif - if( in ) - { - file_exists = true; - in.close(); - } - - return( file_exists ); -} - - -std::string add_trailing_slash_to_directory_path( const std::string& _path ) -{ - std::string log_file_directory_with_trailing_slash = _path; - if( !log_file_directory_with_trailing_slash.empty() && ( *log_file_directory_with_trailing_slash.rbegin() != '/' ) && - ( *log_file_directory_with_trailing_slash.rbegin() != '\\' ) ) - { - log_file_directory_with_trailing_slash += '/'; - } - - if( !log_file_directory_with_trailing_slash.empty() && ( *log_file_directory_with_trailing_slash.rbegin() != '\\' ) ) - { - *log_file_directory_with_trailing_slash.rbegin() = '/'; - } - - if( log_file_directory_with_trailing_slash.empty() ) - { - log_file_directory_with_trailing_slash = "./"; - } - - return( log_file_directory_with_trailing_slash ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "hermes/file_system.hpp" + + +namespace hermes +{ + + +size_t get_file_size( const std::string& _file_name ) +{ +#ifndef SX_CPP03_BOOST + std::ifstream in( _file_name, std::ios::binary | std::ios::ate ); +#else + std::ifstream in( _file_name.c_str(), std::ios::binary | std::ios::ate ); +#endif + return( static_cast< size_t >( in.tellg() ) ); +} + + +bool does_file_exist( const std::string& _file_name ) +{ + bool file_exists = false; +#ifndef SX_CPP03_BOOST + std::ifstream in( _file_name ); +#else + std::ifstream in( _file_name.c_str() ); +#endif + if( in ) + { + file_exists = true; + in.close(); + } + + return( file_exists ); +} + + +std::string add_trailing_slash_to_directory_path( const std::string& _path ) +{ + std::string log_file_directory_with_trailing_slash = _path; + if( !log_file_directory_with_trailing_slash.empty() && ( *log_file_directory_with_trailing_slash.rbegin() != '/' ) && + ( *log_file_directory_with_trailing_slash.rbegin() != '\\' ) ) + { + log_file_directory_with_trailing_slash += '/'; + } + + if( !log_file_directory_with_trailing_slash.empty() && ( *log_file_directory_with_trailing_slash.rbegin() != '\\' ) ) + { + *log_file_directory_with_trailing_slash.rbegin() = '/'; + } + + if( log_file_directory_with_trailing_slash.empty() ) + { + log_file_directory_with_trailing_slash = "./"; + } + + return( log_file_directory_with_trailing_slash ); +} + + +} diff --git a/externals/hermes/source/globals.cpp b/externals/hermes/source/globals.cpp index 34d0257..fe75321 100644 --- a/externals/hermes/source/globals.cpp +++ b/externals/hermes/source/globals.cpp @@ -1,22 +1,21 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "hermes/globals.hpp" - - -namespace hermes -{ - - -const int LOG_LEVEL_BLOCK_WIDTH = 7; -extern const char URI_DELIMITER = '/'; - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "hermes/globals.hpp" + + +namespace hermes +{ + + +const int LOG_LEVEL_BLOCK_WIDTH = 7; + + +} diff --git a/externals/hermes/source/hermes_version.cpp b/externals/hermes/source/hermes_version.cpp index 67d794d..d97db8b 100644 --- a/externals/hermes/source/hermes_version.cpp +++ b/externals/hermes/source/hermes_version.cpp @@ -1,76 +1,76 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/sxprintf.hpp" - -#include "hermes/hermes_version.hpp" -#include "hermes/build_number.hpp" - - -namespace hermes -{ - - -namespace version -{ - - -namespace -{ - - -const sxe::uint16_t VERSION_MAJOR( 1 ); -const sxe::uint16_t VERSION_MINOR( 0 ); -const sxe::uint16_t VERSION_PATCH( 1 ); - - -} - - -// cppcheck-suppress unusedFunction -void log_version() -{ - std::cout << sxe::sxprintf( "hermes library version %.%.%.%.", hermes::version::get_major_version(), - hermes::version::get_minor_version(), hermes::version::get_patch_version(), hermes::version::get_build_number() ) - << std::endl; -} - - -sxe::uint16_t get_major_version() -{ - return( VERSION_MAJOR ); -} - - -sxe::uint16_t get_minor_version() -{ - return( VERSION_MINOR ); -} - - -sxe::uint16_t get_patch_version() -{ - return( VERSION_PATCH ); -} - - -sxe::uint16_t get_build_number() -{ - return( hermes::version::BUILD_NUMBER ); -} - - -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/sxprintf.hpp" + +#include "hermes/hermes_version.hpp" +#include "hermes/build_number.hpp" + + +namespace hermes +{ + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 1 ); +const sxe::uint16_t VERSION_MINOR( 0 ); +const sxe::uint16_t VERSION_PATCH( 2 ); + + +} + + +// cppcheck-suppress unusedFunction +void log_version() +{ + std::cout << sxe::sxprintf( "hermes library version %.%.%.%.", hermes::version::get_major_version(), + hermes::version::get_minor_version(), hermes::version::get_patch_version(), hermes::version::get_build_number() ) + << std::endl; +} + + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( hermes::version::BUILD_NUMBER ); +} + + +} + + +} diff --git a/externals/hermes/source/log_and_throw_helper.cpp b/externals/hermes/source/log_and_throw_helper.cpp index c7ee22d..5ead8a2 100644 --- a/externals/hermes/source/log_and_throw_helper.cpp +++ b/externals/hermes/source/log_and_throw_helper.cpp @@ -1,50 +1,50 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifdef SX_CPP03_BOOST - - -#include "hermes/log_and_throw_helper.hpp" - -#include "essentials/sxprintf.hpp" - - -namespace hermes -{ - - - log_and_throw_helper::log_and_throw_helper( const std::string& _file_name, const int _line ) - : file_name_( _file_name ), - line_( _line ) - { - // Nothing to do... - } - - - log_and_throw_helper::~log_and_throw_helper() SX_NOEXCEPT - { - // Nothing to do... - } - - - void log_and_throw_helper::log( const log_level& _level, const std::string& _message ) const - { - hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); - if( _level <= l_log_manager.get_log_level() ) - { - l_log_manager.log( _level, hermes::log_manager::get_instance().get_timestamp(), file_name_, line_, _message ); - } - throw sxe::exception( _message ); - } - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifdef SX_CPP03_BOOST + + +#include "hermes/log_and_throw_helper.hpp" + +#include "essentials/sxprintf.hpp" + + +namespace hermes +{ + + + log_and_throw_helper::log_and_throw_helper( const std::string& _file_name, const int _line ) + : file_name_( _file_name ), + line_( _line ) + { + // Nothing to do... + } + + + log_and_throw_helper::~log_and_throw_helper() SX_NOEXCEPT + { + // Nothing to do... + } + + + void log_and_throw_helper::log( const log_level& _level, const std::string& _message ) const + { + hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log( _level, hermes::log_manager::get_instance().get_timestamp(), file_name_, line_, _message ); + } + throw sxe::exception( _message ); + } + +} + + +#endif diff --git a/externals/hermes/source/log_helper.cpp b/externals/hermes/source/log_helper.cpp index ee95df0..79c86e3 100644 --- a/externals/hermes/source/log_helper.cpp +++ b/externals/hermes/source/log_helper.cpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef SX_CPP03_BOOST - -#include "hermes/log_helper.hpp" - -#include "essentials/sxprintf.hpp" - - -namespace hermes -{ - - - log_helper::log_helper( const std::string& _file_name, const int _line ) - : file_name_(_file_name), - line_(_line) - { - // Nothing to do... - } - - - log_helper::~log_helper() SX_NOEXCEPT - { - // Nothing to do... - } - - - void log_helper::log( const log_level& _level, const std::string& _message ) const - { - hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); - if( _level <= l_log_manager.get_log_level() ) - { - l_log_manager.log( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message ); - } - } - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef SX_CPP03_BOOST + +#include "hermes/log_helper.hpp" + +#include "essentials/sxprintf.hpp" + + +namespace hermes +{ + + + log_helper::log_helper( const std::string& _file_name, const int _line ) + : file_name_(_file_name), + line_(_line) + { + // Nothing to do... + } + + + log_helper::~log_helper() SX_NOEXCEPT + { + // Nothing to do... + } + + + void log_helper::log( const log_level& _level, const std::string& _message ) const + { + hermes::log_manager_template& l_log_manager = hermes::log_manager::get_instance(); + if( _level <= l_log_manager.get_log_level() ) + { + l_log_manager.log( _level, log_manager::get_instance().get_timestamp(), file_name_, line_, _message ); + } + } + +} + + +#endif diff --git a/externals/hermes/source/log_level.cpp b/externals/hermes/source/log_level.cpp index 4e50ed9..854b7db 100644 --- a/externals/hermes/source/log_level.cpp +++ b/externals/hermes/source/log_level.cpp @@ -1,126 +1,126 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/log_level.hpp" - -#include "essentials/base.hpp" - - -namespace hermes -{ - - -std::string log_level_to_string( const log_level _log_level ) -{ - std::string log_level_string = "???"; - -#ifndef SX_CPP03_BOOST - switch( _log_level ) -#else - switch (_log_level.value_) -#endif - { - case ( log_level::LL_FATAL ): - { - log_level_string = "FATAL"; - } - break; - - case ( log_level::LL_ERROR ): - { - log_level_string = "ERROR"; - } - break; - - case ( log_level::LL_ASSERT ): - { - log_level_string = "ASSERT"; - } - break; - - case ( log_level::LL_WARN ): - { - log_level_string = "WARN"; - } - break; - - case ( log_level::LL_INFO ): - { - log_level_string = "INFO"; - } - break; - - case ( log_level::LL_DEBUG ): - { - log_level_string = "DEBUG"; - } - break; - - case ( log_level::LL_TRACE ): - { - log_level_string = "TRACE"; - } - break; - - case ( log_level::LL_SPAM ): - { - log_level_string = "SPAM"; - } - break; - - default: - SX_ASSERT( false, "Unknown log level!" ); - break; - } - - - return( log_level_string ); -} - - -#ifdef SX_CPP03_BOOST - - -// cppcheck-suppress unusedFunction -bool operator==(const hermes::log_level& _lhs, const hermes::log_level::inner _rhs) -{ - return( _lhs.value_ == _rhs ); -} - - -bool operator==(const hermes::log_level::inner _lhs, const hermes::log_level& _rhs) -{ - return( _lhs == _rhs.value_ ); -} - - -// cppcheck-suppress unusedFunction -bool operator<(const hermes::log_level _lhs, const hermes::log_level _rhs) -{ - return ( _lhs.value_ < _rhs.value_ ); -} - - -// cppcheck-suppress unusedFunction -bool operator<=( const hermes::log_level _lhs, const hermes::log_level _rhs ) -{ - return ( _lhs.value_ <= _rhs.value_ ); -} - - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/log_level.hpp" + +#include "essentials/base.hpp" + + +namespace hermes +{ + + +std::string log_level_to_string( const log_level _log_level ) +{ + std::string log_level_string = "???"; + +#ifndef SX_CPP03_BOOST + switch( _log_level ) +#else + switch (_log_level.value_) +#endif + { + case ( log_level::LL_FATAL ): + { + log_level_string = "FATAL"; + } + break; + + case ( log_level::LL_ERROR ): + { + log_level_string = "ERROR"; + } + break; + + case ( log_level::LL_ASSERT ): + { + log_level_string = "ASSERT"; + } + break; + + case ( log_level::LL_WARN ): + { + log_level_string = "WARN"; + } + break; + + case ( log_level::LL_INFO ): + { + log_level_string = "INFO"; + } + break; + + case ( log_level::LL_DEBUG ): + { + log_level_string = "DEBUG"; + } + break; + + case ( log_level::LL_TRACE ): + { + log_level_string = "TRACE"; + } + break; + + case ( log_level::LL_SPAM ): + { + log_level_string = "SPAM"; + } + break; + + default: + SX_ASSERT( false, "Unknown log level!" ); + break; + } + + + return( log_level_string ); +} + + +#ifdef SX_CPP03_BOOST + + +// cppcheck-suppress unusedFunction +bool operator==(const hermes::log_level& _lhs, const hermes::log_level::inner _rhs) +{ + return( _lhs.value_ == _rhs ); +} + + +bool operator==(const hermes::log_level::inner _lhs, const hermes::log_level& _rhs) +{ + return( _lhs == _rhs.value_ ); +} + + +// cppcheck-suppress unusedFunction +bool operator<(const hermes::log_level _lhs, const hermes::log_level _rhs) +{ + return ( _lhs.value_ < _rhs.value_ ); +} + + +// cppcheck-suppress unusedFunction +bool operator<=( const hermes::log_level _lhs, const hermes::log_level _rhs ) +{ + return ( _lhs.value_ <= _rhs.value_ ); +} + + +#endif + + +} + + +#endif diff --git a/externals/hermes/source/log_message.cpp b/externals/hermes/source/log_message.cpp index bee9017..725e83b 100644 --- a/externals/hermes/source/log_message.cpp +++ b/externals/hermes/source/log_message.cpp @@ -1,58 +1,58 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/log_message.hpp" -#include "hermes/log_callback.hpp" - - -namespace hermes -{ - - -log_message::log_message() - : log_level_(), - time_stamp_(), - file_(), - line_(), - message_(), - log_callback_() -{ - // Nothing to do... -} - - -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 ), - log_callback_( _log_callback ) -{ - // Nothing to do... -} - - -void log_message::done() -{ - if( log_callback_ ) - { - log_callback_->done(); - } -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/log_message.hpp" +#include "hermes/log_callback.hpp" + + +namespace hermes +{ + + +log_message::log_message() + : log_level_(), + time_stamp_(), + file_(), + line_(), + message_(), + log_callback_() +{ + // Nothing to do... +} + + +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 ), + log_callback_( _log_callback ) +{ + // Nothing to do... +} + + +void log_message::done() +{ + if( log_callback_ ) + { + log_callback_->done(); + } +} + + +} + + +#endif diff --git a/externals/hermes/source/std_timestamp_policy.cpp b/externals/hermes/source/std_timestamp_policy.cpp index 8c3e027..77c02f3 100644 --- a/externals/hermes/source/std_timestamp_policy.cpp +++ b/externals/hermes/source/std_timestamp_policy.cpp @@ -1,60 +1,60 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/std_timestamp_policy.hpp" - -#include -#include - -#include - - -namespace hermes -{ - - -namespace -{ - - -const unsigned int WIDTH_YEAR( 4 ); -const unsigned int WIDTH_CLOCK( 2 ); -const char FILL_VALUE( '0' ); -const unsigned int YEAR_1900( 1900 ); -const char DATE_DELIMITER( '/' ); -const char TIME_DELIMITER( ':' ); -const char SPACE_SEPARATOR( ' ' ); - - -} - - -std::string std_timestamp_policy::get_timestamp() -{ - std::stringstream date_time_stream; - time_t rawtime; - time( &rawtime ); - tm timeinfo = *localtime( &rawtime ); - date_time_stream << std::setfill( FILL_VALUE ) << std::setw( WIDTH_YEAR ) << ( YEAR_1900 + timeinfo.tm_year ) << - DATE_DELIMITER << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << ++timeinfo.tm_mon << DATE_DELIMITER << - std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_mday << SPACE_SEPARATOR << std::setfill( FILL_VALUE ) << - std::setw( WIDTH_CLOCK ) << timeinfo.tm_hour << TIME_DELIMITER << std::setfill( FILL_VALUE ) << - std::setw( WIDTH_CLOCK ) << timeinfo.tm_min << TIME_DELIMITER << std::setfill( FILL_VALUE ) << - std::setw( WIDTH_CLOCK ) << timeinfo.tm_sec; - return( date_time_stream.str() ); -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/std_timestamp_policy.hpp" + +#include +#include + +#include + + +namespace hermes +{ + + +namespace +{ + + +const unsigned int WIDTH_YEAR( 4 ); +const unsigned int WIDTH_CLOCK( 2 ); +const char FILL_VALUE( '0' ); +const unsigned int YEAR_1900( 1900 ); +const char DATE_DELIMITER( '/' ); +const char TIME_DELIMITER( ':' ); +const char SPACE_SEPARATOR( ' ' ); + + +} + + +std::string std_timestamp_policy::get_timestamp() +{ + std::stringstream date_time_stream; + time_t rawtime; + time( &rawtime ); + tm timeinfo = *localtime( &rawtime ); + date_time_stream << std::setfill( FILL_VALUE ) << std::setw( WIDTH_YEAR ) << ( YEAR_1900 + timeinfo.tm_year ) << + DATE_DELIMITER << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << ++timeinfo.tm_mon << DATE_DELIMITER << + std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_mday << SPACE_SEPARATOR << std::setfill( FILL_VALUE ) << + std::setw( WIDTH_CLOCK ) << timeinfo.tm_hour << TIME_DELIMITER << std::setfill( FILL_VALUE ) << + std::setw( WIDTH_CLOCK ) << timeinfo.tm_min << TIME_DELIMITER << std::setfill( FILL_VALUE ) << + std::setw( WIDTH_CLOCK ) << timeinfo.tm_sec; + return( date_time_stream.str() ); +} + + +} + + +#endif diff --git a/externals/hermes/source/waiter.cpp b/externals/hermes/source/waiter.cpp index 854f4bf..dd30cc9 100644 --- a/externals/hermes/source/waiter.cpp +++ b/externals/hermes/source/waiter.cpp @@ -1,59 +1,59 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex hermes library (http://hermes.seadex.de). // -// Copyright( C ) 2017 Seadex GmbH // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://hermes.seadex.de/License.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING - - -#include "hermes/waiter.hpp" - - -namespace hermes -{ - - -waiter::waiter() - : done_mutex_(), - done_condition_variable_(), - done_() -{ - // Nothing to do... -} - - -waiter::~waiter() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void waiter::wait() -{ - sxe::unique_lock lock( done_mutex_ ); - done_condition_variable_.wait( lock, sxe::bind( &waiter::is_done, this ) ); -} - - -void waiter::done() -{ - sxe::lock_guard lock( done_mutex_ ); - done_ = true; -} - - -bool waiter::is_done() -{ - // no locking necessary, only used within wait of condition variable - return( done_ ); -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_NO_LOGGING + + +#include "hermes/waiter.hpp" + + +namespace hermes +{ + + +waiter::waiter() + : done_mutex_(), + done_condition_variable_(), + done_() +{ + // Nothing to do... +} + + +waiter::~waiter() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void waiter::wait() +{ + sxe::unique_lock lock( done_mutex_ ); + done_condition_variable_.wait( lock, sxe::bind( &waiter::is_done, this ) ); +} + + +void waiter::done() +{ + sxe::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/genesis/CMakeLists.txt b/genesis/CMakeLists.txt new file mode 100644 index 0000000..37b8ebd --- /dev/null +++ b/genesis/CMakeLists.txt @@ -0,0 +1,158 @@ +cmake_minimum_required(VERSION 3.5) + +project(genesis) + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +file(GLOB genesis_SRC "include/*.hpp" "source/*.cpp") + +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 \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") + else() + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") + endif() + +# genesis'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\"") + message(STATUS "Optimizing for size.") + else() + set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") + message(STATUS "Optimizing for speed.") + endif() + + option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") + if( "${SX_NO_LOGGING}" ) + set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") + message(STATUS "No logging used.") + else() + message(STATUS "Logger is used.") + endif() + + option("SX_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 genesis drop-in replacement template will be used instead then.") + if( "${SX_NO_STD_MAKE_UNIQUE}" ) + set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") + message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") + 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 genesis.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behaviour) 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\"") + message(STATUS "Y_LEAN_AND_MEAN is defined.") + 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\"") + message(STATUS "Y_PROFILER is defined.") + 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 behaviour 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 behaviour. + 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. + if( "${MSVC_VERSION}" STRGREATER "1800" ) + set(extra_flags "${extra_flags} /WX") + #else( "${MSVC_VERSION}" STRLESS "1900" ) + else() + set(extra_flags "${extra_flags} /WX-") + endif() + + + #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") + + # genesis's preprocessor definitions + + option("SX_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 genesis drop-in replacement template will be used instead then.") + if( "${SX_NO_STD_MAKE_UNIQUE}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") + message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") + endif() + +endif() + +include_directories("./include") +include_directories("./../externals/essentials/include") + +# for release +if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) + #Creates fast code. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") + + #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("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_library(genesis SHARED ${genesis_SRC}) +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_library(genesis STATIC ${genesis_SRC}) +endif() + + +install(TARGETS genesis DESTINATION lib) +install(FILES *.hpp DESTINATION include) +set_target_properties(genesis PROPERTIES PREFIX "") \ No newline at end of file diff --git a/genesis/changelog.txt b/genesis/changelog.txt new file mode 100644 index 0000000..3f69df8 --- /dev/null +++ b/genesis/changelog.txt @@ -0,0 +1,12 @@ +# Change log +All notable changes to this project are documented in this file. + +##[0.2.0] - 2017-04-24 + +### Added +• C++03 compatibility + + +##[0.1.0] - 2017-04-24 + +• The very first release version of genesis diff --git a/genesis/genesis.vcxproj b/genesis/genesis.vcxproj new file mode 100644 index 0000000..53f93bc --- /dev/null +++ b/genesis/genesis.vcxproj @@ -0,0 +1,310 @@ + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357} + genesis + 8.1 + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/genesis/genesis.vcxproj.filters b/genesis/genesis.vcxproj.filters new file mode 100644 index 0000000..1ae3d46 --- /dev/null +++ b/genesis/genesis.vcxproj.filters @@ -0,0 +1,215 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {e4072d57-8fc3-45b0-8a55-890235596a11} + + + {405c586e-518d-4d17-880c-e561a09a5c77} + + + {15239cf0-0a42-40d5-80ce-15256d0c1587} + + + {a2ba6865-a71e-441f-9efc-b6c67888c0a0} + + + {fc0c0321-a05d-41cd-a99c-11c3b68abbc0} + + + {5dc27c9e-86a8-4fb6-a2a8-bbdf434e29a0} + + + {97c6b545-0106-4ab1-8645-a95c5e9add8b} + + + + + license + + + license + + + license + + + license + + + license + + + license\essentials + + + license\essentials + + + license\essentials + + + license\essentials + + + license\essentials + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials + + + Header Files\external\essentials\compatibility + + + Header Files\external\essentials\compatibility + + + Header Files\external\essentials\compatibility + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\external\essentials + + + Source Files\external\essentials + + + Source Files\external\essentials + + + Source Files + + + Source Files + + + + + + \ No newline at end of file diff --git a/genesis/include/build_number.hpp b/genesis/include/build_number.hpp new file mode 100644 index 0000000..05323f7 --- /dev/null +++ b/genesis/include/build_number.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_NUMBER_C13F16F5_B4C0_48CA_BF09_D5EB14953C3C +#define BUILD_NUMBER_C13F16F5_B4C0_48CA_BF09_D5EB14953C3C + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +namespace version +{ + + +const sxe::uint16_t BUILD_NUMBER( 31 ); + + +} + + +} + + +} + + +#endif diff --git a/genesis/include/condition_block.hpp b/genesis/include/condition_block.hpp new file mode 100644 index 0000000..a2b684f --- /dev/null +++ b/genesis/include/condition_block.hpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CONDITION_BLOCK_3922737B_1A00_451A_AFCB_B29D0123210C +#define CONDITION_BLOCK_3922737B_1A00_451A_AFCB_B29D0123210C + + +#include "recipe_block.hpp" +#include "condition_modifier.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +//!\class confition_block +//!\brief class representing an 'if'. This block can have children. +class condition_block SX_FINAL + : public recipe_block +{ +public: + //!\brief constructor + //!\param _condition_name name of the condition block. + //!\param _modifier condition modifier. default value is none. + //!\sa condition_modifier + explicit condition_block( const std::string& _condition_name, const condition_modifier& _modifier = condition_modifier::NONE ); + virtual ~condition_block() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( condition_block ) + + //!\brief create the output for a step. + //!\param _recipe_callback generator callback + //!\param _ostream stream to which the generator writes. + virtual void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) SX_OVERRIDE; + + +private: + void apply_modifier( bool& _result ) const; + + const std::string condition_name_; + const condition_modifier modifier_; + + +}; + + +} + + +} + + +#endif diff --git a/genesis/include/condition_modifier.hpp b/genesis/include/condition_modifier.hpp new file mode 100644 index 0000000..ae2dbd4 --- /dev/null +++ b/genesis/include/condition_modifier.hpp @@ -0,0 +1,102 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CONDITION_MODIFIER_5286AF53_4751_4FDE_B4C9_E097AC8FB331 +#define CONDITION_MODIFIER_5286AF53_4751_4FDE_B4C9_E097AC8FB331 + + +#include + + +namespace sx +{ + + +namespace genesis +{ + + +#ifndef SX_CPP03_BOOST + +//!\enum condition_modifier +//!\brief Modifier for conditions. E.g. negate the result of a check. +enum class condition_modifier +{ + NONE = 0, NOT = 1 +}; + + +#else + + + //!\struct condition_modifier + //!\brief Structure representing a predefined modifier for conditions (enum wrapper for C++11 enum class like behavior). + struct condition_modifier + { + //!\enum condition_modifier + //!\brief Enumeration for predefined modifier for conditions. + enum inner + { + NONE = 0, NOT = 1 + }; + + + //!\brief Constructor. Default value is white. + condition_modifier() : value_( NONE ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _value Given modifier for conditions value that is represented by the structure. + condition_modifier( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _condition_modifier Given modifier for conditions structure containing the modifier for conditions that is represented by the structure. + condition_modifier( const condition_modifier& _condition_modifier ) : value_( _condition_modifier.value_ ) + { + // Nothing to do... + } + + + //!\brief Get the modifier for conditions value represented by the structure. + operator inner() const + { + return ( value_ ); + } + + + //!\brief Modifier for conditions represented by the structure. + inner value_; + + }; + + +#endif + + +//!\fn +//!\brief Get the condition modifier value from a string. +//!\param _condition_modifier Modifier as a string, generally read from template files. +//!\return Condition modifier enum value corresponding to the given value. +condition_modifier get_condition_modifier_from_string( const std::string& _condition_modifier ); + + +} + + +} + + +#endif diff --git a/genesis/include/file_reader.hpp b/genesis/include/file_reader.hpp new file mode 100644 index 0000000..9e9be92 --- /dev/null +++ b/genesis/include/file_reader.hpp @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FILE_READER_20EC6A5D_A4B2_4EDC_9B67_57B4B0A0DA31 +#define FILE_READER_20EC6A5D_A4B2_4EDC_9B67_57B4B0A0DA31 + + +#include + + +namespace sx +{ + + +namespace genesis +{ + + +//!\fn +//!\brief Function that reads a file into a given string variable. +//!\param _file_path File that is read. +//!\param _content Target for the content of the file. +//!\return True if the read was successful, false otherwise. +bool read( const std::string& _file_path, std::string& _content ); + + +} + + +} + + +#endif diff --git a/genesis/include/file_writer.hpp b/genesis/include/file_writer.hpp new file mode 100644 index 0000000..d1f6170 --- /dev/null +++ b/genesis/include/file_writer.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FILE_WRITER_27D8B8DE_AD70_4536_857C_1D75B5D34EB8 +#define FILE_WRITER_27D8B8DE_AD70_4536_857C_1D75B5D34EB8 + + +#include + + +namespace sx +{ + + +namespace genesis +{ + + +//!\fn +//!\brief Function that writes the content of a ostream to the file with the given name. +//!\param _file_path Name of the file that will be written. +//!\param _output_stream Stream that is written to the file. +void write( const std::string& _file_path, const std::ostream& _output_stream ); + + +} + + +} + +#endif diff --git a/genesis/include/genesis_exception.hpp b/genesis/include/genesis_exception.hpp new file mode 100644 index 0000000..bb7cfbd --- /dev/null +++ b/genesis/include/genesis_exception.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GENESIS_EXCEPTION_FDA50E1B_5130_4353_9100_E40405E1C32D +#define GENESIS_EXCEPTION_FDA50E1B_5130_4353_9100_E40405E1C32D + + +#include "essentials/exception_template.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +//!\brief Exception class of the genesis library. +SX_EXCEPTION( genesis_exception ) + + +} + + +} + + +#endif diff --git a/genesis/include/grammar.hpp b/genesis/include/grammar.hpp new file mode 100644 index 0000000..4bfb86f --- /dev/null +++ b/genesis/include/grammar.hpp @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GRAMMAR_F628CCE8_06DD_43A9_BEE3_C3EB343AC539 +#define GRAMMAR_F628CCE8_06DD_43A9_BEE3_C3EB343AC539 + + +#include + + +namespace sx +{ + + +namespace genesis +{ + + +extern const std::string condition_modifier_NOT; +extern const std::string condition_modifier_NONE; +extern const char DELIMITER_CHAR; +extern const char LINE_BREAK_CHAR; +extern const char OPEN_PARENTHESIS_CHAR; +extern const char CLOSE_PARENTHESIS_CHAR; +extern const char COMMA_CHAR; +extern const std::string COMMA_CLOSE_PARENTHESIS; +extern const std::string VARIABLE_COMMAND; +extern const std::string LOOP_START_COMMAND; +extern const std::string LOOP_END_COMMAND; +extern const std::string IF_START_COMMAND; +extern const std::string IF_END_COMMAND; +extern const std::string SWITCH_START_COMMAND; +extern const std::string SWITCH_END_COMMAND; +extern const std::string SWITCH_CASE_START_COMMAND; +extern const std::string SWITCH_CASE_END_COMMAND; +extern const std::string SWITCH_DEFAULT_START_COMMAND; +extern const std::string SWITCH_DEFAULT_END_COMMAND; +extern const int SWITCH_DEFAULT_INDEX_VALUE; +extern const std::string TEMPLATE_COMMAND; +extern const char NEW_LINE_CHAR; +extern const std::size_t SIZE_ONE; + + +} + + +} + + +#endif diff --git a/genesis/include/loop_block.hpp b/genesis/include/loop_block.hpp new file mode 100644 index 0000000..6b7b453 --- /dev/null +++ b/genesis/include/loop_block.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef LOOP_BLOCK_08F296C5_8660_453B_9AE3_903E1AEE52D9 +#define LOOP_BLOCK_08F296C5_8660_453B_9AE3_903E1AEE52D9 + + +#include "recipe_block.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +//!\class loop_block +//!\brief Class representing a loop. This block can have children. +class loop_block SX_FINAL + : public recipe_block +{ +public: + //!\brief Constructor + //!\param _loop_name Name of the loop block. + explicit loop_block( const std::string& _loop_name); + virtual ~loop_block() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( loop_block ) + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + virtual void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) SX_OVERRIDE; + + +private: + const std::string loop_name_; +}; + + +} + + +} + + +#endif diff --git a/genesis/include/messages.hpp b/genesis/include/messages.hpp new file mode 100644 index 0000000..9a4bef3 --- /dev/null +++ b/genesis/include/messages.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef MESSAGES_790A336F_D398_4F59_93F0_8C44B7267E3D +#define MESSAGES_790A336F_D398_4F59_93F0_8C44B7267E3D + + +#include + + +namespace sx +{ + + +namespace genesis +{ + + +//!\brief Message for reporting an error while writing a file. +extern const std::string ERROR_WRITE_FILE; + + +} + + +} + + +#endif diff --git a/genesis/include/recipe.hpp b/genesis/include/recipe.hpp new file mode 100644 index 0000000..7c8daf6 --- /dev/null +++ b/genesis/include/recipe.hpp @@ -0,0 +1,64 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef RECIPE_20F2FCF1_99D0_4CC6_9E59_3E9BE7C1A2A6 +#define RECIPE_20F2FCF1_99D0_4CC6_9E59_3E9BE7C1A2A6 + + +#include "template_block.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +class recipe_step; + +//!\class recipe +//!\brief Class for generating code from the given template and using the given callback. It can write the generated code +//!\to the given file. +class recipe : public template_block +{ +public: + //!\brief Constructor + //!\param _template_name Name of the file containing the used template. + //!\param _recipe_callback Generator callback + //!\param _templates_path Path to the templates folder. + explicit recipe( const std::string& _template_name, recipe_callback& _recipe_callback, + const std::string& _templates_path ); + virtual ~recipe() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( recipe ) + + //!\brief Generates the code in a internal stream. + void generate(); + + //!\brief Write the generated code to the file with the given name. + //!\param _file_path Path of the while to which the generated code will be written. + void write_to_file( const std::string& _file_path ) const; + + +private: + void create( recipe_callback& _recipe_callback ); + + recipe_callback& recipe_callback_; + std::stringstream stream_; +}; + + +} + + +} + + +#endif diff --git a/genesis/include/recipe_block.hpp b/genesis/include/recipe_block.hpp new file mode 100644 index 0000000..73d72ea --- /dev/null +++ b/genesis/include/recipe_block.hpp @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef RECIPE_BLOCK_A5AF03FF_E23E_4887_A4C8_44C6E8605983 +#define RECIPE_BLOCK_A5AF03FF_E23E_4887_A4C8_44C6E8605983 + + +#include + +#include "recipe_step.hpp" + + +namespace sx +{ + + +namespace genesis +{ + +//!\class recipe_block +//!\brief Class that represents a recipe block. This block can have children. +class recipe_block : public recipe_step +{ +public: + //!\brief Constructor + explicit recipe_block(); + virtual ~recipe_block() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( recipe_block ) + + //!\brief Add a child to the list of children. + //!\param _child New child + virtual void add_child( sxe::SX_UNIQUE_PTR _child ); + + +protected: + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + virtual void create_children( recipe_callback& _recipe_callback, std::stringstream& _ostream ); + + +private: + std::vector< sxe::SX_UNIQUE_PTR > child_recipes_; +}; + + +} + + +} + + +#endif \ No newline at end of file diff --git a/genesis/include/recipe_callback.hpp b/genesis/include/recipe_callback.hpp new file mode 100644 index 0000000..4d80fe7 --- /dev/null +++ b/genesis/include/recipe_callback.hpp @@ -0,0 +1,98 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef RECIPE_CALLBACK_94CA6C50_A463_41C9_B424_D595F361B6C2 +#define RECIPE_CALLBACK_94CA6C50_A463_41C9_B424_D595F361B6C2 + + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/non_copyable.hpp" + +#include "condition_modifier.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +//!\interface +//!\brief Callback Interface that needs to be implemented by a generator. +class recipe_callback +{ +public: + //!\brief Constructor + explicit recipe_callback() + { + // Nothing to do... + } + + + virtual ~recipe_callback() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( recipe_callback ) + + //!\brief Get the content of a variable. + //!\param _variable_name Name of the variable for which the value is requested. + //!\return String Value of the given variable. + virtual std::string get_variable_content( const std::string& _variable_name ) = 0; + + //!\brief Check the condition of a loop_block. + //!\param _loop_name Name of the loop block that is executed. + virtual bool check_loop_condition( const std::string& _loop_name ) const = 0; + + //!\brief Execute actions before a loop_block. + //!\param _loop_name Name of the loop block that is executed. + virtual void before_loop( const std::string& _loop_name ) = 0; + + //!\brief Execute actions before an iteration of a loop_block. + //!\param _loop_name Name of the loop block that is executed. + virtual void before_loop_iteration( const std::string& _loop_name ) = 0; + + //!\brief Execute actions after an iteration of a loop_block. + //!\param _loop_name Name of the loop block that is executed. + virtual void after_loop_iteration( const std::string& _loop_name ) = 0; + + //!\brief Execute actions after a loop_block. + //!\param _loop_name Name of the loop block that is executed. + virtual void after_loop( const std::string& _loop_name ) = 0; + + //!\brief Check the condition of a condition_block. + //!\param _loop_name Name of the condition block that is executed. + virtual bool check_condition( const std::string& _condition_name ) const = 0; + + //!\brief Execute actions before a condition_block. + //!\param _loop_name Name of the condition block that is executed. + virtual void condition_begin( const std::string& _condition_name ) = 0; + + //!\brief Execute actions after a condition_block. + //!\param _loop_name Name of the condition block that is executed. + virtual void condition_end( const std::string& _condition_name ) = 0; + + //!\brief Returns the index of the case of the switch with the given name which shall be executed. + //!\param _switch_name Name of the switch block for which the case index is requested. + //!\return The index of the case that shall be executed. + virtual int get_switch_case( const std::string& _switch_name ) = 0; +}; + + +} + + +} + + +#endif diff --git a/genesis/include/recipe_step.hpp b/genesis/include/recipe_step.hpp new file mode 100644 index 0000000..553992f --- /dev/null +++ b/genesis/include/recipe_step.hpp @@ -0,0 +1,63 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef RECIPE_STEP_1A42F342_F0C6_49C9_8FC3_0BAEDFBD05AE +#define RECIPE_STEP_1A42F342_F0C6_49C9_8FC3_0BAEDFBD05AE + + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/non_copyable.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +class recipe_callback; + + +//!\interface recipe_step +//!\brief A step of a recipe. +class recipe_step +{ +public: + //!\brief Constructor + recipe_step() + { + // Nothing to do... + } + + + virtual ~recipe_step() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( recipe_step ) + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + virtual void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) = 0; +}; + + +} + + +} + +#endif diff --git a/genesis/include/switch_block.hpp b/genesis/include/switch_block.hpp new file mode 100644 index 0000000..3ad8e38 --- /dev/null +++ b/genesis/include/switch_block.hpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SWITCH_BLOCK_DBBA48C9_294D_4F33_8424_CCD31767B4BC +#define SWITCH_BLOCK_DBBA48C9_294D_4F33_8424_CCD31767B4BC + + +#include "recipe_block.hpp" + +#include + + +namespace sx +{ + + +namespace genesis +{ + + +//!\class switch_block +//!\brief class representing an 'switch'. This block can have children. +class switch_block SX_FINAL + : public recipe_block +{ +public: + //!\brief constructor + //!\param _switch_name Name of the switch block. + explicit switch_block( const std::string& _switch_name ); + virtual ~switch_block() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( switch_block ) + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream stream to which the generator writes. + virtual void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) SX_OVERRIDE; + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + virtual void create_children( recipe_callback& _recipe_callback, std::stringstream& _ostream ) SX_OVERRIDE; + + //!\brief Add a child to the list of children. + //!\param _child New child + virtual void add_child( sxe::SX_UNIQUE_PTR _child ) SX_OVERRIDE; + + + //!\brief Set the internal index for the current case. This is only used during parsing of a template. + //!\param _index Index value. Index value must be greater than or equal to zero. + void set_case_index( const int _index ); + + +private: + const std::string switch_name_; + int current_case_index_; + std::map< int, std::vector< sxe::SX_UNIQUE_PTR > > switch_cases_; + std::vector< sxe::SX_UNIQUE_PTR > default_; + + +}; + + +} + + +} + + +#endif diff --git a/genesis/include/template_block.hpp b/genesis/include/template_block.hpp new file mode 100644 index 0000000..7544977 --- /dev/null +++ b/genesis/include/template_block.hpp @@ -0,0 +1,103 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TEMPLATE_BLOCK_43849414_0A6E_429C_9D51_FB0562A58B05 +#define TEMPLATE_BLOCK_43849414_0A6E_429C_9D51_FB0562A58B05 + + +#include + +#include "recipe_block.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +class text_step; +class variable_step; +class loop_block; +class condition_block; + + +//!\class template_block +//!\brief Class representing a recipe block created from a template file. +class template_block + : public recipe_block +{ +public: + //!\brief Constructor. Get the template file name and the path to the template directory. + //!\param _template_name Name of the template file. + //!\param _template_path Path to templates directory + explicit template_block( const std::string& _template_name, const std::string& _template_path ); + virtual ~template_block() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( template_block ) + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ); + + +private: + void parse( std::string& _file_buffer ); + void get_text( std::string &_file_buffer ); + std::string get_keyword( std::string& _file_buffer ); + void get_variable( std::string &_file_buffer ); + void get_loop( std::string &_file_buffer ); + void get_if( std::string &_file_buffer ); + void get_switch( std::string& _file_buffer ); + void get_switch_case( std::string& _file_buffer ); + void get_switch_default( std::string& _file_buffer ); + void get_template( std::string &_file_buffer ); + const std::string get_last_to_be_closed() const; + static std::string read_template_file( const std::string& _file_buffer, const std::string& _templates_path ); + void check_new_line_after_end_command( std::string &_file_buffer ); + void close_loop( std::string& _file_buffer ); + void close_condition( std::string& _file_buffer ); + void close_switch( std::string& _file_buffer ); + void close_switch_case( std::string& _file_buffer ); + void close_switch_default( std::string& _file_buffer ); + bool is_any_recipe_open() const; + std::vector get_parameters( std::string& _file_buffer ) const; + void final_check() const; + + template + void add_child_to_recipe( sxe::SX_UNIQUE_PTR _child ) + { + if( opened_recipes_.empty() ) + { + add_child( sxe::move( _child ) ); + } + else + { + opened_recipes_.top()->add_child( sxe::move( _child ) ); + } + } + + + std::stack opened_recipes_; + std::vector keywords_; + std::string template_to_parse_; + const std::string& template_path_; + const std::string& template_file_; +}; + + +} + + +} + + +#endif diff --git a/genesis/include/text_step.hpp b/genesis/include/text_step.hpp new file mode 100644 index 0000000..fc7548d --- /dev/null +++ b/genesis/include/text_step.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TEXT_STEP_56DA4C34_9848_4123_AB65_1C9839E009A2 +#define TEXT_STEP_56DA4C34_9848_4123_AB65_1C9839E009A2 + + +#include "recipe_step.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +//!\class test_step +//!\brief Class representing a text step of the recipe. +class text_step SX_FINAL + : public recipe_step +{ +public: + //!\brief Constructor + //!\param _text Content of the text block. + explicit text_step( const std::string& _text ); + virtual ~text_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( text_step ) + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + virtual void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) SX_OVERRIDE; + + +private: + const std::string text_; +}; + + +} + + +} + + +#endif diff --git a/genesis/include/variable_step.hpp b/genesis/include/variable_step.hpp new file mode 100644 index 0000000..c8ae270 --- /dev/null +++ b/genesis/include/variable_step.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef VARIABLE_STEP_11B39100_54E6_40E4_85FC_0A642202937C +#define VARIABLE_STEP_11B39100_54E6_40E4_85FC_0A642202937C + + +#include "recipe_step.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +//!\class variable_step +//!\brief Class representing a variable step of the recipe. +class variable_step SX_FINAL + : public recipe_step +{ +public: + //!\brief Constructor + //!\param _variable_name Name of the variable represented by the variable_step. + explicit variable_step( const std::string& _variable_name ); + virtual ~variable_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( variable_step ) + + //!\brief Create the output for a step. + //!\param _recipe_callback Generator callback + //!\param _ostream Stream to which the generator writes. + virtual void create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) SX_OVERRIDE; + + +private: + const std::string variable_name_; +}; + + +} + + +} + + +#endif diff --git a/genesis/include/version.hpp b/genesis/include/version.hpp new file mode 100644 index 0000000..aede3f0 --- /dev/null +++ b/genesis/include/version.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERSION_11BB60D2_9C1A_4102_BBCC_0486F61F9C1C +#define VERSION_11BB60D2_9C1A_4102_BBCC_0486F61F9C1C + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +namespace version +{ + + +void log_version(); + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +} + + +#endif diff --git a/genesis/license/genesis_Anhang_Appendix_20170406.pdf b/genesis/license/genesis_Anhang_Appendix_20170406.pdf new file mode 100644 index 0000000..b158391 Binary files /dev/null and b/genesis/license/genesis_Anhang_Appendix_20170406.pdf differ diff --git a/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf new file mode 100644 index 0000000..0931c51 Binary files /dev/null and b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf differ diff --git a/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf new file mode 100644 index 0000000..d04e4f1 Binary files /dev/null and b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf differ diff --git a/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf new file mode 100644 index 0000000..7ce3402 Binary files /dev/null and b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf differ diff --git a/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf new file mode 100644 index 0000000..a840855 Binary files /dev/null and b/genesis/license/genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf differ diff --git a/genesis/source/condition_block.cpp b/genesis/source/condition_block.cpp new file mode 100644 index 0000000..32e101a --- /dev/null +++ b/genesis/source/condition_block.cpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "condition_block.hpp" + +#include "essentials/exception.hpp" + +#include "recipe_callback.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +condition_block::condition_block( const std::string& _condition_name, const condition_modifier& _modifier ) : + recipe_block(), + condition_name_( _condition_name ), + modifier_( _modifier ) +{ + // Nothing to do... +} + + +condition_block::~condition_block() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void condition_block::create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + _recipe_callback.condition_begin( condition_name_ ); + bool result = _recipe_callback.check_condition( condition_name_ ); + apply_modifier( result ); + if( result ) + { + create_children( _recipe_callback, _ostream ); + _recipe_callback.condition_end( condition_name_ ); + } +} + + +void condition_block::apply_modifier( bool& _result ) const +{ + switch( modifier_ ) + { + case sx::genesis::condition_modifier::NOT: + _result = !_result; + break; + + case sx::genesis::condition_modifier::NONE: + // Nothing to do... + break; + + default: + sxe::exception( "Incompatible value for condition modifier!" ); + break; + } +} + + +} + + +} \ No newline at end of file diff --git a/genesis/source/condition_modifier.cpp b/genesis/source/condition_modifier.cpp new file mode 100644 index 0000000..b6a8f5c --- /dev/null +++ b/genesis/source/condition_modifier.cpp @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "condition_modifier.hpp" + +#include + +#include "essentials/conversion.hpp" + +#include "grammar.hpp" +#include "genesis_exception.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +condition_modifier get_condition_modifier_from_string( const std::string& _condition_modifier ) +{ + const std::string condition_modifier_caps = sxe::to_upper( _condition_modifier ); + + condition_modifier modifier( condition_modifier::NONE ); + if( condition_modifier_caps == condition_modifier_NOT ) + { + modifier = condition_modifier::NOT; + } + else if( condition_modifier_caps == condition_modifier_NONE ) + { + modifier = condition_modifier::NONE; + } + else + { + throw sx::genesis::genesis_exception( "Invalid condition modifier!" ); + } + return ( modifier ); +} + + +} + + +} diff --git a/genesis/source/file_reader.cpp b/genesis/source/file_reader.cpp new file mode 100644 index 0000000..db25ecc --- /dev/null +++ b/genesis/source/file_reader.cpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "file_reader.hpp" + +#include +#include + + +namespace sx +{ + +namespace genesis +{ + + +bool read( const std::string& _file_path, std::string& _content ) +{ + bool read = false; + std::ostringstream outputString; + std::ifstream inputFile( _file_path.c_str(), std::ios::in ); + if( inputFile ) + { + outputString << inputFile.rdbuf(); + inputFile.close(); + read = true; + } + _content = outputString.str(); + return ( read ); +} + + +} + + +} diff --git a/genesis/source/file_writer.cpp b/genesis/source/file_writer.cpp new file mode 100644 index 0000000..c7f282e --- /dev/null +++ b/genesis/source/file_writer.cpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "file_writer.hpp" + +#include + +#include "genesis_exception.hpp" +#include "messages.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +void write( const std::string& _file_path, const std::ostream& _output_stream ) +{ +#ifdef SX_CPP03_BOOST + std::ofstream target_file( _file_path.c_str(), std::ios_base::out ); +#else + std::ofstream target_file( _file_path, std::ios_base::out ); +#endif + + if( target_file.is_open() ) + { + target_file << _output_stream.rdbuf(); + target_file.close(); + } + else + { + throw sx::genesis::genesis_exception( ERROR_WRITE_FILE, _file_path ); + } +} + + +} + + +} diff --git a/genesis/source/grammar.cpp b/genesis/source/grammar.cpp new file mode 100644 index 0000000..7326e84 --- /dev/null +++ b/genesis/source/grammar.cpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "grammar.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +const std::string condition_modifier_NOT = "NOT"; +const std::string condition_modifier_NONE = "NONE"; +const char DELIMITER_CHAR = '$'; +const char LINE_BREAK_CHAR = '@'; +const char OPEN_PARENTHESIS_CHAR = '('; +const char CLOSE_PARENTHESIS_CHAR = ')'; +const char COMMA_CHAR = ','; +const std::string COMMA_CLOSE_PARENTHESIS = ",)"; +const std::string VARIABLE_COMMAND = "$var"; +const std::string LOOP_START_COMMAND = "$loop"; +const std::string LOOP_END_COMMAND = "$pool"; +const std::string IF_START_COMMAND = "$if"; +const std::string IF_END_COMMAND = "$fi"; +const std::string SWITCH_START_COMMAND = "$switch"; +const std::string SWITCH_END_COMMAND = "$hctiws"; +const std::string SWITCH_CASE_START_COMMAND = "$case"; +const std::string SWITCH_CASE_END_COMMAND = "$esac"; +const std::string SWITCH_DEFAULT_START_COMMAND = "$default"; +const std::string SWITCH_DEFAULT_END_COMMAND = "$tluafed"; +const int SWITCH_DEFAULT_INDEX_VALUE = -1; +const std::string TEMPLATE_COMMAND = "$template"; +const char NEW_LINE_CHAR = '\n'; +const std::size_t SIZE_ONE = 1; + + +} + + +} diff --git a/genesis/source/loop_block.cpp b/genesis/source/loop_block.cpp new file mode 100644 index 0000000..b6e7d8c --- /dev/null +++ b/genesis/source/loop_block.cpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "loop_block.hpp" + +#include "recipe_callback.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +loop_block::loop_block( const std::string& _loop_name ) : + recipe_block(), + loop_name_( _loop_name ) +{ + // Nothing to do... +} + + +loop_block::~loop_block() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void loop_block::create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + _recipe_callback.before_loop( loop_name_ ); + + while( _recipe_callback.check_loop_condition( loop_name_ ) ) + { + _recipe_callback.before_loop_iteration( loop_name_ ); + create_children( _recipe_callback, _ostream ); + _recipe_callback.after_loop_iteration( loop_name_ ); + } + _recipe_callback.after_loop( loop_name_ ); +} + + +} + + +} diff --git a/genesis/source/messages.cpp b/genesis/source/messages.cpp new file mode 100644 index 0000000..1cd39b5 --- /dev/null +++ b/genesis/source/messages.cpp @@ -0,0 +1,27 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "messages.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +const std::string ERROR_WRITE_FILE = "File % cannot be opened for writing!"; + + +} + + +} diff --git a/genesis/source/recipe.cpp b/genesis/source/recipe.cpp new file mode 100644 index 0000000..00b6dba --- /dev/null +++ b/genesis/source/recipe.cpp @@ -0,0 +1,61 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "recipe.hpp" + +#include "file_writer.hpp" +#include "genesis_exception.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +recipe::recipe( const std::string& _template_name, recipe_callback& _recipe_callback, + const std::string& _templates_path ) : + template_block( _template_name, _templates_path ), + recipe_callback_( _recipe_callback ), + stream_() +{ + // Nothing to do... +} + + +recipe::~recipe() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void recipe::generate() +{ + create( recipe_callback_ ); +} + + +void recipe::write_to_file( const std::string& _file_path ) const +{ + write( _file_path, stream_ ); +} + + +void recipe::create( recipe_callback& _recipe_callback ) +{ + template_block::create( _recipe_callback, stream_ ); +} + + +} + + +} diff --git a/genesis/source/recipe_block.cpp b/genesis/source/recipe_block.cpp new file mode 100644 index 0000000..0948130 --- /dev/null +++ b/genesis/source/recipe_block.cpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "recipe_block.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +recipe_block::recipe_block() : + recipe_step(), + child_recipes_() +{ + // Nothing to do... +} + + +recipe_block::~recipe_block() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void recipe_block::create_children( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + SX_FOR( sxe::SX_UNIQUE_PTR& child, child_recipes_ ) + { + child->create( _recipe_callback, _ostream ); + } +} + + +void recipe_block::add_child( sxe::SX_UNIQUE_PTR _child ) +{ + child_recipes_.push_back( sxe::move( _child ) ); +} + + +} + + +} diff --git a/genesis/source/switch_block.cpp b/genesis/source/switch_block.cpp new file mode 100644 index 0000000..af124fe --- /dev/null +++ b/genesis/source/switch_block.cpp @@ -0,0 +1,89 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "switch_block.hpp" + +#include "recipe_callback.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +switch_block::switch_block( const std::string& _switch_name ) : + recipe_block(), + switch_name_( _switch_name ), + current_case_index_(), + switch_cases_(), + default_() +{ + // Nothing to do... +} + + +switch_block::~switch_block() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void switch_block::create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + current_case_index_ = _recipe_callback.get_switch_case( switch_name_ ); + create_children( _recipe_callback, _ostream ); +} + + +void switch_block::create_children( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + if( current_case_index_ >= 0 ) + { + std::vector< sxe::SX_UNIQUE_PTR >& children_steps = switch_cases_[current_case_index_]; + SX_FOR( sxe::SX_UNIQUE_PTR& child , children_steps ) + { + child->create( _recipe_callback, _ostream ); + } + } + else + { + SX_FOR( sxe::SX_UNIQUE_PTR& child , default_ ) + { + child->create( _recipe_callback, _ostream ); + } + } +} + + +void switch_block::add_child( sxe::SX_UNIQUE_PTR _child ) +{ + if( current_case_index_ >= 0 ) + { + switch_cases_[current_case_index_].push_back( sxe::move( _child ) ); + } + else + { + default_.push_back( sxe::move( _child ) ); + } +} + + +void switch_block::set_case_index( const int _index ) +{ + current_case_index_ = _index; +} + + +} + + +} \ No newline at end of file diff --git a/genesis/source/template_block.cpp b/genesis/source/template_block.cpp new file mode 100644 index 0000000..2d39ed3 --- /dev/null +++ b/genesis/source/template_block.cpp @@ -0,0 +1,515 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "template_block.hpp" + +#include +#include +#include + +#include "essentials/base.hpp" +#include "essentials/conversion.hpp" + +#include "genesis_exception.hpp" +#include "file_reader.hpp" +#include "text_step.hpp" +#include "variable_step.hpp" +#include "loop_block.hpp" +#include "switch_block.hpp" +#include "condition_block.hpp" +#include "grammar.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +template_block::template_block( const std::string& _template_name, const std::string& _template_path ) : + recipe_block(), + opened_recipes_(), + keywords_(), + template_to_parse_( read_template_file( _template_name, _template_path ) ), + template_path_( _template_path ), + template_file_( _template_name ) +{ + // Nothing to do... +} + + +template_block::~template_block() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void template_block::create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + parse( template_to_parse_ ); + final_check(); + create_children( _recipe_callback, _ostream ); +} + + +void template_block::parse( std::string& _file_buffer ) +{ + while( !_file_buffer.empty() ) + { + get_text( _file_buffer ); + if( !_file_buffer.empty() ) + { + const std::string command = get_keyword( _file_buffer ); + if( command == VARIABLE_COMMAND ) + { + get_variable( _file_buffer ); + } + else if( command == TEMPLATE_COMMAND ) + { + get_template( _file_buffer ); + } + else if( command == LOOP_START_COMMAND ) + { + get_loop( _file_buffer ); + } + else if( command == IF_START_COMMAND ) + { + get_if( _file_buffer ); + } + else if( command == SWITCH_START_COMMAND ) + { + get_switch( _file_buffer ); + } + else if( command == SWITCH_CASE_START_COMMAND ) + { + get_switch_case( _file_buffer ); + } + else if( command == SWITCH_DEFAULT_START_COMMAND ) + { + get_switch_default( _file_buffer ); + } + else if( command == LOOP_END_COMMAND ) + { + close_loop( _file_buffer ); + } + else if( command == IF_END_COMMAND ) + { + close_condition( _file_buffer ); + } + else if( command == SWITCH_END_COMMAND ) + { + close_switch( _file_buffer ); + } + else if( command == SWITCH_CASE_END_COMMAND ) + { + close_switch_case( _file_buffer ); + } + else if( command == SWITCH_DEFAULT_END_COMMAND ) + { + close_switch_default( _file_buffer ); + } + else + { + throw sx::genesis::genesis_exception( "Unknown command! Check template file '%'!", template_file_ ); + } + } + } +} + + +void template_block::get_text( std::string &_file_buffer ) +{ + std::stringstream buffer; + bool more_text = true; + while( more_text ) + { + const std::size_t position = _file_buffer.find( DELIMITER_CHAR ); + if( position != std::string::npos ) + { + buffer << _file_buffer.substr( 0, position ); + _file_buffer.erase( 0, position ); + const bool is_delimiter_char = _file_buffer[0] == DELIMITER_CHAR; + SX_ASSERT( is_delimiter_char, "First char in the buffer is not the delimiter char!" ); + if( _file_buffer.length() > 2 ) + { + if( _file_buffer[1] == DELIMITER_CHAR ) + { + buffer << DELIMITER_CHAR; + _file_buffer.erase( 0, 2 ); + } + else if( _file_buffer[1] == LINE_BREAK_CHAR ) + { + buffer << '\n'; + _file_buffer.erase( 0, 2 ); + } + else + { + more_text = false; + + const std::string text = buffer.str(); + buffer.str( std::string() ); + add_child_to_recipe( SX_MAKE_UNIQUE( text ) ); + } + } + else + { + throw sx::genesis::genesis_exception( "File '%' ends with a delimiter char!", template_file_ ); + } + } + else + { + more_text = false; + sxe::SX_UNIQUE_PTR new_text_step = SX_MAKE_UNIQUE( buffer.str() + _file_buffer ); + buffer.str( std::string() ); + if( is_any_recipe_open() ) + { + throw sx::genesis::genesis_exception( "A condition/loop not closed in file '%'!", template_file_ ); + } + else + { + add_child( sxe::move( new_text_step ) ); + _file_buffer.clear(); + } + } + } +} + + +std::string template_block::get_keyword( std::string& _file_buffer ) +{ + std::size_t position; + if( keywords_.empty() ) + { + position = _file_buffer.find( OPEN_PARENTHESIS_CHAR ); + } + else + { + if( _file_buffer.substr( 0, get_last_to_be_closed().length() ) == get_last_to_be_closed() ) + { + position = get_last_to_be_closed().length(); + } + else + { + position = _file_buffer.find( OPEN_PARENTHESIS_CHAR ); + } + } + + std::string keyword = ""; + if( position != std::string::npos ) + { + keyword = _file_buffer.substr( 0, position ); + } + else + { + throw sx::genesis::genesis_exception( "No command found!" ); + } + return ( keyword ); +} + + +void template_block::get_variable( std::string &_file_buffer ) +{ + _file_buffer.erase( 0, VARIABLE_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( parameters.size() != 1 ) + { + throw sx::genesis::genesis_exception( "Variable command does not have exactly 1 parameter in file '%'!", template_file_ ); + } + else + { + add_child_to_recipe( SX_MAKE_UNIQUE( parameters[0] ) ); + } +} + + +void template_block::get_loop( std::string &_file_buffer ) +{ + _file_buffer.erase( 0, LOOP_START_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( parameters.size() != 1 ) + { + throw sx::genesis::genesis_exception( "Loop command does not have exactly 1 parameter in file '%'!", template_file_ ); + } + else + { + sxe::SX_UNIQUE_PTR new_loop_block = SX_MAKE_UNIQUE( parameters[0] ); + loop_block* new_loop_block_ptr = new_loop_block.get(); + add_child_to_recipe( sxe::move( new_loop_block ) ); + opened_recipes_.push( new_loop_block_ptr ); + keywords_.push_back( LOOP_END_COMMAND ); + } +} + + +void template_block::get_if( std::string &_file_buffer ) +{ + keywords_.push_back( IF_END_COMMAND ); + _file_buffer.erase( 0, IF_START_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( parameters.size() != 1 && parameters.size() != 2 ) + { + throw sx::genesis::genesis_exception( "No sufficient parameters provided for 'if' command in file '%'!", template_file_ ); + } + else + { + sxe::SX_UNIQUE_PTR new_condition_block; + if( parameters.size() > 1 ) + { + new_condition_block = + SX_MAKE_UNIQUE( parameters[0], get_condition_modifier_from_string( parameters[1] ) ); + } + else + { + new_condition_block = + SX_MAKE_UNIQUE( parameters[0], condition_modifier::NONE ); + } + condition_block* new_condition_block_ptr = new_condition_block.get(); + add_child_to_recipe( sxe::move( new_condition_block ) ); + opened_recipes_.push( new_condition_block_ptr ); + } +} + + +void template_block::get_switch( std::string& _file_buffer ) +{ + _file_buffer.erase( 0, SWITCH_START_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( parameters.size() != 1 ) + { + throw sx::genesis::genesis_exception( "Switch command has not exactly 1 parameter in file '%'!", template_file_ ); + } + else + { + sxe::SX_UNIQUE_PTR new_switch_block = SX_MAKE_UNIQUE( parameters[0] ); + switch_block* new_switch_block_ptr = new_switch_block.get(); + add_child_to_recipe( sxe::move( new_switch_block ) ); + opened_recipes_.push( new_switch_block_ptr ); + keywords_.push_back( SWITCH_END_COMMAND ); + } +} + + +void template_block::get_switch_case( std::string& _file_buffer ) +{ + _file_buffer.erase( 0, SWITCH_CASE_START_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( parameters.size() != 1 ) + { + throw sx::genesis::genesis_exception( "Switch case command has not exactly 1 parameter in file '%'!", template_file_ ); + } + else + { + if( opened_recipes_.empty() ) + { + throw sx::genesis::genesis_exception( "There is no switch for the switch case in '%'!", template_file_ ); + } + else + { + switch_block* switch_ = dynamic_cast< switch_block* >( opened_recipes_.top() ); + if( switch_ ) + { + int index = 0; + sxe::string_to_int( parameters[0].c_str(), index ); + switch_->set_case_index( index ); + keywords_.push_back( SWITCH_CASE_END_COMMAND ); + } + else + { + throw sx::genesis::genesis_exception( "There is no switch for the switch case in '%'!", template_file_ ); + } + } + } +} + + +void template_block::get_switch_default( std::string& _file_buffer ) +{ + _file_buffer.erase( 0, SWITCH_DEFAULT_START_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( !parameters.empty()) + { + throw sx::genesis::genesis_exception( "Switch default command must have no parameters in file '%'!", template_file_ ); + } + else + { + if( opened_recipes_.empty() ) + { + throw sx::genesis::genesis_exception( "There is no switch for the default case in '%'!", template_file_ ); + } + else + { + switch_block* switch_ = dynamic_cast< switch_block* >( opened_recipes_.top() ); + if( switch_ ) + { + switch_->set_case_index( SWITCH_DEFAULT_INDEX_VALUE ); + keywords_.push_back( SWITCH_DEFAULT_END_COMMAND ); + } + else + { + throw sx::genesis::genesis_exception( "There is no switch for the switch default in '%'!", template_file_ ); + } + } + } +} + + +void template_block::get_template( std::string &_file_buffer ) +{ + _file_buffer.erase( 0, TEMPLATE_COMMAND.length() + SIZE_ONE ); + const std::vector parameters = get_parameters( _file_buffer ); + if( parameters.empty() ) + { + throw sx::genesis::genesis_exception( "No sufficient parameters provided for 'template' command in file '%'!", template_file_ ); + } + else + { + add_child_to_recipe( SX_MAKE_UNIQUE( parameters[0], template_path_ ) ); + } +} + + +const std::string template_block::get_last_to_be_closed() const +{ + const std::string last_element = keywords_.back(); + return( last_element ); +} + + +std::string template_block::read_template_file( const std::string& _template_name, const std::string& _templates_path ) +{ + std::string template_file_as_string; + read( _templates_path + "/" + _template_name, template_file_as_string ); + if( template_file_as_string.empty() ) + { + std::cout << "Template file '" << _template_name << "' is empty!" << std::endl; + } + return( template_file_as_string ); +} + + +void template_block::check_new_line_after_end_command( std::string &_file_buffer ) +{ + if( _file_buffer.length() > 2 ) + { + if( _file_buffer[0] == NEW_LINE_CHAR ) + { + _file_buffer.erase( 0, 1 ); + } + } +} + + +void template_block::close_loop( std::string& _file_buffer ) +{ + const std::size_t position = _file_buffer.find( LOOP_END_COMMAND ); + _file_buffer.erase( 0, position + LOOP_END_COMMAND.length() ); + check_new_line_after_end_command( _file_buffer ); + keywords_.pop_back(); + opened_recipes_.pop(); +} + + +void template_block::close_condition( std::string& _file_buffer ) +{ + const std::size_t position = _file_buffer.find( IF_END_COMMAND ); + _file_buffer.erase( 0, position + IF_END_COMMAND.length() ); + check_new_line_after_end_command( _file_buffer ); + keywords_.pop_back(); + opened_recipes_.pop(); +} + + +void template_block::close_switch( std::string& _file_buffer ) +{ + const std::size_t position = _file_buffer.find( SWITCH_END_COMMAND ); + _file_buffer.erase( 0, position + SWITCH_END_COMMAND.length() ); + check_new_line_after_end_command( _file_buffer ); + keywords_.pop_back(); + opened_recipes_.pop(); +} + + +void template_block::close_switch_case( std::string& _file_buffer ) +{ + const std::size_t position = _file_buffer.find( SWITCH_CASE_END_COMMAND ); + _file_buffer.erase( 0, position + SWITCH_CASE_END_COMMAND.length() ); + check_new_line_after_end_command( _file_buffer ); + keywords_.pop_back(); +} + + +void template_block::close_switch_default( std::string& _file_buffer ) +{ + const std::size_t position = _file_buffer.find( SWITCH_DEFAULT_END_COMMAND ); + _file_buffer.erase( 0, position + SWITCH_DEFAULT_END_COMMAND.length() ); + check_new_line_after_end_command( _file_buffer ); + keywords_.pop_back(); +} + + +bool template_block::is_any_recipe_open() const +{ + return( !opened_recipes_.empty() ); +} + + +std::vector template_block::get_parameters( std::string& _file_buffer ) const +{ + std::vector parameters; + std::size_t stop_position = _file_buffer.find( CLOSE_PARENTHESIS_CHAR ); + std::string string_parameters = _file_buffer.substr( 0, stop_position ); + _file_buffer.erase( 0, stop_position + SIZE_ONE ); + + string_parameters.erase( std::remove_if( string_parameters.begin(), string_parameters.end(), ::isspace ), string_parameters.end() ); + + std::string step; + std::istringstream stream( string_parameters ); + while( getline( stream, step, ',' ) ) + { + parameters.push_back( step ); + } + + return( parameters ); +} + + +void template_block::final_check() const +{ + SX_ASSERT( template_to_parse_.empty(), "The file buffer was not completely parsed!" ); + + if( !keywords_.empty() ) + { + std::string command = keywords_.back(); + if( command == LOOP_END_COMMAND ) + { + command = LOOP_START_COMMAND; + } + else if( command == IF_END_COMMAND ) + { + command = IF_START_COMMAND; + } + else + { + sx::genesis::genesis_exception( "Unknown command end: '%'!", command ); + } + + sx::genesis::genesis_exception( "Command '%' does not have a close command in file '%'!", template_file_ ); + } + + if( !opened_recipes_.empty() ) + { + sx::genesis::genesis_exception( "Internal error! Not all recipes were processed at the end of generation." ); + } +} + +} + +} diff --git a/genesis/source/text_step.cpp b/genesis/source/text_step.cpp new file mode 100644 index 0000000..f010ef7 --- /dev/null +++ b/genesis/source/text_step.cpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "text_step.hpp" + +#include "essentials/base.hpp" + +#include "recipe_callback.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +text_step::text_step( const std::string& _text ) : + recipe_step(), + text_( _text ) +{ + // Nothing to do... +} + + +text_step::~text_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void text_step::create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + SX_UNUSED_PARAMETER( _recipe_callback ); + _ostream << text_; +} + + +} + + +} diff --git a/genesis/source/variable_step.cpp b/genesis/source/variable_step.cpp new file mode 100644 index 0000000..fbd1d28 --- /dev/null +++ b/genesis/source/variable_step.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "variable_step.hpp" + +#include "recipe_callback.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +variable_step::variable_step( const std::string& _variable_name ) : + recipe_step(), + variable_name_( _variable_name ) +{ + // Nothing to do... +} + + +variable_step::~variable_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void variable_step::create( recipe_callback& _recipe_callback, std::stringstream& _ostream ) +{ + _ostream << _recipe_callback.get_variable_content( variable_name_ ); +} + + +} + + +} diff --git a/genesis/source/version.cpp b/genesis/source/version.cpp new file mode 100644 index 0000000..f762998 --- /dev/null +++ b/genesis/source/version.cpp @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex genesis library (http://genesis.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://genesis.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include + +#include "essentials/sxprintf.hpp" + +#include "version.hpp" +#include "build_number.hpp" + + +namespace sx +{ + + +namespace genesis +{ + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 0 ); +const sxe::uint16_t VERSION_MINOR( 2 ); +const sxe::uint16_t VERSION_PATCH( 0 ); + + +} + + +// cppcheck-suppress unusedFunction +void log_version() +{ + std::cout << sxe::sxprintf( "genesis library version %.%.%.%.", get_major_version(), + get_minor_version(), get_patch_version(), get_build_number() ) << std::endl; +} + + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( BUILD_NUMBER ); +} + + +} + + +} + + +} diff --git a/libyasmine/changelog.txt b/libyasmine/changelog.txt index 25dd58e..87cea83 100644 --- a/libyasmine/changelog.txt +++ b/libyasmine/changelog.txt @@ -1,265 +1,270 @@ -# Change log -All notable changes to this project are documented in this file. - -##[1.1.1] - 2017-04-07 - -### Added -� SX_NO_ASSIGNMENT_OPERATOR in exception template class (created using SX_EXCEPTION macro) - -### Changed -� Y_CONSTEXPR to SX_CONSTEXPR -� Y_FINAL to SX_FINAL -� Y_NOEXCEPT to SX_NOEXCEPT -� Y_OVERRIDE to SX_OVERRIDE -� Y_NO_COPY to SX_NO_COPY -� Y_NO_COPY_OPERATOR_EQUAL to SX_NO_ASSIGNMENT_OPERATOR -� Y_UNIQUE_PTR to SX_UNIQUE_PTR -� Y_MAKE_UNIQUE to SX_MAKE_UNIQUE -� sxy::shared_ptr to sxe::shared_ptr -� Y_MAKE_SHARED to SX_MAKE_SHARED -� Y_UNUSED_PARAMETER to SX_UNUSED_PARAMETER -� preprocessor definition Y_NO_LOGGING to SX_NO_LOGGING -� Y_LOG to SX_LOG -� Y_LOG_HEX to SX_LOG_HEX -� Y_ASSERT to SX_ASSERT -� Y_NULLPTR to SX_NULLPTR -� Y_FOR to SX_FOR -� preprocessor definition Y_CPP03_BOOST to SX_CPP03_BOOST -� preprocessor definition Y_NO_STD_MAKE_UNIQUE to SX_NO_STD_MAKE_UNIQUE -� preprocessor definition Y_NO_WINDOWS_H to SX_NO_WINDOWS_H - -### Fixed -� log double quote -� log messages -� code documentation improvements. - -### Deprecated -� macro Y_CONSTEXPR use SX_CONSTEXPR instead -� macro Y_FINAL use SX_FINAL instead -� macro Y_NOEXCEPT use SX_NOEXCEPT instead -� macro Y_OVERRIDE use SX_OVERRIDE instead -� macro Y_NO_COPY use SX_NO_COPY instead -� macro Y_NO_COPY_OPERATOR_EQUAL use SX_NO_ASSIGNMENT_OPERATOR instead -� macro Y_UNIQUE_PTR use SX_UNIQUE_PTR instead -� macro Y_MAKE_UNIQUE use SX_MAKE_UNIQUE instead -� sxy::shared_ptr use sxe::shared_ptr instead -� macro Y_MAKE_SHARED use SX_MAKE_SHARED instead -� macro Y_UNUSED_PARAMETER use SX_UNUSED_PARAMETER instead -� preprocessor definition Y_NO_LOGGING use SX_NO_LOGGING instead -� macro Y_LOG use SX_LOG instead -� macro Y_LOG_HEX use SX_LOG_HEX instead -� macro Y_ASSERT use SX_ASSERT instead -� macro Y_NULLPTR use SX_NULLPTR instead -� macro Y_FOR use SX_FOR instead -� preprocessor definition Y_CPP03_BOOST use SX_CPP03_BOOST instead -� preprocessor definition Y_NO_STD_MAKE_UNIQUE use SX_NO_STD_MAKE_UNIQUE instead -� preprocessor definition Y_NO_WINDOWS_H use SX_NO_WINDOWS_H instead - - -##[1.1.0] - 2017-03-06 - -### Added -• (C++11) overloaded macro Y_BEHAVIOR_METHOD2 with support for up to 10 parameters, replacing Y_BEHAVIOR_METHOD and Y_BEHAVIOR_METHOD_EVENT -• (C++11) overloaded macro Y_BEHAVIOR_FUNCTION2 with support for up to 10 parameters, replacing Y_BEHAVIOR_FUNCTION and Y_BEHAVIOR_FUNCTION_EVENT -• (C++11) overloaded macro Y_GUARD_METHOD2 with support for up to 10 parameters, replacing Y_GUARD_METHOD -• (C++11) overloaded macro Y_GUARD_FUNCTION2 with support for up to 10 parameters, replacing Y_GUARD_FUNCTION -• (C++11) Y_BEHAVIOR_ACTION macro for using any type of action as a behavior. -• (C++11) Y_GUARD_ACTION macro for using any type of action returning bool as a guard. -• Y_EVENT_WITH_PRIORITY_CREATE overloaded macro for creating event class with event priority. It supports up to 10 event parameters. -• Y_NO_WINDOWS_H macro: suppress inclusion of windows.h -• new check for a transition emanating from an initial pseudostate: The transition has to target a state inside the initial pseudostate's region. -• Y_EVENT_WITH_PRIORITY_CREATE overloaded macro for creating event classes with up to 10 parameters and event priority -• logging of state machine construction -• overloaded methods to add transitions that are enabled for multiple event IDs to state machine -• log when a pseudostate is reached by a transition -• interrupt method for the state machine: abort a state machine run even during a compound transition -• possibility to fire event from within states and transitions -• new example for demonstrating the feature of firing events from states and transitions - -### Changed -• moved 'conversion.hpp' from 'include_impl' to 'include' -• 'halt' method of asynchronous behavior was renamed to 'halt_and_join' - -### Fixed -• broken log message when displaying event priority - -### Deprecated -• macro Y_BEHAVIOR_METHOD use Y_BEHAVIOR_METHOD2 instead -• macro Y_BEHAVIOR_METHOD_NO_EVENT use Y_BEHAVIOR_METHOD2 instead -• macro Y_BEHAVIOR_FUNCTION use Y_BEHAVIOR_FUNCTION2 instead -• macro Y_BEHAVIOR_FUNCTION_NO_EVENT use Y_BEHAVIOR_FUNCTION2 instead -• macro Y_GUARD_METHOD use Y_GUARD_METHOD2 instead -• macro Y_GUARD_METHOD_NO_EVENT use Y_GUARD_METHOD2 instead -• macro Y_GUARD_FUNCTION_NO_EVENT use Y_GUARD_FUNCTION2 instead -• macro Y_GUARD_FUNCTION use Y_GUARD_FUNCTION2 instead -• macros Y_EVENT_1PARAM_WITH_ID to Y_EVENT_10PARAM_WITH_ID use Y_EVENT_CREATE instead -• macro Y_EVENT_WITH_ID use Y_EVENT_CREATE instead -• macros Y_EVENT_1PARAM_WITH_ID_PRIORITY to Y_EVENT_10PARAM_WITH_ID_PRIORITY use Y_EVENT_WITH_PRIORITY_CREATE instead -• macro Y_EVENT_WITH_ID_PRIORITY use Y_EVENT_WITH_PRIORITY_CREATE instead -• typedef state_machine. Use sync_state_machine instead. - - -##[1.0.1] - 2017-02-08 - -### Changed -• 'halt' method of asynchronous behavior was renamed to 'halt_and_join' - -### Fixed -• bug: Halting an async_state_machine lead to state machine::halt being called before joining the thread that processes events. -This could trigger an assert if there were still events enqueued for processing. Also this could lead to the premature termination -of async do behaviors or to async do behaviors not being terminated at all. - - -##[1.0.0] - 2017-01-20 - -### Added -• The logger now has got a halt_and_join method. -• Logging: A message that can be waited for. Needed for SX_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 -• 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 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 behavior that does nothing -• CMake files for generators under Windows (Visual Studio) and Linux (gcc, clang) - - -##[0.4.0] - 2016-10-07 - -### Added -• Y_OPTIMIZE_4_SPEED and Y_OPTIMIZE_4_MEMORY macros for internal optimization of ancestor lists (performance improvements) -• Y_PROFILER macro was added. When compiled with this macro, the state machine will count the events that were processed. - -### Changed -• 'LL_OFF' as default log level -• assembly.hpp macros were improved to avoid ambiguous function calls -• when Y_NO_LOGGING is defined, no log code will be compiled into the library at all -• moved default implementation of dtor into cpp (behavior_impl and constraint_impl) -• removed namespace from assembly.hpp -• removed usage of unique pointer from timed event creator (performance improvements) -• The handle generator for the timed events is no longer a random function. -• vectors used inside algorithm are now created with a default capacity (performance improvements) - -### Fixed -• error when compiling with gcc (const std::string transition_impl::get_transition_name) -• warnings concerning override when compiling with Clang -• if Y_NO_LOGGING is defined, the function 'log_version' is hidden -• a bug in the check of incoming transitions of a join - - -##[0.3.0] - 2016-09-16 - -### 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 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 -• log macro Y_LOG_HEX for logging hex editor style messages -• get_name method for events. It returns the ID of the event as a string if not overloaded -• event_template.hpp containing macros to created event_impl sub classes with fixed ID and priority (EVENT_WITH_ID, EVENT_WITH_ID_PRIORITY) - - -### Changed -•The extension of the headers is now .hpp instead of .h. -• 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 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' - -• code improvements (e.g. reference instead of pointer in signature of async_behavior::run) - -• Removed the name parameter from transition and implicitly from state_machine::add_transition. A generated transition name can be retrieved by calling get_name() - -### Fixed -• improved texts and log levels of logging calls -• The forward declaration headers of classes are now consistently included in the header of the corresponding class. Thus duplicated included headers could be removed -• 'event_priority = std::int8_t' instead of 'event_priority = int8_t' -• Problem with the URI of the state machine elements. Now, the URI contains all the element's ancestors - - -##[0.2.0] - 2016-08-19 - -### Added -• asynchronous simple state -• error handling for simple states -• collection headers: yasmine.h, states.h, region_pseudostate.h, state_pseudostates.h, logging.h. - -### Changed -• Source code formatting (class names, variable names, and other minor changes). -• updated license - - -##[0.1.1] - 2016-07-22 - -### Changed -• source code formatting (class names, variable names, and other minor changes). -• updated license - - -##[0.1.0] - 2016-06-20 - -• The very first released version of yasmine \ No newline at end of file +# Change log +All notable changes to this project are documented in this file. + +##[1.1.2] - 2017-04-25 + +### Changed +• uri class moved to essentials + + +##[1.1.1] - 2017-04-07 + +### Added +• SX_NO_ASSIGNMENT_OPERATOR in exception template class (created using SX_EXCEPTION macro) + +### Changed +• Y_CONSTEXPR to SX_CONSTEXPR +• Y_FINAL to SX_FINAL +• Y_NOEXCEPT to SX_NOEXCEPT +• Y_OVERRIDE to SX_OVERRIDE +• Y_NO_COPY to SX_NO_COPY +• Y_NO_COPY_OPERATOR_EQUAL to SX_NO_ASSIGNMENT_OPERATOR +• Y_UNIQUE_PTR to SX_UNIQUE_PTR +• Y_MAKE_UNIQUE to SX_MAKE_UNIQUE +• sxy::shared_ptr to sxe::shared_ptr +• Y_MAKE_SHARED to SX_MAKE_SHARED +• Y_UNUSED_PARAMETER to SX_UNUSED_PARAMETER +• preprocessor definition Y_NO_LOGGING to SX_NO_LOGGING +• Y_LOG to SX_LOG +• Y_LOG_HEX to SX_LOG_HEX +• Y_ASSERT to SX_ASSERT +• Y_NULLPTR to SX_NULLPTR +• Y_FOR to SX_FOR +• preprocessor definition Y_CPP03_BOOST to SX_CPP03_BOOST +• preprocessor definition Y_NO_STD_MAKE_UNIQUE to SX_NO_STD_MAKE_UNIQUE +• preprocessor definition Y_NO_WINDOWS_H to SX_NO_WINDOWS_H + +### Fixed +• log double quote +• log messages +• code documentation improvements. + +### Deprecated +• macro Y_CONSTEXPR use SX_CONSTEXPR instead +• macro Y_FINAL use SX_FINAL instead +• macro Y_NOEXCEPT use SX_NOEXCEPT instead +• macro Y_OVERRIDE use SX_OVERRIDE instead +• macro Y_NO_COPY use SX_NO_COPY instead +• macro Y_NO_COPY_OPERATOR_EQUAL use SX_NO_ASSIGNMENT_OPERATOR instead +• macro Y_UNIQUE_PTR use SX_UNIQUE_PTR instead +• macro Y_MAKE_UNIQUE use SX_MAKE_UNIQUE instead +• sxy::shared_ptr use sxe::shared_ptr instead +• macro Y_MAKE_SHARED use SX_MAKE_SHARED instead +• macro Y_UNUSED_PARAMETER use SX_UNUSED_PARAMETER instead +• preprocessor definition Y_NO_LOGGING use SX_NO_LOGGING instead +• macro Y_LOG use SX_LOG instead +• macro Y_LOG_HEX use SX_LOG_HEX instead +• macro Y_ASSERT use SX_ASSERT instead +• macro Y_NULLPTR use SX_NULLPTR instead +• macro Y_FOR use SX_FOR instead +• preprocessor definition Y_CPP03_BOOST use SX_CPP03_BOOST instead +• preprocessor definition Y_NO_STD_MAKE_UNIQUE use SX_NO_STD_MAKE_UNIQUE instead +• preprocessor definition Y_NO_WINDOWS_H use SX_NO_WINDOWS_H instead + + +##[1.1.0] - 2017-03-06 + +### Added +• (C++11) overloaded macro Y_BEHAVIOR_METHOD2 with support for up to 10 parameters, replacing Y_BEHAVIOR_METHOD and Y_BEHAVIOR_METHOD_EVENT +• (C++11) overloaded macro Y_BEHAVIOR_FUNCTION2 with support for up to 10 parameters, replacing Y_BEHAVIOR_FUNCTION and Y_BEHAVIOR_FUNCTION_EVENT +• (C++11) overloaded macro Y_GUARD_METHOD2 with support for up to 10 parameters, replacing Y_GUARD_METHOD +• (C++11) overloaded macro Y_GUARD_FUNCTION2 with support for up to 10 parameters, replacing Y_GUARD_FUNCTION +• (C++11) Y_BEHAVIOR_ACTION macro for using any type of action as a behavior. +• (C++11) Y_GUARD_ACTION macro for using any type of action returning bool as a guard. +• Y_EVENT_WITH_PRIORITY_CREATE overloaded macro for creating event class with event priority. It supports up to 10 event parameters. +• Y_NO_WINDOWS_H macro: suppress inclusion of windows.h +• new check for a transition emanating from an initial pseudostate: The transition has to target a state inside the initial pseudostate's region. +• Y_EVENT_WITH_PRIORITY_CREATE overloaded macro for creating event classes with up to 10 parameters and event priority +• logging of state machine construction +• overloaded methods to add transitions that are enabled for multiple event IDs to state machine +• log when a pseudostate is reached by a transition +• interrupt method for the state machine: abort a state machine run even during a compound transition +• possibility to fire event from within states and transitions +• new example for demonstrating the feature of firing events from states and transitions + +### Changed +• moved 'conversion.hpp' from 'include_impl' to 'include' +• 'halt' method of asynchronous behavior was renamed to 'halt_and_join' + +### Fixed +• broken log message when displaying event priority + +### Deprecated +• macro Y_BEHAVIOR_METHOD use Y_BEHAVIOR_METHOD2 instead +• macro Y_BEHAVIOR_METHOD_NO_EVENT use Y_BEHAVIOR_METHOD2 instead +• macro Y_BEHAVIOR_FUNCTION use Y_BEHAVIOR_FUNCTION2 instead +• macro Y_BEHAVIOR_FUNCTION_NO_EVENT use Y_BEHAVIOR_FUNCTION2 instead +• macro Y_GUARD_METHOD use Y_GUARD_METHOD2 instead +• macro Y_GUARD_METHOD_NO_EVENT use Y_GUARD_METHOD2 instead +• macro Y_GUARD_FUNCTION_NO_EVENT use Y_GUARD_FUNCTION2 instead +• macro Y_GUARD_FUNCTION use Y_GUARD_FUNCTION2 instead +• macros Y_EVENT_1PARAM_WITH_ID to Y_EVENT_10PARAM_WITH_ID use Y_EVENT_CREATE instead +• macro Y_EVENT_WITH_ID use Y_EVENT_CREATE instead +• macros Y_EVENT_1PARAM_WITH_ID_PRIORITY to Y_EVENT_10PARAM_WITH_ID_PRIORITY use Y_EVENT_WITH_PRIORITY_CREATE instead +• macro Y_EVENT_WITH_ID_PRIORITY use Y_EVENT_WITH_PRIORITY_CREATE instead +• typedef state_machine. Use sync_state_machine instead. + + +##[1.0.1] - 2017-02-08 + +### Changed +• 'halt' method of asynchronous behavior was renamed to 'halt_and_join' + +### Fixed +• bug: Halting an async_state_machine lead to state machine::halt being called before joining the thread that processes events. +This could trigger an assert if there were still events enqueued for processing. Also this could lead to the premature termination +of async do behaviors or to async do behaviors not being terminated at all. + + +##[1.0.0] - 2017-01-20 + +### 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 +• 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 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 behavior that does nothing +• CMake files for generators under Windows (Visual Studio) and Linux (gcc, clang) + + +##[0.4.0] - 2016-10-07 + +### Added +• Y_OPTIMIZE_4_SPEED and Y_OPTIMIZE_4_MEMORY macros for internal optimization of ancestor lists (performance improvements) +• Y_PROFILER macro was added. When compiled with this macro, the state machine will count the events that were processed. + +### Changed +• 'LL_OFF' as default log level +• assembly.hpp macros were improved to avoid ambiguous function calls +• when Y_NO_LOGGING is defined, no log code will be compiled into the library at all +• moved default implementation of dtor into cpp (behavior_impl and constraint_impl) +• removed namespace from assembly.hpp +• removed usage of unique pointer from timed event creator (performance improvements) +• The handle generator for the timed events is no longer a random function. +• vectors used inside algorithm are now created with a default capacity (performance improvements) + +### Fixed +• error when compiling with gcc (const std::string transition_impl::get_transition_name) +• warnings concerning override when compiling with Clang +• if Y_NO_LOGGING is defined, the function 'log_version' is hidden +• a bug in the check of incoming transitions of a join + + +##[0.3.0] - 2016-09-16 + +### 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 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 +• log macro Y_LOG_HEX for logging hex editor style messages +• get_name method for events. It returns the ID of the event as a string if not overloaded +• event_template.hpp containing macros to created event_impl sub classes with fixed ID and priority (EVENT_WITH_ID, EVENT_WITH_ID_PRIORITY) + +### Changed +•The extension of the headers is now .hpp instead of .h. +• 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 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' + +• code improvements (e.g. reference instead of pointer in signature of async_behavior::run) + +• Removed the name parameter from transition and implicitly from state_machine::add_transition. A generated transition name can be retrieved by calling get_name() + +### Fixed +• improved texts and log levels of logging calls +• The forward declaration headers of classes are now consistently included in the header of the corresponding class. Thus duplicated included headers could be removed +• 'event_priority = std::int8_t' instead of 'event_priority = int8_t' +• Problem with the URI of the state machine elements. Now, the URI contains all the element's ancestors + + +##[0.2.0] - 2016-08-19 + +### Added +• asynchronous simple state +• error handling for simple states +• collection headers: yasmine.h, states.h, region_pseudostate.h, state_pseudostates.h, logging.h. + +### Changed +• Source code formatting (class names, variable names, and other minor changes). +• updated license + + +##[0.1.1] - 2016-07-22 + +### Changed +• source code formatting (class names, variable names, and other minor changes). +• updated license + + +##[0.1.0] - 2016-06-20 + +• The very first released version of yasmine \ No newline at end of file diff --git a/libyasmine/include/algorithm_parameters.hpp b/libyasmine/include/algorithm_parameters.hpp index aa0b280..d32062c 100644 --- a/libyasmine/include/algorithm_parameters.hpp +++ b/libyasmine/include/algorithm_parameters.hpp @@ -1,44 +1,44 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD -#define ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD - - -namespace sxy -{ - - -extern const int TRANSITION_PRIORITIES_VECTOR_SIZE; -extern const int EXECUTION_STEPS_VECTOR_SIZE; -extern const int TRANSITION_STEPS_VECTOR_SIZE; -extern const int COMPOUND_TRANSITIONS_VECTOR_SIZE; -extern const int STATES_TO_EXIT_VECTOR_SIZE; -extern const int EXCEPTION_EVENTS_VECTOR_SIZE; -extern const int CHOICES_VECTOR_SIZE; -extern const int ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE; -extern const int DEFERRED_EVENTS_VECTOR_SIZE; -extern const int DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE; -extern const int ENTRY_POINTS_VECTOR_SIZE; -extern const int EXIT_POINTS_VECTOR_SIZE; -extern const int PSEUDOSTETS_IN_REGION_VECTOR_SIZE; -extern const int ANCESTORS_VECTOR_SIZE; -extern const int ASCENDING_PATH_ANCESTORS_VECTOR_SIZE; -extern const int REGIONS_OF_FINAL_STATE; -extern const int REGIONS_OF_SIMPLE_STATE; -extern const int ANCESTORS_REGION_VECTOR_SIZE; -extern const int ACTIVE_STATE_CONFIGRATION_VECTOR_SIZE; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD +#define ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD + + +namespace sxy +{ + + +extern const int TRANSITION_PRIORITIES_VECTOR_SIZE; +extern const int EXECUTION_STEPS_VECTOR_SIZE; +extern const int TRANSITION_STEPS_VECTOR_SIZE; +extern const int COMPOUND_TRANSITIONS_VECTOR_SIZE; +extern const int STATES_TO_EXIT_VECTOR_SIZE; +extern const int EXCEPTION_EVENTS_VECTOR_SIZE; +extern const int CHOICES_VECTOR_SIZE; +extern const int ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE; +extern const int DEFERRED_EVENTS_VECTOR_SIZE; +extern const int DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE; +extern const int ENTRY_POINTS_VECTOR_SIZE; +extern const int EXIT_POINTS_VECTOR_SIZE; +extern const int PSEUDOSTETS_IN_REGION_VECTOR_SIZE; +extern const int ANCESTORS_VECTOR_SIZE; +extern const int ASCENDING_PATH_ANCESTORS_VECTOR_SIZE; +extern const int REGIONS_OF_FINAL_STATE; +extern const int REGIONS_OF_SIMPLE_STATE; +extern const int ANCESTORS_REGION_VECTOR_SIZE; +extern const int ACTIVE_STATE_CONFIGRATION_VECTOR_SIZE; + + +} + + +#endif diff --git a/libyasmine/include/assembly.hpp b/libyasmine/include/assembly.hpp index 19654e8..dac9c6d 100644 --- a/libyasmine/include/assembly.hpp +++ b/libyasmine/include/assembly.hpp @@ -1,278 +1,278 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 -#define ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 - -#ifndef SX_CPP03_BOOST - #include -#endif - -#include "essentials/macro_helpers.hpp" - -#include "behavior_fwd.hpp" -#include "constraint_fwd.hpp" -#include "caller.hpp" -#include "guard_caller.hpp" - - -#ifndef SX_CPP03_BOOST - - -//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. -#define Y_BEHAVIOR_METHOD( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_SELECT, __VA_ARGS__ ) ) - -//!\brief Macro for using any type of action as a behavior. -#define Y_BEHAVIOR_ACTION( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_ACTION_SELECT, __VA_ARGS__ ) ) - -//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. -#define Y_BEHAVIOR_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) - -//!\deprecated Use Y_GUARD_METHOD2 instead. -#define Y_GUARD_METHOD( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_SELECT, __VA_ARGS__ ) ) - -//!\brief Macro for using any type of action returning bool as a guard. -#define Y_GUARD_ACTION( ... ) EXPAND( VA_SELECT( Y_GUARD_ACTION_SELECT, __VA_ARGS__ ) ) - -//!\deprecated Use Y_GUARD_METHOD2 instead. -#define Y_GUARD_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) - - -//!\brief Macro for using a class method as a behavior. -//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. -#define Y_BEHAVIOR_METHOD_SELECT_1( _method_name ) \ - sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ); } ) - -//!\brief Macro for using a class method as a behavior. -//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. -#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ); } ) - -//!\brief Macro for using any type of action as a behavior. -#define Y_BEHAVIOR_ACTION_SELECT_1( _action ) \ - sxy::behavior_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) - -//!\brief Macro for using any type of action as a behavior. -#define Y_BEHAVIOR_ACTION_SELECT_2( _class_name, _action ) \ - sxy::behavior_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) - -//!\brief Macro for using a class method as a behavior without an event. -//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. -#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_1( _method_name ) \ - sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); this->_method_name(); } ) - -//!\brief Macro for using a class method as a behavior without an event. -//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. -#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ - sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); this->_method_name(); } ) - -//!\brief Macro for using a class method as a guard. -//!\deprecated USE Y_GUARD_METHOD2 instead. -#define Y_GUARD_METHOD_SELECT_1( _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ return( SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ) ); } ) - -//!\brief Macro for using a class method as a guard. -//!\deprecated USE Y_GUARD_METHOD2 instead. -#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ return( SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ) ); } ) - -//!\brief Macro for using any type of action returning bool as a guard. -#define Y_GUARD_ACTION_SELECT_1( _action ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) - -//!\brief Macro for using any type of action returning bool as a guard. -#define Y_GUARD_ACTION_SELECT_2( _class_name, _action ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) - -//!\brief Macro for using a class method as a guard without an event. -//!\deprecated Use Y_GUARD_METHOD2 instead. -#define Y_GUARD_METHOD_NO_EVENT_SELECT_1( _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name() ); } ) - -//!\brief Macro for using a class method as a guard without an event. -//!\deprecated Use Y_GUARD_METHOD2 instead. -#define Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name() ); } ) - -//!\brief Macro for using a free function as a guard. -//!\deprecated Use Y_GUARD_FUNCTION2 instead. -#define Y_GUARD_FUNCTION( _function_name ) \ - sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { return( SX_UNUSED_PARAMETER(_event_collector); _function_name( _event ) ); } ) - -//!\brief Macro for using a free function as a guard without an event. -//!\deprecated Use Y_GUARD_FUNCTION2 instead. -#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ - sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( _function_name() ); } ) - -//!\brief Macro for using a free function as a behavior. -//!\deprecated Use Y_BEHAVIOR_FUNCTION2 instead. -#define Y_BEHAVIOR_FUNCTION( _function_name ) \ - sxy::behavior_function( []( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); _function_name( _event ); } ) - -//!\brief Macro for using a free function as a behavior without an event. -//!\deprecated Use Y_BEHAVIOR_FUNCTION2 instead. -#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ - sxy::behavior_function( []( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); _function_name(); } )\ - - -#else - - -#define Y_BEHAVIOR_METHOD( _class_name, _method_name ) Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) -#define Y_BEHAVIOR_METHOD_NO_EVENT( _class_name, _method_name ) Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) -#define Y_GUARD_METHOD( _class_name, _method_name ) Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) -#define Y_GUARD_METHOD_NO_EVENT( _class_name, _method_name ) Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) - -//!\brief Macro for using a class method as a behavior. -#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::behavior_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) - -//!\brief Macro for using a class method as a behavior without an event. -#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ - sxy::behavior_function( sxe::bind( &_class_name::_method_name, this ) ) - -#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::constraint_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) - -//!\brief Macro for using a class method as a guard without an event. -#define Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ - sxy::constraint_function( sxe::bind (&_class_name::_method_name, this ) ) - -//!\brief Macro for using a free function as a guard. -#define Y_GUARD_FUNCTION( _function_name ) \ - sxy::constraint_function( sxe::bind( &_function_name, sxe::_1 ) ) - -//!\brief Macro for using a free function as a guard without an event. -#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ - sxy::constraint_function( sxe::bind( &_function_name ) ) - -//!\brief Macro for using a free function as a behavior. -#define Y_BEHAVIOR_FUNCTION( _function_name ) \ - sxy::behavior_function( sxe::bind( &_function_name, sxe::_1 ) ) - -//!\brief Macro for using a free function as a behavior without an event. -#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ - sxy::behavior_function( sxe::bind( &_function_name ) ) - - -#endif - - -//!\brief Macro for an empty behavior. -#define Y_EMPTY_BEHAVIOR sxy::behavior_function() - - -//!\brief Macro for an empty guard. -#define Y_EMPTY_GUARD sxy::constraint_function() - - -#ifndef SX_CPP03_BOOST // C++11 only - // Macros for passing handlers as behavior - - //!\brief The macro creates a behavior_function for the specified method(s). - //!\ The macro is variadic and can take up to 10 class methods pointers as parameters. - //#define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) - #define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( Y_BEHAVIOR_METHOD2( this, __VA_ARGS__ ) ) - - //!\brief The macro creates a behavior_function for the specified function(s). - //!\ The macro is variadic and can take up to 10 function pointers as parameters. - #define Y_BEHAVIOR_FUNCTION_EVENT( ... ) EXPAND( Y_BEHAVIOR_FUNCTION2( __VA_ARGS__ ) ) - - -#define VA_SELECT_WITH_CLASS_INSTANCE( NAME, CLASS_INSTANCE, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )(CLASS_INSTANCE, __VA_ARGS__) ) - -//!\brief The macro creates a behavior_function for the specified method(s). -//!\ The macro is variadic and can take up to 10 class methods pointers as parameters. -#define Y_BEHAVIOR_METHOD2(CLASS_INSTANCE, ...) EXPAND( VA_SELECT_WITH_CLASS_INSTANCE(Y_BEHAVIOR_METHOD2_SELECT, CLASS_INSTANCE, __VA_ARGS__)) - -//!\brief The macro creates a behavior_function for the specified function(s). -//!\ The macro is variadic and can take up to 10 function pointers as parameters. -#define Y_BEHAVIOR_FUNCTION2(...) EXPAND( VA_SELECT(Y_BEHAVIOR_FUNCTION2_SELECT, __VA_ARGS__) ) - -//!\brief The macro creates a behavior_function for the specified method(s). -//!\ The macro is variadic and can take up to 10 class methods pointers as parameters. -#define Y_GUARD_METHOD2(CLASS_INSTANCE, ...) EXPAND( VA_SELECT_WITH_CLASS_INSTANCE(Y_GUARD_METHOD2_SELECT, CLASS_INSTANCE, __VA_ARGS__)) - -//!\brief The macro creates a guard_function for the specified function(s). -//!\ The macro is variadic and can take up to 10 function pointers as parameters. -#define Y_GUARD_FUNCTION2(...) EXPAND( VA_SELECT(Y_GUARD_FUNCTION2_SELECT, __VA_ARGS__) ) - -//!\brief The macro creates a constraint_function for the specified method(s). -//!\ The macro is variadic and can take up to 10 method pointers as parameters. -//#define Y_GUARD_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_GUARDR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) -#define Y_GUARD_METHOD_EVENT(...) EXPAND( Y_GUARD_METHOD2( this, __VA_ARGS__ ) ) - -//!\brief The macro creates a constraint_function for the specified function(s). -//!\ The macro is variadic and can take up to 10 function pointers as parameters. -#define Y_GUARD_FUNCTION_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_FUNCTION_EVENT_SELECT, __VA_ARGS__ ) ) - - -template< typename ... Args > -sxy::behavior_function create_behavior_function( Args...args ) -{ - return ( sxy::behavior_function( [ args... ]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, args... ); } ) ); -} - - -template< typename ... Args > -sxy::constraint_function create_guard_function( Args...args ) -{ - return ( sxy::constraint_function( [args...]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, args... ) ); } ) ); -} - - #define Y_BEHAVIOR_METHOD2_SELECT_1( _class_instance, _method ) create_behavior_function( adapt::type>( _class_instance, _method ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_2( _class_instance, _method1, _method2 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_3( _class_instance, _method1, _method2, _method3 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_4( _class_instance, _method1, _method2, _method3, _method4 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_5( _class_instance, _method1, _method2, _method3, _method4, _method5 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_6( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_7( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_8( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_9( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ) ) - #define Y_BEHAVIOR_METHOD2_SELECT_10( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ), adapt::type>( _class_instance, _method10 ) ) - - #define Y_GUARD_METHOD2_SELECT_1( _class_instance, _method ) create_guard_function( adapt::type>( _class_instance, _method ) ) - #define Y_GUARD_METHOD2_SELECT_2( _class_instance, _method1, _method2 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ) ) - #define Y_GUARD_METHOD2_SELECT_3( _class_instance, _method1, _method2, _method3 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ) ) - #define Y_GUARD_METHOD2_SELECT_4( _class_instance, _method1, _method2, _method3, _method4 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ) ) - #define Y_GUARD_METHOD2_SELECT_5( _class_instance, _method1, _method2, _method3, _method4, _method5 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ) ) - #define Y_GUARD_METHOD2_SELECT_6( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ) ) - #define Y_GUARD_METHOD2_SELECT_7( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ) ) - #define Y_GUARD_METHOD2_SELECT_8( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ) ) - #define Y_GUARD_METHOD2_SELECT_9( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ) ) - #define Y_GUARD_METHOD2_SELECT_10( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ), adapt::type>( _class_instance, _method10 ) ) - - #define Y_BEHAVIOR_FUNCTION2_SELECT_1( _function ) create_behavior_function( adapt_function( _function ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_2( _function1, _function2 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_3( _function1, _function2, _function3 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_4( _function1, _function2, _function3, _function4 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ) ) - #define Y_BEHAVIOR_FUNCTION2_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ), adapt_function( _function10 ) ) - - #define Y_GUARD_FUNCTION2_SELECT_1( _function ) create_guard_function( adapt_function( _function ) ) - #define Y_GUARD_FUNCTION2_SELECT_2( _function1, _function2 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ) ) - #define Y_GUARD_FUNCTION2_SELECT_3( _function1, _function2, _function3 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ) ) - #define Y_GUARD_FUNCTION2_SELECT_4( _function1, _function2, _function3, _function4 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ) ) - #define Y_GUARD_FUNCTION2_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ) ) - #define Y_GUARD_FUNCTION2_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ) ) - #define Y_GUARD_FUNCTION2_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ) ) - #define Y_GUARD_FUNCTION2_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ) ) - #define Y_GUARD_FUNCTION2_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ) ) - #define Y_GUARD_FUNCTION2_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ), adapt_function( _function10 ) ) - - -#endif - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 +#define ASSEMBLY_07A0176B_5967_4CDB_B7CF_624220170138 + +#ifndef SX_CPP03_BOOST + #include +#endif + +#include "essentials/macro_helpers.hpp" + +#include "behavior_fwd.hpp" +#include "constraint_fwd.hpp" +#include "caller.hpp" +#include "guard_caller.hpp" + + +#ifndef SX_CPP03_BOOST + + +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_SELECT, __VA_ARGS__ ) ) + +//!\brief Macro for using any type of action as a behavior. +#define Y_BEHAVIOR_ACTION( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_ACTION_SELECT, __VA_ARGS__ ) ) + +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) + +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_SELECT, __VA_ARGS__ ) ) + +//!\brief Macro for using any type of action returning bool as a guard. +#define Y_GUARD_ACTION( ... ) EXPAND( VA_SELECT( Y_GUARD_ACTION_SELECT, __VA_ARGS__ ) ) + +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_NO_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_METHOD_NO_EVENT_SELECT, __VA_ARGS__ ) ) + + +//!\brief Macro for using a class method as a behavior. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_SELECT_1( _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ); } ) + +//!\brief Macro for using a class method as a behavior. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ); } ) + +//!\brief Macro for using any type of action as a behavior. +#define Y_BEHAVIOR_ACTION_SELECT_1( _action ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using any type of action as a behavior. +#define Y_BEHAVIOR_ACTION_SELECT_2( _class_name, _action ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using a class method as a behavior without an event. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_1( _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); this->_method_name(); } ) + +//!\brief Macro for using a class method as a behavior without an event. +//!\deprecated Use Y_BEHAVIOR_METHOD2 instead. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); this->_method_name(); } ) + +//!\brief Macro for using a class method as a guard. +//!\deprecated USE Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_SELECT_1( _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ return( SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ) ); } ) + +//!\brief Macro for using a class method as a guard. +//!\deprecated USE Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ return( SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ) ); } ) + +//!\brief Macro for using any type of action returning bool as a guard. +#define Y_GUARD_ACTION_SELECT_1( _action ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using any type of action returning bool as a guard. +#define Y_GUARD_ACTION_SELECT_2( _class_name, _action ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event ){ SX_UNUSED_PARAMETER(_event); _action } ) + +//!\brief Macro for using a class method as a guard without an event. +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_1( _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name() ); } ) + +//!\brief Macro for using a class method as a guard without an event. +//!\deprecated Use Y_GUARD_METHOD2 instead. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name() ); } ) + +//!\brief Macro for using a free function as a guard. +//!\deprecated Use Y_GUARD_FUNCTION2 instead. +#define Y_GUARD_FUNCTION( _function_name ) \ + sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { return( SX_UNUSED_PARAMETER(_event_collector); _function_name( _event ) ); } ) + +//!\brief Macro for using a free function as a guard without an event. +//!\deprecated Use Y_GUARD_FUNCTION2 instead. +#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ + sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); return( _function_name() ); } ) + +//!\brief Macro for using a free function as a behavior. +//!\deprecated Use Y_BEHAVIOR_FUNCTION2 instead. +#define Y_BEHAVIOR_FUNCTION( _function_name ) \ + sxy::behavior_function( []( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); _function_name( _event ); } ) + +//!\brief Macro for using a free function as a behavior without an event. +//!\deprecated Use Y_BEHAVIOR_FUNCTION2 instead. +#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ + sxy::behavior_function( []( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event); SX_UNUSED_PARAMETER(_event_collector); _function_name(); } )\ + + +#else + + +#define Y_BEHAVIOR_METHOD( _class_name, _method_name ) Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) +#define Y_BEHAVIOR_METHOD_NO_EVENT( _class_name, _method_name ) Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) +#define Y_GUARD_METHOD( _class_name, _method_name ) Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) +#define Y_GUARD_METHOD_NO_EVENT( _class_name, _method_name ) Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) + +//!\brief Macro for using a class method as a behavior. +#define Y_BEHAVIOR_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) + +//!\brief Macro for using a class method as a behavior without an event. +#define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::behavior_function( sxe::bind( &_class_name::_method_name, this ) ) + +#define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) + +//!\brief Macro for using a class method as a guard without an event. +#define Y_GUARD_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ + sxy::constraint_function( sxe::bind (&_class_name::_method_name, this ) ) + +//!\brief Macro for using a free function as a guard. +#define Y_GUARD_FUNCTION( _function_name ) \ + sxy::constraint_function( sxe::bind( &_function_name, sxe::_1 ) ) + +//!\brief Macro for using a free function as a guard without an event. +#define Y_GUARD_FUNCTION_NO_EVENT( _function_name ) \ + sxy::constraint_function( sxe::bind( &_function_name ) ) + +//!\brief Macro for using a free function as a behavior. +#define Y_BEHAVIOR_FUNCTION( _function_name ) \ + sxy::behavior_function( sxe::bind( &_function_name, sxe::_1 ) ) + +//!\brief Macro for using a free function as a behavior without an event. +#define Y_BEHAVIOR_FUNCTION_NO_EVENT( _function_name ) \ + sxy::behavior_function( sxe::bind( &_function_name ) ) + + +#endif + + +//!\brief Macro for an empty behavior. +#define Y_EMPTY_BEHAVIOR sxy::behavior_function() + + +//!\brief Macro for an empty guard. +#define Y_EMPTY_GUARD sxy::constraint_function() + + +#ifndef SX_CPP03_BOOST // C++11 only + // Macros for passing handlers as behavior + + //!\brief The macro creates a behavior_function for the specified method(s). + //!\ The macro is variadic and can take up to 10 class methods pointers as parameters. + //#define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) + #define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( Y_BEHAVIOR_METHOD2( this, __VA_ARGS__ ) ) + + //!\brief The macro creates a behavior_function for the specified function(s). + //!\ The macro is variadic and can take up to 10 function pointers as parameters. + #define Y_BEHAVIOR_FUNCTION_EVENT( ... ) EXPAND( Y_BEHAVIOR_FUNCTION2( __VA_ARGS__ ) ) + + +#define VA_SELECT_WITH_CLASS_INSTANCE( NAME, CLASS_INSTANCE, ... ) EXPAND( SELECT( NAME, VA_SIZE(__VA_ARGS__) )(CLASS_INSTANCE, __VA_ARGS__) ) + +//!\brief The macro creates a behavior_function for the specified method(s). +//!\ The macro is variadic and can take up to 10 class methods pointers as parameters. +#define Y_BEHAVIOR_METHOD2(CLASS_INSTANCE, ...) EXPAND( VA_SELECT_WITH_CLASS_INSTANCE(Y_BEHAVIOR_METHOD2_SELECT, CLASS_INSTANCE, __VA_ARGS__)) + +//!\brief The macro creates a behavior_function for the specified function(s). +//!\ The macro is variadic and can take up to 10 function pointers as parameters. +#define Y_BEHAVIOR_FUNCTION2(...) EXPAND( VA_SELECT(Y_BEHAVIOR_FUNCTION2_SELECT, __VA_ARGS__) ) + +//!\brief The macro creates a behavior_function for the specified method(s). +//!\ The macro is variadic and can take up to 10 class methods pointers as parameters. +#define Y_GUARD_METHOD2(CLASS_INSTANCE, ...) EXPAND( VA_SELECT_WITH_CLASS_INSTANCE(Y_GUARD_METHOD2_SELECT, CLASS_INSTANCE, __VA_ARGS__)) + +//!\brief The macro creates a guard_function for the specified function(s). +//!\ The macro is variadic and can take up to 10 function pointers as parameters. +#define Y_GUARD_FUNCTION2(...) EXPAND( VA_SELECT(Y_GUARD_FUNCTION2_SELECT, __VA_ARGS__) ) + +//!\brief The macro creates a constraint_function for the specified method(s). +//!\ The macro is variadic and can take up to 10 method pointers as parameters. +//#define Y_GUARD_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_GUARDR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) +#define Y_GUARD_METHOD_EVENT(...) EXPAND( Y_GUARD_METHOD2( this, __VA_ARGS__ ) ) + +//!\brief The macro creates a constraint_function for the specified function(s). +//!\ The macro is variadic and can take up to 10 function pointers as parameters. +#define Y_GUARD_FUNCTION_EVENT( ... ) EXPAND( VA_SELECT( Y_GUARD_FUNCTION_EVENT_SELECT, __VA_ARGS__ ) ) + + +template< typename ... Args > +sxy::behavior_function create_behavior_function( Args...args ) +{ + return ( sxy::behavior_function( [ args... ]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, args... ); } ) ); +} + + +template< typename ... Args > +sxy::constraint_function create_guard_function( Args...args ) +{ + return ( sxy::constraint_function( [args...]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, args... ) ); } ) ); +} + + #define Y_BEHAVIOR_METHOD2_SELECT_1( _class_instance, _method ) create_behavior_function( adapt::type>( _class_instance, _method ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_2( _class_instance, _method1, _method2 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_3( _class_instance, _method1, _method2, _method3 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_4( _class_instance, _method1, _method2, _method3, _method4 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_5( _class_instance, _method1, _method2, _method3, _method4, _method5 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_6( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_7( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_8( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_9( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ) ) + #define Y_BEHAVIOR_METHOD2_SELECT_10( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) create_behavior_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ), adapt::type>( _class_instance, _method10 ) ) + + #define Y_GUARD_METHOD2_SELECT_1( _class_instance, _method ) create_guard_function( adapt::type>( _class_instance, _method ) ) + #define Y_GUARD_METHOD2_SELECT_2( _class_instance, _method1, _method2 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ) ) + #define Y_GUARD_METHOD2_SELECT_3( _class_instance, _method1, _method2, _method3 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ) ) + #define Y_GUARD_METHOD2_SELECT_4( _class_instance, _method1, _method2, _method3, _method4 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ) ) + #define Y_GUARD_METHOD2_SELECT_5( _class_instance, _method1, _method2, _method3, _method4, _method5 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ) ) + #define Y_GUARD_METHOD2_SELECT_6( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ) ) + #define Y_GUARD_METHOD2_SELECT_7( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ) ) + #define Y_GUARD_METHOD2_SELECT_8( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ) ) + #define Y_GUARD_METHOD2_SELECT_9( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ) ) + #define Y_GUARD_METHOD2_SELECT_10( _class_instance, _method1, _method2, _method3, _method4, _method5, _method6, _method7, _method8, _method9, _method10 ) create_guard_function( adapt::type>( _class_instance, _method1 ), adapt::type>( _class_instance, _method2 ), adapt::type>( _class_instance, _method3 ), adapt::type>( _class_instance, _method4 ), adapt::type>( _class_instance, _method5 ), adapt::type>( _class_instance, _method6 ), adapt::type>( _class_instance, _method7 ), adapt::type>( _class_instance, _method8 ), adapt::type>( _class_instance, _method9 ), adapt::type>( _class_instance, _method10 ) ) + + #define Y_BEHAVIOR_FUNCTION2_SELECT_1( _function ) create_behavior_function( adapt_function( _function ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_2( _function1, _function2 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_3( _function1, _function2, _function3 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_4( _function1, _function2, _function3, _function4 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ) ) + #define Y_BEHAVIOR_FUNCTION2_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) create_behavior_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ), adapt_function( _function10 ) ) + + #define Y_GUARD_FUNCTION2_SELECT_1( _function ) create_guard_function( adapt_function( _function ) ) + #define Y_GUARD_FUNCTION2_SELECT_2( _function1, _function2 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ) ) + #define Y_GUARD_FUNCTION2_SELECT_3( _function1, _function2, _function3 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ) ) + #define Y_GUARD_FUNCTION2_SELECT_4( _function1, _function2, _function3, _function4 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ) ) + #define Y_GUARD_FUNCTION2_SELECT_5( _function1, _function2, _function3, _function4, _function5 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ) ) + #define Y_GUARD_FUNCTION2_SELECT_6( _function1, _function2, _function3, _function4, _function5, _function6 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ) ) + #define Y_GUARD_FUNCTION2_SELECT_7( _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ) ) + #define Y_GUARD_FUNCTION2_SELECT_8( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ) ) + #define Y_GUARD_FUNCTION2_SELECT_9( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ) ) + #define Y_GUARD_FUNCTION2_SELECT_10( _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) create_guard_function( adapt_function( _function1 ), adapt_function( _function2 ), adapt_function( _function3 ), adapt_function( _function4 ), adapt_function( _function5 ), adapt_function( _function6 ), adapt_function( _function7 ), adapt_function( _function8 ), adapt_function( _function9 ), adapt_function( _function10 ) ) + + +#endif + +#endif diff --git a/libyasmine/include/async_behavior.hpp b/libyasmine/include/async_behavior.hpp index 8b3c1eb..f71c8d8 100644 --- a/libyasmine/include/async_behavior.hpp +++ b/libyasmine/include/async_behavior.hpp @@ -1,67 +1,66 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB -#define ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB - - -#include "essentials/non_copyable.hpp" -#include "essentials/compatibility/thread.hpp" - -#include "async_behavior_fwd.hpp" - - -namespace sxy -{ - - -class event; -class simple_state_base; -class async_event_handler; -class event_collector; - - -class async_behavior -{ - - -public: - async_behavior(); - virtual ~async_behavior() SX_NOEXCEPT; - SX_NO_COPY(async_behavior) - void run( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); - void halt_and_join(); - - -protected: - bool should_stop() const; - - -private: - void work( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, - async_event_handler& _async_event_handler ); - virtual void run_impl( const event& _event, event_collector& _event_collector, - async_event_handler& _async_event_handler ) = 0; - virtual void notify_should_stop(); - void join(); - - sxe::SX_UNIQUE_PTR worker_; - mutable sxe::mutex mutex_; - bool run_; - - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB +#define ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB + + +#include "essentials/non_copyable.hpp" +#include "essentials/compatibility/thread.hpp" + +#include "async_behavior_fwd.hpp" + + +namespace sxy +{ + + +class event; +class simple_state_base; +class async_event_handler; +class event_collector; + + +class async_behavior +{ + + +public: + async_behavior(); + virtual ~async_behavior() SX_NOEXCEPT; + SX_NO_COPY(async_behavior) + void run( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); + void halt_and_join(); + +protected: + bool should_stop() const; + + +private: + void work( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, + async_event_handler& _async_event_handler ); + virtual void run_impl( const event& _event, event_collector& _event_collector, + async_event_handler& _async_event_handler ) = 0; + virtual void notify_should_stop(); + void join(); + + sxe::SX_UNIQUE_PTR worker_; + mutable sxe::mutex mutex_; + bool run_; + + +}; + + +} + + +#endif diff --git a/libyasmine/include/async_behavior_fwd.hpp b/libyasmine/include/async_behavior_fwd.hpp index 8a54903..85c47a8 100644 --- a/libyasmine/include/async_behavior_fwd.hpp +++ b/libyasmine/include/async_behavior_fwd.hpp @@ -1,31 +1,31 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 -#define ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class async_behavior; -class event; -typedef sxe::SX_UNIQUE_PTR< async_behavior > async_behavior_uptr; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 +#define ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class async_behavior; +class event; +typedef sxe::SX_UNIQUE_PTR< async_behavior > async_behavior_uptr; + + +} + + +#endif diff --git a/libyasmine/include/async_event_handler.hpp b/libyasmine/include/async_event_handler.hpp index d293b30..0a91610 100644 --- a/libyasmine/include/async_event_handler.hpp +++ b/libyasmine/include/async_event_handler.hpp @@ -1,49 +1,49 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E -#define ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E - -#include "event_fwd.hpp" - - -namespace sxy -{ - - -class async_event_handler -{ - - -public: - async_event_handler() - { - // Nothing to do... - } - - - virtual ~async_event_handler() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(async_event_handler) - virtual void on_event( const event_sptr& _event ) = 0; - - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E +#define ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E + +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class async_event_handler +{ + + +public: + async_event_handler() + { + // Nothing to do... + } + + + virtual ~async_event_handler() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(async_event_handler) + virtual void on_event( const event_sptr& _event ) = 0; + + +}; + + +} + + +#endif diff --git a/libyasmine/include/async_simple_state_impl.hpp b/libyasmine/include/async_simple_state_impl.hpp index f8364f0..6383f9d 100644 --- a/libyasmine/include/async_simple_state_impl.hpp +++ b/libyasmine/include/async_simple_state_impl.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD -#define ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD - - -#include "simple_state_base.hpp" -#include "async_behavior_fwd.hpp" - - -namespace sxy -{ - - -class async_simple_state_impl SX_FINAL: - public simple_state_base -{ -public: - explicit async_simple_state_impl( const std::string& _name, async_behavior_uptr _do_action, - behavior_uptr _entry_action = behavior_uptr(), behavior_uptr _exit_action = behavior_uptr(), - const event_ids& _deferred_events = event_ids(), event_sptr _error_event = event_sptr()); - virtual ~async_simple_state_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(async_simple_state_impl) - void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - void stop_do_behavior() const; - - -private: - async_behavior_uptr do_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD +#define ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD + + +#include "simple_state_base.hpp" +#include "async_behavior_fwd.hpp" + + +namespace sxy +{ + + +class async_simple_state_impl SX_FINAL: + public simple_state_base +{ +public: + explicit async_simple_state_impl( const std::string& _name, async_behavior_uptr _do_action, + behavior_uptr _entry_action = behavior_uptr(), behavior_uptr _exit_action = behavior_uptr(), + const event_ids& _deferred_events = event_ids(), event_sptr _error_event = event_sptr()); + virtual ~async_simple_state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(async_simple_state_impl) + void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + void stop_do_behavior() const; + + +private: + async_behavior_uptr do_; +}; + + +} + + +#endif diff --git a/libyasmine/include/async_state_machine.hpp b/libyasmine/include/async_state_machine.hpp index c6b65c7..e2f892b 100644 --- a/libyasmine/include/async_state_machine.hpp +++ b/libyasmine/include/async_state_machine.hpp @@ -1,135 +1,135 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 -#define ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 - - -#include - -#include "essentials/compatibility/thread.hpp" -#include "essentials/compatibility/chrono.hpp" - -#include "state_machine_base.hpp" -#include "async_event_handler.hpp" -#include "state_machine_status.hpp" - - -namespace sxy -{ - - -//!\class async_state_machine -//!\brief Class for the "multi-threaded version" of the state machine. Provides methods to start and halt the state -//! machine and to fire events. -class async_state_machine SX_FINAL: - public state_machine_base, private async_event_handler -{ -public: - //!\brief Constructor of async_state_machine. - //!\param _name Name of the state machine. - //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback - //!interface should be used. - explicit async_state_machine( const std::string& _name, - event_processing_callback* const _event_processing_callback = SX_NULLPTR ); - virtual ~async_state_machine() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(async_state_machine) - - //!\brief Enqueue the given event for firing. - //!\param _event Event to be fired. - //!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing - //!of the event is not possible because the state machine was stopped in the meantime (or was never started). - //!Firing the event enqueues the event for being processed. - virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; - - //!\brief Starts the state machine. When starting the state machine, the initial transitions are searched and - //!executed. Without running the state machine, it is not possible to fire events. - //!\return If the state machine reaches a terminate pseudostate after starting (on calling run), returns false. Else - //!if the state machine is started and running, returns true. - //!\sa halt_and_join, halt, join - virtual bool run() SX_OVERRIDE; - - //!\brief Stops and joins the state machine. When stopping the state machine, all the events remaining in the queue - //!of events will be processed and the event processing thread will be then stopped and joined. The state machine - //!will also check for active asynchronous simple states and will stop the do behavior for all of them. - //!\return void - //!\sa halt, join, run - void halt_and_join(); - - //!\brief Stops the state machine. When stopping the state machine, all the events remaining in the queue - //!of events will be processed and the event processing thread will be then stopped and joined. The state machine - //!will also check for active asynchronous simple states and will stop the do behavior for all of them. - //!\return void - //!\sa halt_and_join, join, run - virtual void halt() SX_OVERRIDE; - - //!\brief Joins the thread of the state machine. - //!\return void - //!\sa halt_and_join, halt, run - void join(); - - - //!\brief Waiting given amount of time for the state machine to terminate (or to stop). - //!\param _timeoutInMs Time in milliseconds to wait for the state machine to terminate. - //!\return bool true if the state machine is terminated or stopped, false otherwise. - //!\sa halt_and_join, halt, run, wait - bool wait( const sxe::milliseconds _timeoutInMs ) const; - - //!\brief Wait for the machine to terminate (or to stop). - //!\return void - //!\sa halt_and_join, halt, run, wait - void wait() const; - - //!\brief Check if the state machine is terminated or stopped. - //!\return bool true if the state machine is terminated or stopped, false otherwise. - //!\sa halt_and_join, halt, run, wait - bool terminated() const; - - - //!\brief Enqueue the given event for firing. - //!\param _event Event to be fired. - //!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing - //!of the event is not possible because the state machine was stopped in the meantime (or was never started). - //!Firing the event enqueues the event for being processed. - virtual bool push( const event_sptr& _event ) SX_OVERRIDE; - - -protected: - void start_state_machine(); - - -private: - bool insert( const event_sptr& _event ); - void insert_impl( const event_sptr& _event ); - bool wait_predicate() const; - bool wait_stop_condition() const; - void work(); - - //!\brief Sends a priority (internal) event and add it in the front of the event list, so it will be processed before other events. - //!\return void - virtual void on_event( const event_sptr& _event ) SX_OVERRIDE; - - virtual void interrupt_impl() SX_OVERRIDE; - - - state_machine_status status_; - mutable sxe::mutex run_and_event_mutex_; - sxe::condition_variable run_and_event_condition_; - mutable sxe::condition_variable terminated_condition_; - sxe::SX_UNIQUE_PTR< sxe::thread > worker_thread_; - std::list event_list_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 +#define ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 + + +#include + +#include "essentials/compatibility/thread.hpp" +#include "essentials/compatibility/chrono.hpp" + +#include "state_machine_base.hpp" +#include "async_event_handler.hpp" +#include "state_machine_status.hpp" + + +namespace sxy +{ + + +//!\class async_state_machine +//!\brief Class for the "multi-threaded version" of the state machine. Provides methods to start and halt the state +//! machine and to fire events. +class async_state_machine SX_FINAL: + public state_machine_base, private async_event_handler +{ +public: + //!\brief Constructor. + //!\param _name Name of the state machine. + //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback + //!interface should be used. + explicit async_state_machine( const std::string& _name, + event_processing_callback* const _event_processing_callback = SX_NULLPTR ); + virtual ~async_state_machine() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(async_state_machine) + + //!\brief Enqueue the given event for firing. + //!\param _event Event to be fired. + //!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing + //!of the event is not possible because the state machine was stopped in the meantime (or was never started). + //!Firing the event enqueues the event for being processed. + virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; + + //!\brief Starts the state machine. When starting the state machine, the initial transitions are searched and + //!executed. Without running the state machine, it is not possible to fire events. + //!\return If the state machine reaches a terminate pseudostate after starting (on calling run), returns false. Else + //!if the state machine is started and running, returns true. + //!\sa halt_and_join, halt, join + virtual bool run() SX_OVERRIDE; + + //!\brief Stops and joins the state machine. When stopping the state machine, all the events remaining in the queue + //!of events will be processed and the event processing thread will be then stopped and joined. The state machine + //!will also check for active asynchronous simple states and will stop the do behavior for all of them. + //!\return void + //!\sa halt, join, run + void halt_and_join(); + + //!\brief Stops the state machine. When stopping the state machine, all the events remaining in the queue + //!of events will be processed and the event processing thread will be then stopped and joined. The state machine + //!will also check for active asynchronous simple states and will stop the do behavior for all of them. + //!\return void + //!\sa halt_and_join, join, run + virtual void halt() SX_OVERRIDE; + + //!\brief Joins the thread of the state machine. + //!\return void + //!\sa halt_and_join, halt, run + void join(); + + + //!\brief Waiting given amount of time for the state machine to terminate (or to stop). + //!\param _timeoutInMs Time in milliseconds to wait for the state machine to terminate. + //!\return bool true if the state machine is terminated or stopped, false otherwise. + //!\sa halt_and_join, halt, run, wait + bool wait( const sxe::milliseconds _timeoutInMs ) const; + + //!\brief Wait for the machine to terminate (or to stop). + //!\return void + //!\sa halt_and_join, halt, run, wait + void wait() const; + + //!\brief Check if the state machine is terminated or stopped. + //!\return bool true if the state machine is terminated or stopped, false otherwise. + //!\sa halt_and_join, halt, run, wait + bool terminated() const; + + + //!\brief Enqueue the given event for firing. + //!\param _event Event to be fired. + //!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing + //!of the event is not possible because the state machine was stopped in the meantime (or was never started). + //!Firing the event enqueues the event for being processed. + virtual bool push( const event_sptr& _event ) SX_OVERRIDE; + + +protected: + void start_state_machine(); + + +private: + bool insert( const event_sptr& _event ); + void insert_impl( const event_sptr& _event ); + bool wait_predicate() const; + bool wait_stop_condition() const; + void work(); + + //!\brief Sends a priority (internal) event and add it in the front of the event list, so it will be processed before other events. + //!\return void + virtual void on_event( const event_sptr& _event ) SX_OVERRIDE; + + virtual void interrupt_impl() SX_OVERRIDE; + + + state_machine_status status_; + mutable sxe::mutex run_and_event_mutex_; + sxe::condition_variable run_and_event_condition_; + mutable sxe::condition_variable terminated_condition_; + sxe::SX_UNIQUE_PTR< sxe::thread > worker_thread_; + std::list event_list_; +}; + + +} + + +#endif diff --git a/libyasmine/include/backward_compatibility.hpp b/libyasmine/include/backward_compatibility.hpp index 96faae5..7d53980 100644 --- a/libyasmine/include/backward_compatibility.hpp +++ b/libyasmine/include/backward_compatibility.hpp @@ -1,65 +1,65 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef BACKWARD_COMPATIBILITY_51D0150C_395A_4339_9F99_DFFD7274916D -#define BACKWARD_COMPATIBILITY_51D0150C_395A_4339_9F99_DFFD7274916D - - -#include "essentials/compatibility/compatibility.hpp" - - -#ifdef Y_NO_LOGGING -#define SX_NO_LOGGING -#endif - - -#ifdef Y_NO_STD_MAKE_UNIQUE -#define SX_NO_STD_MAKE_UNIQUE -#endif - - -#ifdef Y_CPP03_BOOST -#define SX_CPP03_BOOST -#endif - - -#ifdef Y_NO_WINDOWS_H -#define SX_NO_WINDOWS_H -#endif - - -#define Y_CONSTEXPR SX_CONSTEXPR -#define Y_FINAL SX_FINAL -#define Y_NOEXCEPT SX_NOEXCEPT -#define Y_OVERRIDE SX_OVERRIDE -#define Y_NO_COPY SX_NO_COPY -#define Y_NO_COPY_OPERATOR_EQUAL SX_NO_ASSIGNMENT_OPERATOR -#define Y_UNIQUE_PTR SX_UNIQUE_PTR -#define Y_MAKE_UNIQUE SX_MAKE_UNIQUE -#define Y_MAKE_SHARED SX_MAKE_SHARED -#define Y_UNUSED_PARAMETER SX_UNUSED_PARAMETER -#define Y_NO_LOGGING SX_NO_LOGGING -#define Y_LOG SX_LOG -#define Y_LOG_HEX SX_LOG_HEX -#define Y_ASSERT SX_ASSERT -#define Y_NULLPTR SX_NULLPTR -#define Y_FOR SX_FOR -#define Y_CPP03_BOOST SX_CPP03_BOOST -#define Y_NO_STD_MAKE_UNIQUE SX_NO_STD_MAKE_UNIQUE -#define Y_NO_WINDOWS_H SX_NO_WINDOWS_H - - -namespace sxy -{ - using sxe::shared_ptr; -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef BACKWARD_COMPATIBILITY_51D0150C_395A_4339_9F99_DFFD7274916D +#define BACKWARD_COMPATIBILITY_51D0150C_395A_4339_9F99_DFFD7274916D + + +#include "essentials/compatibility/compatibility.hpp" + + +#ifdef Y_NO_LOGGING +#define SX_NO_LOGGING +#endif + + +#ifdef Y_NO_STD_MAKE_UNIQUE +#define SX_NO_STD_MAKE_UNIQUE +#endif + + +#ifdef Y_CPP03_BOOST +#define SX_CPP03_BOOST +#endif + + +#ifdef Y_NO_WINDOWS_H +#define SX_NO_WINDOWS_H +#endif + + +#define Y_CONSTEXPR SX_CONSTEXPR +#define Y_FINAL SX_FINAL +#define Y_NOEXCEPT SX_NOEXCEPT +#define Y_OVERRIDE SX_OVERRIDE +#define Y_NO_COPY SX_NO_COPY +#define Y_NO_COPY_OPERATOR_EQUAL SX_NO_ASSIGNMENT_OPERATOR +#define Y_UNIQUE_PTR SX_UNIQUE_PTR +#define Y_MAKE_UNIQUE SX_MAKE_UNIQUE +#define Y_MAKE_SHARED SX_MAKE_SHARED +#define Y_UNUSED_PARAMETER SX_UNUSED_PARAMETER +#define Y_NO_LOGGING SX_NO_LOGGING +#define Y_LOG SX_LOG +#define Y_LOG_HEX SX_LOG_HEX +#define Y_ASSERT SX_ASSERT +#define Y_NULLPTR SX_NULLPTR +#define Y_FOR SX_FOR +#define Y_CPP03_BOOST SX_CPP03_BOOST +#define Y_NO_STD_MAKE_UNIQUE SX_NO_STD_MAKE_UNIQUE +#define Y_NO_WINDOWS_H SX_NO_WINDOWS_H + + +namespace sxy +{ + using sxe::shared_ptr; +} + + +#endif diff --git a/libyasmine/include/behavior.hpp b/libyasmine/include/behavior.hpp index 90f8681..a04b4dc 100644 --- a/libyasmine/include/behavior.hpp +++ b/libyasmine/include/behavior.hpp @@ -1,49 +1,49 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 -#define BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 - - -#include "essentials/non_copyable.hpp" - -#include "behavior_fwd.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -class behavior -{ -public: - behavior() - { - // Nothing to do... - } - - - virtual ~behavior() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(behavior) - virtual void operator()( const event&, event_collector& ) const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 +#define BEHAVIOR_2A20341F_93C3_409E_8792_B05E0D83C7D1 + + +#include "essentials/non_copyable.hpp" + +#include "behavior_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class behavior +{ +public: + behavior() + { + // Nothing to do... + } + + + virtual ~behavior() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(behavior) + virtual void operator()( const event&, event_collector& ) const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/behavior_exception.hpp b/libyasmine/include/behavior_exception.hpp index 6fbe159..e7db417 100644 --- a/libyasmine/include/behavior_exception.hpp +++ b/libyasmine/include/behavior_exception.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C -#define BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C - - -#include "essentials/exception.hpp" -#include "essentials/non_copyable.hpp" - -#include "event_fwd.hpp" -#include "event_id.hpp" -#include "behavior_exception_fwd.hpp" - - -namespace sxy -{ - - -class behavior_exception SX_FINAL: - public sxe::exception -{ - - -public: - explicit behavior_exception( const event_sptr& _event ); - virtual ~behavior_exception() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_ASSIGNMENT_OPERATOR( behavior_exception ) - const event_sptr get_error_event() const; - - -private: - const event_sptr error_event_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C +#define BEHAVIOR_EXCEPTION_626C2339_34D7_4BC1_A01A_DB4C0914AA6C + + +#include "essentials/exception.hpp" +#include "essentials/non_copyable.hpp" + +#include "event_fwd.hpp" +#include "event_id.hpp" +#include "behavior_exception_fwd.hpp" + + +namespace sxy +{ + + +class behavior_exception SX_FINAL: + public sxe::exception +{ + + +public: + explicit behavior_exception( const event_sptr& _event ); + virtual ~behavior_exception() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_ASSIGNMENT_OPERATOR( behavior_exception ) + const event_sptr get_error_event() const; + + +private: + const event_sptr error_event_; +}; + + +} + + +#endif diff --git a/libyasmine/include/behavior_exception_fwd.hpp b/libyasmine/include/behavior_exception_fwd.hpp index 30abe28..c820200 100644 --- a/libyasmine/include/behavior_exception_fwd.hpp +++ b/libyasmine/include/behavior_exception_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A -#define BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class behavior_exception; - - -typedef sxe::SX_UNIQUE_PTR< behavior_exception > behavior_exception_uptr; -typedef std::vector< behavior_exception_uptr > behavior_exceptions; - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A +#define BEHAVIOR_EXCEPTION_FWD_10403E70_B796_4F09_9764_470D42AF9C4A + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class behavior_exception; + + +typedef sxe::SX_UNIQUE_PTR< behavior_exception > behavior_exception_uptr; +typedef std::vector< behavior_exception_uptr > behavior_exceptions; + +} + + +#endif diff --git a/libyasmine/include/behavior_fwd.hpp b/libyasmine/include/behavior_fwd.hpp index 663917d..d9dd6dd 100644 --- a/libyasmine/include/behavior_fwd.hpp +++ b/libyasmine/include/behavior_fwd.hpp @@ -1,35 +1,35 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 -#define BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class behavior; -class event; -class event_collector; - - -typedef sxe::SX_UNIQUE_PTR< behavior > behavior_uptr; -typedef sxe::function< void ( const event&, event_collector& ) > behavior_function; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 +#define BEHAVIOR_FWD_0AA81213_6028_46A1_AB10_9FB2E31B8069 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class behavior; +class event; +class event_collector; + + +typedef sxe::SX_UNIQUE_PTR< behavior > behavior_uptr; +typedef sxe::function< void ( const event&, event_collector& ) > behavior_function; + + +} + + +#endif diff --git a/libyasmine/include/caller.hpp b/libyasmine/include/caller.hpp index 26d5f36..0408236 100644 --- a/libyasmine/include/caller.hpp +++ b/libyasmine/include/caller.hpp @@ -1,1297 +1,1297 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F -#define CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F - - -#include "essentials/base.hpp" -#include "essentials/exception.hpp" - -#include "event.hpp" -#include "caller_adapter.hpp" -#include "caller_helper.hpp" -#include "event_adjuster.hpp" -#include "event_collector.hpp" - - -namespace sxy -{ - - -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ); - - -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ); - - -template< typename _event_type > -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - SX_UNUSED_PARAMETER( _event_collector ); - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); - if( specialized_event ) - { - _method( specialized_event ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - - -#else - - - auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); - _method( specialized_event ); - - -#endif -} - - -template< typename _event_type > -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); - if( specialized_event ) - { - _method( specialized_event, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - - -#else - - - auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); - _method( specialized_event, _event_collector ); - - -#endif -} - - -template< typename _event_type1, typename _event_type2 > -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2 ) -{ - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - const auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3 > -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5 > -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - _method5( specialized_event5, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type5>::value, - "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - _method5( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6 > - void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - _method6( specialized_event6, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type5>::value, - "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type6>::value, - "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - _method6( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7 > - void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - _method7( specialized_event7, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type5>::value, - "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type6>::value, - "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type7>::value, - "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - _method7( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 > - void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7, - sxe::function _method8 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - _method7( specialized_event7, _event_collector ); - } - else - { - const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); - if( specialized_event8 ) - { - _method8( specialized_event8, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type5>::value, - "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type6>::value, - "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type7>::value, - "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type8>::value, - "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - _method7( specialized_event, _event_collector ); - break; - } - - case _event_type8::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); - _method8( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 > - void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7, - sxe::function _method8, - sxe::function _method9 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - _method7( specialized_event7, _event_collector ); - } - else - { - const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); - if( specialized_event8 ) - { - _method8( specialized_event8, _event_collector ); - } - else - { - const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); - if( specialized_event9 ) - { - _method9( specialized_event9, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - } - } - - -#else - - - static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type5>::value, - "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type6>::value, - "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type7>::value, - "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type8>::value, - "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - static_assert( has_get_event_id<_event_type9>::value, - "Event type 9 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - _method7( specialized_event, _event_collector ); - break; - } - - case _event_type8::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); - _method8( specialized_event, _event_collector ); - break; - } - - case _event_type9::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); - _method9( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, - typename _event_type10 > - void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7, - sxe::function _method8, - sxe::function _method9, - sxe::function _method10 ) -{ -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - _method7( specialized_event7, _event_collector ); - } - else - { - const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); - if( specialized_event8 ) - { - _method8( specialized_event8, _event_collector ); - } - else - { - const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); - if( specialized_event9 ) - { - _method9( specialized_event9, _event_collector ); - } - else - { - const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); - if( specialized_event10 ) - { - _method10( specialized_event10, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - } - } - } - - -#else - - -static_assert( has_get_event_id<_event_type1>::value, - "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type2>::value, - "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type3>::value, - "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type4>::value, - "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type5>::value, - "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type6>::value, - "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type7>::value, - "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type8>::value, - "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type9>::value, - "Event type 9 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); -static_assert( has_get_event_id<_event_type10>::value, - "Event type 10 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - _method7( specialized_event, _event_collector ); - break; - } - - case _event_type8::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); - _method8( specialized_event, _event_collector ); - break; - } - - case _event_type9::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); - _method9( specialized_event, _event_collector ); - break; - } - - case _event_type10::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); - _method10( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif -} - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F +#define CALLER_8B0F592E_A1FC_4089_9145_BB3BF453FE5F + + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" + +#include "event.hpp" +#include "caller_adapter.hpp" +#include "caller_helper.hpp" +#include "event_adjuster.hpp" +#include "event_collector.hpp" + + +namespace sxy +{ + + +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +template< typename _event_type > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + _method( specialized_event ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + _method( specialized_event ); + + +#endif +} + + +template< typename _event_type > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + _method( specialized_event, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + _method( specialized_event, _event_collector ); + + +#endif +} + + +template< typename _event_type1, typename _event_type2 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2 ) +{ + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + const auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5 > +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + _method8( specialized_event8, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type8>::value, + "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + _method8( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + _method9( specialized_event9, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + + +#else + + + static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type8>::value, + "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + static_assert( has_get_event_id<_event_type9>::value, + "Event type 9 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + _method9( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, + typename _event_type10 > + void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9, + sxe::function _method10 ) +{ +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + _method9( specialized_event9, _event_collector ); + } + else + { + const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); + if( specialized_event10 ) + { + _method10( specialized_event10, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + } + + +#else + + +static_assert( has_get_event_id<_event_type1>::value, + "Event type 1 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type2>::value, + "Event type 2 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type3>::value, + "Event type 3 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type4>::value, + "Event type 4 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type5>::value, + "Event type 5 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type6>::value, + "Event type 6 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type7>::value, + "Event type 7 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type8>::value, + "Event type 8 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type9>::value, + "Event type 9 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); +static_assert( has_get_event_id<_event_type10>::value, + "Event type 10 does not have the method 'get_event_id'. This is mandatory for using the behavior_caller!" ); + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + _method9( specialized_event, _event_collector ); + break; + } + + case _event_type10::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); + _method10( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif +} + + +} + +#endif diff --git a/libyasmine/include/caller_adapter.hpp b/libyasmine/include/caller_adapter.hpp index b6a771a..e8fdad8 100644 --- a/libyasmine/include/caller_adapter.hpp +++ b/libyasmine/include/caller_adapter.hpp @@ -1,277 +1,277 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26 -#define CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26 - -#ifndef SX_CPP03_BOOST - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class event_collector; - - -} - - -template -sxe::function adapt( T* _class, void ( T::*method )() ) -{ - return( [_class, method]() - { - ( _class->*method )(); - } - ); -} - - -template -sxe::function adapt( T* _class, void ( T::*method )( ) const ) -{ - return( [_class, method]() - { - ( _class->*method )( ); - } - ); -} - - -template -sxe::function adapt( T* _class, - void ( T::*method )( const _event_type& ) ) -{ - return( [_class, method]( const _event_type& _event) - { - ( _class->*method )( _event ); - } - ); -} - - -template -sxe::function adapt( T* _class, - void ( T::*method )( const _event_type& ) const ) -{ - return( [_class, method]( const _event_type& _event ) - { - ( _class->*method )( _event ); - } - ); -} - - -template -sxe::function adapt( T* _class, - void ( T::*method )( sxy::event_collector& ) ) -{ - return( [_class, method]( sxy::event_collector& _event_collector ) - { - ( _class->*method )( _event_collector ); - } - ); -} - - -template -sxe::function adapt( T* _class, - void ( T::*method )( sxy::event_collector& ) const ) -{ - return( [_class, method]( sxy::event_collector& _event_collector ) - { - ( _class->*method )( _event_collector ); - } - ); -} - - -template -sxe::function adapt( T* _class, - void ( T::*method )( const _event_type&, sxy::event_collector& ) ) -{ - return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) - { - ( _class->*method )( _event, _event_collector ); - } - ); -} - - -template -sxe::function adapt( T* _class, - void ( T::*method )( const _event_type&, sxy::event_collector& ) const ) -{ - return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) - { - ( _class->*method )( _event, _event_collector ); - } - ); -} - - -sxe::function adapt_function( void( *_function )() ); - - -template< typename _event_type > -sxe::function adapt_function( - void ( *_function )( const _event_type& ) ) -{ - return( [ _function ]( const _event_type& _event ) - { - ( *_function )( _event ); - } - ); -} - - -sxe::function adapt_function( void( *_function )( sxy::event_collector& ) ); - - -template< typename _event_type > -sxe::function adapt_function( - void( *_function )( const _event_type&, sxy::event_collector& ) ) -{ - return( [ _function ]( const _event_type& _event, sxy::event_collector& _event_collector ) - { - ( *_function )( _event, _event_collector ); - } - ); -} - - - -template -sxe::function adapt( T* _class, bool ( T::*method )() ) -{ - return( [_class, method]() - { - return( ( _class->*method )( ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, bool ( T::*method )() const ) -{ - return( [_class, method]() - { - return( ( _class->*method )( ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, bool ( T::*method )( const _event_type& ) ) -{ - return( [_class, method]( const _event_type& _event ) - { - return( ( _class->*method )( _event ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, bool ( T::*method )( const _event_type& ) const ) -{ - return( [_class, method]( const _event_type& _event ) - { - return( ( _class->*method )( _event ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, - bool ( T::*method )( sxy::event_collector& ) ) -{ - return( [_class, method]( sxy::event_collector& _event_collector ) - { - return ( ( _class->*method )( _event_collector ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, - bool ( T::*method )( sxy::event_collector& ) const ) -{ - return( [_class, method]( sxy::event_collector& _event_collector ) - { - return( ( _class->*method )( _event_collector ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, - bool ( T::*method )( const _event_type&, sxy::event_collector& ) ) -{ - return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) - { - return( ( _class->*method )( _event, _event_collector ) ); - } - ); -} - - -template -sxe::function adapt( T* _class, - bool ( T::*method )( const _event_type&, sxy::event_collector& ) const ) -{ - return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) - { - return( ( _class->*method )( _event, _event_collector ) ); - } - ); -} - - -sxe::function adapt_function( bool( *_function )() ); - - -template< typename _event_type > -sxe::function adapt_function( bool( *_function )( const _event_type& ) ) -{ - return( [_function]( const _event_type& _event ) - { - return( ( *_function )( _event ) ); - } - ); -} - - -sxe::function adapt_function( bool( *_function )( sxy::event_collector& ) ); - - -template< typename _event_type > -sxe::function adapt_function( - bool( *_function )( const _event_type&, sxy::event_collector& ) ) -{ - return( [_function]( const _event_type& _event, sxy::event_collector& _event_collector ) - { - return( ( *_function )( _event, _event_collector ) ); - } - ); -} - - -#endif - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26 +#define CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26 + +#ifndef SX_CPP03_BOOST + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class event_collector; + + +} + + +template +sxe::function adapt( T* _class, void ( T::*method )() ) +{ + return( [_class, method]() + { + ( _class->*method )(); + } + ); +} + + +template +sxe::function adapt( T* _class, void ( T::*method )( ) const ) +{ + return( [_class, method]() + { + ( _class->*method )( ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type& ) ) +{ + return( [_class, method]( const _event_type& _event) + { + ( _class->*method )( _event ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type& ) const ) +{ + return( [_class, method]( const _event_type& _event ) + { + ( _class->*method )( _event ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( sxy::event_collector& ) ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event_collector ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( sxy::event_collector& ) const ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event_collector ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type&, sxy::event_collector& ) ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event, _event_collector ); + } + ); +} + + +template +sxe::function adapt( T* _class, + void ( T::*method )( const _event_type&, sxy::event_collector& ) const ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + ( _class->*method )( _event, _event_collector ); + } + ); +} + + +sxe::function adapt_function( void( *_function )() ); + + +template< typename _event_type > +sxe::function adapt_function( + void ( *_function )( const _event_type& ) ) +{ + return( [ _function ]( const _event_type& _event ) + { + ( *_function )( _event ); + } + ); +} + + +sxe::function adapt_function( void( *_function )( sxy::event_collector& ) ); + + +template< typename _event_type > +sxe::function adapt_function( + void( *_function )( const _event_type&, sxy::event_collector& ) ) +{ + return( [ _function ]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + ( *_function )( _event, _event_collector ); + } + ); +} + + + +template +sxe::function adapt( T* _class, bool ( T::*method )() ) +{ + return( [_class, method]() + { + return( ( _class->*method )( ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, bool ( T::*method )() const ) +{ + return( [_class, method]() + { + return( ( _class->*method )( ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, bool ( T::*method )( const _event_type& ) ) +{ + return( [_class, method]( const _event_type& _event ) + { + return( ( _class->*method )( _event ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, bool ( T::*method )( const _event_type& ) const ) +{ + return( [_class, method]( const _event_type& _event ) + { + return( ( _class->*method )( _event ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( sxy::event_collector& ) ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + return ( ( _class->*method )( _event_collector ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( sxy::event_collector& ) const ) +{ + return( [_class, method]( sxy::event_collector& _event_collector ) + { + return( ( _class->*method )( _event_collector ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( const _event_type&, sxy::event_collector& ) ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + return( ( _class->*method )( _event, _event_collector ) ); + } + ); +} + + +template +sxe::function adapt( T* _class, + bool ( T::*method )( const _event_type&, sxy::event_collector& ) const ) +{ + return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + return( ( _class->*method )( _event, _event_collector ) ); + } + ); +} + + +sxe::function adapt_function( bool( *_function )() ); + + +template< typename _event_type > +sxe::function adapt_function( bool( *_function )( const _event_type& ) ) +{ + return( [_function]( const _event_type& _event ) + { + return( ( *_function )( _event ) ); + } + ); +} + + +sxe::function adapt_function( bool( *_function )( sxy::event_collector& ) ); + + +template< typename _event_type > +sxe::function adapt_function( + bool( *_function )( const _event_type&, sxy::event_collector& ) ) +{ + return( [_function]( const _event_type& _event, sxy::event_collector& _event_collector ) + { + return( ( *_function )( _event, _event_collector ) ); + } + ); +} + + +#endif + +#endif diff --git a/libyasmine/include/caller_helper.hpp b/libyasmine/include/caller_helper.hpp index df3104b..e4cbf8f 100644 --- a/libyasmine/include/caller_helper.hpp +++ b/libyasmine/include/caller_helper.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef CALLER_HELPER_F7FFB6C9_339F_471F_B7A1_C77902353FBA -#define CALLER_HELPER_F7FFB6C9_339F_471F_B7A1_C77902353FBA - - -#include "event_id.hpp" - - -namespace sxy -{ - -#ifndef SX_CPP03_BOOST // C++11 only - - - template - struct has_get_event_id - { - private: - template - static constexpr auto check( T* ) -> typename - std::is_same< decltype( T::get_event_id() ), sxy::event_id >::type; - - template - static constexpr std::false_type check( ... ); - - typedef decltype( check( 0 ) ) type; - - public: - static constexpr bool value = type::value; - }; - - -#endif - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CALLER_HELPER_F7FFB6C9_339F_471F_B7A1_C77902353FBA +#define CALLER_HELPER_F7FFB6C9_339F_471F_B7A1_C77902353FBA + + +#include "event_id.hpp" + + +namespace sxy +{ + +#ifndef SX_CPP03_BOOST // C++11 only + + + template + struct has_get_event_id + { + private: + template + static constexpr auto check( T* ) -> typename + std::is_same< decltype( T::get_event_id() ), sxy::event_id >::type; + + template + static constexpr std::false_type check( ... ); + + typedef decltype( check( 0 ) ) type; + + public: + static constexpr bool value = type::value; + }; + + +#endif + +} + + +#endif diff --git a/libyasmine/include/choice.hpp b/libyasmine/include/choice.hpp index a51b2a5..6e28b13 100644 --- a/libyasmine/include/choice.hpp +++ b/libyasmine/include/choice.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CHOICE_31837C1D_B3FD_41D7_94FB_CD7B16FEBD73 -#define CHOICE_31837C1D_B3FD_41D7_94FB_CD7B16FEBD73 - - -#include "region_pseudostate.hpp" -#include "choice_fwd.hpp" - - -namespace sxy -{ - - -class choice: - public virtual region_pseudostate -{ -public: - choice() - { - // Nothing to do... - } - - - virtual ~choice() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(choice) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHOICE_31837C1D_B3FD_41D7_94FB_CD7B16FEBD73 +#define CHOICE_31837C1D_B3FD_41D7_94FB_CD7B16FEBD73 + + +#include "region_pseudostate.hpp" +#include "choice_fwd.hpp" + + +namespace sxy +{ + + +class choice: + public virtual region_pseudostate +{ +public: + choice() + { + // Nothing to do... + } + + + virtual ~choice() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(choice) +}; + + +} + + +#endif diff --git a/libyasmine/include/choice_fwd.hpp b/libyasmine/include/choice_fwd.hpp index 7e713a7..0071f98 100644 --- a/libyasmine/include/choice_fwd.hpp +++ b/libyasmine/include/choice_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CHOICE_FWD_CC41E744_8F28_465B_8CD6_4F3A437D121C -#define CHOICE_FWD_CC41E744_8F28_465B_8CD6_4F3A437D121C - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class choice; -typedef sxe::SX_UNIQUE_PTR< choice > choice_uptr; -typedef std::vector< choice_uptr > choices; -typedef std::vector< const choice* > raw_const_choices; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHOICE_FWD_CC41E744_8F28_465B_8CD6_4F3A437D121C +#define CHOICE_FWD_CC41E744_8F28_465B_8CD6_4F3A437D121C + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class choice; +typedef sxe::SX_UNIQUE_PTR< choice > choice_uptr; +typedef std::vector< choice_uptr > choices; +typedef std::vector< const choice* > raw_const_choices; + + +} + + +#endif diff --git a/libyasmine/include/completion_event.hpp b/libyasmine/include/completion_event.hpp index df1b87c..a295db0 100644 --- a/libyasmine/include/completion_event.hpp +++ b/libyasmine/include/completion_event.hpp @@ -1,36 +1,36 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 -#define COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 - - -#include "event_template.hpp" -#include "internal_completion_event_id.hpp" - - -namespace sxy -{ - - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - extern const event_id Y_COMPLETION_EVENT_ID; - Y_EVENT_WITH_ID( completion_event, Y_INTERNAL_COMPLETION_EVENT_ID ) -#else - constexpr event_id Y_COMPLETION_EVENT_ID = std::numeric_limits::max(); - Y_EVENT_WITH_ID( completion_event, Y_COMPLETION_EVENT_ID ) -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 +#define COMPLETION_EVENT_DD072799_B626_4F7D_B694_0A3B97990632 + + +#include "event_template.hpp" +#include "internal_completion_event_id.hpp" + + +namespace sxy +{ + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + extern const event_id Y_COMPLETION_EVENT_ID; + Y_EVENT_WITH_ID( completion_event, Y_INTERNAL_COMPLETION_EVENT_ID ) +#else + constexpr event_id Y_COMPLETION_EVENT_ID = std::numeric_limits::max(); + Y_EVENT_WITH_ID( completion_event, Y_COMPLETION_EVENT_ID ) +#endif + + +} + + +#endif diff --git a/libyasmine/include/complex_state.hpp b/libyasmine/include/complex_state.hpp index 55a0ed6..7701e76 100644 --- a/libyasmine/include/complex_state.hpp +++ b/libyasmine/include/complex_state.hpp @@ -1,50 +1,50 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPLEX_STATE_91053A02_65AF_40C3_B9F9_C283A743A85F -#define COMPLEX_STATE_91053A02_65AF_40C3_B9F9_C283A743A85F - - -#include "state.hpp" - - -namespace sxy -{ - - -class complex_state_visitor; - - -class complex_state: - public virtual state -{ -public: - complex_state() - { - // Nothing to do... - } - - - virtual ~complex_state() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(complex_state) - virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLEX_STATE_91053A02_65AF_40C3_B9F9_C283A743A85F +#define COMPLEX_STATE_91053A02_65AF_40C3_B9F9_C283A743A85F + + +#include "state.hpp" + + +namespace sxy +{ + + +class complex_state_visitor; + + +class complex_state: + public virtual state +{ +public: + complex_state() + { + // Nothing to do... + } + + + virtual ~complex_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(complex_state) + virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/complex_state_impl.hpp b/libyasmine/include/complex_state_impl.hpp index 0e0cfb9..566c19d 100644 --- a/libyasmine/include/complex_state_impl.hpp +++ b/libyasmine/include/complex_state_impl.hpp @@ -1,52 +1,52 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPLEX_STATE_IMPL_38C23A75_BCF7_419A_BC41_CD8FB9F8C011 -#define COMPLEX_STATE_IMPL_38C23A75_BCF7_419A_BC41_CD8FB9F8C011 - - -#include "complex_state.hpp" -#include "state_impl.hpp" -#include "behavior.hpp" - - -namespace sxy -{ - - -class complex_state_impl: - public virtual complex_state, public state_impl -{ -public: - explicit complex_state_impl( const std::string& _name, behavior_uptr _entry_behavior, - behavior_uptr _exit_behavior, const event_ids& _deferred_events = event_ids() ); - virtual ~complex_state_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(complex_state_impl) - virtual behavior * get_entry_behavior() const SX_OVERRIDE; - virtual behavior * get_exit_behavior() const SX_OVERRIDE; - virtual bool is_event_deferred( const event_id& _event_id ) const SX_OVERRIDE; - - -protected: - bool check_if_one_of_the_deferred_events_triggers_a_transition() const; - - -private: - behavior_uptr entry_; - behavior_uptr exit_; - event_ids deferred_events_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLEX_STATE_IMPL_38C23A75_BCF7_419A_BC41_CD8FB9F8C011 +#define COMPLEX_STATE_IMPL_38C23A75_BCF7_419A_BC41_CD8FB9F8C011 + + +#include "complex_state.hpp" +#include "state_impl.hpp" +#include "behavior.hpp" + + +namespace sxy +{ + + +class complex_state_impl: + public virtual complex_state, public state_impl +{ +public: + explicit complex_state_impl( const std::string& _name, behavior_uptr _entry_behavior, + behavior_uptr _exit_behavior, const event_ids& _deferred_events = event_ids() ); + virtual ~complex_state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(complex_state_impl) + virtual behavior * get_entry_behavior() const SX_OVERRIDE; + virtual behavior * get_exit_behavior() const SX_OVERRIDE; + virtual bool is_event_deferred( const event_id& _event_id ) const SX_OVERRIDE; + + +protected: + bool check_if_one_of_the_deferred_events_triggers_a_transition() const; + + +private: + behavior_uptr entry_; + behavior_uptr exit_; + event_ids deferred_events_; +}; + + +} + + +#endif diff --git a/libyasmine/include/composite_state.hpp b/libyasmine/include/composite_state.hpp index 0080156..db3df1e 100644 --- a/libyasmine/include/composite_state.hpp +++ b/libyasmine/include/composite_state.hpp @@ -1,68 +1,68 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOSITE_STATE_1AD1142C_AAD0_4161_B700_32D0C0441769 -#define COMPOSITE_STATE_1AD1142C_AAD0_4161_B700_32D0C0441769 - - -#include "composite_state_fwd.hpp" -#include "complex_state.hpp" -#include "shallow_history_fwd.hpp" -#include "deep_history_fwd.hpp" -#include "entry_point_fwd.hpp" -#include "exit_point_fwd.hpp" - - -namespace sxy -{ - - -class composite_state: - public virtual complex_state -{ -public: - composite_state() - { - // Nothing to do... - } - - - virtual ~composite_state() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(composite_state) - virtual region& add_region( region_uptr _region ) = 0; - virtual region& add_region( const std::string& _region_name ) = 0; - virtual const deep_history * get_deep_history() const = 0; - virtual deep_history& add_deep_history( deep_history_uptr _deep_history ) = 0; - virtual deep_history& add_deep_history( const std::string& _deep_history_name ) = 0; - virtual shallow_history * get_shallow_history() const = 0; - virtual shallow_history& add_shallow_history( shallow_history_uptr _shallow_history ) = 0; - virtual shallow_history& add_shallow_history( const std::string& _shallow_history_name ) = 0; - virtual const raw_const_entry_points get_entry_points() const = 0; - virtual entry_point& add_entry_point( entry_point_uptr _entry_point ) = 0; - virtual entry_point& add_entry_point( const std::string& _entry_point_name ) = 0; - virtual const raw_const_exit_points get_exit_points() const = 0; - virtual exit_point& add_exit_point( exit_point_uptr _exit_point ) = 0; - virtual exit_point& add_exit_point( const std::string& _exit_point ) = 0; - virtual size_t get_region_index( const region* const _region ) const = 0; - virtual bool check_if_regions_are_completed() const = 0; - virtual bool is_orthogonal() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOSITE_STATE_1AD1142C_AAD0_4161_B700_32D0C0441769 +#define COMPOSITE_STATE_1AD1142C_AAD0_4161_B700_32D0C0441769 + + +#include "composite_state_fwd.hpp" +#include "complex_state.hpp" +#include "shallow_history_fwd.hpp" +#include "deep_history_fwd.hpp" +#include "entry_point_fwd.hpp" +#include "exit_point_fwd.hpp" + + +namespace sxy +{ + + +class composite_state: + public virtual complex_state +{ +public: + composite_state() + { + // Nothing to do... + } + + + virtual ~composite_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(composite_state) + virtual region& add_region( region_uptr _region ) = 0; + virtual region& add_region( const std::string& _region_name ) = 0; + virtual const deep_history * get_deep_history() const = 0; + virtual deep_history& add_deep_history( deep_history_uptr _deep_history ) = 0; + virtual deep_history& add_deep_history( const std::string& _deep_history_name ) = 0; + virtual shallow_history * get_shallow_history() const = 0; + virtual shallow_history& add_shallow_history( shallow_history_uptr _shallow_history ) = 0; + virtual shallow_history& add_shallow_history( const std::string& _shallow_history_name ) = 0; + virtual const raw_const_entry_points get_entry_points() const = 0; + virtual entry_point& add_entry_point( entry_point_uptr _entry_point ) = 0; + virtual entry_point& add_entry_point( const std::string& _entry_point_name ) = 0; + virtual const raw_const_exit_points get_exit_points() const = 0; + virtual exit_point& add_exit_point( exit_point_uptr _exit_point ) = 0; + virtual exit_point& add_exit_point( const std::string& _exit_point ) = 0; + virtual size_t get_region_index( const region* const _region ) const = 0; + virtual bool check_if_regions_are_completed() const = 0; + virtual bool is_orthogonal() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/composite_state_fwd.hpp b/libyasmine/include/composite_state_fwd.hpp index ea6349d..8c13dfe 100644 --- a/libyasmine/include/composite_state_fwd.hpp +++ b/libyasmine/include/composite_state_fwd.hpp @@ -1,33 +1,33 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOSITE_STATE_FWD_4E6EFA7D_4400_4B33_A330_603146E114BD -#define COMPOSITE_STATE_FWD_4E6EFA7D_4400_4B33_A330_603146E114BD - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class composite_state; -typedef sxe::SX_UNIQUE_PTR< composite_state > composite_state_uptr; -typedef std::vector< composite_state* > raw_composite_states; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOSITE_STATE_FWD_4E6EFA7D_4400_4B33_A330_603146E114BD +#define COMPOSITE_STATE_FWD_4E6EFA7D_4400_4B33_A330_603146E114BD + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class composite_state; +typedef sxe::SX_UNIQUE_PTR< composite_state > composite_state_uptr; +typedef std::vector< composite_state* > raw_composite_states; + + +} + + +#endif diff --git a/libyasmine/include/constraint.hpp b/libyasmine/include/constraint.hpp index 9c8cef7..98a92a6 100644 --- a/libyasmine/include/constraint.hpp +++ b/libyasmine/include/constraint.hpp @@ -1,51 +1,51 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CONSTRAINT_DFC0FBD5_ACF7_4863_BB5F_129E8620FAB3 -#define CONSTRAINT_DFC0FBD5_ACF7_4863_BB5F_129E8620FAB3 - - -#include "essentials/non_copyable.hpp" - -#include "constraint_fwd.hpp" - - -namespace sxy -{ - - -class event; - - -class constraint -{ -public: - constraint() - { - // Nothing to do... - } - - - virtual ~constraint() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(constraint) - virtual bool operator()( const event& _event, event_collector& _event_collector ) const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONSTRAINT_DFC0FBD5_ACF7_4863_BB5F_129E8620FAB3 +#define CONSTRAINT_DFC0FBD5_ACF7_4863_BB5F_129E8620FAB3 + + +#include "essentials/non_copyable.hpp" + +#include "constraint_fwd.hpp" + + +namespace sxy +{ + + +class event; + + +class constraint +{ +public: + constraint() + { + // Nothing to do... + } + + + virtual ~constraint() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(constraint) + virtual bool operator()( const event& _event, event_collector& _event_collector ) const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/constraint_fwd.hpp b/libyasmine/include/constraint_fwd.hpp index 99e42a2..9f5ff15 100644 --- a/libyasmine/include/constraint_fwd.hpp +++ b/libyasmine/include/constraint_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CONSTRAINT_FWD_1FEE3CF1_5B7B_43EF_9E40_8CE0D3170E67 -#define CONSTRAINT_FWD_1FEE3CF1_5B7B_43EF_9E40_8CE0D3170E67 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class constraint; -class event; -class event_collector; - -typedef sxe::SX_UNIQUE_PTR< constraint > constraint_uptr; -typedef sxe::function< bool ( const event&, event_collector& ) > constraint_function; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONSTRAINT_FWD_1FEE3CF1_5B7B_43EF_9E40_8CE0D3170E67 +#define CONSTRAINT_FWD_1FEE3CF1_5B7B_43EF_9E40_8CE0D3170E67 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class constraint; +class event; +class event_collector; + +typedef sxe::SX_UNIQUE_PTR< constraint > constraint_uptr; +typedef sxe::function< bool ( const event&, event_collector& ) > constraint_function; + + +} + + +#endif diff --git a/libyasmine/include/deep_history.hpp b/libyasmine/include/deep_history.hpp index c9f55ea..953cdcb 100644 --- a/libyasmine/include/deep_history.hpp +++ b/libyasmine/include/deep_history.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DEEP_HISTORY_4B2625A9_6406_4084_B3D3_7D67EDE09048 -#define DEEP_HISTORY_4B2625A9_6406_4084_B3D3_7D67EDE09048 - - -#include "history.hpp" -#include "deep_history_fwd.hpp" - - -namespace sxy -{ - - -class deep_history: - public virtual history -{ -public: - deep_history() - { - // Nothing to do... - } - - - virtual ~deep_history() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(deep_history) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DEEP_HISTORY_4B2625A9_6406_4084_B3D3_7D67EDE09048 +#define DEEP_HISTORY_4B2625A9_6406_4084_B3D3_7D67EDE09048 + + +#include "history.hpp" +#include "deep_history_fwd.hpp" + + +namespace sxy +{ + + +class deep_history: + public virtual history +{ +public: + deep_history() + { + // Nothing to do... + } + + + virtual ~deep_history() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(deep_history) +}; + + +} + + +#endif diff --git a/libyasmine/include/deep_history_fwd.hpp b/libyasmine/include/deep_history_fwd.hpp index 8067176..d546242 100644 --- a/libyasmine/include/deep_history_fwd.hpp +++ b/libyasmine/include/deep_history_fwd.hpp @@ -1,32 +1,32 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DEEP_HISTORY_FWD_DD821F91_9A4E_4520_988E_E457089412D0 -#define DEEP_HISTORY_FWD_DD821F91_9A4E_4520_988E_E457089412D0 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class deep_history; -typedef sxe::SX_UNIQUE_PTR< deep_history > deep_history_uptr; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DEEP_HISTORY_FWD_DD821F91_9A4E_4520_988E_E457089412D0 +#define DEEP_HISTORY_FWD_DD821F91_9A4E_4520_988E_E457089412D0 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class deep_history; +typedef sxe::SX_UNIQUE_PTR< deep_history > deep_history_uptr; + + +} + + +#endif diff --git a/libyasmine/include/entry_point.hpp b/libyasmine/include/entry_point.hpp index 8069b81..9167772 100644 --- a/libyasmine/include/entry_point.hpp +++ b/libyasmine/include/entry_point.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F -#define ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F - - -#include "state_pseudostate.hpp" -#include "entry_point_fwd.hpp" - - -namespace sxy -{ - - -class entry_point: - public virtual state_pseudostate -{ -public: - entry_point() - { - // Nothing to do... - } - - - virtual ~entry_point() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(entry_point) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F +#define ENTRY_POINT_A89D8062_12B7_44EC_8ACF_C3F54611609F + + +#include "state_pseudostate.hpp" +#include "entry_point_fwd.hpp" + + +namespace sxy +{ + + +class entry_point: + public virtual state_pseudostate +{ +public: + entry_point() + { + // Nothing to do... + } + + + virtual ~entry_point() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(entry_point) +}; + + +} + + +#endif diff --git a/libyasmine/include/entry_point_fwd.hpp b/libyasmine/include/entry_point_fwd.hpp index 3f7c900..0a83392 100644 --- a/libyasmine/include/entry_point_fwd.hpp +++ b/libyasmine/include/entry_point_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ENTRY_POINT_FWD_058240BC_C6BC_49D2_AEB5_CFF4935EC599 -#define ENTRY_POINT_FWD_058240BC_C6BC_49D2_AEB5_CFF4935EC599 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class entry_point; -typedef sxe::SX_UNIQUE_PTR< entry_point > entry_point_uptr; -typedef std::vector< entry_point_uptr > entry_points; -typedef std::vector< const entry_point* > raw_const_entry_points; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ENTRY_POINT_FWD_058240BC_C6BC_49D2_AEB5_CFF4935EC599 +#define ENTRY_POINT_FWD_058240BC_C6BC_49D2_AEB5_CFF4935EC599 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class entry_point; +typedef sxe::SX_UNIQUE_PTR< entry_point > entry_point_uptr; +typedef std::vector< entry_point_uptr > entry_points; +typedef std::vector< const entry_point* > raw_const_entry_points; + + +} + + +#endif diff --git a/libyasmine/include/event.hpp b/libyasmine/include/event.hpp index 3041fca..53f33fd 100644 --- a/libyasmine/include/event.hpp +++ b/libyasmine/include/event.hpp @@ -1,67 +1,67 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_990555DD_B4D7_49E4_AC39_7448568164F0 -#define EVENT_990555DD_B4D7_49E4_AC39_7448568164F0 - - -#include "essentials/non_copyable.hpp" - -#include "event_id.hpp" -#include "event_priority.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - -//!\interface event -//!\brief Interface of an event. An event has an ID, a name and a priority (for processing by the async state machine). -class event -{ -public: - event() - { - // Nothing to do... - } - - - virtual ~event() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(event) - - //!\brief Getter of event's ID. - //!\return ID of event. - virtual event_id get_id() const = 0; - - //!\brief Getter of event's name. - //!\return Name of event. - virtual std::string get_name() const = 0; - - //!\brief Getter of event's priority. - //!\return Priority of event. - virtual event_priority get_priority() const = 0; - - //!\brief Method for comparing the priorities between the current event and a given event. - //!\param _rhs Reference to an event whose priority is compared with the current event's priority. - //!\return True if the current event has a greater priority, else false. - virtual bool operator>(const event& _rhs) const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_990555DD_B4D7_49E4_AC39_7448568164F0 +#define EVENT_990555DD_B4D7_49E4_AC39_7448568164F0 + + +#include "essentials/non_copyable.hpp" + +#include "event_id.hpp" +#include "event_priority.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + +//!\interface event +//!\brief Interface of an event. An event has an ID, a name and a priority (for processing by the async state machine). +class event +{ +public: + event() + { + // Nothing to do... + } + + + virtual ~event() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(event) + + //!\brief Getter of event's ID. + //!\return ID of event. + virtual event_id get_id() const = 0; + + //!\brief Getter of event's name. + //!\return Name of event. + virtual std::string get_name() const = 0; + + //!\brief Getter of event's priority. + //!\return Priority of event. + virtual event_priority get_priority() const = 0; + + //!\brief Method for comparing the priorities between the current event and a given event. + //!\param _rhs Reference to an event whose priority is compared with the current event's priority. + //!\return True if the current event has a greater priority, else false. + virtual bool operator>(const event& _rhs) const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/event_adjuster.hpp b/libyasmine/include/event_adjuster.hpp index d5b0841..df63091 100644 --- a/libyasmine/include/event_adjuster.hpp +++ b/libyasmine/include/event_adjuster.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5 -#define EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5 - - -#ifdef NDEBUG -#else -#include "essentials/base.hpp" -#include "hermes/log.hpp" -#endif - - -namespace sxy -{ - - -template -const _event_type& adjust_event_type( const event& _event ) -{ -#ifdef NDEBUG - return( static_cast< const _event_type& >( _event ) ); -#else - const _event_type* const specialized_event = dynamic_cast< const _event_type* const >( &_event ); - const std::string message = "Event " + _event.get_name() + " is not of given type."; - if( !specialized_event ) - { - SX_LOG( hermes::log_level::LL_ASSERT, message ); - SX_ASSERT( false, "Invalid event type!" ); - } - return( *specialized_event ); -#endif -} - - -} - - +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5 +#define EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5 + + +#ifdef NDEBUG +#else +#include "essentials/base.hpp" +#include "hermes/log.hpp" +#endif + + +namespace sxy +{ + + +template +const _event_type& adjust_event_type( const event& _event ) +{ +#ifdef NDEBUG + return( static_cast< const _event_type& >( _event ) ); +#else + const _event_type* const specialized_event = dynamic_cast< const _event_type* const >( &_event ); + const std::string message = "Event " + _event.get_name() + " is not of given type."; + if( !specialized_event ) + { + SX_LOG( hermes::log_level::LL_ASSERT, message ); + SX_ASSERT( false, "Invalid event type!" ); + } + return( *specialized_event ); +#endif +} + + +} + + #endif \ No newline at end of file diff --git a/libyasmine/include/event_collector.hpp b/libyasmine/include/event_collector.hpp index c070414..b077d45 100644 --- a/libyasmine/include/event_collector.hpp +++ b/libyasmine/include/event_collector.hpp @@ -1,49 +1,49 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_COLLECTOR_B423B8BB_DC7E_4957_95F5_2B5ECB9DD689 -#define EVENT_COLLECTOR_B423B8BB_DC7E_4957_95F5_2B5ECB9DD689 - - -#include "essentials/non_copyable.hpp" - -#include "event.hpp" - - -namespace sxy -{ - - -class event_collector -{ -public: - event_collector() - { - // Nothing to do... - } - - virtual ~event_collector() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY( event_collector ) - virtual bool push( const event_sptr& _event ) = 0; - - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_COLLECTOR_B423B8BB_DC7E_4957_95F5_2B5ECB9DD689 +#define EVENT_COLLECTOR_B423B8BB_DC7E_4957_95F5_2B5ECB9DD689 + + +#include "essentials/non_copyable.hpp" + +#include "event.hpp" + + +namespace sxy +{ + + +class event_collector +{ +public: + event_collector() + { + // Nothing to do... + } + + virtual ~event_collector() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( event_collector ) + virtual bool push( const event_sptr& _event ) = 0; + + +}; + + +} + + +#endif diff --git a/libyasmine/include/event_creation_request.hpp b/libyasmine/include/event_creation_request.hpp index baecfa8..cc0af63 100644 --- a/libyasmine/include/event_creation_request.hpp +++ b/libyasmine/include/event_creation_request.hpp @@ -1,56 +1,56 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_CREATION_REQUEST_05BAD27E_EBBD_405D_B23D_00670DF91241 -#define EVENT_CREATION_REQUEST_05BAD27E_EBBD_405D_B23D_00670DF91241 - - -#include "essentials/compatibility/chrono.hpp" -#include "essentials/non_copyable.hpp" - -#include "event_id.hpp" -#include "event_fwd.hpp" -#include "event_handle.hpp" - - -namespace sxy -{ - - -class event_creation_request SX_FINAL -{ -public: - - - event_creation_request( const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event, - const handle_type _handle ); - ~event_creation_request() SX_NOEXCEPT; -#ifndef SX_CPP03_BOOST - SX_NO_COPY(event_creation_request) - event_creation_request( event_creation_request&& ); - event_creation_request& operator=( event_creation_request&& ); -#endif - sxe::time_point< sxe::system_clock > get_time() const; - handle_type get_handle() const; - event_sptr get_event() const; - - -private: - sxe::time_point< sxe::system_clock > time_; - event_sptr event_; - handle_type handle_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_CREATION_REQUEST_05BAD27E_EBBD_405D_B23D_00670DF91241 +#define EVENT_CREATION_REQUEST_05BAD27E_EBBD_405D_B23D_00670DF91241 + + +#include "essentials/compatibility/chrono.hpp" +#include "essentials/non_copyable.hpp" + +#include "event_id.hpp" +#include "event_fwd.hpp" +#include "event_handle.hpp" + + +namespace sxy +{ + + +class event_creation_request SX_FINAL +{ +public: + + + event_creation_request( const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event, + const handle_type _handle ); + ~event_creation_request() SX_NOEXCEPT; +#ifndef SX_CPP03_BOOST + SX_NO_COPY(event_creation_request) + event_creation_request( event_creation_request&& ); + event_creation_request& operator=( event_creation_request&& ); +#endif + sxe::time_point< sxe::system_clock > get_time() const; + handle_type get_handle() const; + event_sptr get_event() const; + + +private: + sxe::time_point< sxe::system_clock > time_; + event_sptr event_; + handle_type handle_; +}; + + +} + + +#endif diff --git a/libyasmine/include/event_creation_request_time_comparer.hpp b/libyasmine/include/event_creation_request_time_comparer.hpp index 92a1caf..14f46f4 100644 --- a/libyasmine/include/event_creation_request_time_comparer.hpp +++ b/libyasmine/include/event_creation_request_time_comparer.hpp @@ -1,33 +1,33 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A -#define EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A - - -namespace sxy -{ - - -class event_creation_request; - - -struct event_creation_request_time_comparer -{ -public: - bool operator()( const event_creation_request& _lhs, const event_creation_request& _rhs ) const; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A +#define EVENT_CREATION_REQUEST_TIME_COMPARER_348858A8_8897_4A44_B2C8_A253190C9C1A + + +namespace sxy +{ + + +class event_creation_request; + + +struct event_creation_request_time_comparer +{ +public: + bool operator()( const event_creation_request& _lhs, const event_creation_request& _rhs ) const; +}; + + +} + + +#endif diff --git a/libyasmine/include/event_fwd.hpp b/libyasmine/include/event_fwd.hpp index 9c07707..e5b6010 100644 --- a/libyasmine/include/event_fwd.hpp +++ b/libyasmine/include/event_fwd.hpp @@ -1,33 +1,33 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_FWD_622C6A23_5E15_4A6B_8278_460C74941A10 -#define EVENT_FWD_622C6A23_5E15_4A6B_8278_460C74941A10 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class event; -typedef sxe::shared_ptr< event > event_sptr; -typedef std::vector< event_sptr > events; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_FWD_622C6A23_5E15_4A6B_8278_460C74941A10 +#define EVENT_FWD_622C6A23_5E15_4A6B_8278_460C74941A10 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class event; +typedef sxe::shared_ptr< event > event_sptr; +typedef std::vector< event_sptr > events; + + +} + + +#endif diff --git a/libyasmine/include/event_handle.hpp b/libyasmine/include/event_handle.hpp index 697cc0f..3f2e0b2 100644 --- a/libyasmine/include/event_handle.hpp +++ b/libyasmine/include/event_handle.hpp @@ -1,40 +1,40 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_HANDLE_57AE05A6_DA8B_4D0C_A50D_06AF8DFB46BF -#define EVENT_HANDLE_57AE05A6_DA8B_4D0C_A50D_06AF8DFB46BF - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - - //!\brief The type alias for yasmine's event handle. - typedef sxe::uint32_t handle_type; - -#ifndef SX_CPP03_BOOST - extern const handle_type Y_INVALID_EVENT_CREATION_REQUEST_HANDLE; -#else - #define Y_INVALID_EVENT_CREATION_REQUEST_HANDLE UINT_MAX -#endif - - extern const handle_type Y_DEFAULT_HANDLE; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_HANDLE_57AE05A6_DA8B_4D0C_A50D_06AF8DFB46BF +#define EVENT_HANDLE_57AE05A6_DA8B_4D0C_A50D_06AF8DFB46BF + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + + //!\brief The type alias for yasmine's event handle. + typedef sxe::uint32_t handle_type; + +#ifndef SX_CPP03_BOOST + extern const handle_type Y_INVALID_EVENT_CREATION_REQUEST_HANDLE; +#else + #define Y_INVALID_EVENT_CREATION_REQUEST_HANDLE UINT_MAX +#endif + + extern const handle_type Y_DEFAULT_HANDLE; + + +} + + +#endif diff --git a/libyasmine/include/event_id.hpp b/libyasmine/include/event_id.hpp index 35fe9cd..5e5e2b9 100644 --- a/libyasmine/include/event_id.hpp +++ b/libyasmine/include/event_id.hpp @@ -1,35 +1,35 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_ID_C05A5A39_AC17_467C_B975_8D744CC77D8B -#define EVENT_ID_C05A5A39_AC17_467C_B975_8D744CC77D8B - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -//!\brief The type alias for yasmine's event IDs. -typedef sxe::uint32_t event_id; - -//!\brief The type alias for yasmine's event ID list. -typedef std::vector< event_id > event_ids; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_ID_C05A5A39_AC17_467C_B975_8D744CC77D8B +#define EVENT_ID_C05A5A39_AC17_467C_B975_8D744CC77D8B + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +//!\brief The type alias for yasmine's event IDs. +typedef sxe::uint32_t event_id; + +//!\brief The type alias for yasmine's event ID list. +typedef std::vector< event_id > event_ids; + + +} + + +#endif diff --git a/libyasmine/include/event_impl.hpp b/libyasmine/include/event_impl.hpp index 1d63888..a696754 100644 --- a/libyasmine/include/event_impl.hpp +++ b/libyasmine/include/event_impl.hpp @@ -1,67 +1,67 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 -#define EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 - - -#include "event.hpp" - - -namespace sxy -{ - -//!\class event_impl -//!\brief Events that are processed by the state machine. -//!\An event can have an ID, a name and a priority (for processing by the async state machine). -class event_impl: - public event -{ -public: - explicit event_impl( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ); - virtual ~event_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(event_impl) - - //!\brief Getter of event's ID. - //!\return ID of event. - virtual event_id get_id() const SX_OVERRIDE; - - //!\brief Getter of event's name. - //!\return Name of event. - virtual std::string get_name() const SX_OVERRIDE; - - //!\brief Getter of event's priority. - //!\return Priority of event. - virtual event_priority get_priority() const SX_OVERRIDE; - - //!\brief Method for comparing the priorities between the current event and a given event. - //!\param _rhs Reference to an event whose priority is compared with the current event's priority. - //!\return True if the current event has a greater priority, else false. - virtual bool operator>(const event& _rhs) const SX_OVERRIDE; - - //!\brief Static method for creating an event with the given ID and a priority. - //!\Priority has DEFAULT_EVENT_PRIORITY as default value. - //!\param _event_id ID of the event that is created. - //!\param _event_priority Priority of the event that is created. DEFAULT_EVENT_PRIORITY is the default value. - //!\return The created event. - static event_sptr create( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ); - - -private: - event_id event_id_; - event_priority event_priority_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 +#define EVENT_IMPL_447B2A6E_B2CC_4851_A3EB_68ACC838AEA2 + + +#include "event.hpp" + + +namespace sxy +{ + +//!\class event_impl +//!\brief Events that are processed by the state machine. +//!\An event can have an ID, a name and a priority (for processing by the async state machine). +class event_impl: + public event +{ +public: + explicit event_impl( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ); + virtual ~event_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(event_impl) + + //!\brief Getter of event's ID. + //!\return ID of event. + virtual event_id get_id() const SX_OVERRIDE; + + //!\brief Getter of event's name. + //!\return Name of event. + virtual std::string get_name() const SX_OVERRIDE; + + //!\brief Getter of event's priority. + //!\return Priority of event. + virtual event_priority get_priority() const SX_OVERRIDE; + + //!\brief Method for comparing the priorities between the current event and a given event. + //!\param _rhs Reference to an event whose priority is compared with the current event's priority. + //!\return True if the current event has a greater priority, else false. + virtual bool operator>(const event& _rhs) const SX_OVERRIDE; + + //!\brief Static method for creating an event with the given ID and a priority. + //!\Priority has DEFAULT_EVENT_PRIORITY as default value. + //!\param _event_id ID of the event that is created. + //!\param _event_priority Priority of the event that is created. DEFAULT_EVENT_PRIORITY is the default value. + //!\return The created event. + static event_sptr create( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ); + + +private: + event_id event_id_; + event_priority event_priority_; +}; + + +} + + +#endif diff --git a/libyasmine/include/event_priority.hpp b/libyasmine/include/event_priority.hpp index 334bc55..6556c7e 100644 --- a/libyasmine/include/event_priority.hpp +++ b/libyasmine/include/event_priority.hpp @@ -1,50 +1,50 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_PRIORITY_A7F92EA4_6076_48E4_B56A_E5BDDC99A655 -#define EVENT_PRIORITY_A7F92EA4_6076_48E4_B56A_E5BDDC99A655 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -//!\brief The type alias for yasmine's event priorities. -typedef sxe::int8_t event_priority; - -//!\brief The type alias for yasmine's event priority list. -typedef std::vector< event_priority > event_prioritys; - - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - -#define STATE_MACHINE_INTERNAL_EVENT_PRIORITY 127u -#define DEFAULT_EVENT_PRIORITY 0u - -#else - -//!\brief yasmine's predefined event priority for the internal use. -constexpr event_priority STATE_MACHINE_INTERNAL_EVENT_PRIORITY = 127; -//!\brief yasmine's predefined default event priority. -constexpr event_priority DEFAULT_EVENT_PRIORITY = 0; - -#endif - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_PRIORITY_A7F92EA4_6076_48E4_B56A_E5BDDC99A655 +#define EVENT_PRIORITY_A7F92EA4_6076_48E4_B56A_E5BDDC99A655 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +//!\brief The type alias for yasmine's event priorities. +typedef sxe::int8_t event_priority; + +//!\brief The type alias for yasmine's event priority list. +typedef std::vector< event_priority > event_prioritys; + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + +#define STATE_MACHINE_INTERNAL_EVENT_PRIORITY 127u +#define DEFAULT_EVENT_PRIORITY 0u + +#else + +//!\brief yasmine's predefined event priority for the internal use. +constexpr event_priority STATE_MACHINE_INTERNAL_EVENT_PRIORITY = 127; +//!\brief yasmine's predefined default event priority. +constexpr event_priority DEFAULT_EVENT_PRIORITY = 0; + +#endif + + +} + + +#endif diff --git a/libyasmine/include/event_template.hpp b/libyasmine/include/event_template.hpp index 8810691..dcf70fc 100644 --- a/libyasmine/include/event_template.hpp +++ b/libyasmine/include/event_template.hpp @@ -1,1136 +1,1136 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 -#define EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 - - -#include "essentials/compatibility/compatibility.hpp" - -#include "specialized_event.hpp" - - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - #define Y_AUX_DEFAULT_EVENT_PRIORITY DEFAULT_EVENT_PRIORITY -#else - #define Y_AUX_DEFAULT_EVENT_PRIORITY sxy::DEFAULT_EVENT_PRIORITY -#endif - - -#ifndef SX_NO_VARIADIC_MACRO - -#define Y_EVENT_EXPAND( x ) x - -#define Y_EVENT_CAT( A, B ) A ## B -#define Y_EVENT_SELECT( NAME, NUM ) Y_EVENT_CAT( NAME ## _, NUM ) - -#define Y_EVENT_GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, _SIXTEEN, _EIGHTEEN, _NINETEEN, _TWENTY, _TWENTY_ONE, _TWENTY_TWO, COUNT, ... ) COUNT -#define Y_EVENT_VA_SIZE( ... ) Y_EVENT_EXPAND( Y_EVENT_GET_COUNT( __VA_ARGS__, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 0, 0, -1, -1, -2, -2 ) ) - -#define Y_VA_SELECT( NAME, _level, ... ) Y_EVENT_EXPAND( Y_EVENT_SELECT( NAME, Y_EVENT_VA_SIZE(__VA_ARGS__) )( _level, __VA_ARGS__) ) -#define Y_VA_SELECT_PRIORITY( NAME, _level, _level_2, ... ) Y_EVENT_EXPAND( Y_EVENT_SELECT( NAME, Y_EVENT_VA_SIZE(__VA_ARGS__) )( _level, _level_2, __VA_ARGS__) ) - -//!\brief Macro for creating event class. It supports up to 10 event parameters. For each parameter, the type and the -//!\getter name must be specified. -#define Y_EVENT_CREATE( _class_name, ... ) Y_EVENT_EXPAND( Y_VA_SELECT( Y_EVENT_PARAM, _class_name, __VA_ARGS__ ) ) - -#define Y_EVENT_PARAM_0( _class_name, _event_id ) Y_EVENT_WITH_ID( _class_name, _event_id ) -#define Y_EVENT_PARAM_1( _class_name, _event_id, _parameter_type1, _getter_name1 ) Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id ) -#define Y_EVENT_PARAM_2( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2 ) Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id ) -#define Y_EVENT_PARAM_3( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3 ) Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id ) -#define Y_EVENT_PARAM_4( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4 ) Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id ) -#define Y_EVENT_PARAM_5( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5 ) Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id ) -#define Y_EVENT_PARAM_6( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6 ) Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id ) -#define Y_EVENT_PARAM_7( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7 ) Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id ) -#define Y_EVENT_PARAM_8( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8 ) Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id ) -#define Y_EVENT_PARAM_9( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9 ) Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id ) -#define Y_EVENT_PARAM_10( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10 ) Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id ) - - -//!\brief Macro for creating event class with event priority. It supports up to 10 event parameters. For each -//!\parameter, the type and the getter name must be specified. -#define Y_EVENT_WITH_PRIORITY_CREATE( _class_name, _event_id, ... ) Y_EVENT_EXPAND( Y_VA_SELECT_PRIORITY( Y_EVENT_PARAM_PRIORITY, _class_name, _event_id, __VA_ARGS__ ) ) - -#define Y_EVENT_PARAM_PRIORITY_0( _class_name, _event_id, _event_priority ) Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_1( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1 ) Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_2( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2 ) Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_3( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3 ) Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_4( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4 ) Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_5( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5 ) Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_6( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6 ) Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_7( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7 ) Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_8( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8 ) Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_9( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9 ) Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority ) -#define Y_EVENT_PARAM_PRIORITY_10( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10 ) Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority ) - -#endif - - - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID and a priority. -//!\param _class_name Name of the event class. -//!\param _event_id Event's ID. -//!\param _event_priority Event's priority. -#define Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - explicit _class_name() \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY( _class_name )\ -\ -\ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _event_id Event's id. -#define Y_EVENT_WITH_ID( _class_name, _event_id ) Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and a given type parameter. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the parameter. -//!\param _getter_name1 Name of the method that returns the value of the parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - explicit _class_name( const _param_type1& _p1 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ -SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has one parameter. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the parameter. -//!\param _getter_name1 Name of the method that returns the value of the parameter. -//!\param _event_id Event's id. -#define Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id ) Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and two given type parameter. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has two parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _event_id Event's id. -#define Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id ) Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and three given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has three parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _event_id Event's id. -#define Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id ) Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and four given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the fourth parameter. -//!\param _getter_name4 Name of the method that returns the value of the fourth parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has four parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _event_id Event's id. -#define Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id ) Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and five given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - typedef sxe::remove_reference::type>::type _param_type5;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _param_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ - const _param_type5 p5_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has five parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _event_id Event's id. -#define Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id ) Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and six given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - typedef sxe::remove_reference::type>::type _param_type5;\ - typedef sxe::remove_reference::type>::type _param_type6;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ), \ - p6_( _p6 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _param_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ - const _parameter_type6& _getter_name6() const \ - { \ - return( p6_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ - const _param_type5 p5_; \ - const _param_type6 p6_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has six parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _event_id Event's id. -#define Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id ) Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and seven given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - typedef sxe::remove_reference::type>::type _param_type5;\ - typedef sxe::remove_reference::type>::type _param_type6;\ - typedef sxe::remove_reference::type>::type _param_type7;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ), \ - p6_( _p6 ), \ - p7_( _p7 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _param_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ - const _param_type6& _getter_name6() const \ - { \ - return( p6_ ); \ - } \ -\ -\ - const _param_type7& _getter_name7() const \ - { \ - return( p7_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ - const _param_type5 p5_; \ - const _param_type6 p6_; \ - const _param_type7 p7_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _event_id Event's id. -#define Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id ) Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and eight given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _parameter_type8 Type of the eighth parameter. -//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - typedef sxe::remove_reference::type>::type _param_type5;\ - typedef sxe::remove_reference::type>::type _param_type6;\ - typedef sxe::remove_reference::type>::type _param_type7;\ - typedef sxe::remove_reference::type>::type _param_type8;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ), \ - p6_( _p6 ), \ - p7_( _p7 ), \ - p8_( _p8 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _param_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ - const _param_type6& _getter_name6() const \ - { \ - return( p6_ ); \ - } \ -\ -\ - const _param_type7& _getter_name7() const \ - { \ - return( p7_ ); \ - } \ -\ -\ - const _param_type8& _getter_name8() const \ - { \ - return( p8_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ - const _param_type5 p5_; \ - const _param_type6 p6_; \ - const _param_type7 p7_; \ - const _param_type8 p8_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _parameter_type8 Type of the eighth parameter. -//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. -//!\param _event_id Event's id. -#define Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id ) Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and nine given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _parameter_type8 Type of the eighth parameter. -//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. -//!\param _parameter_type9 Type of the ninth parameter. -//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - typedef sxe::remove_reference::type>::type _param_type5;\ - typedef sxe::remove_reference::type>::type _param_type6;\ - typedef sxe::remove_reference::type>::type _param_type7;\ - typedef sxe::remove_reference::type>::type _param_type8;\ - typedef sxe::remove_reference::type>::type _param_type9;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8, const _param_type9& _p9 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ), \ - p6_( _p6 ), \ - p7_( _p7 ), \ - p8_( _p8 ), \ - p9_( _p9 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _param_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ - const _param_type6& _getter_name6() const \ - { \ - return( p6_ ); \ - } \ -\ -\ - const _param_type7& _getter_name7() const \ - { \ - return( p7_ ); \ - } \ -\ -\ -const _param_type8& _getter_name8() const \ - { \ - return( p8_ ); \ - } \ -\ -\ - const _param_type9& _getter_name9() const \ - { \ - return( p9_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ - const _param_type5 p5_; \ - const _param_type6 p6_; \ - const _param_type7 p7_; \ - const _param_type8 p8_; \ - const _param_type9 p9_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _parameter_type8 Type of the eighth parameter. -//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. -//!\param _parameter_type9 Type of the ninth parameter. -//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. -//!\param _event_id Event's id. -#define Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id ) Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and ten given type parameters. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _parameter_type8 Type of the eighth parameter. -//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. -//!\param _parameter_type9 Type of the ninth parameter. -//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. -//!\param _parameter_type10 Type of the tenth parameter. -//!\param _getter_name10 Name of the method that returns the value of the tenth parameter. -//!\param _event_id Event's id. -//!\param _event_priority Event's priority. -#define Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority ) \ -class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ -public: \ - typedef sxe::remove_reference::type>::type _param_type1;\ - typedef sxe::remove_reference::type>::type _param_type2;\ - typedef sxe::remove_reference::type>::type _param_type3;\ - typedef sxe::remove_reference::type>::type _param_type4;\ - typedef sxe::remove_reference::type>::type _param_type5;\ - typedef sxe::remove_reference::type>::type _param_type6;\ - typedef sxe::remove_reference::type>::type _param_type7;\ - typedef sxe::remove_reference::type>::type _param_type8;\ - typedef sxe::remove_reference::type>::type _param_type9;\ - typedef sxe::remove_reference::type>::type _param_type10;\ - explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8, const _param_type9& _p9, const _param_type10& _p10 ) \ - : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ - p1_( _p1 ), \ - p2_( _p2 ), \ - p3_( _p3 ), \ - p4_( _p4 ), \ - p5_( _p5 ), \ - p6_( _p6 ), \ - p7_( _p7 ), \ - p8_( _p8 ), \ - p9_( _p9 ), \ - p10_( _p10 ) \ - { \ - } \ -\ -\ - virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ - { \ - } \ -\ -\ - SX_NO_COPY(_class_name)\ -\ -\ - const _param_type1& _getter_name1() const \ - { \ - return( p1_ ); \ - } \ -\ -\ - const _param_type2& _getter_name2() const \ - { \ - return( p2_ ); \ - } \ -\ -\ - const _param_type3& _getter_name3() const \ - { \ - return( p3_ ); \ - } \ -\ -\ - const _param_type4& _getter_name4() const \ - { \ - return( p4_ ); \ - } \ -\ -\ - const _param_type5& _getter_name5() const \ - { \ - return( p5_ ); \ - } \ -\ -\ - const _param_type6& _getter_name6() const \ - { \ - return( p6_ ); \ - } \ -\ -\ - const _param_type7& _getter_name7() const \ - { \ - return( p7_ ); \ - } \ -\ -\ - const _param_type8& _getter_name8() const \ - { \ - return( p8_ ); \ - } \ -\ -\ - const _param_type9& _getter_name9() const \ - { \ - return( p9_ ); \ - } \ -\ -\ - const _param_type10& _getter_name10() const \ - { \ - return( p10_ ); \ - } \ -\ -\ -private: \ - const _param_type1 p1_; \ - const _param_type2 p2_; \ - const _param_type3 p3_; \ - const _param_type4 p4_; \ - const _param_type5 p5_; \ - const _param_type6 p6_; \ - const _param_type7 p7_; \ - const _param_type8 p8_; \ - const _param_type9 p9_; \ - const _param_type10 p10_; \ -}; - - -//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. -//!\param _class_name Name of the event class. -//!\param _parameter_type1 Type of the first parameter. -//!\param _getter_name1 Name of the method that returns the value of the first parameter. -//!\param _parameter_type2 Type of the second parameter. -//!\param _getter_name2 Name of the method that returns the value of the second parameter. -//!\param _parameter_type3 Type of the third parameter. -//!\param _getter_name3 Name of the method that returns the value of the third parameter. -//!\param _parameter_type4 Type of the forth parameter. -//!\param _getter_name4 Name of the method that returns the value of the forth parameter. -//!\param _parameter_type5 Type of the fifth parameter. -//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. -//!\param _parameter_type6 Type of the sixth parameter. -//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. -//!\param _parameter_type7 Type of the seventh parameter. -//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. -//!\param _parameter_type8 Type of the eighth parameter. -//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. -//!\param _parameter_type9 Type of the ninth parameter. -//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. -//!\param _parameter_type10 Type of the tenth parameter. -//!\param _getter_name10 Name of the method that returns the value of the tenth parameter. -//!\param _event_id Event's id. -#define Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id ) Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 +#define EVENT_TEMPLATE_D5281A8F_E064_45B5_B1E6_0C5B91DCD932 + + +#include "essentials/compatibility/compatibility.hpp" + +#include "specialized_event.hpp" + + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + #define Y_AUX_DEFAULT_EVENT_PRIORITY DEFAULT_EVENT_PRIORITY +#else + #define Y_AUX_DEFAULT_EVENT_PRIORITY sxy::DEFAULT_EVENT_PRIORITY +#endif + + +#ifndef SX_NO_VARIADIC_MACRO + +#define Y_EVENT_EXPAND( x ) x + +#define Y_EVENT_CAT( A, B ) A ## B +#define Y_EVENT_SELECT( NAME, NUM ) Y_EVENT_CAT( NAME ## _, NUM ) + +#define Y_EVENT_GET_COUNT( _ONE, _TWO, _THREE, _FOUR, _FIVE, _SIX, _SEVEN, _EIGHT, _NINE, _TEN, _ELEVEN, _TWELVE, _THIRTEEN, _FOURTEEN, _FIFTEEN, _SIXTEEN, _EIGHTEEN, _NINETEEN, _TWENTY, _TWENTY_ONE, _TWENTY_TWO, COUNT, ... ) COUNT +#define Y_EVENT_VA_SIZE( ... ) Y_EVENT_EXPAND( Y_EVENT_GET_COUNT( __VA_ARGS__, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 0, 0, -1, -1, -2, -2 ) ) + +#define Y_VA_SELECT( NAME, _level, ... ) Y_EVENT_EXPAND( Y_EVENT_SELECT( NAME, Y_EVENT_VA_SIZE(__VA_ARGS__) )( _level, __VA_ARGS__) ) +#define Y_VA_SELECT_PRIORITY( NAME, _level, _level_2, ... ) Y_EVENT_EXPAND( Y_EVENT_SELECT( NAME, Y_EVENT_VA_SIZE(__VA_ARGS__) )( _level, _level_2, __VA_ARGS__) ) + +//!\brief Macro for creating event class. It supports up to 10 event parameters. For each parameter, the type and the +//!\getter name must be specified. +#define Y_EVENT_CREATE( _class_name, ... ) Y_EVENT_EXPAND( Y_VA_SELECT( Y_EVENT_PARAM, _class_name, __VA_ARGS__ ) ) + +#define Y_EVENT_PARAM_0( _class_name, _event_id ) Y_EVENT_WITH_ID( _class_name, _event_id ) +#define Y_EVENT_PARAM_1( _class_name, _event_id, _parameter_type1, _getter_name1 ) Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id ) +#define Y_EVENT_PARAM_2( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2 ) Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id ) +#define Y_EVENT_PARAM_3( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3 ) Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id ) +#define Y_EVENT_PARAM_4( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4 ) Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id ) +#define Y_EVENT_PARAM_5( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5 ) Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id ) +#define Y_EVENT_PARAM_6( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6 ) Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id ) +#define Y_EVENT_PARAM_7( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7 ) Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id ) +#define Y_EVENT_PARAM_8( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8 ) Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id ) +#define Y_EVENT_PARAM_9( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9 ) Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id ) +#define Y_EVENT_PARAM_10( _class_name, _event_id, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10 ) Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id ) + + +//!\brief Macro for creating event class with event priority. It supports up to 10 event parameters. For each +//!\parameter, the type and the getter name must be specified. +#define Y_EVENT_WITH_PRIORITY_CREATE( _class_name, _event_id, ... ) Y_EVENT_EXPAND( Y_VA_SELECT_PRIORITY( Y_EVENT_PARAM_PRIORITY, _class_name, _event_id, __VA_ARGS__ ) ) + +#define Y_EVENT_PARAM_PRIORITY_0( _class_name, _event_id, _event_priority ) Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_1( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1 ) Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_2( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2 ) Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_3( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3 ) Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_4( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4 ) Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_5( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5 ) Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_6( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6 ) Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_7( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7 ) Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_8( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8 ) Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_9( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9 ) Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority ) +#define Y_EVENT_PARAM_PRIORITY_10( _class_name, _event_id, _event_priority, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10 ) Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority ) + +#endif + + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID and a priority. +//!\param _class_name Name of the event class. +//!\param _event_id Event's ID. +//!\param _event_priority Event's priority. +#define Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + explicit _class_name() \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY( _class_name )\ +\ +\ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _event_id Event's id. +#define Y_EVENT_WITH_ID( _class_name, _event_id ) Y_EVENT_WITH_ID_PRIORITY( _class_name, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and a given type parameter. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the parameter. +//!\param _getter_name1 Name of the method that returns the value of the parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + explicit _class_name( const _param_type1& _p1 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ +SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has one parameter. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the parameter. +//!\param _getter_name1 Name of the method that returns the value of the parameter. +//!\param _event_id Event's id. +#define Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id ) Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and two given type parameter. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has two parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _event_id Event's id. +#define Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id ) Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and three given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has three parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _event_id Event's id. +#define Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id ) Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and four given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the fourth parameter. +//!\param _getter_name4 Name of the method that returns the value of the fourth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has four parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id ) Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and five given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has five parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id ) Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and six given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _parameter_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has six parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id ) Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and seven given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _event_id Event's id. +#define Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id ) Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and eight given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + typedef sxe::remove_reference::type>::type _param_type8;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ), \ + p8_( _p8 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ + const _param_type8& _getter_name8() const \ + { \ + return( p8_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ + const _param_type8 p8_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id ) Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and nine given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + typedef sxe::remove_reference::type>::type _param_type8;\ + typedef sxe::remove_reference::type>::type _param_type9;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8, const _param_type9& _p9 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ), \ + p8_( _p8 ), \ + p9_( _p9 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ +const _param_type8& _getter_name8() const \ + { \ + return( p8_ ); \ + } \ +\ +\ + const _param_type9& _getter_name9() const \ + { \ + return( p9_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ + const _param_type8 p8_; \ + const _param_type9 p9_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id ) Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has an ID, a priority and ten given type parameters. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _parameter_type10 Type of the tenth parameter. +//!\param _getter_name10 Name of the method that returns the value of the tenth parameter. +//!\param _event_id Event's id. +//!\param _event_priority Event's priority. +#define Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority ) \ +class _class_name: public sxy::specialized_event< _class_name, _event_id, _event_priority > { \ +public: \ + typedef sxe::remove_reference::type>::type _param_type1;\ + typedef sxe::remove_reference::type>::type _param_type2;\ + typedef sxe::remove_reference::type>::type _param_type3;\ + typedef sxe::remove_reference::type>::type _param_type4;\ + typedef sxe::remove_reference::type>::type _param_type5;\ + typedef sxe::remove_reference::type>::type _param_type6;\ + typedef sxe::remove_reference::type>::type _param_type7;\ + typedef sxe::remove_reference::type>::type _param_type8;\ + typedef sxe::remove_reference::type>::type _param_type9;\ + typedef sxe::remove_reference::type>::type _param_type10;\ + explicit _class_name( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, const _param_type8& _p8, const _param_type9& _p9, const _param_type10& _p10 ) \ + : sxy::specialized_event< _class_name, _event_id, _event_priority >( #_class_name ), \ + p1_( _p1 ), \ + p2_( _p2 ), \ + p3_( _p3 ), \ + p4_( _p4 ), \ + p5_( _p5 ), \ + p6_( _p6 ), \ + p7_( _p7 ), \ + p8_( _p8 ), \ + p9_( _p9 ), \ + p10_( _p10 ) \ + { \ + } \ +\ +\ + virtual ~_class_name() SX_NOEXCEPT SX_OVERRIDE \ + { \ + } \ +\ +\ + SX_NO_COPY(_class_name)\ +\ +\ + const _param_type1& _getter_name1() const \ + { \ + return( p1_ ); \ + } \ +\ +\ + const _param_type2& _getter_name2() const \ + { \ + return( p2_ ); \ + } \ +\ +\ + const _param_type3& _getter_name3() const \ + { \ + return( p3_ ); \ + } \ +\ +\ + const _param_type4& _getter_name4() const \ + { \ + return( p4_ ); \ + } \ +\ +\ + const _param_type5& _getter_name5() const \ + { \ + return( p5_ ); \ + } \ +\ +\ + const _param_type6& _getter_name6() const \ + { \ + return( p6_ ); \ + } \ +\ +\ + const _param_type7& _getter_name7() const \ + { \ + return( p7_ ); \ + } \ +\ +\ + const _param_type8& _getter_name8() const \ + { \ + return( p8_ ); \ + } \ +\ +\ + const _param_type9& _getter_name9() const \ + { \ + return( p9_ ); \ + } \ +\ +\ + const _param_type10& _getter_name10() const \ + { \ + return( p10_ ); \ + } \ +\ +\ +private: \ + const _param_type1 p1_; \ + const _param_type2 p2_; \ + const _param_type3 p3_; \ + const _param_type4 p4_; \ + const _param_type5 p5_; \ + const _param_type6 p6_; \ + const _param_type7 p7_; \ + const _param_type8 p8_; \ + const _param_type9 p9_; \ + const _param_type10 p10_; \ +}; + + +//!\brief Macro for creating an event class that inherits the specialized_event. The event has seven parameters. The event priority is the default priority. +//!\param _class_name Name of the event class. +//!\param _parameter_type1 Type of the first parameter. +//!\param _getter_name1 Name of the method that returns the value of the first parameter. +//!\param _parameter_type2 Type of the second parameter. +//!\param _getter_name2 Name of the method that returns the value of the second parameter. +//!\param _parameter_type3 Type of the third parameter. +//!\param _getter_name3 Name of the method that returns the value of the third parameter. +//!\param _parameter_type4 Type of the forth parameter. +//!\param _getter_name4 Name of the method that returns the value of the forth parameter. +//!\param _parameter_type5 Type of the fifth parameter. +//!\param _getter_name5 Name of the method that returns the value of the fifth parameter. +//!\param _parameter_type6 Type of the sixth parameter. +//!\param _getter_name6 Name of the method that returns the value of the sixth parameter. +//!\param _parameter_type7 Type of the seventh parameter. +//!\param _getter_name7 Name of the method that returns the value of the seventh parameter. +//!\param _parameter_type8 Type of the eighth parameter. +//!\param _getter_name8 Name of the method that returns the value of the eighth parameter. +//!\param _parameter_type9 Type of the ninth parameter. +//!\param _getter_name9 Name of the method that returns the value of the ninth parameter. +//!\param _parameter_type10 Type of the tenth parameter. +//!\param _getter_name10 Name of the method that returns the value of the tenth parameter. +//!\param _event_id Event's id. +#define Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id ) Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, Y_AUX_DEFAULT_EVENT_PRIORITY ) + + +#endif diff --git a/libyasmine/include/exit_point.hpp b/libyasmine/include/exit_point.hpp index 473b301..7d94bae 100644 --- a/libyasmine/include/exit_point.hpp +++ b/libyasmine/include/exit_point.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 -#define EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 - - -#include "state_pseudostate.hpp" -#include "exit_point_fwd.hpp" - - -namespace sxy -{ - - -class exit_point: - public virtual state_pseudostate -{ -public: - exit_point() - { - // Nothing to do... - } - - - virtual ~exit_point() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(exit_point) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 +#define EXIT_POINT_5F80CE76_2E5B_488A_B9C4_BF7529E2A712 + + +#include "state_pseudostate.hpp" +#include "exit_point_fwd.hpp" + + +namespace sxy +{ + + +class exit_point: + public virtual state_pseudostate +{ +public: + exit_point() + { + // Nothing to do... + } + + + virtual ~exit_point() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(exit_point) +}; + + +} + + +#endif diff --git a/libyasmine/include/exit_point_fwd.hpp b/libyasmine/include/exit_point_fwd.hpp index ad113fb..49e9951 100644 --- a/libyasmine/include/exit_point_fwd.hpp +++ b/libyasmine/include/exit_point_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXIT_POINT_FWD_7358F91A_C52C_47DC_9CF0_BB37E354B382 -#define EXIT_POINT_FWD_7358F91A_C52C_47DC_9CF0_BB37E354B382 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class exit_point; -typedef sxe::SX_UNIQUE_PTR< exit_point > exit_point_uptr; -typedef std::vector< exit_point_uptr > exit_points; -typedef std::vector< const exit_point* > raw_const_exit_points; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXIT_POINT_FWD_7358F91A_C52C_47DC_9CF0_BB37E354B382 +#define EXIT_POINT_FWD_7358F91A_C52C_47DC_9CF0_BB37E354B382 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class exit_point; +typedef sxe::SX_UNIQUE_PTR< exit_point > exit_point_uptr; +typedef std::vector< exit_point_uptr > exit_points; +typedef std::vector< const exit_point* > raw_const_exit_points; + + +} + + +#endif diff --git a/libyasmine/include/final_state.hpp b/libyasmine/include/final_state.hpp index dd79c3c..a864ead 100644 --- a/libyasmine/include/final_state.hpp +++ b/libyasmine/include/final_state.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FINAL_STATE_029A393C_1CDD_45AC_8FBD_860D1EC631D4 -#define FINAL_STATE_029A393C_1CDD_45AC_8FBD_860D1EC631D4 - - -#include "state.hpp" - - -namespace sxy -{ - - -class final_state: - public virtual state -{ -public: - final_state() - { - // Nothing to do... - } - - - virtual ~final_state() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(final_state) - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FINAL_STATE_029A393C_1CDD_45AC_8FBD_860D1EC631D4 +#define FINAL_STATE_029A393C_1CDD_45AC_8FBD_860D1EC631D4 + + +#include "state.hpp" + + +namespace sxy +{ + + +class final_state: + public virtual state +{ +public: + final_state() + { + // Nothing to do... + } + + + virtual ~final_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(final_state) + +}; + + +} + + +#endif diff --git a/libyasmine/include/fork.hpp b/libyasmine/include/fork.hpp index 2f29fef..79c7ad5 100644 --- a/libyasmine/include/fork.hpp +++ b/libyasmine/include/fork.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FORK_AE64610F_E053_4011_9005_1CB9698FDE30 -#define FORK_AE64610F_E053_4011_9005_1CB9698FDE30 - - -#include "region_pseudostate.hpp" -#include "fork_fwd.hpp" - - -namespace sxy -{ - - -class fork: - public virtual region_pseudostate -{ -public: - fork() - { - // Nothing to do... - } - - - virtual ~fork() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(fork) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORK_AE64610F_E053_4011_9005_1CB9698FDE30 +#define FORK_AE64610F_E053_4011_9005_1CB9698FDE30 + + +#include "region_pseudostate.hpp" +#include "fork_fwd.hpp" + + +namespace sxy +{ + + +class fork: + public virtual region_pseudostate +{ +public: + fork() + { + // Nothing to do... + } + + + virtual ~fork() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(fork) +}; + + +} + + +#endif diff --git a/libyasmine/include/fork_fwd.hpp b/libyasmine/include/fork_fwd.hpp index 2b6c2a8..a921360 100644 --- a/libyasmine/include/fork_fwd.hpp +++ b/libyasmine/include/fork_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FORK_FWD_9E024994_76D1_4B32_AAA5_30630EC8F828 -#define FORK_FWD_9E024994_76D1_4B32_AAA5_30630EC8F828 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class fork; -typedef sxe::SX_UNIQUE_PTR< fork > fork_uptr; -typedef std::vector< fork_uptr > forks; -typedef std::vector< const fork* > raw_const_forks; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORK_FWD_9E024994_76D1_4B32_AAA5_30630EC8F828 +#define FORK_FWD_9E024994_76D1_4B32_AAA5_30630EC8F828 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class fork; +typedef sxe::SX_UNIQUE_PTR< fork > fork_uptr; +typedef std::vector< fork_uptr > forks; +typedef std::vector< const fork* > raw_const_forks; + + +} + + +#endif diff --git a/libyasmine/include/guard_caller.hpp b/libyasmine/include/guard_caller.hpp index 0e4f838..fa42b33 100644 --- a/libyasmine/include/guard_caller.hpp +++ b/libyasmine/include/guard_caller.hpp @@ -1,1221 +1,1221 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef GUARD_CALLER_739F1B72_B584_4F9E_AD3B_56149B96F7BE -#define GUARD_CALLER_739F1B72_B584_4F9E_AD3B_56149B96F7BE - - -#include "essentials/base.hpp" -#include "essentials/exception.hpp" - -#include "event.hpp" -#include "caller_adapter.hpp" -#include "event_adjuster.hpp" -#include "event_collector.hpp" - - -namespace sxy -{ - -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ); - - -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ); - - -template< typename _event_type > -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - SX_UNUSED_PARAMETER( _event_collector ); - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); - if( specialized_event ) - { - enabled = _method( specialized_event ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - - -#else - - - auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); - enabled = _method( specialized_event ); - - - -#endif - - return( enabled ); -} - - -template< typename _event_type > -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); - if( specialized_event ) - { - enabled = _method( specialized_event, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - - -#else - - - auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); - enabled = _method( specialized_event, _event_collector ); - - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2 > -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - const auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3 > -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5 > -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - enabled = _method5( specialized_event5, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - enabled = _method5( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6 > - bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - enabled = _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - enabled = _method6( specialized_event6, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - enabled = _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - enabled = _method6( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7 > - bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - enabled = _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - enabled = _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - enabled = _method7( specialized_event7, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - enabled = _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - enabled = _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - enabled = _method7( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 > - bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7, - sxe::function _method8 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - enabled = _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - enabled = _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - enabled = _method7( specialized_event7, _event_collector ); - } - else - { - const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); - if( specialized_event8 ) - { - enabled = _method8( specialized_event8, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - enabled = _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - enabled = _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - enabled = _method7( specialized_event, _event_collector ); - break; - } - - case _event_type8::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); - enabled = _method8( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 > - bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7, - sxe::function _method8, - sxe::function _method9 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - enabled = _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - enabled = _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - enabled = _method7( specialized_event7, _event_collector ); - } - else - { - const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); - if( specialized_event8 ) - { - enabled = _method8( specialized_event8, _event_collector ); - } - else - { - const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); - if( specialized_event9 ) - { - enabled = _method9( specialized_event9, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - enabled = _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - enabled = _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - enabled = _method7( specialized_event, _event_collector ); - break; - } - - case _event_type8::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); - enabled = _method8( specialized_event, _event_collector ); - break; - } - - case _event_type9::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); - enabled = _method9( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, - typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, - typename _event_type10 > - bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method1, - sxe::function _method2, - sxe::function _method3, - sxe::function _method4, - sxe::function _method5, - sxe::function _method6, - sxe::function _method7, - sxe::function _method8, - sxe::function _method9, - sxe::function _method10 ) -{ - bool enabled = false; - -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - - - const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); - if( specialized_event ) - { - enabled = _method1( specialized_event, _event_collector ); - } - else - { - const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); - if( specialized_event2 ) - { - enabled = _method2( specialized_event2, _event_collector ); - } - else - { - const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); - if( specialized_event3 ) - { - enabled = _method3( specialized_event3, _event_collector ); - } - else - { - const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); - if( specialized_event4 ) - { - enabled = _method4( specialized_event4, _event_collector ); - } - else - { - const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); - if( specialized_event5 ) - { - enabled = _method5( specialized_event5, _event_collector ); - } - else - { - const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); - if( specialized_event6 ) - { - enabled = _method6( specialized_event6, _event_collector ); - } - else - { - const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); - if( specialized_event7 ) - { - enabled = _method7( specialized_event7, _event_collector ); - } - else - { - const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); - if( specialized_event8 ) - { - enabled = _method8( specialized_event8, _event_collector ); - } - else - { - const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); - if( specialized_event9 ) - { - enabled = _method9( specialized_event9, _event_collector ); - } - else - { - const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); - if( specialized_event10 ) - { - enabled = _method10( specialized_event10, _event_collector ); - } - else - { - throw sxe::exception( "Invalid event type!" ); - } - } - } - } - } - } - } - } - } - } - - -#else - - - switch( _event.get_id() ) - { - case _event_type1::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); - enabled = _method1( specialized_event, _event_collector ); - break; - } - - case _event_type2::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); - enabled = _method2( specialized_event, _event_collector ); - break; - } - - case _event_type3::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); - enabled = _method3( specialized_event, _event_collector ); - break; - } - - case _event_type4::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); - enabled = _method4( specialized_event, _event_collector ); - break; - } - - case _event_type5::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); - enabled = _method5( specialized_event, _event_collector ); - break; - } - - case _event_type6::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); - enabled = _method6( specialized_event, _event_collector ); - break; - } - - case _event_type7::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); - enabled = _method7( specialized_event, _event_collector ); - break; - } - - case _event_type8::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); - enabled = _method8( specialized_event, _event_collector ); - break; - } - - case _event_type9::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); - enabled = _method9( specialized_event, _event_collector ); - break; - } - - case _event_type10::get_event_id(): - { - auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); - enabled = _method10( specialized_event, _event_collector ); - break; - } - - default: - SX_ASSERT( false, "Invalid event type!" ); - } - - -#endif - - return( enabled ); -} - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef GUARD_CALLER_739F1B72_B584_4F9E_AD3B_56149B96F7BE +#define GUARD_CALLER_739F1B72_B584_4F9E_AD3B_56149B96F7BE + + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" + +#include "event.hpp" +#include "caller_adapter.hpp" +#include "event_adjuster.hpp" +#include "event_collector.hpp" + + +namespace sxy +{ + +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ); + + +template< typename _event_type > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event_collector ); + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + enabled = _method( specialized_event ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + enabled = _method( specialized_event ); + + + +#endif + + return( enabled ); +} + + +template< typename _event_type > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type* specialized_event = dynamic_cast< const _event_type* >( &_event ); + if( specialized_event ) + { + enabled = _method( specialized_event, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + + +#else + + + auto& specialized_event = sxy::adjust_event_type< _event_type >( _event ); + enabled = _method( specialized_event, _event_collector ); + + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + const auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5 > +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + enabled = _method8( specialized_event8, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + enabled = _method8( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + enabled = _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + enabled = _method9( specialized_event9, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + enabled = _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + enabled = _method9( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, + typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, + typename _event_type10 > + bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method1, + sxe::function _method2, + sxe::function _method3, + sxe::function _method4, + sxe::function _method5, + sxe::function _method6, + sxe::function _method7, + sxe::function _method8, + sxe::function _method9, + sxe::function _method10 ) +{ + bool enabled = false; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + + + const _event_type1* specialized_event = dynamic_cast< const _event_type1* >( &_event ); + if( specialized_event ) + { + enabled = _method1( specialized_event, _event_collector ); + } + else + { + const _event_type2* specialized_event2 = dynamic_cast< const _event_type2* >( &_event ); + if( specialized_event2 ) + { + enabled = _method2( specialized_event2, _event_collector ); + } + else + { + const _event_type3* specialized_event3 = dynamic_cast< const _event_type3* >( &_event ); + if( specialized_event3 ) + { + enabled = _method3( specialized_event3, _event_collector ); + } + else + { + const _event_type4* specialized_event4 = dynamic_cast< const _event_type4* >( &_event ); + if( specialized_event4 ) + { + enabled = _method4( specialized_event4, _event_collector ); + } + else + { + const _event_type5* specialized_event5 = dynamic_cast< const _event_type5* >( &_event ); + if( specialized_event5 ) + { + enabled = _method5( specialized_event5, _event_collector ); + } + else + { + const _event_type6* specialized_event6 = dynamic_cast< const _event_type6* >( &_event ); + if( specialized_event6 ) + { + enabled = _method6( specialized_event6, _event_collector ); + } + else + { + const _event_type7* specialized_event7 = dynamic_cast< const _event_type7* >( &_event ); + if( specialized_event7 ) + { + enabled = _method7( specialized_event7, _event_collector ); + } + else + { + const _event_type8* specialized_event8 = dynamic_cast< const _event_type8* >( &_event ); + if( specialized_event8 ) + { + enabled = _method8( specialized_event8, _event_collector ); + } + else + { + const _event_type9* specialized_event9 = dynamic_cast< const _event_type9* >( &_event ); + if( specialized_event9 ) + { + enabled = _method9( specialized_event9, _event_collector ); + } + else + { + const _event_type10* specialized_event10 = dynamic_cast< const _event_type10* >( &_event ); + if( specialized_event10 ) + { + enabled = _method10( specialized_event10, _event_collector ); + } + else + { + throw sxe::exception( "Invalid event type!" ); + } + } + } + } + } + } + } + } + } + } + + +#else + + + switch( _event.get_id() ) + { + case _event_type1::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type1 >( _event ); + enabled = _method1( specialized_event, _event_collector ); + break; + } + + case _event_type2::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type2 >( _event ); + enabled = _method2( specialized_event, _event_collector ); + break; + } + + case _event_type3::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type3 >( _event ); + enabled = _method3( specialized_event, _event_collector ); + break; + } + + case _event_type4::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type4 >( _event ); + enabled = _method4( specialized_event, _event_collector ); + break; + } + + case _event_type5::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type5 >( _event ); + enabled = _method5( specialized_event, _event_collector ); + break; + } + + case _event_type6::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type6 >( _event ); + enabled = _method6( specialized_event, _event_collector ); + break; + } + + case _event_type7::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type7 >( _event ); + enabled = _method7( specialized_event, _event_collector ); + break; + } + + case _event_type8::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type8 >( _event ); + enabled = _method8( specialized_event, _event_collector ); + break; + } + + case _event_type9::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type9 >( _event ); + enabled = _method9( specialized_event, _event_collector ); + break; + } + + case _event_type10::get_event_id(): + { + auto& specialized_event = sxy::adjust_event_type< _event_type10 >( _event ); + enabled = _method10( specialized_event, _event_collector ); + break; + } + + default: + SX_ASSERT( false, "Invalid event type!" ); + } + + +#endif + + return( enabled ); +} + + +} + +#endif diff --git a/libyasmine/include/history.hpp b/libyasmine/include/history.hpp index f4ef229..8f0abf2 100644 --- a/libyasmine/include/history.hpp +++ b/libyasmine/include/history.hpp @@ -1,49 +1,49 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 -#define HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 - - -#include "state_pseudostate.hpp" - - -namespace sxy -{ - - -class history: - public virtual state_pseudostate -{ -public: - history() - { - // Nothing to do... - } - - - virtual ~history() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(history) - virtual raw_transitions get_default_transitions() const = 0; - virtual void add_default_transition( transition& _default_transition ) = 0; - virtual bool check_if_state_was_active_before() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 +#define HISTORY_8019EFCB_44B8_4B81_A578_46C97A9B4E81 + + +#include "state_pseudostate.hpp" + + +namespace sxy +{ + + +class history: + public virtual state_pseudostate +{ +public: + history() + { + // Nothing to do... + } + + + virtual ~history() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(history) + virtual raw_transitions get_default_transitions() const = 0; + virtual void add_default_transition( transition& _default_transition ) = 0; + virtual bool check_if_state_was_active_before() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/initial_pseudostate.hpp b/libyasmine/include/initial_pseudostate.hpp index e66c7ca..dcbd696 100644 --- a/libyasmine/include/initial_pseudostate.hpp +++ b/libyasmine/include/initial_pseudostate.hpp @@ -1,51 +1,51 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E -#define INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E - - -#include "region_pseudostate.hpp" -#include "initial_pseudostate_fwd.hpp" - - -namespace sxy -{ - - -class transition; - - -class initial_pseudostate: - public virtual region_pseudostate -{ -public: - initial_pseudostate() - { - // Nothing to do... - } - - - virtual ~initial_pseudostate() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(initial_pseudostate) - virtual transition * get_transition() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E +#define INITIAL_PSEUDOSTATE_D6A63505_2F02_4013_8A3E_A471096DE40E + + +#include "region_pseudostate.hpp" +#include "initial_pseudostate_fwd.hpp" + + +namespace sxy +{ + + +class transition; + + +class initial_pseudostate: + public virtual region_pseudostate +{ +public: + initial_pseudostate() + { + // Nothing to do... + } + + + virtual ~initial_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(initial_pseudostate) + virtual transition * get_transition() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/initial_pseudostate_fwd.hpp b/libyasmine/include/initial_pseudostate_fwd.hpp index 3307935..f9421f3 100644 --- a/libyasmine/include/initial_pseudostate_fwd.hpp +++ b/libyasmine/include/initial_pseudostate_fwd.hpp @@ -1,30 +1,30 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef INITIAL_PSEUDOSTATE_FWD_70DC64B4_80F9_4F69_9922_93DA7009BBF8 -#define INITIAL_PSEUDOSTATE_FWD_70DC64B4_80F9_4F69_9922_93DA7009BBF8 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class initial_pseudostate; -typedef sxe::SX_UNIQUE_PTR< initial_pseudostate > initial_pseudostate_uptr; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INITIAL_PSEUDOSTATE_FWD_70DC64B4_80F9_4F69_9922_93DA7009BBF8 +#define INITIAL_PSEUDOSTATE_FWD_70DC64B4_80F9_4F69_9922_93DA7009BBF8 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class initial_pseudostate; +typedef sxe::SX_UNIQUE_PTR< initial_pseudostate > initial_pseudostate_uptr; + + +} + + +#endif diff --git a/libyasmine/include/internal_completion_event_id.hpp b/libyasmine/include/internal_completion_event_id.hpp index 276884e..e65d39c 100644 --- a/libyasmine/include/internal_completion_event_id.hpp +++ b/libyasmine/include/internal_completion_event_id.hpp @@ -1,35 +1,35 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 -#define INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 - - -#include "event_template.hpp" - -#ifndef SX_CPP03_BOOST - -#include - -#endif - -#ifdef max - #undef max -#endif - - -//!\brief yasmine's predefined internal event ID for the completion event. -#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) - #define Y_INTERNAL_COMPLETION_EVENT_ID UINT_MAX -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 +#define INTERNAL_COMPLETION_EVENT_ID_E92CB14A_F191_491F_9D5D_EAC18995DBB7 + + +#include "event_template.hpp" + +#ifndef SX_CPP03_BOOST + +#include + +#endif + +#ifdef max + #undef max +#endif + + +//!\brief yasmine's predefined internal event ID for the completion event. +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + #define Y_INTERNAL_COMPLETION_EVENT_ID UINT_MAX +#endif + + +#endif diff --git a/libyasmine/include/interruptible.hpp b/libyasmine/include/interruptible.hpp index c0fa84b..545be17 100644 --- a/libyasmine/include/interruptible.hpp +++ b/libyasmine/include/interruptible.hpp @@ -1,44 +1,44 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef INTERRUPTIBLE_32EC8385_109D_4338_BA8D_A82356BDBAF2 -#define INTERRUPTIBLE_32EC8385_109D_4338_BA8D_A82356BDBAF2 - - -#include "essentials/non_copyable.hpp" - - -namespace sxy -{ - - - class interruptible - { - public: - interruptible() - { - // Nothing to do... - } - - virtual ~interruptible() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY( interruptible ) - virtual bool is_interrupted() const = 0; - }; - - -} - - +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef INTERRUPTIBLE_32EC8385_109D_4338_BA8D_A82356BDBAF2 +#define INTERRUPTIBLE_32EC8385_109D_4338_BA8D_A82356BDBAF2 + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + + class interruptible + { + public: + interruptible() + { + // Nothing to do... + } + + virtual ~interruptible() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( interruptible ) + virtual bool is_interrupted() const = 0; + }; + + +} + + #endif \ No newline at end of file diff --git a/libyasmine/include/join.hpp b/libyasmine/include/join.hpp index bb9820e..694092d 100644 --- a/libyasmine/include/join.hpp +++ b/libyasmine/include/join.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef JOIN_712B59B9_F9E6_4E4B_9427_477A4782E70E -#define JOIN_712B59B9_F9E6_4E4B_9427_477A4782E70E - - -#include "region_pseudostate.hpp" -#include "join_fwd.hpp" - - -namespace sxy -{ - - -class join: - public virtual region_pseudostate -{ -public: - join() - { - // Nothing to do... - } - - - virtual ~join() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(join) - virtual bool check_if_all_source_states_of_incoming_transitions_are_active() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JOIN_712B59B9_F9E6_4E4B_9427_477A4782E70E +#define JOIN_712B59B9_F9E6_4E4B_9427_477A4782E70E + + +#include "region_pseudostate.hpp" +#include "join_fwd.hpp" + + +namespace sxy +{ + + +class join: + public virtual region_pseudostate +{ +public: + join() + { + // Nothing to do... + } + + + virtual ~join() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(join) + virtual bool check_if_all_source_states_of_incoming_transitions_are_active() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/join_fwd.hpp b/libyasmine/include/join_fwd.hpp index 4647bb2..ffff59e 100644 --- a/libyasmine/include/join_fwd.hpp +++ b/libyasmine/include/join_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef JOIN_FWD_62FA1B0B_2997_4645_A325_BD9ED4C1EC7D -#define JOIN_FWD_62FA1B0B_2997_4645_A325_BD9ED4C1EC7D - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class join; -typedef sxe::SX_UNIQUE_PTR< join > join_uptr; -typedef std::vector< join_uptr > joins; -typedef std::vector< const join* > raw_const_joins; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JOIN_FWD_62FA1B0B_2997_4645_A325_BD9ED4C1EC7D +#define JOIN_FWD_62FA1B0B_2997_4645_A325_BD9ED4C1EC7D + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class join; +typedef sxe::SX_UNIQUE_PTR< join > join_uptr; +typedef std::vector< join_uptr > joins; +typedef std::vector< const join* > raw_const_joins; + + +} + + +#endif diff --git a/libyasmine/include/junction.hpp b/libyasmine/include/junction.hpp index 1530f14..a6ba46a 100644 --- a/libyasmine/include/junction.hpp +++ b/libyasmine/include/junction.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef JUNCTION_C9792E4F_85DB_4377_AFE4_E1A1B9F101E0 -#define JUNCTION_C9792E4F_85DB_4377_AFE4_E1A1B9F101E0 - - -#include "region_pseudostate.hpp" -#include "join_fwd.hpp" - - -namespace sxy -{ - - -class junction: - public virtual region_pseudostate -{ -public: - junction() - { - // Nothing to do... - } - - - virtual ~junction() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(junction) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JUNCTION_C9792E4F_85DB_4377_AFE4_E1A1B9F101E0 +#define JUNCTION_C9792E4F_85DB_4377_AFE4_E1A1B9F101E0 + + +#include "region_pseudostate.hpp" +#include "join_fwd.hpp" + + +namespace sxy +{ + + +class junction: + public virtual region_pseudostate +{ +public: + junction() + { + // Nothing to do... + } + + + virtual ~junction() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(junction) +}; + + +} + + +#endif diff --git a/libyasmine/include/junction_fwd.hpp b/libyasmine/include/junction_fwd.hpp index 9d0924a..661a88c 100644 --- a/libyasmine/include/junction_fwd.hpp +++ b/libyasmine/include/junction_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef JUNCTION_FWD_7B62488D_9661_42DD_BC43_8E9737158029 -#define JUNCTION_FWD_7B62488D_9661_42DD_BC43_8E9737158029 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class junction; -typedef sxe::SX_UNIQUE_PTR< junction > junction_uptr; -typedef std::vector< junction_uptr > junctions; -typedef std::vector< const junction* > raw_const_junctions; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JUNCTION_FWD_7B62488D_9661_42DD_BC43_8E9737158029 +#define JUNCTION_FWD_7B62488D_9661_42DD_BC43_8E9737158029 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class junction; +typedef sxe::SX_UNIQUE_PTR< junction > junction_uptr; +typedef std::vector< junction_uptr > junctions; +typedef std::vector< const junction* > raw_const_junctions; + + +} + + +#endif diff --git a/libyasmine/include/logging.hpp b/libyasmine/include/logging.hpp index 9d6fa00..af17df4 100644 --- a/libyasmine/include/logging.hpp +++ b/libyasmine/include/logging.hpp @@ -1,20 +1,20 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef LOGGING_BD013464_0F4C_4276_ADB7_312BF2A33912 -#define LOGGING_BD013464_0F4C_4276_ADB7_312BF2A33912 - - -#include "hermes/log.hpp" -#include "hermes/cout_logger.hpp" -#include "hermes/file_logger.hpp" - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef LOGGING_BD013464_0F4C_4276_ADB7_312BF2A33912 +#define LOGGING_BD013464_0F4C_4276_ADB7_312BF2A33912 + + +#include "hermes/log.hpp" +#include "hermes/cout_logger.hpp" +#include "hermes/file_logger.hpp" + + +#endif diff --git a/libyasmine/include/optimization.hpp b/libyasmine/include/optimization.hpp index a4e03fa..26469ef 100644 --- a/libyasmine/include/optimization.hpp +++ b/libyasmine/include/optimization.hpp @@ -1,44 +1,44 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef OPTIMIZATION_3A290AFB_D672_4E4A_98AD_94841A01D76D -#define OPTIMIZATION_3A290AFB_D672_4E4A_98AD_94841A01D76D - - -#ifdef Y_OPTIMIZE_4_SPEED - - - #ifdef Y_OPTIMIZE_4_SIZE - - - #error "Y_OPTIMIZE_4_SPEED and Y_OPTIMIZE_4_SIZE are both defined!" - - - - #endif - - -#else - - - #ifndef Y_OPTIMIZE_4_SIZE - - - #define Y_OPTIMIZE_4_SIZE - - - #endif - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef OPTIMIZATION_3A290AFB_D672_4E4A_98AD_94841A01D76D +#define OPTIMIZATION_3A290AFB_D672_4E4A_98AD_94841A01D76D + + +#ifdef Y_OPTIMIZE_4_SPEED + + + #ifdef Y_OPTIMIZE_4_SIZE + + + #error "Y_OPTIMIZE_4_SPEED and Y_OPTIMIZE_4_SIZE are both defined!" + + + + #endif + + +#else + + + #ifndef Y_OPTIMIZE_4_SIZE + + + #define Y_OPTIMIZE_4_SIZE + + + #endif + + +#endif + + +#endif diff --git a/libyasmine/include/pseudostate.hpp b/libyasmine/include/pseudostate.hpp index 90987b3..2d31691 100644 --- a/libyasmine/include/pseudostate.hpp +++ b/libyasmine/include/pseudostate.hpp @@ -1,52 +1,52 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef PSEUDOSTATE_595E5B94_1CE0_41B8_AD35_F0DB43C647B2 -#define PSEUDOSTATE_595E5B94_1CE0_41B8_AD35_F0DB43C647B2 - - -#include "vertex.hpp" -#include "pseudostate_fwd.hpp" - - -namespace sxy -{ - - -class pseudostate_visitor; - - -class pseudostate: - public virtual vertex -{ -public: - pseudostate() - { - // Nothing to do... - } - - - virtual ~pseudostate() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(pseudostate) - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const = 0; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PSEUDOSTATE_595E5B94_1CE0_41B8_AD35_F0DB43C647B2 +#define PSEUDOSTATE_595E5B94_1CE0_41B8_AD35_F0DB43C647B2 + + +#include "vertex.hpp" +#include "pseudostate_fwd.hpp" + + +namespace sxy +{ + + +class pseudostate_visitor; + + +class pseudostate: + public virtual vertex +{ +public: + pseudostate() + { + // Nothing to do... + } + + + virtual ~pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(pseudostate) + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/pseudostate_fwd.hpp b/libyasmine/include/pseudostate_fwd.hpp index 2d8988e..0b8ef98 100644 --- a/libyasmine/include/pseudostate_fwd.hpp +++ b/libyasmine/include/pseudostate_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef PSEUDOSTATE_FWD_64C5B45A_A614_4CE6_8634_E96D6DF41F04 -#define PSEUDOSTATE_FWD_64C5B45A_A614_4CE6_8634_E96D6DF41F04 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class pseudostate; -typedef sxe::SX_UNIQUE_PTR< pseudostate > pseudostate_uptr; -typedef std::vector< pseudostate_uptr > pseudostates; -typedef std::vector< const pseudostate* > raw_const_pseudostates; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PSEUDOSTATE_FWD_64C5B45A_A614_4CE6_8634_E96D6DF41F04 +#define PSEUDOSTATE_FWD_64C5B45A_A614_4CE6_8634_E96D6DF41F04 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class pseudostate; +typedef sxe::SX_UNIQUE_PTR< pseudostate > pseudostate_uptr; +typedef std::vector< pseudostate_uptr > pseudostates; +typedef std::vector< const pseudostate* > raw_const_pseudostates; + + +} + + +#endif diff --git a/libyasmine/include/region.hpp b/libyasmine/include/region.hpp index add5a86..6f8b9d5 100644 --- a/libyasmine/include/region.hpp +++ b/libyasmine/include/region.hpp @@ -1,117 +1,117 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef REGION_06648EA9_E80A_49B8_9814_1723273908D2 -#define REGION_06648EA9_E80A_49B8_9814_1723273908D2 - - -#include "state_machine_element.hpp" -#include "state_fwd.hpp" -#include "region_fwd.hpp" -#include "pseudostate_fwd.hpp" -#include "initial_pseudostate_fwd.hpp" -#include "choice_fwd.hpp" -#include "fork_fwd.hpp" -#include "join_fwd.hpp" -#include "junction_fwd.hpp" -#include "terminate_pseudostate_fwd.hpp" -#include "behavior_fwd.hpp" -#include "async_behavior.hpp" -#include "event_fwd.hpp" -#include "event_id.hpp" - - -namespace sxy -{ - - -class vertex; -class composite_state; -class simple_state; -class final_state; - - -class region: public virtual state_machine_element -{ -public: - region() - { - // Nothing to do... - } - - - virtual ~region () SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(region) - virtual void set_parent_state( composite_state* const _composite_state ) = 0; - virtual const composite_state& get_parent_state() const = 0; - virtual composite_state& get_parent_state() = 0; - virtual raw_const_states get_states() const = 0; - virtual size_t get_pseudostate_count() const = 0; - virtual vertex* get_pseudostate( const std::string& _name ) const = 0; - virtual vertex* get_vertex( const std::string& _vertex_name ) const = 0; - virtual raw_const_pseudostates get_pseudostates() const = 0; - virtual initial_pseudostate* get_initial_pseudostate() const = 0; - virtual initial_pseudostate& add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) = 0; - virtual initial_pseudostate& add_initial_pseudostate( const std::string& _initial_state_name ) = 0; - virtual state& add_state( state_uptr _state ) = 0; - virtual choice& add_choice( choice_uptr _choice ) = 0; - virtual choice& add_choice( const std::string& _choice_name ) = 0; - virtual fork& add_fork( fork_uptr _fork ) = 0; - virtual fork& add_fork( const std::string& _fork_name ) = 0; - virtual join& add_join( join_uptr _join ) = 0; - virtual join& add_join( const std::string& _join_name ) = 0; - virtual junction& add_junction( junction_uptr _junction ) = 0; - virtual junction& add_junction( const std::string& _junction_name ) = 0; - virtual terminate_pseudostate& add_terminate_pseudostate( - terminate_pseudostate_uptr _terminate_pseudostate ) = 0; - virtual terminate_pseudostate& add_terminate_pseudostate( const std::string& _terminate_pseudostate_name ) = 0; - virtual simple_state& add_simple_state( const std::string& _name, - const behavior_function& _behavior = behavior_function(), - const behavior_function& _entry_behavior = behavior_function(), - const behavior_function& _exit_behavior = behavior_function() ) = 0; - virtual simple_state& add_simple_state( const std::string& _name, const event_ids& _deferred_events, - const behavior_function& _behavior = behavior_function(), - const behavior_function& _entry_behavior = behavior_function(), - const behavior_function& _exit_behavior = behavior_function(), - event_sptr _error_event = event_sptr() ) = 0; - virtual simple_state& add_async_simple_state( const std::string& _name, const event_ids& _deferred_events, - async_behavior_uptr _do_action = async_behavior_uptr(), const behavior_function& _entry_behavior = behavior_function(), - const behavior_function& _exit_behavior = behavior_function(), - event_sptr _error_event = event_sptr() ) = 0; - virtual composite_state& add_composite_state( const std::string& _name, - const behavior_function& _entry_action = behavior_function(), - const behavior_function& _exit_action = behavior_function() ) = 0; - virtual composite_state& add_composite_state( const std::string& _name, const event_ids& _deferred_events, - const behavior_function& _entry_action = behavior_function(), - const behavior_function& _exit_action = behavior_function() ) = 0; - virtual final_state& add_final_state( const std::string& _name ) = 0; - virtual size_t get_state_count() const = 0; - virtual state* get_state( const std::string& _name ) const = 0; - virtual const state* get_active_state() const = 0; - virtual state* get_active_state() = 0; - virtual void set_active_state( state* const _active_state ) = 0; - virtual void set_state_was_active( state* const _active_state ) = 0; - virtual const state* get_last_active_state() const = 0; - virtual state* get_last_active_state() = 0; - virtual bool is_active_state_final() const = 0; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_06648EA9_E80A_49B8_9814_1723273908D2 +#define REGION_06648EA9_E80A_49B8_9814_1723273908D2 + + +#include "state_machine_element.hpp" +#include "state_fwd.hpp" +#include "region_fwd.hpp" +#include "pseudostate_fwd.hpp" +#include "initial_pseudostate_fwd.hpp" +#include "choice_fwd.hpp" +#include "fork_fwd.hpp" +#include "join_fwd.hpp" +#include "junction_fwd.hpp" +#include "terminate_pseudostate_fwd.hpp" +#include "behavior_fwd.hpp" +#include "async_behavior.hpp" +#include "event_fwd.hpp" +#include "event_id.hpp" + + +namespace sxy +{ + + +class vertex; +class composite_state; +class simple_state; +class final_state; + + +class region: public virtual state_machine_element +{ +public: + region() + { + // Nothing to do... + } + + + virtual ~region () SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(region) + virtual void set_parent_state( composite_state* const _composite_state ) = 0; + virtual const composite_state& get_parent_state() const = 0; + virtual composite_state& get_parent_state() = 0; + virtual raw_const_states get_states() const = 0; + virtual size_t get_pseudostate_count() const = 0; + virtual vertex* get_pseudostate( const std::string& _name ) const = 0; + virtual vertex* get_vertex( const std::string& _vertex_name ) const = 0; + virtual raw_const_pseudostates get_pseudostates() const = 0; + virtual initial_pseudostate* get_initial_pseudostate() const = 0; + virtual initial_pseudostate& add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) = 0; + virtual initial_pseudostate& add_initial_pseudostate( const std::string& _initial_state_name ) = 0; + virtual state& add_state( state_uptr _state ) = 0; + virtual choice& add_choice( choice_uptr _choice ) = 0; + virtual choice& add_choice( const std::string& _choice_name ) = 0; + virtual fork& add_fork( fork_uptr _fork ) = 0; + virtual fork& add_fork( const std::string& _fork_name ) = 0; + virtual join& add_join( join_uptr _join ) = 0; + virtual join& add_join( const std::string& _join_name ) = 0; + virtual junction& add_junction( junction_uptr _junction ) = 0; + virtual junction& add_junction( const std::string& _junction_name ) = 0; + virtual terminate_pseudostate& add_terminate_pseudostate( + terminate_pseudostate_uptr _terminate_pseudostate ) = 0; + virtual terminate_pseudostate& add_terminate_pseudostate( const std::string& _terminate_pseudostate_name ) = 0; + virtual simple_state& add_simple_state( const std::string& _name, + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function() ) = 0; + virtual simple_state& add_simple_state( const std::string& _name, const event_ids& _deferred_events, + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function(), + event_sptr _error_event = event_sptr() ) = 0; + virtual simple_state& add_async_simple_state( const std::string& _name, const event_ids& _deferred_events, + async_behavior_uptr _do_action = async_behavior_uptr(), const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function(), + event_sptr _error_event = event_sptr() ) = 0; + virtual composite_state& add_composite_state( const std::string& _name, + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) = 0; + virtual composite_state& add_composite_state( const std::string& _name, const event_ids& _deferred_events, + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) = 0; + virtual final_state& add_final_state( const std::string& _name ) = 0; + virtual size_t get_state_count() const = 0; + virtual state* get_state( const std::string& _name ) const = 0; + virtual const state* get_active_state() const = 0; + virtual state* get_active_state() = 0; + virtual void set_active_state( state* const _active_state ) = 0; + virtual void set_state_was_active( state* const _active_state ) = 0; + virtual const state* get_last_active_state() const = 0; + virtual state* get_last_active_state() = 0; + virtual bool is_active_state_final() const = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/region_fwd.hpp b/libyasmine/include/region_fwd.hpp index a1bdfc4..bc9db74 100644 --- a/libyasmine/include/region_fwd.hpp +++ b/libyasmine/include/region_fwd.hpp @@ -1,36 +1,36 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef REGION_FWD_DFB0F2A6_B441_4314_BB3D_18DCDE9ADF7B -#define REGION_FWD_DFB0F2A6_B441_4314_BB3D_18DCDE9ADF7B - - -#include -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class region; -typedef sxe::SX_UNIQUE_PTR< region > region_uptr; -typedef std::vector< region_uptr > regions; -typedef std::vector< region* > raw_regions; -typedef std::set< const region* > raw_const_region_set; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_FWD_DFB0F2A6_B441_4314_BB3D_18DCDE9ADF7B +#define REGION_FWD_DFB0F2A6_B441_4314_BB3D_18DCDE9ADF7B + + +#include +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class region; +typedef sxe::SX_UNIQUE_PTR< region > region_uptr; +typedef std::vector< region_uptr > regions; +typedef std::vector< region* > raw_regions; +typedef std::set< const region* > raw_const_region_set; + + +} + + +#endif diff --git a/libyasmine/include/region_pseudostate.hpp b/libyasmine/include/region_pseudostate.hpp index 8ae060e..da502cc 100644 --- a/libyasmine/include/region_pseudostate.hpp +++ b/libyasmine/include/region_pseudostate.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef REGION_PSEUDOSTATE_B33005D7_D302_495D_9118_F45EA4443736 -#define REGION_PSEUDOSTATE_B33005D7_D302_495D_9118_F45EA4443736 - - -#include "pseudostate.hpp" - - -namespace sxy -{ - - -class region_pseudostate: - public virtual pseudostate -{ -public: - region_pseudostate() - { - // Nothing to do... - } - - - virtual ~region_pseudostate() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(region_pseudostate) - virtual region* get_parent_region() const = 0; - virtual void set_parent_region( region* const _parent_region ) = 0; -}; - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_PSEUDOSTATE_B33005D7_D302_495D_9118_F45EA4443736 +#define REGION_PSEUDOSTATE_B33005D7_D302_495D_9118_F45EA4443736 + + +#include "pseudostate.hpp" + + +namespace sxy +{ + + +class region_pseudostate: + public virtual pseudostate +{ +public: + region_pseudostate() + { + // Nothing to do... + } + + + virtual ~region_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(region_pseudostate) + virtual region* get_parent_region() const = 0; + virtual void set_parent_region( region* const _parent_region ) = 0; +}; + + +} + +#endif diff --git a/libyasmine/include/region_pseudostates.hpp b/libyasmine/include/region_pseudostates.hpp index 38d5e74..f40cacc 100644 --- a/libyasmine/include/region_pseudostates.hpp +++ b/libyasmine/include/region_pseudostates.hpp @@ -1,24 +1,24 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef REGION_PSEUDOSTATES_96ABC260_2695_4935_9AFD_A76CA61987E0 -#define REGION_PSEUDOSTATES_96ABC260_2695_4935_9AFD_A76CA61987E0 - - -#include "initial_pseudostate.hpp" -#include "terminate_pseudostate.hpp" -#include "choice.hpp" -#include "junction.hpp" -#include "join.hpp" -#include "fork.hpp" - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_PSEUDOSTATES_96ABC260_2695_4935_9AFD_A76CA61987E0 +#define REGION_PSEUDOSTATES_96ABC260_2695_4935_9AFD_A76CA61987E0 + + +#include "initial_pseudostate.hpp" +#include "terminate_pseudostate.hpp" +#include "choice.hpp" +#include "junction.hpp" +#include "join.hpp" +#include "fork.hpp" + + +#endif diff --git a/libyasmine/include/shallow_history.hpp b/libyasmine/include/shallow_history.hpp index 8c0efb0..8f1fa77 100644 --- a/libyasmine/include/shallow_history.hpp +++ b/libyasmine/include/shallow_history.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SHALLOW_HISTORY_2F18336E_AEBD_4040_B40D_E96E0738B83E -#define SHALLOW_HISTORY_2F18336E_AEBD_4040_B40D_E96E0738B83E - - -#include "history.hpp" -#include "shallow_history_fwd.hpp" - - -namespace sxy -{ - - -class shallow_history: - public virtual history -{ -public: - shallow_history() - { - // Nothing to do... - } - - - virtual ~shallow_history() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(shallow_history) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SHALLOW_HISTORY_2F18336E_AEBD_4040_B40D_E96E0738B83E +#define SHALLOW_HISTORY_2F18336E_AEBD_4040_B40D_E96E0738B83E + + +#include "history.hpp" +#include "shallow_history_fwd.hpp" + + +namespace sxy +{ + + +class shallow_history: + public virtual history +{ +public: + shallow_history() + { + // Nothing to do... + } + + + virtual ~shallow_history() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(shallow_history) +}; + + +} + + +#endif diff --git a/libyasmine/include/shallow_history_fwd.hpp b/libyasmine/include/shallow_history_fwd.hpp index 0762d32..7125a93 100644 --- a/libyasmine/include/shallow_history_fwd.hpp +++ b/libyasmine/include/shallow_history_fwd.hpp @@ -1,30 +1,30 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SHALLOW_HISTORY_FWD_42B01401_8D1E_4108_B4C2_7EED7CAE9DFB -#define SHALLOW_HISTORY_FWD_42B01401_8D1E_4108_B4C2_7EED7CAE9DFB - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class shallow_history; -typedef sxe::SX_UNIQUE_PTR< shallow_history > shallow_history_uptr; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SHALLOW_HISTORY_FWD_42B01401_8D1E_4108_B4C2_7EED7CAE9DFB +#define SHALLOW_HISTORY_FWD_42B01401_8D1E_4108_B4C2_7EED7CAE9DFB + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class shallow_history; +typedef sxe::SX_UNIQUE_PTR< shallow_history > shallow_history_uptr; + + +} + + +#endif diff --git a/libyasmine/include/simple_state.hpp b/libyasmine/include/simple_state.hpp index c889ebe..8efda24 100644 --- a/libyasmine/include/simple_state.hpp +++ b/libyasmine/include/simple_state.hpp @@ -1,46 +1,46 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SIMPLE_STATE_FE75D8CB_F61A_4291_94EC_206E43F291AA -#define SIMPLE_STATE_FE75D8CB_F61A_4291_94EC_206E43F291AA - - -#include "complex_state.hpp" - - -namespace sxy -{ - - -class simple_state: - public virtual complex_state -{ -public: - simple_state() - { - // Nothing to do... - } - - - virtual ~simple_state() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(simple_state) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SIMPLE_STATE_FE75D8CB_F61A_4291_94EC_206E43F291AA +#define SIMPLE_STATE_FE75D8CB_F61A_4291_94EC_206E43F291AA + + +#include "complex_state.hpp" + + +namespace sxy +{ + + +class simple_state: + public virtual complex_state +{ +public: + simple_state() + { + // Nothing to do... + } + + + virtual ~simple_state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(simple_state) +}; + + +} + + +#endif diff --git a/libyasmine/include/simple_state_base.hpp b/libyasmine/include/simple_state_base.hpp index cfa0d79..2b9ab90 100644 --- a/libyasmine/include/simple_state_base.hpp +++ b/libyasmine/include/simple_state_base.hpp @@ -1,53 +1,53 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SIMPLE_STATE_BASE_804FA805_18CB_4778_8C90_9B7AB2023D3B -#define SIMPLE_STATE_BASE_804FA805_18CB_4778_8C90_9B7AB2023D3B - - -#include "simple_state.hpp" -#include "complex_state_impl.hpp" - - -namespace sxy -{ - - -class simple_state_base: - public virtual simple_state, public complex_state_impl -{ - - -public: - simple_state_base( const std::string& _name, behavior_uptr _entry_action, behavior_uptr _exit_action, - const event_ids& _deferred_events, event_sptr _error_event ); - virtual ~simple_state_base() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(simple_state_base) - virtual const regions& get_regions() const SX_OVERRIDE; - virtual regions& get_regions() SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual bool has_error_event() const SX_OVERRIDE; - virtual event_sptr get_error_event() const SX_OVERRIDE; - - -private: - event_sptr error_event_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SIMPLE_STATE_BASE_804FA805_18CB_4778_8C90_9B7AB2023D3B +#define SIMPLE_STATE_BASE_804FA805_18CB_4778_8C90_9B7AB2023D3B + + +#include "simple_state.hpp" +#include "complex_state_impl.hpp" + + +namespace sxy +{ + + +class simple_state_base: + public virtual simple_state, public complex_state_impl +{ + + +public: + simple_state_base( const std::string& _name, behavior_uptr _entry_action, behavior_uptr _exit_action, + const event_ids& _deferred_events, event_sptr _error_event ); + virtual ~simple_state_base() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(simple_state_base) + virtual const regions& get_regions() const SX_OVERRIDE; + virtual regions& get_regions() SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual bool has_error_event() const SX_OVERRIDE; + virtual event_sptr get_error_event() const SX_OVERRIDE; + + +private: + event_sptr error_event_; +}; + + +} + + +#endif diff --git a/libyasmine/include/specialized_event.hpp b/libyasmine/include/specialized_event.hpp index 7508a00..e5f5d62 100644 --- a/libyasmine/include/specialized_event.hpp +++ b/libyasmine/include/specialized_event.hpp @@ -1,211 +1,211 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SPECIALIZED_EVENT_CA823D7C_65A6_4094_8641_FA9496F11C1F -#define SPECIALIZED_EVENT_CA823D7C_65A6_4094_8641_FA9496F11C1F - - -#include "event_impl.hpp" - - -namespace sxy -{ - -//!\class specialized_event -//!\brief Class that inherits event_impl and provides a fixed event ID and priority as well as create methods -//!for creating instances of the event. -template -class specialized_event: public event_impl -{ -public: - //!\brief Constructor of the specialized_event class. - explicit specialized_event(const std::string _name = std::string()) - : event_impl( _event_id, _event_priority ), - name_( _name ) - { - // Nothing to do. - } - - - virtual ~specialized_event() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do. - } - - - SX_NO_COPY(specialized_event) - - //!\brief Getter for event's name. - //!\return Name of the event. - virtual std::string get_name() const SX_OVERRIDE - { - const std::string name = name_.empty() ? event_impl::get_name() : name_; - return(name); - } - - - //!\brief Getter for event's ID. - //!\return ID of the event. - virtual sxy::event_id get_id() const SX_OVERRIDE - { - return( _event_id ); - } - - - //!\brief Static getter for event's ID. - //!\return ID of the event.Static method for creating an event - static SX_CONSTEXPR sxy::event_id get_event_id() - { - return( _event_id ); - } - - -#ifdef SX_CPP03_BOOST - - - //!\brief Method for creating an event with no parameters. - //!\return The created event. - static sxe::shared_ptr< _concrete_event > create() - { - return( SX_MAKE_SHARED< _concrete_event >() ); - } - - - //!\brief Method for creating an event with 1 parameter. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1 ) ); - } - - - //!\brief Method for creating an event with 2 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2 ) ); - } - - - //!\brief Method for creating an event with 3 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3 ) ); - } - - - //!\brief Method for creating an event with 4 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4 ) ); - } - - - //!\brief Method for creating an event with 5 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4, const _param_type5& _p5 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5 ) ); - } - - - //!\brief Method for creating an event with 6 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6 ) ); - } - - - //!\brief Method for creating an event with 7 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) ); - } - - - //!\brief Method for creating an event with 8 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, - const _param_type8& _p8 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) ); - } - - - //!\brief Method for creating an event with 9 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, - const _param_type8& _p8, const _param_type9& _p9 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9 ) ); - } - - - //!\brief Method for creating an event with 10 parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, - const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, - const _param_type8& _p8, const _param_type9& _p9, const _param_type10& _p10 ) - { - return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10 ) ); - } - - -#else - //!\brief Method for creating an event with its parameters. - //!\return The created event. - template - static sxe::shared_ptr< _concrete_event > create( _param_types... args ) - { - return( SX_MAKE_SHARED< _concrete_event >( args... ) ); - } - - -#endif - - - -private: - std::string name_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SPECIALIZED_EVENT_CA823D7C_65A6_4094_8641_FA9496F11C1F +#define SPECIALIZED_EVENT_CA823D7C_65A6_4094_8641_FA9496F11C1F + + +#include "event_impl.hpp" + + +namespace sxy +{ + +//!\class specialized_event +//!\brief Class that inherits event_impl and provides a fixed event ID and priority as well as create methods +//!for creating instances of the event. +template +class specialized_event: public event_impl +{ +public: + //!\brief Constructor. + explicit specialized_event(const std::string _name = std::string()) + : event_impl( _event_id, _event_priority ), + name_( _name ) + { + // Nothing to do. + } + + + virtual ~specialized_event() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do. + } + + + SX_NO_COPY(specialized_event) + + //!\brief Getter for event's name. + //!\return Name of the event. + virtual std::string get_name() const SX_OVERRIDE + { + const std::string name = name_.empty() ? event_impl::get_name() : name_; + return(name); + } + + + //!\brief Getter for event's ID. + //!\return ID of the event. + virtual sxy::event_id get_id() const SX_OVERRIDE + { + return( _event_id ); + } + + + //!\brief Static getter for event's ID. + //!\return ID of the event.Static method for creating an event + static SX_CONSTEXPR sxy::event_id get_event_id() + { + return( _event_id ); + } + + +#ifdef SX_CPP03_BOOST + + + //!\brief Method for creating an event with no parameters. + //!\return The created event. + static sxe::shared_ptr< _concrete_event > create() + { + return( SX_MAKE_SHARED< _concrete_event >() ); + } + + + //!\brief Method for creating an event with 1 parameter. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1 ) ); + } + + + //!\brief Method for creating an event with 2 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2 ) ); + } + + + //!\brief Method for creating an event with 3 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3 ) ); + } + + + //!\brief Method for creating an event with 4 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4 ) ); + } + + + //!\brief Method for creating an event with 5 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5 ) ); + } + + + //!\brief Method for creating an event with 6 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6 ) ); + } + + + //!\brief Method for creating an event with 7 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) ); + } + + + //!\brief Method for creating an event with 8 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, + const _param_type8& _p8 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) ); + } + + + //!\brief Method for creating an event with 9 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, + const _param_type8& _p8, const _param_type9& _p9 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9 ) ); + } + + + //!\brief Method for creating an event with 10 parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( const _param_type1& _p1, const _param_type2& _p2, const _param_type3& _p3, + const _param_type4& _p4, const _param_type5& _p5, const _param_type6& _p6, const _param_type7& _p7, + const _param_type8& _p8, const _param_type9& _p9, const _param_type10& _p10 ) + { + return( SX_MAKE_SHARED< _concrete_event >( _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10 ) ); + } + + +#else + //!\brief Method for creating an event with its parameters. + //!\return The created event. + template + static sxe::shared_ptr< _concrete_event > create( _param_types... args ) + { + return( SX_MAKE_SHARED< _concrete_event >( args... ) ); + } + + +#endif + + + +private: + std::string name_; +}; + + +} + + +#endif diff --git a/libyasmine/include/state.hpp b/libyasmine/include/state.hpp index dfc43e2..93a5b71 100644 --- a/libyasmine/include/state.hpp +++ b/libyasmine/include/state.hpp @@ -1,82 +1,82 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_A72D37CD_D9B1_430D_BBCA_13371745FC80 -#define STATE_A72D37CD_D9B1_430D_BBCA_13371745FC80 - - -#include "vertex.hpp" -#include "state_fwd.hpp" -#include "region_fwd.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -class state_visitor; -class behavior; -class event; -class async_event_handler; -class event_collector; - - -class state: - public virtual vertex -{ -public: - state() - { - // Nothing to do... - } - - - virtual ~state() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(state) - virtual void set_parent_region( region* const _parent_region ) = 0; - virtual region * get_parent_region() const = 0; - virtual size_t get_parent_region_index() const = 0; - virtual region * get_region( const std::string& _region_name ) const = 0; - virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const = 0; - virtual behavior * get_entry_behavior() const = 0; - virtual behavior * get_exit_behavior() const = 0; - virtual std::size_t get_nesting_level() const = 0; - virtual void set_active() = 0; - virtual void set_inactive() = 0; - virtual bool is_active() const = 0; - virtual bool is_complete() const = 0; - virtual bool is_event_deferred( const event_id& _event_id ) const = 0; - virtual bool was_active() const = 0; - virtual void set_was_active() = 0; - virtual const regions& get_regions() const = 0; - virtual regions& get_regions() = 0; - virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const = 0; - virtual void execute_enter_behavior( const event& _event, event_collector& _event_collector ) const = 0; - virtual void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const = 0; - virtual void accept_state_visitor( state_visitor& _visitor ) const = 0; - virtual void enter_state( const event& _event, event_collector& _event_collector ) = 0; - virtual void exit_state( const event& _event, event_collector& _event_collector ) = 0; - virtual bool has_error_event() const = 0; - virtual event_sptr get_error_event() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_A72D37CD_D9B1_430D_BBCA_13371745FC80 +#define STATE_A72D37CD_D9B1_430D_BBCA_13371745FC80 + + +#include "vertex.hpp" +#include "state_fwd.hpp" +#include "region_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class state_visitor; +class behavior; +class event; +class async_event_handler; +class event_collector; + + +class state: + public virtual vertex +{ +public: + state() + { + // Nothing to do... + } + + + virtual ~state() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(state) + virtual void set_parent_region( region* const _parent_region ) = 0; + virtual region * get_parent_region() const = 0; + virtual size_t get_parent_region_index() const = 0; + virtual region * get_region( const std::string& _region_name ) const = 0; + virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const = 0; + virtual behavior * get_entry_behavior() const = 0; + virtual behavior * get_exit_behavior() const = 0; + virtual std::size_t get_nesting_level() const = 0; + virtual void set_active() = 0; + virtual void set_inactive() = 0; + virtual bool is_active() const = 0; + virtual bool is_complete() const = 0; + virtual bool is_event_deferred( const event_id& _event_id ) const = 0; + virtual bool was_active() const = 0; + virtual void set_was_active() = 0; + virtual const regions& get_regions() const = 0; + virtual regions& get_regions() = 0; + virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const = 0; + virtual void execute_enter_behavior( const event& _event, event_collector& _event_collector ) const = 0; + virtual void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const = 0; + virtual void accept_state_visitor( state_visitor& _visitor ) const = 0; + virtual void enter_state( const event& _event, event_collector& _event_collector ) = 0; + virtual void exit_state( const event& _event, event_collector& _event_collector ) = 0; + virtual bool has_error_event() const = 0; + virtual event_sptr get_error_event() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/state_fwd.hpp b/libyasmine/include/state_fwd.hpp index 2bcd268..1793b20 100644 --- a/libyasmine/include/state_fwd.hpp +++ b/libyasmine/include/state_fwd.hpp @@ -1,40 +1,40 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_FWD_B1FE7EC2_9444_4D6B_AD05_C59EA6F7FF8A -#define STATE_FWD_B1FE7EC2_9444_4D6B_AD05_C59EA6F7FF8A - - -#include -#include - -#include "states_nesting_comparer.hpp" -#include "states_nesting_comparer_ascending.hpp" - - -namespace sxy -{ - - -class state; -typedef sxe::SX_UNIQUE_PTR< state > state_uptr; -typedef std::vector< const state* > raw_const_states; -typedef std::vector< state_uptr > states; -typedef std::set< const state* > raw_const_state_set; -typedef std::set< const state*, states_nesting_comparer > raw_const_states_by_nesting_level; -typedef std::set< state*, states_nesting_comparer > raw_states_by_nesting_level; -typedef std::set< state*, states_nesting_comparer_ascending > raw_states_by_nesting_level_ascending; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_FWD_B1FE7EC2_9444_4D6B_AD05_C59EA6F7FF8A +#define STATE_FWD_B1FE7EC2_9444_4D6B_AD05_C59EA6F7FF8A + + +#include +#include + +#include "states_nesting_comparer.hpp" +#include "states_nesting_comparer_ascending.hpp" + + +namespace sxy +{ + + +class state; +typedef sxe::SX_UNIQUE_PTR< state > state_uptr; +typedef std::vector< const state* > raw_const_states; +typedef std::vector< state_uptr > states; +typedef std::set< const state* > raw_const_state_set; +typedef std::set< const state*, states_nesting_comparer > raw_const_states_by_nesting_level; +typedef std::set< state*, states_nesting_comparer > raw_states_by_nesting_level; +typedef std::set< state*, states_nesting_comparer_ascending > raw_states_by_nesting_level_ascending; + + +} + + +#endif diff --git a/libyasmine/include/state_impl.hpp b/libyasmine/include/state_impl.hpp index f626e3c..05eff80 100644 --- a/libyasmine/include/state_impl.hpp +++ b/libyasmine/include/state_impl.hpp @@ -1,77 +1,77 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_IMPL_3DE89F57_84D8_41A8_98D2_67E95A9D1C27 -#define STATE_IMPL_3DE89F57_84D8_41A8_98D2_67E95A9D1C27 - - -#include "state.hpp" -#include "vertex_impl.hpp" -#include "behavior_fwd.hpp" -#include "event_fwd.hpp" -#include "optimization.hpp" - - -namespace sxy -{ - - -class state_impl: - public virtual state, public vertex_impl -{ -public: - explicit state_impl( const std::string& _name ); - virtual ~state_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(state_impl) - virtual const state_machine_element * get_parent() const SX_OVERRIDE; - virtual void set_parent_region( region* const _parent_region ) SX_OVERRIDE; - virtual region * get_parent_region() const SX_OVERRIDE; - virtual size_t get_parent_region_index() const SX_OVERRIDE; - virtual region * get_region( const std::string& _region_name ) const SX_OVERRIDE; - virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const SX_OVERRIDE; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, - bool _include_final_ancestor = true ) const SX_OVERRIDE; - virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; - virtual std::size_t get_nesting_level() const SX_OVERRIDE; - virtual void set_was_active() SX_OVERRIDE; - virtual bool was_active() const SX_OVERRIDE; - virtual void set_active() SX_OVERRIDE; - virtual void set_inactive() SX_OVERRIDE; - virtual bool is_active() const SX_OVERRIDE; - virtual bool is_complete() const SX_OVERRIDE; - virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - virtual void execute_enter_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - virtual void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - virtual void enter_state( const event& _event, event_collector& _event_collector ) SX_OVERRIDE; - virtual void exit_state( const event& _event, event_collector& _event_collector ) SX_OVERRIDE; - virtual bool has_error_event() const SX_OVERRIDE; - virtual event_sptr get_error_event() const SX_OVERRIDE; - - -private: - void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const; - void collect_ancestors_as_regions( raw_regions& _ancestors_as_regions ) const; - - bool was_active_; - region* parent_; - -#ifdef Y_OPTIMIZE_4_SPEED - mutable raw_composite_states ancestors_; - mutable raw_regions ancestors_as_regions_; -#endif -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_IMPL_3DE89F57_84D8_41A8_98D2_67E95A9D1C27 +#define STATE_IMPL_3DE89F57_84D8_41A8_98D2_67E95A9D1C27 + + +#include "state.hpp" +#include "vertex_impl.hpp" +#include "behavior_fwd.hpp" +#include "event_fwd.hpp" +#include "optimization.hpp" + + +namespace sxy +{ + + +class state_impl: + public virtual state, public vertex_impl +{ +public: + explicit state_impl( const std::string& _name ); + virtual ~state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(state_impl) + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + virtual void set_parent_region( region* const _parent_region ) SX_OVERRIDE; + virtual region * get_parent_region() const SX_OVERRIDE; + virtual size_t get_parent_region_index() const SX_OVERRIDE; + virtual region * get_region( const std::string& _region_name ) const SX_OVERRIDE; + virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const SX_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const SX_OVERRIDE; + virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; + virtual std::size_t get_nesting_level() const SX_OVERRIDE; + virtual void set_was_active() SX_OVERRIDE; + virtual bool was_active() const SX_OVERRIDE; + virtual void set_active() SX_OVERRIDE; + virtual void set_inactive() SX_OVERRIDE; + virtual bool is_active() const SX_OVERRIDE; + virtual bool is_complete() const SX_OVERRIDE; + virtual void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + virtual void execute_enter_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual void enter_state( const event& _event, event_collector& _event_collector ) SX_OVERRIDE; + virtual void exit_state( const event& _event, event_collector& _event_collector ) SX_OVERRIDE; + virtual bool has_error_event() const SX_OVERRIDE; + virtual event_sptr get_error_event() const SX_OVERRIDE; + + +private: + void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const; + void collect_ancestors_as_regions( raw_regions& _ancestors_as_regions ) const; + + bool was_active_; + region* parent_; + +#ifdef Y_OPTIMIZE_4_SPEED + mutable raw_composite_states ancestors_; + mutable raw_regions ancestors_as_regions_; +#endif +}; + + +} + + +#endif diff --git a/libyasmine/include/state_machine_base.hpp b/libyasmine/include/state_machine_base.hpp index 7ca5fba..e05a784 100644 --- a/libyasmine/include/state_machine_base.hpp +++ b/libyasmine/include/state_machine_base.hpp @@ -1,233 +1,233 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 -#define STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 - - -#include "essentials/compatibility/thread.hpp" - -#include "state_machine_introspection.hpp" -#include "event_collector.hpp" -#include "interruptible.hpp" -#include "transition_kind.hpp" -#include "constraint_fwd.hpp" -#include "behavior_fwd.hpp" -#include "transition_fwd.hpp" -#include "composite_state_fwd.hpp" -#include "region_fwd.hpp" -#include "event_id.hpp" -#include "state_machine_defect_fwd.hpp" - - -namespace sxy -{ - - - class vertex; - class async_event_handler; - class event_processing_callback; - class uri; - class region; - - - //!\class state_machine - //!\brief Base class for the state machines. It provides methods to start the state machine, to fire events, - //!to add transitions, to check the state machine for possible defects and to get the root state reference. - class state_machine_base : - private state_machine_introspection, public event_collector, private interruptible - { - public: - //!\brief Constructor - //!\param _name Name of the state machine. - //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback - //!interface should be used. - explicit state_machine_base( const std::string& _name, - event_processing_callback* const _event_processing_callback = SX_NULLPTR ); - virtual ~state_machine_base() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY( state_machine_base ) - - //!\brief Returns the root state of the state machine. Commonly used to add regions to the root state and to create transitions - //!from and to the root state. - //!\return Reference to the root state of the state machine. - composite_state& get_root_state() const; - -#ifdef Y_PROFILER - sxe::uint32_t get_number_of_processed_events() const; -#endif - - //!\brief Add a transition to the state machine. The state machine takes ownership of the transition. - //!\param _transition A transition. - //!\return transition Reference to the added transition. - virtual transition& add_transition( transition_uptr _transition ); - - //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and - //! target and adds it to the state machine. - //!\param _event_id ID of the event for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\param _guard The guard of the transition. Default is an empty function. - //!\param _behavior The behavior of the transition. Default is an empty function. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const sxy::transition_kind _kind = transition_kind::EXTERNAL, - const constraint_function& _guard = constraint_function(), - const behavior_function& _behavior = behavior_function() ); - - //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and - //! target and adds it to the state machine. - //!\param event_ids List of IDs of the events for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\param _guard The guard of the transition. Default is an empty function. - //!\param _behavior The behavior of the transition. Default is an empty function. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const sxy::transition_kind _kind = transition_kind::EXTERNAL, - const constraint_function& _guard = constraint_function(), - const behavior_function& _behavior = behavior_function() ); - - //!\brief Creates a transition with the given name, kind, event, guard between the given source and - //! target and adds it to the state machine. No behavior is provided. - //!\param _event_id ID of the event for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _guard The guard of the transition. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const constraint_function& _guard, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); - - //!\brief Creates a transition with the given name, kind, events, guard between the given source and - //! target and adds it to the state machine. No behavior is provided. - //!\param _event_ids IDs of the events for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _guard The guard of the transition. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const constraint_function& _guard, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); - - //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and - //! target and adds it to the state machine. - //!\param _event_id ID of the event for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _guard The guard of the transition. - //!\param _behavior The behavior of the transition. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const constraint_function& _guard, const behavior_function& _behavior, - const sxy::transition_kind _kind = transition_kind::EXTERNAL ); - - //!\brief Creates a transition with the given name, kind, events, guard and behavior between the given source and - //! target and adds it to the state machine. - //!\param _event_ids IDs of the events for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _guard The guard of the transition. - //!\param _behavior The behavior of the transition. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const constraint_function& _guard, const behavior_function& _behavior, - const sxy::transition_kind _kind = transition_kind::EXTERNAL ); - - //!\brief Creates a transition with the given name, kind, event and behavior between the given source and - //! target and adds it to the state machine. No guard is provided. - //!\param _event_id ID of the event for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _behavior The behavior of the transition. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); - - //!\brief Creates a transition with the given name, kind, events and behavior between the given source and - //! target and adds it to the state machine. No guard is provided. - //!\param _event_ids IDs of the events for which the transition is enabled. - //!\param _source The source vertex. - //!\param _target The target vertex. - //!\param _behavior The behavior of the transition. - //!\param _kind Transition kind. Default is EXTERNAL. - //!\return A reference to the newly created transition. - virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); - - virtual bool fire_event( const event_sptr& _event ) = 0; - - //!\brief Check the state machine for defects by checking the constraints of each component. - //!\param _defects Collected for all found defects. - //!\return bool true if there are no defects, else false. - bool check( state_machine_defects& _defects ) const; - - virtual bool run() = 0; - - //!\brief Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors. - virtual void halt(); - - //!\brief Sets the internal flag of the state machine, to interrupt all processes inside the state machine and - //!to stop the state machine. - virtual void interrupt(); - - //!\brief Gets the internal flag of the state machine that specify if the run of state machine is interrupted. - //!\return true if the internal flag is set to interrupt the state machine, false otherwise. - //!\sa interrupt - virtual bool is_interrupted() const SX_OVERRIDE; - - - protected: - std::string get_name() const; - - //!\brief Starts the state machine. - //!\param _async_event_handler Pointer to an asynchronous event handler. It's used by - //!the asynchronous state machine if it has to process asynchronous errors that occur in the - //!asynchronous behavior of asynchronous simple states. - //!\return bool true if state machine can be started, else false what means that a terminate pseudostate has been - //!reached and the state machine is stopped. - bool run( async_event_handler* const _async_event_handler ); - bool process_event( const event_sptr& _event, async_event_handler* const _async_event_handler ); - static void stop_all_async_states( state& _state ); - - - private: - virtual const events& get_deferred_events() const SX_OVERRIDE; - virtual raw_const_states get_active_state_configuration() const SX_OVERRIDE; - void get_active_states_from_region( raw_const_states& _active_state_configuration, const region& _region ) const; - void check_regions_for_active_states( raw_const_states& _active_state_configuration, const state& _state ) const; - void add_deferred_event( const event_sptr& _event_id ); - bool process_deferred_events( async_event_handler* const _async_event_handler ); - static void stop_all_async_states_from_region( region_uptr& _region ); - virtual void interrupt_impl(); - - const std::string name_; - event_processing_callback* event_processing_callback_; - composite_state_uptr root_state_; - transitions transitions_; - events deferred_events_; - sxe::atomic state_machine_is_running_; - sxe::atomic interrupt_; -#ifdef Y_PROFILER - sxe::uint32_t processed_events_; -#endif - - }; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 +#define STATE_MACHINE_BASE_484EA235_EEDE_4C19_9C46_C0687D950A13 + + +#include "essentials/compatibility/thread.hpp" + +#include "state_machine_introspection.hpp" +#include "event_collector.hpp" +#include "interruptible.hpp" +#include "transition_kind.hpp" +#include "constraint_fwd.hpp" +#include "behavior_fwd.hpp" +#include "transition_fwd.hpp" +#include "composite_state_fwd.hpp" +#include "region_fwd.hpp" +#include "event_id.hpp" +#include "state_machine_defect_fwd.hpp" + + +namespace sxy +{ + + + class vertex; + class async_event_handler; + class event_processing_callback; + class uri; + class region; + + + //!\class state_machine + //!\brief Base class for the state machines. It provides methods to start the state machine, to fire events, + //!to add transitions, to check the state machine for possible defects and to get the root state reference. + class state_machine_base : + private state_machine_introspection, public event_collector, private interruptible + { + public: + //!\brief Constructor + //!\param _name Name of the state machine. + //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback + //!interface should be used. + explicit state_machine_base( const std::string& _name, + event_processing_callback* const _event_processing_callback = SX_NULLPTR ); + virtual ~state_machine_base() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( state_machine_base ) + + //!\brief Returns the root state of the state machine. Commonly used to add regions to the root state and to create transitions + //!from and to the root state. + //!\return Reference to the root state of the state machine. + composite_state& get_root_state() const; + +#ifdef Y_PROFILER + sxe::uint32_t get_number_of_processed_events() const; +#endif + + //!\brief Add a transition to the state machine. The state machine takes ownership of the transition. + //!\param _transition A transition. + //!\return transition Reference to the added transition. + virtual transition& add_transition( transition_uptr _transition ); + + //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\param _guard The guard of the transition. Default is an empty function. + //!\param _behavior The behavior of the transition. Default is an empty function. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + const constraint_function& _guard = constraint_function(), + const behavior_function& _behavior = behavior_function() ); + + //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param event_ids List of IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\param _guard The guard of the transition. Default is an empty function. + //!\param _behavior The behavior of the transition. Default is an empty function. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + const constraint_function& _guard = constraint_function(), + const behavior_function& _behavior = behavior_function() ); + + //!\brief Creates a transition with the given name, kind, event, guard between the given source and + //! target and adds it to the state machine. No behavior is provided. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const constraint_function& _guard, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, events, guard between the given source and + //! target and adds it to the state machine. No behavior is provided. + //!\param _event_ids IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const constraint_function& _guard, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, event, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const constraint_function& _guard, const behavior_function& _behavior, + const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, events, guard and behavior between the given source and + //! target and adds it to the state machine. + //!\param _event_ids IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _guard The guard of the transition. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const constraint_function& _guard, const behavior_function& _behavior, + const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, event and behavior between the given source and + //! target and adds it to the state machine. No guard is provided. + //!\param _event_id ID of the event for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + //!\brief Creates a transition with the given name, kind, events and behavior between the given source and + //! target and adds it to the state machine. No guard is provided. + //!\param _event_ids IDs of the events for which the transition is enabled. + //!\param _source The source vertex. + //!\param _target The target vertex. + //!\param _behavior The behavior of the transition. + //!\param _kind Transition kind. Default is EXTERNAL. + //!\return A reference to the newly created transition. + virtual transition& add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const behavior_function& _behavior, const sxy::transition_kind _kind = transition_kind::EXTERNAL ); + + virtual bool fire_event( const event_sptr& _event ) = 0; + + //!\brief Check the state machine for defects by checking the constraints of each component. + //!\param _defects Collected for all found defects. + //!\return bool true if there are no defects, else false. + bool check( state_machine_defects& _defects ) const; + + virtual bool run() = 0; + + //!\brief Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors. + virtual void halt(); + + //!\brief Set the internal flag of the state machine, to interrupt all processes inside the state machine and + //!to stop the state machine. + virtual void interrupt(); + + //!\brief Get the internal flag of the state machine that specify if the run of state machine is interrupted. + //!\return true if the internal flag is set to interrupt the state machine, false otherwise. + //!\sa interrupt + virtual bool is_interrupted() const SX_OVERRIDE; + + + protected: + std::string get_name() const; + + //!\brief Starts the state machine. + //!\param _async_event_handler Pointer to an asynchronous event handler. It's used by + //!the asynchronous state machine if it has to process asynchronous errors that occur in the + //!asynchronous behavior of asynchronous simple states. + //!\return bool true if state machine can be started, else false what means that a terminate pseudostate has been + //!reached and the state machine is stopped. + bool run( async_event_handler* const _async_event_handler ); + bool process_event( const event_sptr& _event, async_event_handler* const _async_event_handler ); + static void stop_all_async_states( state& _state ); + + + private: + virtual const events& get_deferred_events() const SX_OVERRIDE; + virtual raw_const_states get_active_state_configuration() const SX_OVERRIDE; + void get_active_states_from_region( raw_const_states& _active_state_configuration, const region& _region ) const; + void check_regions_for_active_states( raw_const_states& _active_state_configuration, const state& _state ) const; + void add_deferred_event( const event_sptr& _event_id ); + bool process_deferred_events( async_event_handler* const _async_event_handler ); + static void stop_all_async_states_from_region( region_uptr& _region ); + virtual void interrupt_impl(); + + const std::string name_; + event_processing_callback* event_processing_callback_; + composite_state_uptr root_state_; + transitions transitions_; + events deferred_events_; + sxe::atomic state_machine_is_running_; + sxe::atomic interrupt_; +#ifdef Y_PROFILER + sxe::uint32_t processed_events_; +#endif + + }; + + +} + + +#endif diff --git a/libyasmine/include/state_machine_defect.hpp b/libyasmine/include/state_machine_defect.hpp index 75dc9f2..1d40639 100644 --- a/libyasmine/include/state_machine_defect.hpp +++ b/libyasmine/include/state_machine_defect.hpp @@ -1,80 +1,80 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC -#define STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC - - -#include "essentials/sxprintf.hpp" -#include "essentials/compatibility/compatibility.hpp" - -#include "state_machine_defect_fwd.hpp" - - -namespace sxy -{ - - -class state_machine_element; - - -class state_machine_defect SX_FINAL -{ - -public: - - -#ifndef SX_CPP03_BOOST - - - template< typename ... args > - state_machine_defect( const state_machine_element &_element, const std::string & _message, args ... _args ): - element_( &_element ), message_( sxe::sxprintf( _message.c_str(), _args ... ) ) - { - // Nothing to do. - } - - -#else - - state_machine_defect( const state_machine_element&_element, const std::string & _message ); - state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value ); - state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, - const sxe::value_type &_value2 ); - state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, - const sxe::value_type &_value2, const sxe::value_type&_value3 ); - state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, - const sxe::value_type &_value2, const sxe::value_type &_value3, const sxe::value_type &_value4 ); - state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, - const sxe::value_type &_value2, const sxe::value_type &_value3, const sxe::value_type &_value4, - const sxe::value_type &_value5 ); - -#endif - - - ~state_machine_defect() SX_NOEXCEPT; - - - const state_machine_element& get_element() const; - const std::string& get_message() const; - - -private: - const state_machine_element* element_; - std::string message_; -}; - - -void write_defects_to_log( const state_machine_defects& _defects ); -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC +#define STATE_MACHINE_DEFECT_B3B7FA9A_C6E8_496E_8A31_E00451C9B7AC + + +#include "essentials/sxprintf.hpp" +#include "essentials/compatibility/compatibility.hpp" + +#include "state_machine_defect_fwd.hpp" + + +namespace sxy +{ + + +class state_machine_element; + + +class state_machine_defect SX_FINAL +{ + +public: + + +#ifndef SX_CPP03_BOOST + + + template< typename ... args > + state_machine_defect( const state_machine_element &_element, const std::string & _message, args ... _args ): + element_( &_element ), message_( sxe::sxprintf( _message.c_str(), _args ... ) ) + { + // Nothing to do. + } + + +#else + + state_machine_defect( const state_machine_element&_element, const std::string & _message ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2 ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2, const sxe::value_type&_value3 ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2, const sxe::value_type &_value3, const sxe::value_type &_value4 ); + state_machine_defect( const state_machine_element&_element, const std::string & _message, const sxe::value_type &_value1, + const sxe::value_type &_value2, const sxe::value_type &_value3, const sxe::value_type &_value4, + const sxe::value_type &_value5 ); + +#endif + + + ~state_machine_defect() SX_NOEXCEPT; + + + const state_machine_element& get_element() const; + const std::string& get_message() const; + + +private: + const state_machine_element* element_; + std::string message_; +}; + + +void write_defects_to_log( const state_machine_defects& _defects ); +} + + +#endif diff --git a/libyasmine/include/state_machine_defect_fwd.hpp b/libyasmine/include/state_machine_defect_fwd.hpp index e1a2f6a..d5c445a 100644 --- a/libyasmine/include/state_machine_defect_fwd.hpp +++ b/libyasmine/include/state_machine_defect_fwd.hpp @@ -1,31 +1,31 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_DEFECT_FWD_1B447269_4868_47C6_AE95_566BF658EAE3 -#define STATE_MACHINE_DEFECT_FWD_1B447269_4868_47C6_AE95_566BF658EAE3 - - -#include - - -namespace sxy -{ - - -class state_machine_defect; - -typedef std::vector< state_machine_defect > state_machine_defects; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_DEFECT_FWD_1B447269_4868_47C6_AE95_566BF658EAE3 +#define STATE_MACHINE_DEFECT_FWD_1B447269_4868_47C6_AE95_566BF658EAE3 + + +#include + + +namespace sxy +{ + + +class state_machine_defect; + +typedef std::vector< state_machine_defect > state_machine_defects; + + +} + + +#endif diff --git a/libyasmine/include/state_machine_element.hpp b/libyasmine/include/state_machine_element.hpp index 90a90c1..dae5bf1 100644 --- a/libyasmine/include/state_machine_element.hpp +++ b/libyasmine/include/state_machine_element.hpp @@ -1,53 +1,53 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_ELEMENT_122BB9E6_0CA4_4EEC_A341_EAD756AC89E9 -#define STATE_MACHINE_ELEMENT_122BB9E6_0CA4_4EEC_A341_EAD756AC89E9 - - -#include "essentials/non_copyable.hpp" - -#include "state_machine_defect_fwd.hpp" -#include "uri.hpp" - - -namespace sxy -{ - - -class state_machine_element -{ -public: - state_machine_element() - { - // Nothing to do... - } - - - virtual ~state_machine_element() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(state_machine_element) - virtual const std::string& get_name() const = 0; - virtual uri get_uri() const = 0; - virtual void add_ancestor_uri( uri& _uri ) const = 0; - virtual bool check( state_machine_defects& _defects ) const = 0; - virtual const state_machine_element * get_parent() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_ELEMENT_122BB9E6_0CA4_4EEC_A341_EAD756AC89E9 +#define STATE_MACHINE_ELEMENT_122BB9E6_0CA4_4EEC_A341_EAD756AC89E9 + + +#include "essentials/non_copyable.hpp" +#include "essentials/uri.hpp" + +#include "state_machine_defect_fwd.hpp" + + +namespace sxy +{ + + +class state_machine_element +{ +public: + state_machine_element() + { + // Nothing to do... + } + + + virtual ~state_machine_element() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(state_machine_element) + virtual const std::string& get_name() const = 0; + virtual sxe::uri get_uri() const = 0; + virtual void add_ancestor_uri( sxe::uri& _uri ) const = 0; + virtual bool check( state_machine_defects& _defects ) const = 0; + virtual const state_machine_element * get_parent() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/state_machine_element_impl.hpp b/libyasmine/include/state_machine_element_impl.hpp index d4411a8..3b7bfa1 100644 --- a/libyasmine/include/state_machine_element_impl.hpp +++ b/libyasmine/include/state_machine_element_impl.hpp @@ -1,43 +1,43 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_ELEMENT_IMPL_EC5B279B_E7A2_40CF_8D97_F0581F89B36C -#define STATE_MACHINE_ELEMENT_IMPL_EC5B279B_E7A2_40CF_8D97_F0581F89B36C - - -#include - -#include "state_machine_element.hpp" - - -namespace sxy -{ - - -class state_machine_element_impl: - public virtual state_machine_element -{ -public: - explicit state_machine_element_impl( const std::string& _name ); - virtual ~state_machine_element_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(state_machine_element_impl) - virtual const std::string& get_name() const SX_OVERRIDE; - - -private: - const std::string name_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_ELEMENT_IMPL_EC5B279B_E7A2_40CF_8D97_F0581F89B36C +#define STATE_MACHINE_ELEMENT_IMPL_EC5B279B_E7A2_40CF_8D97_F0581F89B36C + + +#include + +#include "state_machine_element.hpp" + + +namespace sxy +{ + + +class state_machine_element_impl: + public virtual state_machine_element +{ +public: + explicit state_machine_element_impl( const std::string& _name ); + virtual ~state_machine_element_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(state_machine_element_impl) + virtual const std::string& get_name() const SX_OVERRIDE; + + +private: + const std::string name_; +}; + + +} + + +#endif diff --git a/libyasmine/include/state_machine_introspection.hpp b/libyasmine/include/state_machine_introspection.hpp index 214906d..357ae20 100644 --- a/libyasmine/include/state_machine_introspection.hpp +++ b/libyasmine/include/state_machine_introspection.hpp @@ -1,56 +1,56 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_MACHINE_INTROSPECTION_45E0820B_4D2F_4EF7_AF0D_EA840DA9F7C0 -#define STATE_MACHINE_INTROSPECTION_45E0820B_4D2F_4EF7_AF0D_EA840DA9F7C0 - - -#include "essentials/non_copyable.hpp" - -#include "state_fwd.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -//!\interface state_machine_introspection -//!\brief The interface for state machine introspection. It is inherited by the state machine class state_machine. -class state_machine_introspection -{ -public: - //!\brief Constructor of state_machine_introspection. - state_machine_introspection() - { - // Nothing to do... - } - - - virtual ~state_machine_introspection() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(state_machine_introspection) - - //!\brief Gets the active state configuration of the state machine. - //!\return A list of active states of the state machine at the moment when the function is called. - virtual raw_const_states get_active_state_configuration() const = 0; - virtual const events& get_deferred_events() const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_MACHINE_INTROSPECTION_45E0820B_4D2F_4EF7_AF0D_EA840DA9F7C0 +#define STATE_MACHINE_INTROSPECTION_45E0820B_4D2F_4EF7_AF0D_EA840DA9F7C0 + + +#include "essentials/non_copyable.hpp" + +#include "state_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +//!\interface state_machine_introspection +//!\brief The interface for state machine introspection. It is inherited by the state machine class state_machine. +class state_machine_introspection +{ +public: + //!\brief Constructor. + state_machine_introspection() + { + // Nothing to do... + } + + + virtual ~state_machine_introspection() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(state_machine_introspection) + + //!\brief Get the active state configuration of the state machine. + //!\return A list of active states of the state machine at the moment when the function is called. + virtual raw_const_states get_active_state_configuration() const = 0; + virtual const events& get_deferred_events() const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/state_machine_status.hpp b/libyasmine/include/state_machine_status.hpp index f93fa63..3b57a60 100644 --- a/libyasmine/include/state_machine_status.hpp +++ b/libyasmine/include/state_machine_status.hpp @@ -1,68 +1,68 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 -#define STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 - - -namespace sxy -{ - - -#ifndef SX_CPP03_BOOST - enum class state_machine_status - { - NEW, STARTED, STOP_REQUESTED, TERMINATED, STOPPED - }; -#else - struct state_machine_status - { - enum inner - { - NEW, STARTED, STOP_REQUESTED, TERMINATED, STOPPED - }; - - - state_machine_status() : value_( NEW ) - { - // Nothing to do... - } - - - // cppcheck-suppress noExplicitConstructor - state_machine_status( const inner _value ) : value_( _value ) - { - // Nothing to do... - } - - - // cppcheck-suppress functionConst - operator inner() - { - return ( value_ ); - } - - - inner value_; - - }; - - - bool operator==( const state_machine_status& _lhs, const state_machine_status::inner _rhs ); - bool operator==( const state_machine_status::inner _lhs, const state_machine_status& _rhs ); - - -#endif - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 +#define STATUS_A02F2056_A314_4093_B3AB_75FEBFB43A57 + + +namespace sxy +{ + + +#ifndef SX_CPP03_BOOST + enum class state_machine_status + { + NEW, STARTED, STOP_REQUESTED, TERMINATED, STOPPED + }; +#else + struct state_machine_status + { + enum inner + { + NEW, STARTED, STOP_REQUESTED, TERMINATED, STOPPED + }; + + + state_machine_status() : value_( NEW ) + { + // Nothing to do... + } + + + // cppcheck-suppress noExplicitConstructor + state_machine_status( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + // cppcheck-suppress functionConst + operator inner() + { + return ( value_ ); + } + + + inner value_; + + }; + + + bool operator==( const state_machine_status& _lhs, const state_machine_status::inner _rhs ); + bool operator==( const state_machine_status::inner _lhs, const state_machine_status& _rhs ); + + +#endif + + +} + +#endif diff --git a/libyasmine/include/state_pseudostate.hpp b/libyasmine/include/state_pseudostate.hpp index 018edc6..75fbd37 100644 --- a/libyasmine/include/state_pseudostate.hpp +++ b/libyasmine/include/state_pseudostate.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_PSEUDOSTATE_73003664_F128_436A_8412_B1453D067026 -#define STATE_PSEUDOSTATE_73003664_F128_436A_8412_B1453D067026 - - -#include "pseudostate.hpp" -#include "composite_state.hpp" - - -namespace sxy -{ - - -class state_pseudostate: - public virtual pseudostate -{ -public: - state_pseudostate() - { - // Nothing to do... - } - - - virtual ~state_pseudostate() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(state_pseudostate) - virtual composite_state& get_parent_state() const = 0; - virtual void set_parent_state( composite_state* const _parent_state ) = 0; -}; - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_PSEUDOSTATE_73003664_F128_436A_8412_B1453D067026 +#define STATE_PSEUDOSTATE_73003664_F128_436A_8412_B1453D067026 + + +#include "pseudostate.hpp" +#include "composite_state.hpp" + + +namespace sxy +{ + + +class state_pseudostate: + public virtual pseudostate +{ +public: + state_pseudostate() + { + // Nothing to do... + } + + + virtual ~state_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(state_pseudostate) + virtual composite_state& get_parent_state() const = 0; + virtual void set_parent_state( composite_state* const _parent_state ) = 0; +}; + + +} + +#endif diff --git a/libyasmine/include/state_pseudostates.hpp b/libyasmine/include/state_pseudostates.hpp index e747bcc..88ff247 100644 --- a/libyasmine/include/state_pseudostates.hpp +++ b/libyasmine/include/state_pseudostates.hpp @@ -1,22 +1,22 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef INCLUDE_STATE_PSEUDOSTATES_16AAE994_A9EF_4E66_A5EE_A0900700796C -#define INCLUDE_STATE_PSEUDOSTATES_16AAE994_A9EF_4E66_A5EE_A0900700796C - - -#include "entry_point.hpp" -#include "exit_point.hpp" -#include "deep_history.hpp" -#include "shallow_history.hpp" - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INCLUDE_STATE_PSEUDOSTATES_16AAE994_A9EF_4E66_A5EE_A0900700796C +#define INCLUDE_STATE_PSEUDOSTATES_16AAE994_A9EF_4E66_A5EE_A0900700796C + + +#include "entry_point.hpp" +#include "exit_point.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" + + +#endif diff --git a/libyasmine/include/states.hpp b/libyasmine/include/states.hpp index d1e97e6..f8d415e 100644 --- a/libyasmine/include/states.hpp +++ b/libyasmine/include/states.hpp @@ -1,30 +1,30 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATES_6E221415_EBDC_407C_B71B_99E822319A77 -#define STATES_6E221415_EBDC_407C_B71B_99E822319A77 - - -#include "simple_state.hpp" -#include "composite_state.hpp" -#include "final_state.hpp" - - -#ifndef Y_LEAN_AND_MEAN - - -#include "async_simple_state_impl.hpp" - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_6E221415_EBDC_407C_B71B_99E822319A77 +#define STATES_6E221415_EBDC_407C_B71B_99E822319A77 + + +#include "simple_state.hpp" +#include "composite_state.hpp" +#include "final_state.hpp" + + +#ifndef Y_LEAN_AND_MEAN + + +#include "async_simple_state_impl.hpp" + + +#endif + + +#endif diff --git a/libyasmine/include/states_nesting_comparer.hpp b/libyasmine/include/states_nesting_comparer.hpp index 790c691..7fffadd 100644 --- a/libyasmine/include/states_nesting_comparer.hpp +++ b/libyasmine/include/states_nesting_comparer.hpp @@ -1,38 +1,38 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATES_NESTING_COMPARER_B8C0C256_3761_47DC_A60A_DB2BF706EEB0 -#define STATES_NESTING_COMPARER_B8C0C256_3761_47DC_A60A_DB2BF706EEB0 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class state; - - -struct states_nesting_comparer SX_FINAL -{ -public: - states_nesting_comparer(); - ~states_nesting_comparer() SX_NOEXCEPT; - bool operator()( const state& _lhs, const state& _rhs ) const; - bool operator()( const state* const _lhs, const state* const _rhs ) const; -}; - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_NESTING_COMPARER_B8C0C256_3761_47DC_A60A_DB2BF706EEB0 +#define STATES_NESTING_COMPARER_B8C0C256_3761_47DC_A60A_DB2BF706EEB0 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class state; + + +struct states_nesting_comparer SX_FINAL +{ +public: + states_nesting_comparer(); + ~states_nesting_comparer() SX_NOEXCEPT; + bool operator()( const state& _lhs, const state& _rhs ) const; + bool operator()( const state* const _lhs, const state* const _rhs ) const; +}; + +} + + +#endif diff --git a/libyasmine/include/states_nesting_comparer_ascending.hpp b/libyasmine/include/states_nesting_comparer_ascending.hpp index e7ec336..d88372f 100644 --- a/libyasmine/include/states_nesting_comparer_ascending.hpp +++ b/libyasmine/include/states_nesting_comparer_ascending.hpp @@ -1,38 +1,38 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATES_NESTING_COMPARER_ASCENDING_D08136C5_FE07_48F1_8D77_5C460EC2EFF4 -#define STATES_NESTING_COMPARER_ASCENDING_D08136C5_FE07_48F1_8D77_5C460EC2EFF4 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class state; - - -struct states_nesting_comparer_ascending SX_FINAL -{ -public: - states_nesting_comparer_ascending(); - ~states_nesting_comparer_ascending() SX_NOEXCEPT; - bool operator()( const state& _lhs, const state& _rhs ) const; - bool operator()( const state* const _lhs, const state* const _rhs ) const; -}; - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_NESTING_COMPARER_ASCENDING_D08136C5_FE07_48F1_8D77_5C460EC2EFF4 +#define STATES_NESTING_COMPARER_ASCENDING_D08136C5_FE07_48F1_8D77_5C460EC2EFF4 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class state; + + +struct states_nesting_comparer_ascending SX_FINAL +{ +public: + states_nesting_comparer_ascending(); + ~states_nesting_comparer_ascending() SX_NOEXCEPT; + bool operator()( const state& _lhs, const state& _rhs ) const; + bool operator()( const state* const _lhs, const state* const _rhs ) const; +}; + +} + + +#endif diff --git a/libyasmine/include/sync_state_machine.hpp b/libyasmine/include/sync_state_machine.hpp index d0ecd1b..443ed34 100644 --- a/libyasmine/include/sync_state_machine.hpp +++ b/libyasmine/include/sync_state_machine.hpp @@ -1,68 +1,68 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SYNC_STATE_MACHINE_5352FE73_987B_4ECB_9320_685740A30EAA -#define SYNC_STATE_MACHINE_5352FE73_987B_4ECB_9320_685740A30EAA - - -#include -#include "state_machine_base.hpp" - - -namespace sxy -{ - - -//!\class sync_state_machine -//!\brief Class for the "single-threaded version" of the state machine. It provides the methods to start the state -//!machine, to fire events, to check the state machine for possible defects and to get the root state reference. -class sync_state_machine: - public state_machine_base -{ -public: - //!\brief Constructor of sync_state_machine. - //!\param _name Name of the state machine. - //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback - //!interface should be used. - explicit sync_state_machine( const std::string& _name, - event_processing_callback* const _event_processing_callback = SX_NULLPTR ); - virtual ~sync_state_machine() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY( sync_state_machine ) - - virtual bool push( const event_sptr& _event ) SX_OVERRIDE; - - //!\brief Fire the given event. - //!\param _event Event to be fired. - //!\return true if event was successfully fired, else false what means that a terminate pseudostate has been reached, - //!the state machine was stopped and no further events can be fired. - virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; - - //!\brief Starts the state machine. - //!\return bool true if state machine can be started, else false what means that a terminate pseudostate has been - //!reached and the state machine is stopped. - virtual bool run() SX_OVERRIDE; - - -private: - bool process_events_from_queue(); - - std::list event_list_; -}; - - -//!\deprecated use sync_state_machine instead -typedef sync_state_machine state_machine; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SYNC_STATE_MACHINE_5352FE73_987B_4ECB_9320_685740A30EAA +#define SYNC_STATE_MACHINE_5352FE73_987B_4ECB_9320_685740A30EAA + + +#include +#include "state_machine_base.hpp" + + +namespace sxy +{ + + +//!\class sync_state_machine +//!\brief Class for the "single-threaded version" of the state machine. It provides the methods to start the state +//!machine, to fire events, to check the state machine for possible defects and to get the root state reference. +class sync_state_machine: + public state_machine_base +{ +public: + //!\brief Constructor. + //!\param _name Name of the state machine. + //!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback + //!interface should be used. + explicit sync_state_machine( const std::string& _name, + event_processing_callback* const _event_processing_callback = SX_NULLPTR ); + virtual ~sync_state_machine() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( sync_state_machine ) + + virtual bool push( const event_sptr& _event ) SX_OVERRIDE; + + //!\brief Fire the given event. + //!\param _event Event to be fired. + //!\return true if event was successfully fired, else false what means that a terminate pseudostate has been reached, + //!the state machine was stopped and no further events can be fired. + virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; + + //!\brief Starts the state machine. + //!\return bool true if state machine can be started, else false what means that a terminate pseudostate has been + //!reached and the state machine is stopped. + virtual bool run() SX_OVERRIDE; + + +private: + bool process_events_from_queue(); + + std::list event_list_; +}; + + +//!\deprecated use sync_state_machine instead +typedef sync_state_machine state_machine; + + +} + + +#endif diff --git a/libyasmine/include/terminate_pseudostate.hpp b/libyasmine/include/terminate_pseudostate.hpp index a689d61..d21635a 100644 --- a/libyasmine/include/terminate_pseudostate.hpp +++ b/libyasmine/include/terminate_pseudostate.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TERMINATE_PSEUDOSTATE_86477850_30F8_412F_B194_45E54964DF7B -#define TERMINATE_PSEUDOSTATE_86477850_30F8_412F_B194_45E54964DF7B - - -#include "region_pseudostate.hpp" -#include "terminate_pseudostate_fwd.hpp" - - -namespace sxy -{ - - -class terminate_pseudostate: - public virtual region_pseudostate -{ -public: - terminate_pseudostate() - { - // Nothing to do... - } - - - virtual ~terminate_pseudostate() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(terminate_pseudostate) -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TERMINATE_PSEUDOSTATE_86477850_30F8_412F_B194_45E54964DF7B +#define TERMINATE_PSEUDOSTATE_86477850_30F8_412F_B194_45E54964DF7B + + +#include "region_pseudostate.hpp" +#include "terminate_pseudostate_fwd.hpp" + + +namespace sxy +{ + + +class terminate_pseudostate: + public virtual region_pseudostate +{ +public: + terminate_pseudostate() + { + // Nothing to do... + } + + + virtual ~terminate_pseudostate() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(terminate_pseudostate) +}; + + +} + + +#endif diff --git a/libyasmine/include/terminate_pseudostate_fwd.hpp b/libyasmine/include/terminate_pseudostate_fwd.hpp index 44eaa03..86bd1e8 100644 --- a/libyasmine/include/terminate_pseudostate_fwd.hpp +++ b/libyasmine/include/terminate_pseudostate_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TERMINATE_PSEUDOSTATE_FWD_C63AEEFF_DBF1_44D5_961A_A2E4D0BB745B -#define TERMINATE_PSEUDOSTATE_FWD_C63AEEFF_DBF1_44D5_961A_A2E4D0BB745B - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class terminate_pseudostate; -typedef sxe::SX_UNIQUE_PTR< terminate_pseudostate > terminate_pseudostate_uptr; -typedef std::vector< terminate_pseudostate_uptr > terminate_pseudostates; -typedef std::vector< const terminate_pseudostate* > raw_const_terminate_pseudostates; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TERMINATE_PSEUDOSTATE_FWD_C63AEEFF_DBF1_44D5_961A_A2E4D0BB745B +#define TERMINATE_PSEUDOSTATE_FWD_C63AEEFF_DBF1_44D5_961A_A2E4D0BB745B + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class terminate_pseudostate; +typedef sxe::SX_UNIQUE_PTR< terminate_pseudostate > terminate_pseudostate_uptr; +typedef std::vector< terminate_pseudostate_uptr > terminate_pseudostates; +typedef std::vector< const terminate_pseudostate* > raw_const_terminate_pseudostates; + + +} + + +#endif diff --git a/libyasmine/include/timed_event_creator.hpp b/libyasmine/include/timed_event_creator.hpp index 321a59b..5b77fd3 100644 --- a/libyasmine/include/timed_event_creator.hpp +++ b/libyasmine/include/timed_event_creator.hpp @@ -1,115 +1,115 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TIMED_EVENT_CREATOR_14DCF0FF_0E5B_41DE_B213_C7CC1610A406 -#define TIMED_EVENT_CREATOR_14DCF0FF_0E5B_41DE_B213_C7CC1610A406 - - -#include - -#include "essentials/compatibility/thread.hpp" - -#include "event_creation_request_time_comparer.hpp" -#include "event_creation_request.hpp" - - -namespace sxy -{ - - -class async_state_machine; - - -typedef std::set< event_creation_request, event_creation_request_time_comparer > event_queue; - -//!\class timed_event_creator -//!\brief Provides the possibility to create timed events. It uses the state machine passed into the constructor as -//!target for the events. -class timed_event_creator SX_FINAL -{ -public: - //!\brief Constructor of timed_event_creator. - //!\param _async_state_machine - state_machine the created events are sent to. - explicit timed_event_creator( async_state_machine& _async_state_machine ); - ~timed_event_creator() SX_NOEXCEPT; - SX_NO_COPY(timed_event_creator) - - //!\brief Creates an event creation request. - //!\param _time_till_event_is_fired The time point when the event should be fired. - //!\param _event The event that will be fired. - //!\return Handle of the new event creation request. The handle can be used for canceling the request. - //!\sa cancel() - handle_type create_event_creation_request( const sxe::time_point< sxe::system_clock >& _time_till_event_is_fired, - const event_sptr _event ); - - //!\brief Creates an event creation request. - //!\param _time The time duration after that the event should be fired. - //!\param _event The event that will be fired. - //!\return Handle of the new event creation request. The handle can be used for canceling the request. - //!\sa cancel() - handle_type create_event_creation_request( const sxe::milliseconds& _time, const event_sptr& _event ); - - //!\brief Cancels the event creation request with the given handle if the event is still in the queue of the event - //!creator. - //!\param _handle const handle_type Handle of the event creation request that should be canceled. - //!\return true if the event was canceled or false if the event could not be canceled. - //!\sa create() - bool cancel( const handle_type _handle ); - - //!\brief Starts the event creator. This has to be called before creating timed events. - //!\return void - //!\sa halt(), join(), halt_and_join() - void run(); - - //!\brief Stops the event creator. The event creator needs to be stopped before it is destroyed (if it was started). - //!Else the internal thread is not cleaned-up correctly. - //!\return void - //!\sa run(), join(), halt_and_join() - void halt(); - - //!\brief Joins the event creator thread. - //!\return void - //!\sa run(), stop(), halt_and_join() - void join(); - - //!\brief Stops and joins the event creator thread. The event creator needs to be stopped before it is destroyed (if it was started). - //!Else the internal thread is not cleaned-up correctly. - //!\return void - //!\sa run(), join(), halt() - void halt_and_join(); - - -private: - // cppcheck-suppress unusedPrivateFunction - handle_type generate_handle(); - bool check_if_handle_exists( const handle_type _handle ) const; - void generate_event(); - event_queue::const_iterator find_element_by_handle( const handle_type _handle ) const; - static bool compare_handles( const handle_type _handle, const event_creation_request& _event_creation_request ); - bool check_wait_condition() const; - - async_state_machine& state_machine_; - event_queue event_creation_requests_; - sxe::SX_UNIQUE_PTR< sxe::thread > worker_; - sxe::mutex mutex_; - sxe::condition_variable condition_variable_; - bool run_; - - handle_type maximum_handle_; - - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TIMED_EVENT_CREATOR_14DCF0FF_0E5B_41DE_B213_C7CC1610A406 +#define TIMED_EVENT_CREATOR_14DCF0FF_0E5B_41DE_B213_C7CC1610A406 + + +#include + +#include "essentials/compatibility/thread.hpp" + +#include "event_creation_request_time_comparer.hpp" +#include "event_creation_request.hpp" + + +namespace sxy +{ + + +class async_state_machine; + + +typedef std::set< event_creation_request, event_creation_request_time_comparer > event_queue; + +//!\class timed_event_creator +//!\brief Provides the possibility to create timed events. It uses the state machine passed into the constructor as +//!target for the events. +class timed_event_creator SX_FINAL +{ +public: + //!\brief Constructor. + //!\param _async_state_machine - state_machine the created events are sent to. + explicit timed_event_creator( async_state_machine& _async_state_machine ); + ~timed_event_creator() SX_NOEXCEPT; + SX_NO_COPY(timed_event_creator) + + //!\brief Creates an event creation request. + //!\param _time_till_event_is_fired The time point when the event should be fired. + //!\param _event The event that will be fired. + //!\return Handle of the new event creation request. The handle can be used for canceling the request. + //!\sa cancel() + handle_type create_event_creation_request( const sxe::time_point< sxe::system_clock >& _time_till_event_is_fired, + const event_sptr _event ); + + //!\brief Creates an event creation request. + //!\param _time The time duration after that the event should be fired. + //!\param _event The event that will be fired. + //!\return Handle of the new event creation request. The handle can be used for canceling the request. + //!\sa cancel() + handle_type create_event_creation_request( const sxe::milliseconds& _time, const event_sptr& _event ); + + //!\brief Cancels the event creation request with the given handle if the event is still in the queue of the event + //!creator. + //!\param _handle const handle_type Handle of the event creation request that should be canceled. + //!\return true if the event was canceled or false if the event could not be canceled. + //!\sa create() + bool cancel( const handle_type _handle ); + + //!\brief Starts the event creator. This has to be called before creating timed events. + //!\return void + //!\sa halt(), join(), halt_and_join() + void run(); + + //!\brief Stops the event creator. The event creator needs to be stopped before it is destroyed (if it was started). + //!Else the internal thread is not cleaned-up correctly. + //!\return void + //!\sa run(), join(), halt_and_join() + void halt(); + + //!\brief Joins the event creator thread. + //!\return void + //!\sa run(), stop(), halt_and_join() + void join(); + + //!\brief Stops and joins the event creator thread. The event creator needs to be stopped before it is destroyed (if it was started). + //!Else the internal thread is not cleaned-up correctly. + //!\return void + //!\sa run(), join(), halt() + void halt_and_join(); + + +private: + // cppcheck-suppress unusedPrivateFunction + handle_type generate_handle(); + bool check_if_handle_exists( const handle_type _handle ) const; + void generate_event(); + event_queue::const_iterator find_element_by_handle( const handle_type _handle ) const; + static bool compare_handles( const handle_type _handle, const event_creation_request& _event_creation_request ); + bool check_wait_condition() const; + + async_state_machine& state_machine_; + event_queue event_creation_requests_; + sxe::SX_UNIQUE_PTR< sxe::thread > worker_; + sxe::mutex mutex_; + sxe::condition_variable condition_variable_; + bool run_; + + handle_type maximum_handle_; + + +}; + + +} + + +#endif diff --git a/libyasmine/include/transition.hpp b/libyasmine/include/transition.hpp index 7180563..08689c3 100644 --- a/libyasmine/include/transition.hpp +++ b/libyasmine/include/transition.hpp @@ -1,67 +1,67 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_9D568568_F100_40E3_B02C_1141C218D7D8 -#define TRANSITION_9D568568_F100_40E3_B02C_1141C218D7D8 - - -#include "state_machine_element.hpp" - -#include "transition_kind.hpp" -#include "event_id.hpp" -#include "transition_fwd.hpp" - - -namespace sxy -{ - - -class vertex; -class constraint; -class behavior; -class event; -class event_collector; - - -class transition: - public virtual state_machine_element -{ -public: - transition() - { - // Nothing to do... - } - - - virtual ~transition() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(transition) - virtual const vertex& get_source() const = 0; - virtual const vertex& get_target() const = 0; - virtual vertex& get_target() = 0; - virtual const constraint * get_guard() const = 0; - virtual const behavior * get_behavior() const = 0; - virtual sxy::transition_kind get_kind() const = 0; - virtual void on_transition_behavior( const event& _event, event_collector& _event_collector ) const = 0; - virtual bool check_guard( const event& _event, event_collector& _event_collector ) const = 0; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; - virtual bool can_accept_event( const event_id _event ) const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_9D568568_F100_40E3_B02C_1141C218D7D8 +#define TRANSITION_9D568568_F100_40E3_B02C_1141C218D7D8 + + +#include "state_machine_element.hpp" + +#include "transition_kind.hpp" +#include "event_id.hpp" +#include "transition_fwd.hpp" + + +namespace sxy +{ + + +class vertex; +class constraint; +class behavior; +class event; +class event_collector; + + +class transition: + public virtual state_machine_element +{ +public: + transition() + { + // Nothing to do... + } + + + virtual ~transition() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(transition) + virtual const vertex& get_source() const = 0; + virtual const vertex& get_target() const = 0; + virtual vertex& get_target() = 0; + virtual const constraint * get_guard() const = 0; + virtual const behavior * get_behavior() const = 0; + virtual sxy::transition_kind get_kind() const = 0; + virtual void on_transition_behavior( const event& _event, event_collector& _event_collector ) const = 0; + virtual bool check_guard( const event& _event, event_collector& _event_collector ) const = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; + virtual bool can_accept_event( const event_id _event ) const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/transition_fwd.hpp b/libyasmine/include/transition_fwd.hpp index 15fbe7e..ebe00e3 100644 --- a/libyasmine/include/transition_fwd.hpp +++ b/libyasmine/include/transition_fwd.hpp @@ -1,37 +1,37 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_FWD_394BD21E_9C09_454E_8C58_19F984D09497 -#define TRANSITION_FWD_394BD21E_9C09_454E_8C58_19F984D09497 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class transition; - - -typedef sxe::SX_UNIQUE_PTR< transition > transition_uptr; -typedef std::vector< const transition* > raw_const_transitions; -typedef std::vector< transition* > raw_transitions; -typedef std::vector< transition_uptr > transitions; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_FWD_394BD21E_9C09_454E_8C58_19F984D09497 +#define TRANSITION_FWD_394BD21E_9C09_454E_8C58_19F984D09497 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class transition; + + +typedef sxe::SX_UNIQUE_PTR< transition > transition_uptr; +typedef std::vector< const transition* > raw_const_transitions; +typedef std::vector< transition* > raw_transitions; +typedef std::vector< transition_uptr > transitions; + + +} + + +#endif diff --git a/libyasmine/include/transition_impl.hpp b/libyasmine/include/transition_impl.hpp index 3a3f79c..2c721f5 100644 --- a/libyasmine/include/transition_impl.hpp +++ b/libyasmine/include/transition_impl.hpp @@ -1,78 +1,78 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_IMPL_9F6CF536_11D2_4F11_B5FB_AB930B935720 -#define TRANSITION_IMPL_9F6CF536_11D2_4F11_B5FB_AB930B935720 - - -#include "transition.hpp" -#include "state_machine_element_impl.hpp" -#include "constraint.hpp" -#include "behavior.hpp" - - -namespace sxy -{ - - -class composite_state; - - -class transition_impl SX_FINAL: - public virtual transition, public state_machine_element_impl -{ -public: - transition_impl( const event_id _event_id, vertex& _source, vertex& _target, - const sxy::transition_kind _kind = transition_kind::EXTERNAL, - constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); - transition_impl( const event_ids _event_ids, vertex& _source, vertex& _target, - const sxy::transition_kind _kind = transition_kind::EXTERNAL, - constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); - virtual ~transition_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(transition_impl) - virtual const vertex& get_source() const SX_OVERRIDE; - virtual const vertex& get_target() const SX_OVERRIDE; - virtual vertex& get_target() SX_OVERRIDE; - virtual const constraint * get_guard() const SX_OVERRIDE; - virtual const behavior * get_behavior() const SX_OVERRIDE; - virtual uri get_uri() const SX_OVERRIDE; - virtual const state_machine_element * get_parent() const SX_OVERRIDE; - virtual sxy::transition_kind get_kind() const SX_OVERRIDE; - virtual void add_ancestor_uri( uri& _uri ) const SX_OVERRIDE; - virtual void on_transition_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - virtual bool check_guard( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual bool can_accept_event( const event_id _event ) const SX_OVERRIDE; - - -private: - static bool check_if_source_and_target_are_in_ancestor_relationship( const vertex& _source, - const vertex& _target ); - static bool check_relationship( const vertex& _lhs, const composite_state* _rhs ); - static std::string get_transition_name( vertex& _source, vertex& _target, const event_ids& _event_ids ); - bool check_for_cross_region_transition( state_machine_defects& _defects ) const; - bool check_child_parent_relationship_of_source_target_of_transition( state_machine_defects& _defects ) const; - bool check_initial_pseudostate( state_machine_defects& _defects ) const; - bool check_exit_point( state_machine_defects& _defects ) const; - - event_ids event_ids_; - vertex& source_; - vertex& target_; - constraint_uptr guard_; - behavior_uptr behavior_; - transition_kind kind_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_IMPL_9F6CF536_11D2_4F11_B5FB_AB930B935720 +#define TRANSITION_IMPL_9F6CF536_11D2_4F11_B5FB_AB930B935720 + + +#include "transition.hpp" +#include "state_machine_element_impl.hpp" +#include "constraint.hpp" +#include "behavior.hpp" + + +namespace sxy +{ + + +class composite_state; + + +class transition_impl SX_FINAL: + public virtual transition, public state_machine_element_impl +{ +public: + transition_impl( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); + transition_impl( const event_ids _event_ids, vertex& _source, vertex& _target, + const sxy::transition_kind _kind = transition_kind::EXTERNAL, + constraint_uptr _guard = constraint_uptr(), behavior_uptr _behavior = behavior_uptr()); + virtual ~transition_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(transition_impl) + virtual const vertex& get_source() const SX_OVERRIDE; + virtual const vertex& get_target() const SX_OVERRIDE; + virtual vertex& get_target() SX_OVERRIDE; + virtual const constraint * get_guard() const SX_OVERRIDE; + virtual const behavior * get_behavior() const SX_OVERRIDE; + virtual sxe::uri get_uri() const SX_OVERRIDE; + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + virtual sxy::transition_kind get_kind() const SX_OVERRIDE; + virtual void add_ancestor_uri( sxe::uri& _uri ) const SX_OVERRIDE; + virtual void on_transition_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual bool check_guard( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual bool can_accept_event( const event_id _event ) const SX_OVERRIDE; + + +private: + static bool check_if_source_and_target_are_in_ancestor_relationship( const vertex& _source, + const vertex& _target ); + static bool check_relationship( const vertex& _lhs, const composite_state* _rhs ); + static std::string get_transition_name( vertex& _source, vertex& _target, const event_ids& _event_ids ); + bool check_for_cross_region_transition( state_machine_defects& _defects ) const; + bool check_child_parent_relationship_of_source_target_of_transition( state_machine_defects& _defects ) const; + bool check_initial_pseudostate( state_machine_defects& _defects ) const; + bool check_exit_point( state_machine_defects& _defects ) const; + + event_ids event_ids_; + vertex& source_; + vertex& target_; + constraint_uptr guard_; + behavior_uptr behavior_; + transition_kind kind_; +}; + + +} + + +#endif diff --git a/libyasmine/include/transition_kind.hpp b/libyasmine/include/transition_kind.hpp index bdc7731..1c45db4 100644 --- a/libyasmine/include/transition_kind.hpp +++ b/libyasmine/include/transition_kind.hpp @@ -1,88 +1,88 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_KIND_BA4883BC_C6FF_4F55_BA40_3FF8C973631D -#define TRANSITION_KIND_BA4883BC_C6FF_4F55_BA40_3FF8C973631D - - -#include - - -namespace sxy -{ - -#ifndef SX_CPP03_BOOST - - - enum class transition_kind - { - EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 - }; - - -#else - - - struct transition_kind - { - - enum inner - { - EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 - }; - - - // cppcheck-suppress noExplicitConstructor - transition_kind() : value_( EXTERNAL ) - { - // Nothing to do... - } - - - // cppcheck-suppress noExplicitConstructor - transition_kind( const inner _value ) : value_( _value ) - { - // Nothing to do... - } - - - // cppcheck-suppress functionConst - operator inner() - { - return ( value_ ); - } - - - inner value_; - - }; - -#endif - - -std::string to_string( const transition_kind _kind ); - - -#ifdef SX_CPP03_BOOST - - -bool operator==( const sxy::transition_kind& _lhs, const sxy::transition_kind::inner _rhs ); -bool operator==( const sxy::transition_kind::inner _lhs, const sxy::transition_kind& _rhs ); -bool operator<( const sxy::transition_kind _lhs, const sxy::transition_kind _rhs ); - - - -#endif - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_KIND_BA4883BC_C6FF_4F55_BA40_3FF8C973631D +#define TRANSITION_KIND_BA4883BC_C6FF_4F55_BA40_3FF8C973631D + + +#include + + +namespace sxy +{ + +#ifndef SX_CPP03_BOOST + + + enum class transition_kind + { + EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 + }; + + +#else + + + struct transition_kind + { + + enum inner + { + EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 + }; + + + // cppcheck-suppress noExplicitConstructor + transition_kind() : value_( EXTERNAL ) + { + // Nothing to do... + } + + + // cppcheck-suppress noExplicitConstructor + transition_kind( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + // cppcheck-suppress functionConst + operator inner() + { + return ( value_ ); + } + + + inner value_; + + }; + +#endif + + +std::string to_string( const transition_kind _kind ); + + +#ifdef SX_CPP03_BOOST + + +bool operator==( const sxy::transition_kind& _lhs, const sxy::transition_kind::inner _rhs ); +bool operator==( const sxy::transition_kind::inner _lhs, const sxy::transition_kind& _rhs ); +bool operator<( const sxy::transition_kind _lhs, const sxy::transition_kind _rhs ); + + + +#endif + +} + + +#endif diff --git a/libyasmine/include/utils.hpp b/libyasmine/include/utils.hpp index 2bc4fef..93ac286 100644 --- a/libyasmine/include/utils.hpp +++ b/libyasmine/include/utils.hpp @@ -1,62 +1,62 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B -#define UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B - - -#ifdef WIN32 - - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#ifndef SX_NO_WINDOWS_H - #include -#endif - - -#endif - - -namespace sxy -{ - - -namespace utils -{ - - -#ifdef WIN32 - - -//!\brief Sets the size of the console. -//!\param _width Number of columns in Windows console. -//!\param _height Number of lines in Windows console. -//!\return void -void set_window_size( const SHORT _width, const SHORT _height ); - -//!\brief Maximize the Windows console. -//!\return void -void maximize_window(); - - -#endif - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B +#define UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B + + +#ifdef WIN32 + + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#ifndef SX_NO_WINDOWS_H + #include +#endif + + +#endif + + +namespace sxy +{ + + +namespace utils +{ + + +#ifdef WIN32 + + +//!\brief Set the size of the console. +//!\param _width Number of columns in Windows console. +//!\param _height Number of lines in Windows console. +//!\return void +void set_window_size( const SHORT _width, const SHORT _height ); + +//!\brief Maximize the Windows console. +//!\return void +void maximize_window(); + + +#endif + + +} + + +} + + +#endif diff --git a/libyasmine/include/version.hpp b/libyasmine/include/version.hpp index edf92ff..e8e3071 100644 --- a/libyasmine/include/version.hpp +++ b/libyasmine/include/version.hpp @@ -1,46 +1,46 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERSION_53B7B4DC_2A8B_4736_B190_6348C9D8F8F2 -#define VERSION_53B7B4DC_2A8B_4736_B190_6348C9D8F8F2 - - -#include "essentials/base.hpp" -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -namespace version -{ - -#ifndef SX_NO_LOGGING - -void log_version(); - -#endif - - -sxe::uint16_t get_major_version(); -sxe::uint16_t get_minor_version(); -sxe::uint16_t get_patch_version(); -sxe::uint16_t get_build_number(); - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERSION_53B7B4DC_2A8B_4736_B190_6348C9D8F8F2 +#define VERSION_53B7B4DC_2A8B_4736_B190_6348C9D8F8F2 + + +#include "essentials/base.hpp" +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + +#ifndef SX_NO_LOGGING + +void log_version(); + +#endif + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +#endif diff --git a/libyasmine/include/vertex.hpp b/libyasmine/include/vertex.hpp index 6285059..bcda9b2 100644 --- a/libyasmine/include/vertex.hpp +++ b/libyasmine/include/vertex.hpp @@ -1,76 +1,76 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERTEX_126F87F3_2278_4867_B69F_ABEE5AB88A61 -#define VERTEX_126F87F3_2278_4867_B69F_ABEE5AB88A61 - - -#include "state_machine_element.hpp" -#include "vertex_fwd.hpp" -#include "transition_fwd.hpp" -#include "region_fwd.hpp" -#include "composite_state_fwd.hpp" -#include "event_id.hpp" -#include "event_priority.hpp" - - -namespace sxy -{ - - -class const_vertex_visitor; -class vertex_visitor; -class uri; -class event; -class event_collector; - - -class vertex: - public virtual state_machine_element -{ -public: - vertex() - { - // Nothing to do... - } - - - virtual ~vertex() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY( vertex ) - virtual composite_state* get_root_state() = 0; - virtual const composite_state* get_root_state() const = 0; - virtual void add_outgoing_transition( transition& _outgoing_transition ) = 0; - virtual void add_incoming_transition( transition& _incoming_transition ) = 0; - virtual void remove_outgoing_transition( const transition& _outgoing_transition ) = 0; - virtual void remove_incoming_transition( const transition& _incoming_transition ) = 0; - virtual const raw_transitions& get_outgoing_transitions() const = 0; - virtual const raw_transitions& get_incoming_transitions() const = 0; - virtual raw_regions get_ancestors_as_regions() const = 0; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, - bool _include_final_ancestor = true ) const = 0; - virtual transition * search_transition( const event& _event, event_collector& _event_collector ) const = 0; - virtual region * LCA_region( const vertex& _target_vertex ) const = 0; - virtual composite_state * LCA_composite_state( const vertex& _rhs ) const = 0; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const = 0; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) = 0; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_126F87F3_2278_4867_B69F_ABEE5AB88A61 +#define VERTEX_126F87F3_2278_4867_B69F_ABEE5AB88A61 + + +#include "state_machine_element.hpp" +#include "vertex_fwd.hpp" +#include "transition_fwd.hpp" +#include "region_fwd.hpp" +#include "composite_state_fwd.hpp" +#include "event_id.hpp" +#include "event_priority.hpp" + + +namespace sxy +{ + + +class const_vertex_visitor; +class vertex_visitor; +class uri; +class event; +class event_collector; + + +class vertex: + public virtual state_machine_element +{ +public: + vertex() + { + // Nothing to do... + } + + + virtual ~vertex() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( vertex ) + virtual composite_state* get_root_state() = 0; + virtual const composite_state* get_root_state() const = 0; + virtual void add_outgoing_transition( transition& _outgoing_transition ) = 0; + virtual void add_incoming_transition( transition& _incoming_transition ) = 0; + virtual void remove_outgoing_transition( const transition& _outgoing_transition ) = 0; + virtual void remove_incoming_transition( const transition& _incoming_transition ) = 0; + virtual const raw_transitions& get_outgoing_transitions() const = 0; + virtual const raw_transitions& get_incoming_transitions() const = 0; + virtual raw_regions get_ancestors_as_regions() const = 0; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const = 0; + virtual transition * search_transition( const event& _event, event_collector& _event_collector ) const = 0; + virtual region * LCA_region( const vertex& _target_vertex ) const = 0; + virtual composite_state * LCA_composite_state( const vertex& _rhs ) const = 0; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const = 0; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) = 0; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include/vertex_fwd.hpp b/libyasmine/include/vertex_fwd.hpp index 69d739d..51fa4d1 100644 --- a/libyasmine/include/vertex_fwd.hpp +++ b/libyasmine/include/vertex_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERTEX_FWD_9F913860_C5C3_4773_BB31_D98183BE0565 -#define VERTEX_FWD_9F913860_C5C3_4773_BB31_D98183BE0565 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class vertex; -typedef sxe::SX_UNIQUE_PTR< vertex > vertex_uptr; -typedef std::vector< const vertex* > raw_const_vertices; -typedef std::vector< vertex_uptr > vertices; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_FWD_9F913860_C5C3_4773_BB31_D98183BE0565 +#define VERTEX_FWD_9F913860_C5C3_4773_BB31_D98183BE0565 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class vertex; +typedef sxe::SX_UNIQUE_PTR< vertex > vertex_uptr; +typedef std::vector< const vertex* > raw_const_vertices; +typedef std::vector< vertex_uptr > vertices; + + +} + + +#endif diff --git a/libyasmine/include/vertex_impl.hpp b/libyasmine/include/vertex_impl.hpp index e731582..989d753 100644 --- a/libyasmine/include/vertex_impl.hpp +++ b/libyasmine/include/vertex_impl.hpp @@ -1,61 +1,61 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERTEX_IMPL_B16E40A6_719B_4DFD_91DB_D4790C6EC14D -#define VERTEX_IMPL_B16E40A6_719B_4DFD_91DB_D4790C6EC14D - - -#include - -#include "vertex.hpp" -#include "state_machine_element_impl.hpp" - - -namespace sxy -{ - - -class vertex_impl: - public virtual vertex, public state_machine_element_impl -{ -public: - explicit vertex_impl( const std::string& _name ); - virtual ~vertex_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY( vertex_impl ) - virtual composite_state* get_root_state() SX_OVERRIDE; - virtual const composite_state* get_root_state() const SX_OVERRIDE; - virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; - virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; - virtual void remove_outgoing_transition( const transition& _outgoing_transition ) SX_OVERRIDE; - virtual void remove_incoming_transition( const transition& _incoming_transition ) SX_OVERRIDE; - virtual const raw_transitions& get_outgoing_transitions() const SX_OVERRIDE; - virtual const raw_transitions& get_incoming_transitions() const SX_OVERRIDE; - virtual uri get_uri() const SX_OVERRIDE; - transition* search_transition( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - virtual region* LCA_region( const vertex& _target_vertex ) const SX_OVERRIDE; - virtual composite_state* LCA_composite_state( const vertex& _rhs ) const SX_OVERRIDE; - - -private: - void add_ancestor_uri( uri& _uri ) const SX_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_; - raw_transitions incoming_transitions_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_IMPL_B16E40A6_719B_4DFD_91DB_D4790C6EC14D +#define VERTEX_IMPL_B16E40A6_719B_4DFD_91DB_D4790C6EC14D + + +#include + +#include "vertex.hpp" +#include "state_machine_element_impl.hpp" + + +namespace sxy +{ + + +class vertex_impl: + public virtual vertex, public state_machine_element_impl +{ +public: + explicit vertex_impl( const std::string& _name ); + virtual ~vertex_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( vertex_impl ) + virtual composite_state* get_root_state() SX_OVERRIDE; + virtual const composite_state* get_root_state() const SX_OVERRIDE; + virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; + virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; + virtual void remove_outgoing_transition( const transition& _outgoing_transition ) SX_OVERRIDE; + virtual void remove_incoming_transition( const transition& _incoming_transition ) SX_OVERRIDE; + virtual const raw_transitions& get_outgoing_transitions() const SX_OVERRIDE; + virtual const raw_transitions& get_incoming_transitions() const SX_OVERRIDE; + virtual sxe::uri get_uri() const SX_OVERRIDE; + transition* search_transition( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + virtual region* LCA_region( const vertex& _target_vertex ) const SX_OVERRIDE; + virtual composite_state* LCA_composite_state( const vertex& _rhs ) const SX_OVERRIDE; + + +private: + void add_ancestor_uri( sxe::uri& _uri ) const SX_OVERRIDE; + raw_transitions::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_; + raw_transitions incoming_transitions_; +}; + + +} + + +#endif diff --git a/libyasmine/include/y_assert.hpp b/libyasmine/include/y_assert.hpp index 329b1c2..ff633dc 100644 --- a/libyasmine/include/y_assert.hpp +++ b/libyasmine/include/y_assert.hpp @@ -1,30 +1,30 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef Y_ASSERT_99E5ACCD_95C4_419D_A257_7294D6692569 -#define Y_ASSERT_99E5ACCD_95C4_419D_A257_7294D6692569 - - -#define Y_ASSERT( _condition, _message ) \ - do \ - { \ - if( !( _condition ) ) \ - { \ - SX_LOG_AND_WAIT( hermes::log_level::LL_ASSERT, "Assert failed! Message: '%', Condition '%'", _message, #_condition ); \ - assert( ( _condition ) && _message ); \ - } \ - } \ - while( 0 ) - -#include "hermes/log.hpp" - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef Y_ASSERT_99E5ACCD_95C4_419D_A257_7294D6692569 +#define Y_ASSERT_99E5ACCD_95C4_419D_A257_7294D6692569 + + +#define Y_ASSERT( _condition, _message ) \ + do \ + { \ + if( !( _condition ) ) \ + { \ + SX_LOG_AND_WAIT( hermes::log_level::LL_ASSERT, "Assert failed! Message: '%', Condition '%'", _message, #_condition ); \ + assert( ( _condition ) && _message ); \ + } \ + } \ + while( 0 ) + +#include "hermes/log.hpp" + + +#endif diff --git a/libyasmine/include/yasmine.hpp b/libyasmine/include/yasmine.hpp index 1807e68..060648f 100644 --- a/libyasmine/include/yasmine.hpp +++ b/libyasmine/include/yasmine.hpp @@ -1,59 +1,59 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 -#define YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 - - -#include "backward_compatibility.hpp" - -#include "essentials/compatibility/compatibility.hpp" -#include "essentials/compatibility/chrono.hpp" -#include "essentials/compatibility/thread.hpp" -#include "essentials/non_copyable.hpp" - -#include "sync_state_machine.hpp" -#include "async_state_machine.hpp" -#include "timed_event_creator.hpp" - -#include "state_machine_defect.hpp" -#include "state_machine_introspection.hpp" - -#include "states.hpp" -#include "region.hpp" -#include "region_pseudostates.hpp" - -#include "transition.hpp" -#include "transition_impl.hpp" -#include "behavior.hpp" -#include "behavior_exception.hpp" -#include "event_impl.hpp" - -#include "event_template.hpp" -#include "constraint.hpp" -#include "completion_event.hpp" - -#include "logging.hpp" -#include "utils.hpp" -#include "assembly.hpp" -#include "version.hpp" - - -#ifndef Y_LEAN_AND_MEAN - - -#include "state_pseudostates.hpp" -#include "async_behavior.hpp" - - -#endif - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 +#define YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 + + +#include "backward_compatibility.hpp" + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/compatibility/chrono.hpp" +#include "essentials/compatibility/thread.hpp" +#include "essentials/non_copyable.hpp" + +#include "sync_state_machine.hpp" +#include "async_state_machine.hpp" +#include "timed_event_creator.hpp" + +#include "state_machine_defect.hpp" +#include "state_machine_introspection.hpp" + +#include "states.hpp" +#include "region.hpp" +#include "region_pseudostates.hpp" + +#include "transition.hpp" +#include "transition_impl.hpp" +#include "behavior.hpp" +#include "behavior_exception.hpp" +#include "event_impl.hpp" + +#include "event_template.hpp" +#include "constraint.hpp" +#include "completion_event.hpp" + +#include "logging.hpp" +#include "utils.hpp" +#include "assembly.hpp" +#include "version.hpp" + + +#ifndef Y_LEAN_AND_MEAN + + +#include "state_pseudostates.hpp" +#include "async_behavior.hpp" + + +#endif + + +#endif diff --git a/libyasmine/include_impl/behavior_impl.hpp b/libyasmine/include_impl/behavior_impl.hpp index 4956b43..7c296b5 100644 --- a/libyasmine/include_impl/behavior_impl.hpp +++ b/libyasmine/include_impl/behavior_impl.hpp @@ -1,49 +1,49 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BEHAVIOR_IMPL_44F1A85F_F127_46DE_811B_DD146F1AECD6 -#define BEHAVIOR_IMPL_44F1A85F_F127_46DE_811B_DD146F1AECD6 - - -#include "behavior.hpp" - - -namespace sxy -{ - - -class event; - - -class behavior_impl SX_FINAL: - public virtual behavior -{ -public: - explicit behavior_impl( const behavior_function& _function ); - virtual ~behavior_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY( behavior_impl ) - virtual void operator()( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - - //!\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: - behavior_function function_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BEHAVIOR_IMPL_44F1A85F_F127_46DE_811B_DD146F1AECD6 +#define BEHAVIOR_IMPL_44F1A85F_F127_46DE_811B_DD146F1AECD6 + + +#include "behavior.hpp" + + +namespace sxy +{ + + +class event; + + +class behavior_impl SX_FINAL: + public virtual behavior +{ +public: + explicit behavior_impl( const behavior_function& _function ); + virtual ~behavior_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( behavior_impl ) + virtual void operator()( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + + //!\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: + behavior_function function_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/build_number.hpp b/libyasmine/include_impl/build_number.hpp index 3e17063..ca91b13 100644 --- a/libyasmine/include_impl/build_number.hpp +++ b/libyasmine/include_impl/build_number.hpp @@ -1,36 +1,36 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BUILD_NUMBER_35F7322C_8D29_42B1_AC5E_A38094AF5EF6 -#define BUILD_NUMBER_35F7322C_8D29_42B1_AC5E_A38094AF5EF6 - - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -namespace version -{ - - -const sxe::uint16_t BUILD_NUMBER( 616 ); - - -} - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_NUMBER_35F7322C_8D29_42B1_AC5E_A38094AF5EF6 +#define BUILD_NUMBER_35F7322C_8D29_42B1_AC5E_A38094AF5EF6 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + + +const sxe::uint16_t BUILD_NUMBER( 656 ); + + +} + + +} + + +#endif diff --git a/libyasmine/include_impl/build_transition_steps_visitor.hpp b/libyasmine/include_impl/build_transition_steps_visitor.hpp index 69d943c..3236ac8 100644 --- a/libyasmine/include_impl/build_transition_steps_visitor.hpp +++ b/libyasmine/include_impl/build_transition_steps_visitor.hpp @@ -1,81 +1,81 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef BUILD_TRANSITION_STEPS_VISITOR_85FF1B04_191D_4BED_A446_C9280A2883C8 -#define BUILD_TRANSITION_STEPS_VISITOR_85FF1B04_191D_4BED_A446_C9280A2883C8 - - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "transition_step_fwd.hpp" -#include "transition_fwd.hpp" - - -namespace sxy -{ - - -class transition; -class pseudostate; -class history; -class event; -class event_collector; - - -class build_transition_steps_visitor SX_FINAL: - public virtual const_vertex_visitor -{ -public: - build_transition_steps_visitor( transition& _current_transition, transition_steps& _transitions_steps, - const event& _event, event_collector& _event_collector ); - virtual ~build_transition_steps_visitor() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(build_transition_steps_visitor) - virtual void visit( const composite_state& _composite_state ) SX_OVERRIDE; - virtual void visit( const simple_state& _simple_state ) SX_OVERRIDE; - virtual void visit( const final_state& _final_state ) SX_OVERRIDE; - virtual void visit( const initial_pseudostate& _initial_pseudostate ) SX_OVERRIDE; - virtual void visit( const choice& _choice ) SX_OVERRIDE; - virtual void visit( const junction& _junction ) SX_OVERRIDE; - virtual void visit( const join& _join ) SX_OVERRIDE; - virtual void visit( const fork& _fork ) SX_OVERRIDE; - virtual void visit( const entry_point& _entry_point ) SX_OVERRIDE; - virtual void visit( const exit_point& _exit_point ) SX_OVERRIDE; - virtual void visit( const deep_history& _deep_history ) SX_OVERRIDE; - virtual void visit( const shallow_history& _shallow_history ) SX_OVERRIDE; - virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) SX_OVERRIDE; - transition * get_next_transition() const; - bool reached_end_of_transition() const; - - -private: - transition* find_next_transition( const pseudostate& _target_pseudostate, const event& _event ); - static raw_transitions get_default_transition_if_state_was_not_active_before( const history& _history ); - void handle_history_pseudostate( const history& _history_pseudostate ); - void handle_as_junction( const pseudostate& _pseudostate ); - void handle_as_fork( const pseudostate& _fork ) const; - void handle_as_join( const pseudostate& _pseudostate ); - void handle_entry_point( const entry_point& _entry_point ); - void handle_exit_point( const exit_point& _exit_point ); - void create_simple_transition_step(); - - transition& current_transition_; - transition_steps& transition_steps_; - transition* next_transition_; - bool reached_end_of_transition_; - const event& event_; - event_collector& event_collector_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_TRANSITION_STEPS_VISITOR_85FF1B04_191D_4BED_A446_C9280A2883C8 +#define BUILD_TRANSITION_STEPS_VISITOR_85FF1B04_191D_4BED_A446_C9280A2883C8 + + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "transition_step_fwd.hpp" +#include "transition_fwd.hpp" + + +namespace sxy +{ + + +class transition; +class pseudostate; +class history; +class event; +class event_collector; + + +class build_transition_steps_visitor SX_FINAL: + public virtual const_vertex_visitor +{ +public: + build_transition_steps_visitor( transition& _current_transition, transition_steps& _transitions_steps, + const event& _event, event_collector& _event_collector ); + virtual ~build_transition_steps_visitor() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(build_transition_steps_visitor) + virtual void visit( const composite_state& _composite_state ) SX_OVERRIDE; + virtual void visit( const simple_state& _simple_state ) SX_OVERRIDE; + virtual void visit( const final_state& _final_state ) SX_OVERRIDE; + virtual void visit( const initial_pseudostate& _initial_pseudostate ) SX_OVERRIDE; + virtual void visit( const choice& _choice ) SX_OVERRIDE; + virtual void visit( const junction& _junction ) SX_OVERRIDE; + virtual void visit( const join& _join ) SX_OVERRIDE; + virtual void visit( const fork& _fork ) SX_OVERRIDE; + virtual void visit( const entry_point& _entry_point ) SX_OVERRIDE; + virtual void visit( const exit_point& _exit_point ) SX_OVERRIDE; + virtual void visit( const deep_history& _deep_history ) SX_OVERRIDE; + virtual void visit( const shallow_history& _shallow_history ) SX_OVERRIDE; + virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) SX_OVERRIDE; + transition * get_next_transition() const; + bool reached_end_of_transition() const; + + +private: + transition* find_next_transition( const pseudostate& _target_pseudostate, const event& _event ); + static raw_transitions get_default_transition_if_state_was_not_active_before( const history& _history ); + void handle_history_pseudostate( const history& _history_pseudostate ); + void handle_as_junction( const pseudostate& _pseudostate ); + void handle_as_fork( const pseudostate& _fork ) const; + void handle_as_join( const pseudostate& _pseudostate ); + void handle_entry_point( const entry_point& _entry_point ); + void handle_exit_point( const exit_point& _exit_point ); + void create_simple_transition_step(); + + transition& current_transition_; + transition_steps& transition_steps_; + transition* next_transition_; + bool reached_end_of_transition_; + const event& event_; + event_collector& event_collector_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/check_if_all_incoming_transitions_sources_are_active_visitor.hpp b/libyasmine/include_impl/check_if_all_incoming_transitions_sources_are_active_visitor.hpp index e3c0b1b..b8adaaa 100644 --- a/libyasmine/include_impl/check_if_all_incoming_transitions_sources_are_active_visitor.hpp +++ b/libyasmine/include_impl/check_if_all_incoming_transitions_sources_are_active_visitor.hpp @@ -1,44 +1,44 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CHECK_IF_ALL_INCOMING_TRANSITIONS_SOURCES_ARE_ACTIVE_VISITOR_H -#define CHECK_IF_ALL_INCOMING_TRANSITIONS_SOURCES_ARE_ACTIVE_VISITOR_H - - -#include "complex_state_visitor.hpp" - - -namespace sxy -{ - - -class event; - - -class check_if_all_incoming_transitions_sources_are_active_visitor SX_FINAL: - public complex_state_visitor -{ -public: - check_if_all_incoming_transitions_sources_are_active_visitor(); - virtual ~check_if_all_incoming_transitions_sources_are_active_visitor() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(check_if_all_incoming_transitions_sources_are_active_visitor) - virtual void visit( const composite_state& _composite_state ) SX_OVERRIDE; - virtual void visit( const simple_state& _simple_state ) SX_OVERRIDE; - bool get_result() const; - - -private: - bool source_is_finished_; -}; - - -} -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHECK_IF_ALL_INCOMING_TRANSITIONS_SOURCES_ARE_ACTIVE_VISITOR_H +#define CHECK_IF_ALL_INCOMING_TRANSITIONS_SOURCES_ARE_ACTIVE_VISITOR_H + + +#include "complex_state_visitor.hpp" + + +namespace sxy +{ + + +class event; + + +class check_if_all_incoming_transitions_sources_are_active_visitor SX_FINAL: + public complex_state_visitor +{ +public: + check_if_all_incoming_transitions_sources_are_active_visitor(); + virtual ~check_if_all_incoming_transitions_sources_are_active_visitor() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(check_if_all_incoming_transitions_sources_are_active_visitor) + virtual void visit( const composite_state& _composite_state ) SX_OVERRIDE; + virtual void visit( const simple_state& _simple_state ) SX_OVERRIDE; + bool get_result() const; + + +private: + bool source_is_finished_; +}; + + +} +#endif diff --git a/libyasmine/include_impl/choice_impl.hpp b/libyasmine/include_impl/choice_impl.hpp index 2aad3d1..375e8a3 100644 --- a/libyasmine/include_impl/choice_impl.hpp +++ b/libyasmine/include_impl/choice_impl.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CHOICE_IMPL_E8DE2646_E657_4A8B_96EE_B0699FB5652D -#define CHOICE_IMPL_E8DE2646_E657_4A8B_96EE_B0699FB5652D - - -#include "choice.hpp" -#include "region_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class choice_impl SX_FINAL: - public virtual choice, public region_pseudostate_impl -{ -public: - explicit choice_impl( const std::string& _name ); - virtual ~choice_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(choice_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CHOICE_IMPL_E8DE2646_E657_4A8B_96EE_B0699FB5652D +#define CHOICE_IMPL_E8DE2646_E657_4A8B_96EE_B0699FB5652D + + +#include "choice.hpp" +#include "region_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class choice_impl SX_FINAL: + public virtual choice, public region_pseudostate_impl +{ +public: + explicit choice_impl( const std::string& _name ); + virtual ~choice_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(choice_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/complex_state_visitor.hpp b/libyasmine/include_impl/complex_state_visitor.hpp index 8663c68..04e603d 100644 --- a/libyasmine/include_impl/complex_state_visitor.hpp +++ b/libyasmine/include_impl/complex_state_visitor.hpp @@ -1,51 +1,51 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPLEX_STATE_VISITOR_A1E31C49_08E0_400B_A6A9_20A333A8FD42 -#define COMPLEX_STATE_VISITOR_A1E31C49_08E0_400B_A6A9_20A333A8FD42 - - -#include "essentials/non_copyable.hpp" - - -namespace sxy -{ - - -class composite_state; -class simple_state; - - -class complex_state_visitor -{ -public: - complex_state_visitor() - { - // Nothing to do... - } - - - virtual ~complex_state_visitor() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(complex_state_visitor) - virtual void visit( const composite_state& _composite_state ) = 0; - virtual void visit( const simple_state& _simple_state ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPLEX_STATE_VISITOR_A1E31C49_08E0_400B_A6A9_20A333A8FD42 +#define COMPLEX_STATE_VISITOR_A1E31C49_08E0_400B_A6A9_20A333A8FD42 + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + +class composite_state; +class simple_state; + + +class complex_state_visitor +{ +public: + complex_state_visitor() + { + // Nothing to do... + } + + + virtual ~complex_state_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(complex_state_visitor) + virtual void visit( const composite_state& _composite_state ) = 0; + virtual void visit( const simple_state& _simple_state ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/composite_state_impl.hpp b/libyasmine/include_impl/composite_state_impl.hpp index ca9d1d2..7037831 100644 --- a/libyasmine/include_impl/composite_state_impl.hpp +++ b/libyasmine/include_impl/composite_state_impl.hpp @@ -1,102 +1,102 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOSITE_STATE_IMPL_2BA1A84B_EF73_4C0C_98B9_F75BA2FF388B -#define COMPOSITE_STATE_IMPL_2BA1A84B_EF73_4C0C_98B9_F75BA2FF388B - - -#include "composite_state.hpp" -#include "complex_state_impl.hpp" -#include "deep_history.hpp" -#include "shallow_history.hpp" -#include "entry_point.hpp" -#include "exit_point.hpp" - - -namespace sxy -{ - - -class composite_state_impl SX_FINAL: - public virtual composite_state, public complex_state_impl -{ -public: - 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() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(composite_state_impl) - virtual region& add_region( region_uptr _region ) SX_OVERRIDE; - - //!\brief Creates a region with the given name and adds it to the parent composite state. - //!\param _region_name Name of the region. - //!\return A reference to the newly created final state. - virtual region& add_region( const std::string& _region_name ) SX_OVERRIDE; - virtual const regions& get_regions() const SX_OVERRIDE; - virtual regions& get_regions() SX_OVERRIDE; - virtual region * get_region( const std::string& _region_name ) const SX_OVERRIDE; - bool is_complete() const SX_OVERRIDE; - - virtual const deep_history * get_deep_history() const SX_OVERRIDE; - virtual deep_history& add_deep_history( deep_history_uptr _deep_history ) SX_OVERRIDE; - - //!\brief Creates a deep history with the given name and adds it to the parent composite state. - //!\param _deep_history_name Name of the deep history. - //!\return A reference to the newly created deep history. - virtual deep_history& add_deep_history( const std::string& _deep_history_name ) SX_OVERRIDE; - virtual shallow_history * get_shallow_history() const SX_OVERRIDE; - virtual shallow_history& add_shallow_history( shallow_history_uptr _shallow_history ) SX_OVERRIDE; - - //!\brief Creates a shallow history with the given name and adds it to the parent composite state. - //!\param _shallow_history_name Name of the shallow history. - //!\return A reference to the newly created shallow history. - virtual shallow_history& add_shallow_history( const std::string& _shallow_history_name ) SX_OVERRIDE; - virtual const raw_const_entry_points get_entry_points() const SX_OVERRIDE; - virtual entry_point& add_entry_point( entry_point_uptr _entry_point ) SX_OVERRIDE; - - //!\brief Creates an entry point with the given name and adds it to the parent composite state. - //!\param _entry_point_name Name of the entry point. - //!\return A reference to the newly created entry point. - virtual entry_point& add_entry_point( const std::string& _entry_point_name ) SX_OVERRIDE; - virtual const raw_const_exit_points get_exit_points() const SX_OVERRIDE; - virtual exit_point& add_exit_point( exit_point_uptr _exit_point ) SX_OVERRIDE; - - //!\brief Creates an exit point with the given name and adds it to the parent composite state. - //!\param _exit_point_name Name of the exit point. - //!\return A reference to the newly created exit point. - virtual exit_point& add_exit_point( const std::string& _exit_point_name ) SX_OVERRIDE; - virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const SX_OVERRIDE; - virtual size_t get_region_index( const region* const _region ) const SX_OVERRIDE; - virtual size_t get_parent_region_index() const SX_OVERRIDE; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; - virtual bool is_orthogonal() const SX_OVERRIDE; - - -private: - virtual bool check_if_regions_are_completed() const SX_OVERRIDE; - static bool regions_are_equal( const region* const _region, const region_uptr& _vector_element_region ); - - - regions regions_; - deep_history_uptr deep_history_; - shallow_history_uptr shallow_history_; - entry_points entry_points_; - exit_points exit_points_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOSITE_STATE_IMPL_2BA1A84B_EF73_4C0C_98B9_F75BA2FF388B +#define COMPOSITE_STATE_IMPL_2BA1A84B_EF73_4C0C_98B9_F75BA2FF388B + + +#include "composite_state.hpp" +#include "complex_state_impl.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" +#include "entry_point.hpp" +#include "exit_point.hpp" + + +namespace sxy +{ + + +class composite_state_impl SX_FINAL: + public virtual composite_state, public complex_state_impl +{ +public: + 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() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(composite_state_impl) + virtual region& add_region( region_uptr _region ) SX_OVERRIDE; + + //!\brief Creates a region with the given name and adds it to the parent composite state. + //!\param _region_name Name of the region. + //!\return A reference to the newly created final state. + virtual region& add_region( const std::string& _region_name ) SX_OVERRIDE; + virtual const regions& get_regions() const SX_OVERRIDE; + virtual regions& get_regions() SX_OVERRIDE; + virtual region * get_region( const std::string& _region_name ) const SX_OVERRIDE; + bool is_complete() const SX_OVERRIDE; + + virtual const deep_history * get_deep_history() const SX_OVERRIDE; + virtual deep_history& add_deep_history( deep_history_uptr _deep_history ) SX_OVERRIDE; + + //!\brief Creates a deep history with the given name and adds it to the parent composite state. + //!\param _deep_history_name Name of the deep history. + //!\return A reference to the newly created deep history. + virtual deep_history& add_deep_history( const std::string& _deep_history_name ) SX_OVERRIDE; + virtual shallow_history * get_shallow_history() const SX_OVERRIDE; + virtual shallow_history& add_shallow_history( shallow_history_uptr _shallow_history ) SX_OVERRIDE; + + //!\brief Creates a shallow history with the given name and adds it to the parent composite state. + //!\param _shallow_history_name Name of the shallow history. + //!\return A reference to the newly created shallow history. + virtual shallow_history& add_shallow_history( const std::string& _shallow_history_name ) SX_OVERRIDE; + virtual const raw_const_entry_points get_entry_points() const SX_OVERRIDE; + virtual entry_point& add_entry_point( entry_point_uptr _entry_point ) SX_OVERRIDE; + + //!\brief Creates an entry point with the given name and adds it to the parent composite state. + //!\param _entry_point_name Name of the entry point. + //!\return A reference to the newly created entry point. + virtual entry_point& add_entry_point( const std::string& _entry_point_name ) SX_OVERRIDE; + virtual const raw_const_exit_points get_exit_points() const SX_OVERRIDE; + virtual exit_point& add_exit_point( exit_point_uptr _exit_point ) SX_OVERRIDE; + + //!\brief Creates an exit point with the given name and adds it to the parent composite state. + //!\param _exit_point_name Name of the exit point. + //!\return A reference to the newly created exit point. + virtual exit_point& add_exit_point( const std::string& _exit_point_name ) SX_OVERRIDE; + virtual vertex * get_pseudostate( const std::string& _name_of_pseudostate ) const SX_OVERRIDE; + virtual size_t get_region_index( const region* const _region ) const SX_OVERRIDE; + virtual size_t get_parent_region_index() const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_complex_state_visitor( complex_state_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; + virtual bool is_orthogonal() const SX_OVERRIDE; + + +private: + virtual bool check_if_regions_are_completed() const SX_OVERRIDE; + static bool regions_are_equal( const region* const _region, const region_uptr& _vector_element_region ); + + + regions regions_; + deep_history_uptr deep_history_; + shallow_history_uptr shallow_history_; + entry_points entry_points_; + exit_points exit_points_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/compound_transition.hpp b/libyasmine/include_impl/compound_transition.hpp index 1eb1ff5..cb670a6 100644 --- a/libyasmine/include_impl/compound_transition.hpp +++ b/libyasmine/include_impl/compound_transition.hpp @@ -1,60 +1,60 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOUND_TRANSITION_E7300B8C_33B4_4D4B_9093_A864A5ADA27C -#define COMPOUND_TRANSITION_E7300B8C_33B4_4D4B_9093_A864A5ADA27C - - -#include "compound_transition_consumer.hpp" -#include "compound_transition_fwd.hpp" -#include "transition_step_fwd.hpp" - - -namespace sxy -{ - - -class vertex; -class region; -class transition; -class composite_state; -class event; -class event_collector; - - -class compound_transition: - public virtual compound_transition_consumer -{ -public: - compound_transition() - { - // Nothing to do... - } - - - virtual ~compound_transition() SX_NOEXCEPT SX_OVERRIDE - { - // Nothing to do... - } - - - SX_NO_COPY(compound_transition) - virtual void add_sub_compound_transition( compound_transition_uptr _sub_compound_transition ) = 0; - virtual bool check_if_starts_with( const transition& _incoming_transition ) = 0; - virtual bool create_and_check_transition_path( transition& _start_transition, const event& _event, - event_collector& _event_collector ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOUND_TRANSITION_E7300B8C_33B4_4D4B_9093_A864A5ADA27C +#define COMPOUND_TRANSITION_E7300B8C_33B4_4D4B_9093_A864A5ADA27C + + +#include "compound_transition_consumer.hpp" +#include "compound_transition_fwd.hpp" +#include "transition_step_fwd.hpp" + + +namespace sxy +{ + + +class vertex; +class region; +class transition; +class composite_state; +class event; +class event_collector; + + +class compound_transition: + public virtual compound_transition_consumer +{ +public: + compound_transition() + { + // Nothing to do... + } + + + virtual ~compound_transition() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY(compound_transition) + virtual void add_sub_compound_transition( compound_transition_uptr _sub_compound_transition ) = 0; + virtual bool check_if_starts_with( const transition& _incoming_transition ) = 0; + virtual bool create_and_check_transition_path( transition& _start_transition, const event& _event, + event_collector& _event_collector ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/compound_transition_builder.hpp b/libyasmine/include_impl/compound_transition_builder.hpp index 31fd96a..1532d98 100644 --- a/libyasmine/include_impl/compound_transition_builder.hpp +++ b/libyasmine/include_impl/compound_transition_builder.hpp @@ -1,37 +1,37 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOUND_TRANSITION_BUILDER_C7111HB4_8573_9C38_866E_6GG11C57C802 -#define COMPOUND_TRANSITION_BUILDER_C7111HB4_8573_9C38_866E_6GG11C57C802 - - -#include "compound_transition_fwd.hpp" - - -namespace sxy -{ - - -class transition; -class event; -class event_collector; - - -bool try_to_build_compound_transition( transition& _enabled_transition, - compound_transitions& _enabled_compound_transitions, const event& _event, event_collector& _event_collector ); -compound_transition_uptr build_compound_transition( transition& _first_transition, const event& _event, - event_collector& _event_collector ); - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOUND_TRANSITION_BUILDER_C7111HB4_8573_9C38_866E_6GG11C57C802 +#define COMPOUND_TRANSITION_BUILDER_C7111HB4_8573_9C38_866E_6GG11C57C802 + + +#include "compound_transition_fwd.hpp" + + +namespace sxy +{ + + +class transition; +class event; +class event_collector; + + +bool try_to_build_compound_transition( transition& _enabled_transition, + compound_transitions& _enabled_compound_transitions, const event& _event, event_collector& _event_collector ); +compound_transition_uptr build_compound_transition( transition& _first_transition, const event& _event, + event_collector& _event_collector ); + + +} + + +#endif diff --git a/libyasmine/include_impl/compound_transition_consumer.hpp b/libyasmine/include_impl/compound_transition_consumer.hpp index 1358c3d..f7986e3 100644 --- a/libyasmine/include_impl/compound_transition_consumer.hpp +++ b/libyasmine/include_impl/compound_transition_consumer.hpp @@ -1,60 +1,60 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOUND_TRANSITION_CONSUMER_01F0BAAD_6712_44B9_AA77_76A33352E801 -#define COMPOUND_TRANSITION_CONSUMER_01F0BAAD_6712_44B9_AA77_76A33352E801 - - -#include "essentials/non_copyable.hpp" - -#include "transition_step_fwd.hpp" -#include "compound_transition_fwd.hpp" -#include "transition_kind.hpp" - - -namespace sxy -{ - - -class vertex; -class region; -class composite_state; - - -class compound_transition_consumer -{ -public: - compound_transition_consumer() - { - // Nothing to do... - } - - - virtual ~compound_transition_consumer() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(compound_transition_consumer) - virtual transition_steps& get_transition_steps() = 0; - virtual const vertex& get_last_target() const = 0; - virtual const compound_transitions& get_sub_compound_transitions() const = 0; - virtual region * get_LCA_region() = 0; - virtual composite_state * get_LCA_composite_state() = 0; - virtual transition_kind get_transition_kind() = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOUND_TRANSITION_CONSUMER_01F0BAAD_6712_44B9_AA77_76A33352E801 +#define COMPOUND_TRANSITION_CONSUMER_01F0BAAD_6712_44B9_AA77_76A33352E801 + + +#include "essentials/non_copyable.hpp" + +#include "transition_step_fwd.hpp" +#include "compound_transition_fwd.hpp" +#include "transition_kind.hpp" + + +namespace sxy +{ + + +class vertex; +class region; +class composite_state; + + +class compound_transition_consumer +{ +public: + compound_transition_consumer() + { + // Nothing to do... + } + + + virtual ~compound_transition_consumer() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(compound_transition_consumer) + virtual transition_steps& get_transition_steps() = 0; + virtual const vertex& get_last_target() const = 0; + virtual const compound_transitions& get_sub_compound_transitions() const = 0; + virtual region * get_LCA_region() = 0; + virtual composite_state * get_LCA_composite_state() = 0; + virtual transition_kind get_transition_kind() = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/compound_transition_fwd.hpp b/libyasmine/include_impl/compound_transition_fwd.hpp index 2bf0a12..1dba3ac 100644 --- a/libyasmine/include_impl/compound_transition_fwd.hpp +++ b/libyasmine/include_impl/compound_transition_fwd.hpp @@ -1,38 +1,38 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOUND_TRANSITION_FWD_79254C3C_069E_410C_93A7_AD53E8D21487 -#define COMPOUND_TRANSITION_FWD_79254C3C_069E_410C_93A7_AD53E8D21487 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class compound_transition; -class compound_transition_consumer; - - -typedef sxe::SX_UNIQUE_PTR< compound_transition > compound_transition_uptr; - -typedef std::vector< compound_transition* > raw_compound_transitions; -typedef std::vector< compound_transition_uptr > compound_transitions; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOUND_TRANSITION_FWD_79254C3C_069E_410C_93A7_AD53E8D21487 +#define COMPOUND_TRANSITION_FWD_79254C3C_069E_410C_93A7_AD53E8D21487 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class compound_transition; +class compound_transition_consumer; + + +typedef sxe::SX_UNIQUE_PTR< compound_transition > compound_transition_uptr; + +typedef std::vector< compound_transition* > raw_compound_transitions; +typedef std::vector< compound_transition_uptr > compound_transitions; + + +} + + +#endif diff --git a/libyasmine/include_impl/compound_transition_impl.hpp b/libyasmine/include_impl/compound_transition_impl.hpp index 3183eb4..7ef0984 100644 --- a/libyasmine/include_impl/compound_transition_impl.hpp +++ b/libyasmine/include_impl/compound_transition_impl.hpp @@ -1,52 +1,52 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOUND_TRANSITION_IMPL_A5F32559_6ACF_4113_92D6_FD2473853A3A -#define COMPOUND_TRANSITION_IMPL_A5F32559_6ACF_4113_92D6_FD2473853A3A - - -#include "compound_transition.hpp" -#include "transition_step.hpp" - - -namespace sxy -{ - - -class compound_transition_impl SX_FINAL: - public virtual compound_transition -{ -public: - compound_transition_impl(); - virtual ~compound_transition_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(compound_transition_impl) - virtual transition_steps& get_transition_steps() SX_OVERRIDE; - virtual const vertex& get_last_target() const SX_OVERRIDE; - virtual const compound_transitions& get_sub_compound_transitions() const SX_OVERRIDE; - virtual void add_sub_compound_transition( compound_transition_uptr _sub_compound_transition ) SX_OVERRIDE; - virtual region * get_LCA_region() SX_OVERRIDE; - virtual composite_state * get_LCA_composite_state() SX_OVERRIDE; - virtual transition_kind get_transition_kind() SX_OVERRIDE; - virtual bool check_if_starts_with( const transition& _incoming_transition ) SX_OVERRIDE; - virtual bool create_and_check_transition_path( transition& _start_transition, const event& _event, - event_collector& _event_collector ) SX_OVERRIDE; - - -private: - transition_steps transition_steps_; - compound_transitions sub_compound_transitions_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOUND_TRANSITION_IMPL_A5F32559_6ACF_4113_92D6_FD2473853A3A +#define COMPOUND_TRANSITION_IMPL_A5F32559_6ACF_4113_92D6_FD2473853A3A + + +#include "compound_transition.hpp" +#include "transition_step.hpp" + + +namespace sxy +{ + + +class compound_transition_impl SX_FINAL: + public virtual compound_transition +{ +public: + compound_transition_impl(); + virtual ~compound_transition_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(compound_transition_impl) + virtual transition_steps& get_transition_steps() SX_OVERRIDE; + virtual const vertex& get_last_target() const SX_OVERRIDE; + virtual const compound_transitions& get_sub_compound_transitions() const SX_OVERRIDE; + virtual void add_sub_compound_transition( compound_transition_uptr _sub_compound_transition ) SX_OVERRIDE; + virtual region * get_LCA_region() SX_OVERRIDE; + virtual composite_state * get_LCA_composite_state() SX_OVERRIDE; + virtual transition_kind get_transition_kind() SX_OVERRIDE; + virtual bool check_if_starts_with( const transition& _incoming_transition ) SX_OVERRIDE; + virtual bool create_and_check_transition_path( transition& _start_transition, const event& _event, + event_collector& _event_collector ) SX_OVERRIDE; + + +private: + transition_steps transition_steps_; + compound_transitions sub_compound_transitions_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/compound_transition_step.hpp b/libyasmine/include_impl/compound_transition_step.hpp index 7cbc1c3..0c8d0b0 100644 --- a/libyasmine/include_impl/compound_transition_step.hpp +++ b/libyasmine/include_impl/compound_transition_step.hpp @@ -1,47 +1,47 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef COMPOUND_TRANSITION_STEP_5FE5C12E_E6AE_4F16_AD93_764327C2E299 -#define COMPOUND_TRANSITION_STEP_5FE5C12E_E6AE_4F16_AD93_764327C2E299 - - -#include "transition_step.hpp" - - -namespace sxy -{ - - -class compound_transition_step SX_FINAL: - public transition_step -{ -public: - explicit compound_transition_step( const raw_transitions& _transition_step ); - virtual ~compound_transition_step() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(compound_transition_step) - virtual const raw_transitions& get_transitions() const SX_OVERRIDE; - virtual const vertex& get_unique_source() const SX_OVERRIDE; - virtual const vertex& get_unique_target() const SX_OVERRIDE; - virtual const exit_point * get_exit_point() const SX_OVERRIDE; - virtual const entry_point * get_entry_point() const SX_OVERRIDE; - virtual const raw_const_vertices get_target_vertices() SX_OVERRIDE; - void execute_transition_behaviors( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - - -private: - const raw_transitions transitions_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef COMPOUND_TRANSITION_STEP_5FE5C12E_E6AE_4F16_AD93_764327C2E299 +#define COMPOUND_TRANSITION_STEP_5FE5C12E_E6AE_4F16_AD93_764327C2E299 + + +#include "transition_step.hpp" + + +namespace sxy +{ + + +class compound_transition_step SX_FINAL: + public transition_step +{ +public: + explicit compound_transition_step( const raw_transitions& _transition_step ); + virtual ~compound_transition_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(compound_transition_step) + virtual const raw_transitions& get_transitions() const SX_OVERRIDE; + virtual const vertex& get_unique_source() const SX_OVERRIDE; + virtual const vertex& get_unique_target() const SX_OVERRIDE; + virtual const exit_point * get_exit_point() const SX_OVERRIDE; + virtual const entry_point * get_entry_point() const SX_OVERRIDE; + virtual const raw_const_vertices get_target_vertices() SX_OVERRIDE; + void execute_transition_behaviors( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + + +private: + const raw_transitions transitions_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/const_vertex_visitor.hpp b/libyasmine/include_impl/const_vertex_visitor.hpp index ab61733..f9629b1 100644 --- a/libyasmine/include_impl/const_vertex_visitor.hpp +++ b/libyasmine/include_impl/const_vertex_visitor.hpp @@ -1,73 +1,73 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CONST_VERTEX_VISITOR_7EEF8936_8C47_401E_BE7D_997A1A245728 -#define CONST_VERTEX_VISITOR_7EEF8936_8C47_401E_BE7D_997A1A245728 - - -#include "essentials/non_copyable.hpp" - - -namespace sxy -{ - - -class composite_state; -class final_state; -class simple_state; -class choice; -class deep_history; -class entry_point; -class exit_point; -class fork; -class initial_pseudostate; -class join; -class junction; -class shallow_history; -class terminate_pseudostate; - - -class const_vertex_visitor -{ -public: - const_vertex_visitor() - { - // Nothing to do... - } - - - virtual ~const_vertex_visitor() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(const_vertex_visitor) - virtual void visit( const composite_state& _composite_state ) = 0; - virtual void visit( const simple_state& _simple_state ) = 0; - virtual void visit( const final_state& _final_state ) = 0; - virtual void visit( const initial_pseudostate& _initial_pseudostate ) = 0; - virtual void visit( const choice& _choice ) = 0; - virtual void visit( const junction& _junction ) = 0; - virtual void visit( const join& _join ) = 0; - virtual void visit( const fork& _fork ) = 0; - virtual void visit( const entry_point& _entry_point ) = 0; - virtual void visit( const exit_point& _exit_point ) = 0; - virtual void visit( const deep_history& _deep_history ) = 0; - virtual void visit( const shallow_history& _shallow_history ) = 0; - virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONST_VERTEX_VISITOR_7EEF8936_8C47_401E_BE7D_997A1A245728 +#define CONST_VERTEX_VISITOR_7EEF8936_8C47_401E_BE7D_997A1A245728 + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + +class composite_state; +class final_state; +class simple_state; +class choice; +class deep_history; +class entry_point; +class exit_point; +class fork; +class initial_pseudostate; +class join; +class junction; +class shallow_history; +class terminate_pseudostate; + + +class const_vertex_visitor +{ +public: + const_vertex_visitor() + { + // Nothing to do... + } + + + virtual ~const_vertex_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(const_vertex_visitor) + virtual void visit( const composite_state& _composite_state ) = 0; + virtual void visit( const simple_state& _simple_state ) = 0; + virtual void visit( const final_state& _final_state ) = 0; + virtual void visit( const initial_pseudostate& _initial_pseudostate ) = 0; + virtual void visit( const choice& _choice ) = 0; + virtual void visit( const junction& _junction ) = 0; + virtual void visit( const join& _join ) = 0; + virtual void visit( const fork& _fork ) = 0; + virtual void visit( const entry_point& _entry_point ) = 0; + virtual void visit( const exit_point& _exit_point ) = 0; + virtual void visit( const deep_history& _deep_history ) = 0; + virtual void visit( const shallow_history& _shallow_history ) = 0; + virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/constraint_impl.hpp b/libyasmine/include_impl/constraint_impl.hpp index c68a097..be75416 100644 --- a/libyasmine/include_impl/constraint_impl.hpp +++ b/libyasmine/include_impl/constraint_impl.hpp @@ -1,46 +1,46 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef CONSTRAINT_IMPL_A7A39030_C6D6_49D6_A051_B151370B7147 -#define CONSTRAINT_IMPL_A7A39030_C6D6_49D6_A051_B151370B7147 - - -#include "constraint.hpp" - - -namespace sxy -{ - - -class constraint_impl SX_FINAL: - public virtual constraint -{ -public: - explicit constraint_impl( const constraint_function& _function ); - virtual ~constraint_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(constraint_impl) - virtual bool operator()( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - - //!\brief Creates a constraint with the given function that implements the constraint. - //!\param _function Function that implements the constraint. - //!\return A unique pointer to the created constraint. - static constraint_uptr create( const constraint_function& _function ); - - -private: - constraint_function function_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONSTRAINT_IMPL_A7A39030_C6D6_49D6_A051_B151370B7147 +#define CONSTRAINT_IMPL_A7A39030_C6D6_49D6_A051_B151370B7147 + + +#include "constraint.hpp" + + +namespace sxy +{ + + +class constraint_impl SX_FINAL: + public virtual constraint +{ +public: + explicit constraint_impl( const constraint_function& _function ); + virtual ~constraint_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(constraint_impl) + virtual bool operator()( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + + //!\brief Creates a constraint with the given function that implements the constraint. + //!\param _function Function that implements the constraint. + //!\return A unique pointer to the created constraint. + static constraint_uptr create( const constraint_function& _function ); + + +private: + constraint_function function_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/deep_history_impl.hpp b/libyasmine/include_impl/deep_history_impl.hpp index 13ce3ee..6c2d379 100644 --- a/libyasmine/include_impl/deep_history_impl.hpp +++ b/libyasmine/include_impl/deep_history_impl.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DEEP_HISTORY_IMPL_F0E414BF_2D3A_406F_9BCF_9E6A87E7329D -#define DEEP_HISTORY_IMPL_F0E414BF_2D3A_406F_9BCF_9E6A87E7329D - - -#include "deep_history.hpp" -#include "history_impl.hpp" - - -namespace sxy -{ - - -class deep_history_impl SX_FINAL: - public virtual deep_history, public history_impl -{ -public: - explicit deep_history_impl( const std::string& _name ); - virtual ~deep_history_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(deep_history_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef DEEP_HISTORY_IMPL_F0E414BF_2D3A_406F_9BCF_9E6A87E7329D +#define DEEP_HISTORY_IMPL_F0E414BF_2D3A_406F_9BCF_9E6A87E7329D + + +#include "deep_history.hpp" +#include "history_impl.hpp" + + +namespace sxy +{ + + +class deep_history_impl SX_FINAL: + public virtual deep_history, public history_impl +{ +public: + explicit deep_history_impl( const std::string& _name ); + virtual ~deep_history_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(deep_history_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/entry_point_impl.hpp b/libyasmine/include_impl/entry_point_impl.hpp index 9121d1d..398ece1 100644 --- a/libyasmine/include_impl/entry_point_impl.hpp +++ b/libyasmine/include_impl/entry_point_impl.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ENTRY_POINT_IMPL_78A17172_D649_4870_988D_50A995692441 -#define ENTRY_POINT_IMPL_78A17172_D649_4870_988D_50A995692441 - - -#include "entry_point.hpp" -#include "state_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class entry_point_impl SX_FINAL: - public virtual entry_point, public state_pseudostate_impl -{ -public: - explicit entry_point_impl( const std::string& _name ); - virtual ~entry_point_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(entry_point_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ENTRY_POINT_IMPL_78A17172_D649_4870_988D_50A995692441 +#define ENTRY_POINT_IMPL_78A17172_D649_4870_988D_50A995692441 + + +#include "entry_point.hpp" +#include "state_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class entry_point_impl SX_FINAL: + public virtual entry_point, public state_pseudostate_impl +{ +public: + explicit entry_point_impl( const std::string& _name ); + virtual ~entry_point_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(entry_point_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/event_processing_callback.hpp b/libyasmine/include_impl/event_processing_callback.hpp index e90374e..f7dd2c2 100644 --- a/libyasmine/include_impl/event_processing_callback.hpp +++ b/libyasmine/include_impl/event_processing_callback.hpp @@ -1,131 +1,131 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EVENT_PROCESSING_CALLBACK_7D1528DE_08BA_4C56_90DF_290C3353040B -#define EVENT_PROCESSING_CALLBACK_7D1528DE_08BA_4C56_90DF_290C3353040B - - -#include "essentials/non_copyable.hpp" - -#include "event_id.hpp" -#include "event_priority.hpp" -#include "state_fwd.hpp" -#include "choice_fwd.hpp" - - -namespace sxy -{ - - -class state; -class transition; -class execution_step; -class choice; -class state_machine_introspection; - -//!\interface event_processing_callback -//!\brief Callback interface that is called by a state machine during event processing. See the different methods to -//!find out which events can be monitored. -class event_processing_callback -{ -public: - event_processing_callback() - { - // Nothing to do... - } - - - virtual ~event_processing_callback() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(event_processing_callback) - - //!\brief Adds a state machine introspection interface. - //!\param _state_machine The state machine which is monitored. - //!\return void - virtual void add_state_machine_introspection( state_machine_introspection& _state_machine ) = 0; - - //!\brief Callback before an event is processed. - //!\param _event_id ID of the event. - //!\return void - virtual void before_event( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ) = 0; - - //!\brief Callback after an event is processed. - //!\param _event_id ID of the event. - //!\return void - virtual void after_event( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ) = 0; - - //!\brief Callback before a event execution stage. - //!\return void - virtual void before_event_processings_stage() = 0; - - //!\brief Callback after a event execution stage. - //!\param _choices List of choices that need to be processed after the last execution stage. - //!\return void - virtual void after_event_processings_stage( const raw_const_choices& _choices ) = 0; - - //!\brief Callback before the processing of a compound transition. - //!\return void - virtual void before_compound_transition() = 0; - - //!\brief Callback after the processing of a compound transition. - //!\return void - virtual void after_compound_transition() = 0; - - //!\brief Callback before exiting a state. - //!\param _state State that will be exited. - //!\return void - virtual void before_exit( const state& _state ) = 0; - - //!\brief Callback after exiting a state. - //!\param _state State that was exited. - //!\return void - virtual void after_exit( const state& _state ) = 0; - - //!\brief Callback before entering a state. - //!\param _state State that will be entered. - //!\return void. - virtual void before_enter( const state& _state ) = 0; - - //!\brief Callback after entering a state. - //!\param _state State that was entered. - //!\return void - virtual void after_enter( const state& _state ) = 0; - - //!\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 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 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 behavior. - //!\param _transition Transition whose behavior was executed. - //!\return void - virtual void after_transition( const transition& _transition ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EVENT_PROCESSING_CALLBACK_7D1528DE_08BA_4C56_90DF_290C3353040B +#define EVENT_PROCESSING_CALLBACK_7D1528DE_08BA_4C56_90DF_290C3353040B + + +#include "essentials/non_copyable.hpp" + +#include "event_id.hpp" +#include "event_priority.hpp" +#include "state_fwd.hpp" +#include "choice_fwd.hpp" + + +namespace sxy +{ + + +class state; +class transition; +class execution_step; +class choice; +class state_machine_introspection; + +//!\interface event_processing_callback +//!\brief Callback interface that is called by a state machine during event processing. See the different methods to +//!find out which events can be monitored. +class event_processing_callback +{ +public: + event_processing_callback() + { + // Nothing to do... + } + + + virtual ~event_processing_callback() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(event_processing_callback) + + //!\brief Adds a state machine introspection interface. + //!\param _state_machine The state machine which is monitored. + //!\return void + virtual void add_state_machine_introspection( state_machine_introspection& _state_machine ) = 0; + + //!\brief Callback before an event is processed. + //!\param _event_id ID of the event. + //!\return void + virtual void before_event( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ) = 0; + + //!\brief Callback after an event is processed. + //!\param _event_id ID of the event. + //!\return void + virtual void after_event( const event_id _event_id, const event_priority _event_priority = DEFAULT_EVENT_PRIORITY ) = 0; + + //!\brief Callback before a event execution stage. + //!\return void + virtual void before_event_processings_stage() = 0; + + //!\brief Callback after a event execution stage. + //!\param _choices List of choices that need to be processed after the last execution stage. + //!\return void + virtual void after_event_processings_stage( const raw_const_choices& _choices ) = 0; + + //!\brief Callback before the processing of a compound transition. + //!\return void + virtual void before_compound_transition() = 0; + + //!\brief Callback after the processing of a compound transition. + //!\return void + virtual void after_compound_transition() = 0; + + //!\brief Callback before exiting a state. + //!\param _state State that will be exited. + //!\return void + virtual void before_exit( const state& _state ) = 0; + + //!\brief Callback after exiting a state. + //!\param _state State that was exited. + //!\return void + virtual void after_exit( const state& _state ) = 0; + + //!\brief Callback before entering a state. + //!\param _state State that will be entered. + //!\return void. + virtual void before_enter( const state& _state ) = 0; + + //!\brief Callback after entering a state. + //!\param _state State that was entered. + //!\return void + virtual void after_enter( const state& _state ) = 0; + + //!\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 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 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 behavior. + //!\param _transition Transition whose behavior was executed. + //!\return void + virtual void after_transition( const transition& _transition ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_state_do_step.hpp b/libyasmine/include_impl/execution_state_do_step.hpp index 55e9a8f..ac87dd1 100644 --- a/libyasmine/include_impl/execution_state_do_step.hpp +++ b/libyasmine/include_impl/execution_state_do_step.hpp @@ -1,51 +1,51 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_STATE_DO_STEP_E8739F61_00B1_43BD_9E32_2DCD7B890E2C -#define EXECUTION_STATE_DO_STEP_E8739F61_00B1_43BD_9E32_2DCD7B890E2C - - -#include "essentials/non_copyable.hpp" - -#include "execution_step.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -class state; - - -class execution_state_do_step SX_FINAL : - public execution_step -{ -public: - explicit execution_state_do_step(const state& _state); - virtual ~execution_state_do_step() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(execution_state_do_step) - virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; - const state& get_state() const; - - -private: - const state& state_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_STATE_DO_STEP_E8739F61_00B1_43BD_9E32_2DCD7B890E2C +#define EXECUTION_STATE_DO_STEP_E8739F61_00B1_43BD_9E32_2DCD7B890E2C + + +#include "essentials/non_copyable.hpp" + +#include "execution_step.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class state; + + +class execution_state_do_step SX_FINAL : + public execution_step +{ +public: + explicit execution_state_do_step(const state& _state); + virtual ~execution_state_do_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(execution_state_do_step) + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; + const state& get_state() const; + + +private: + const state& state_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_state_enter_step.hpp b/libyasmine/include_impl/execution_state_enter_step.hpp index 1275e6a..f8edcab 100644 --- a/libyasmine/include_impl/execution_state_enter_step.hpp +++ b/libyasmine/include_impl/execution_state_enter_step.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_STATE_ENTER_STEP_455BAA75_9584_4CCF_87C2_AFA0FB76F9AB -#define EXECUTION_STATE_ENTER_STEP_455BAA75_9584_4CCF_87C2_AFA0FB76F9AB - - -#include "execution_step.hpp" - - -namespace sxy -{ - - -class state; - - -class execution_state_enter_step SX_FINAL: - public execution_step -{ -public: - explicit execution_state_enter_step( state& _state ); - virtual ~execution_state_enter_step() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(execution_state_enter_step) - virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; - const state& get_state() const; - - -private: - state& state_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_STATE_ENTER_STEP_455BAA75_9584_4CCF_87C2_AFA0FB76F9AB +#define EXECUTION_STATE_ENTER_STEP_455BAA75_9584_4CCF_87C2_AFA0FB76F9AB + + +#include "execution_step.hpp" + + +namespace sxy +{ + + +class state; + + +class execution_state_enter_step SX_FINAL: + public execution_step +{ +public: + explicit execution_state_enter_step( state& _state ); + virtual ~execution_state_enter_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(execution_state_enter_step) + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; + const state& get_state() const; + + +private: + state& state_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_state_exit_step.hpp b/libyasmine/include_impl/execution_state_exit_step.hpp index b0d213f..268f519 100644 --- a/libyasmine/include_impl/execution_state_exit_step.hpp +++ b/libyasmine/include_impl/execution_state_exit_step.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_STATE_EXIT_STEP_C20999E7_5BFF_464B_905E_7192F6153955 -#define EXECUTION_STATE_EXIT_STEP_C20999E7_5BFF_464B_905E_7192F6153955 - - -#include "execution_step.hpp" - - -namespace sxy -{ - - -class state; - - -class execution_state_exit_step SX_FINAL: - public execution_step -{ -public: - explicit execution_state_exit_step( state& _state ); - virtual ~execution_state_exit_step() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(execution_state_exit_step) - virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; - const state& get_state() const; - - -private: - state& state_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_STATE_EXIT_STEP_C20999E7_5BFF_464B_905E_7192F6153955 +#define EXECUTION_STATE_EXIT_STEP_C20999E7_5BFF_464B_905E_7192F6153955 + + +#include "execution_step.hpp" + + +namespace sxy +{ + + +class state; + + +class execution_state_exit_step SX_FINAL: + public execution_step +{ +public: + explicit execution_state_exit_step( state& _state ); + virtual ~execution_state_exit_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(execution_state_exit_step) + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; + const state& get_state() const; + + +private: + state& state_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_step.hpp b/libyasmine/include_impl/execution_step.hpp index d81c3e2..9304d75 100644 --- a/libyasmine/include_impl/execution_step.hpp +++ b/libyasmine/include_impl/execution_step.hpp @@ -1,59 +1,59 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_STEP_H_94397D2C_C792_4163_B87A_1CB896808779 -#define EXECUTION_STEP_H_94397D2C_C792_4163_B87A_1CB896808779 - - -#include "essentials/non_copyable.hpp" - -#include "execution_step_fwd.hpp" -#include "behavior_exception_fwd.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -class execution_step_visitor; -class event_processing_callback; -class async_event_handler; -class event_collector; - - -class execution_step -{ -public: - execution_step() - { - // Nothing to do... - } - - - virtual ~execution_step() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(execution_step) - virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const = 0; - virtual void accept( execution_step_visitor& _visitor ) const = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_STEP_H_94397D2C_C792_4163_B87A_1CB896808779 +#define EXECUTION_STEP_H_94397D2C_C792_4163_B87A_1CB896808779 + + +#include "essentials/non_copyable.hpp" + +#include "execution_step_fwd.hpp" +#include "behavior_exception_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class execution_step_visitor; +class event_processing_callback; +class async_event_handler; +class event_collector; + + +class execution_step +{ +public: + execution_step() + { + // Nothing to do... + } + + + virtual ~execution_step() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(execution_step) + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const = 0; + virtual void accept( execution_step_visitor& _visitor ) const = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_step_fwd.hpp b/libyasmine/include_impl/execution_step_fwd.hpp index 0212d11..0d927c3 100644 --- a/libyasmine/include_impl/execution_step_fwd.hpp +++ b/libyasmine/include_impl/execution_step_fwd.hpp @@ -1,33 +1,33 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_STEP_FWD_86F078EE_87D2_4AEA_9D9A_D6AACB48CD42 -#define EXECUTION_STEP_FWD_86F078EE_87D2_4AEA_9D9A_D6AACB48CD42 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class execution_step; -typedef sxe::SX_UNIQUE_PTR< execution_step > execution_step_uptr; -typedef std::vector< execution_step_uptr > execution_steps; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_STEP_FWD_86F078EE_87D2_4AEA_9D9A_D6AACB48CD42 +#define EXECUTION_STEP_FWD_86F078EE_87D2_4AEA_9D9A_D6AACB48CD42 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class execution_step; +typedef sxe::SX_UNIQUE_PTR< execution_step > execution_step_uptr; +typedef std::vector< execution_step_uptr > execution_steps; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_step_visitor.hpp b/libyasmine/include_impl/execution_step_visitor.hpp index ae0dc7c..c20cfd6 100644 --- a/libyasmine/include_impl/execution_step_visitor.hpp +++ b/libyasmine/include_impl/execution_step_visitor.hpp @@ -1,55 +1,55 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_STEP_VISITOR_7AEFC8D8_8C36_4529_AC9E_F3A2B20622B4 -#define EXECUTION_STEP_VISITOR_7AEFC8D8_8C36_4529_AC9E_F3A2B20622B4 - - -#include "essentials/non_copyable.hpp" - - -namespace sxy -{ - - -class execution_state_enter_step; -class execution_state_do_step; -class execution_state_exit_step; -class execution_transition_step; - - -class execution_step_visitor -{ -public: - execution_step_visitor() - { - // Nothing to do... - } - - - virtual ~execution_step_visitor() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(execution_step_visitor) - virtual void visit( const execution_state_enter_step& _execution_state_enter_step ) = 0; - virtual void visit( const execution_state_do_step& _execution_state_do_step ) = 0; - virtual void visit( const execution_state_exit_step& _execution_state_exit_step ) = 0; - virtual void visit( const execution_transition_step& _execution_transition_step ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_STEP_VISITOR_7AEFC8D8_8C36_4529_AC9E_F3A2B20622B4 +#define EXECUTION_STEP_VISITOR_7AEFC8D8_8C36_4529_AC9E_F3A2B20622B4 + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + +class execution_state_enter_step; +class execution_state_do_step; +class execution_state_exit_step; +class execution_transition_step; + + +class execution_step_visitor +{ +public: + execution_step_visitor() + { + // Nothing to do... + } + + + virtual ~execution_step_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(execution_step_visitor) + virtual void visit( const execution_state_enter_step& _execution_state_enter_step ) = 0; + virtual void visit( const execution_state_do_step& _execution_state_do_step ) = 0; + virtual void visit( const execution_state_exit_step& _execution_state_exit_step ) = 0; + virtual void visit( const execution_transition_step& _execution_transition_step ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/execution_transition_step.hpp b/libyasmine/include_impl/execution_transition_step.hpp index 3495434..70ad840 100644 --- a/libyasmine/include_impl/execution_transition_step.hpp +++ b/libyasmine/include_impl/execution_transition_step.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXECUTION_TRANSITION_STEP_H_94397D2C_C792_4163_B87A_1CB4931208779 -#define EXECUTION_TRANSITION_STEP_H_94397D2C_C792_4163_B87A_1CB4931208779 - - -#include "execution_step.hpp" - - -namespace sxy -{ - - -class transition_step; - - -class execution_transition_step SX_FINAL: - public execution_step -{ -public: - explicit execution_transition_step( transition_step& _transition_step ); - virtual ~execution_transition_step() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(execution_transition_step) - virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; - const transition_step& get_transition_step() const; - - -private: - transition_step& transition_step_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXECUTION_TRANSITION_STEP_H_94397D2C_C792_4163_B87A_1CB4931208779 +#define EXECUTION_TRANSITION_STEP_H_94397D2C_C792_4163_B87A_1CB4931208779 + + +#include "execution_step.hpp" + + +namespace sxy +{ + + +class transition_step; + + +class execution_transition_step SX_FINAL: + public execution_step +{ +public: + explicit execution_transition_step( transition_step& _transition_step ); + virtual ~execution_transition_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(execution_transition_step) + virtual bool execute_behavior( event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + virtual void accept( execution_step_visitor& _visitor ) const SX_OVERRIDE; + const transition_step& get_transition_step() const; + + +private: + transition_step& transition_step_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/exit_point_impl.hpp b/libyasmine/include_impl/exit_point_impl.hpp index cf7f76f..ffb670a 100644 --- a/libyasmine/include_impl/exit_point_impl.hpp +++ b/libyasmine/include_impl/exit_point_impl.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef EXIT_POINT_IMPL_3F9A1319_C306_4E7D_A153_D725292B4763 -#define EXIT_POINT_IMPL_3F9A1319_C306_4E7D_A153_D725292B4763 - - -#include "exit_point.hpp" -#include "state_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class exit_point_impl SX_FINAL: - public virtual exit_point, public state_pseudostate_impl -{ -public: - explicit exit_point_impl( const std::string& _name ); - virtual ~exit_point_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(exit_point_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef EXIT_POINT_IMPL_3F9A1319_C306_4E7D_A153_D725292B4763 +#define EXIT_POINT_IMPL_3F9A1319_C306_4E7D_A153_D725292B4763 + + +#include "exit_point.hpp" +#include "state_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class exit_point_impl SX_FINAL: + public virtual exit_point, public state_pseudostate_impl +{ +public: + explicit exit_point_impl( const std::string& _name ); + virtual ~exit_point_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(exit_point_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/final_state_impl.hpp b/libyasmine/include_impl/final_state_impl.hpp index b52fb5d..2d9ca17 100644 --- a/libyasmine/include_impl/final_state_impl.hpp +++ b/libyasmine/include_impl/final_state_impl.hpp @@ -1,46 +1,46 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FINAL_STATE_IMPL_05AFD9ED_2F4A_46B8_9C77_4933E67B5520 -#define FINAL_STATE_IMPL_05AFD9ED_2F4A_46B8_9C77_4933E67B5520 - - -#include "final_state.hpp" -#include "state_impl.hpp" - - -namespace sxy -{ - - -class final_state_impl SX_FINAL: - public virtual final_state, public state_impl -{ -public: - explicit final_state_impl( const std::string& _name ); - virtual ~final_state_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(final_state_impl) - virtual behavior * get_entry_behavior() const SX_OVERRIDE; - virtual behavior * get_exit_behavior() const SX_OVERRIDE; - virtual const regions& get_regions() const SX_OVERRIDE; - virtual regions& get_regions() SX_OVERRIDE; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; - virtual bool is_event_deferred( const event_id& _event_id ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FINAL_STATE_IMPL_05AFD9ED_2F4A_46B8_9C77_4933E67B5520 +#define FINAL_STATE_IMPL_05AFD9ED_2F4A_46B8_9C77_4933E67B5520 + + +#include "final_state.hpp" +#include "state_impl.hpp" + + +namespace sxy +{ + + +class final_state_impl SX_FINAL: + public virtual final_state, public state_impl +{ +public: + explicit final_state_impl( const std::string& _name ); + virtual ~final_state_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(final_state_impl) + virtual behavior * get_entry_behavior() const SX_OVERRIDE; + virtual behavior * get_exit_behavior() const SX_OVERRIDE; + virtual const regions& get_regions() const SX_OVERRIDE; + virtual regions& get_regions() SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_state_visitor( state_visitor& _visitor ) const SX_OVERRIDE; + virtual bool is_event_deferred( const event_id& _event_id ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/fork_impl.hpp b/libyasmine/include_impl/fork_impl.hpp index 77362cb..be5d53a 100644 --- a/libyasmine/include_impl/fork_impl.hpp +++ b/libyasmine/include_impl/fork_impl.hpp @@ -1,42 +1,42 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef FORK_IMPL_DCB9F2CB_E7C4_4E00_BD05_B2C179DEFCB0 -#define FORK_IMPL_DCB9F2CB_E7C4_4E00_BD05_B2C179DEFCB0 - - -#include "fork.hpp" -#include "region_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class fork_impl SX_FINAL: - public virtual fork, public region_pseudostate_impl -{ -public: - explicit fork_impl( const std::string& _name ); - virtual ~fork_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(fork_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; - virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef FORK_IMPL_DCB9F2CB_E7C4_4E00_BD05_B2C179DEFCB0 +#define FORK_IMPL_DCB9F2CB_E7C4_4E00_BD05_B2C179DEFCB0 + + +#include "fork.hpp" +#include "region_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class fork_impl SX_FINAL: + public virtual fork, public region_pseudostate_impl +{ +public: + explicit fork_impl( const std::string& _name ); + virtual ~fork_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(fork_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; + virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/history_impl.hpp b/libyasmine/include_impl/history_impl.hpp index 4c801b0..bfaa496 100644 --- a/libyasmine/include_impl/history_impl.hpp +++ b/libyasmine/include_impl/history_impl.hpp @@ -1,40 +1,40 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef HISTORY_IMPL_D2F99021_CF5E_4B90_8BC7_DD0E3610DE94 -#define HISTORY_IMPL_D2F99021_CF5E_4B90_8BC7_DD0E3610DE94 - - -#include "history.hpp" -#include "state_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class history_impl: - public virtual history, public state_pseudostate_impl -{ -public: - explicit history_impl( const std::string& _name ); - virtual ~history_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(history_impl) - virtual raw_transitions get_default_transitions() const SX_OVERRIDE; - virtual void add_default_transition( transition& _default_transition ) SX_OVERRIDE; - virtual bool check_if_state_was_active_before() const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef HISTORY_IMPL_D2F99021_CF5E_4B90_8BC7_DD0E3610DE94 +#define HISTORY_IMPL_D2F99021_CF5E_4B90_8BC7_DD0E3610DE94 + + +#include "history.hpp" +#include "state_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class history_impl: + public virtual history, public state_pseudostate_impl +{ +public: + explicit history_impl( const std::string& _name ); + virtual ~history_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(history_impl) + virtual raw_transitions get_default_transitions() const SX_OVERRIDE; + virtual void add_default_transition( transition& _default_transition ) SX_OVERRIDE; + virtual bool check_if_state_was_active_before() const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/initial_pseudostate_impl.hpp b/libyasmine/include_impl/initial_pseudostate_impl.hpp index 5b3efdd..84f28b4 100644 --- a/libyasmine/include_impl/initial_pseudostate_impl.hpp +++ b/libyasmine/include_impl/initial_pseudostate_impl.hpp @@ -1,43 +1,43 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef INITIAL_PSEUDOSTATE_IMPL_39ED4963_725A_495E_ADAE_09739A333E71 -#define INITIAL_PSEUDOSTATE_IMPL_39ED4963_725A_495E_ADAE_09739A333E71 - - -#include "initial_pseudostate.hpp" -#include "region_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class initial_pseudostate_impl SX_FINAL: - public virtual initial_pseudostate, public region_pseudostate_impl -{ -public: - explicit initial_pseudostate_impl( const std::string& _name ); - virtual ~initial_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(initial_pseudostate_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; - virtual transition * get_transition() const SX_OVERRIDE; - virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef INITIAL_PSEUDOSTATE_IMPL_39ED4963_725A_495E_ADAE_09739A333E71 +#define INITIAL_PSEUDOSTATE_IMPL_39ED4963_725A_495E_ADAE_09739A333E71 + + +#include "initial_pseudostate.hpp" +#include "region_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class initial_pseudostate_impl SX_FINAL: + public virtual initial_pseudostate, public region_pseudostate_impl +{ +public: + explicit initial_pseudostate_impl( const std::string& _name ); + virtual ~initial_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(initial_pseudostate_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; + virtual transition * get_transition() const SX_OVERRIDE; + virtual void add_incoming_transition( transition& _incoming_transition ) SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/join_impl.hpp b/libyasmine/include_impl/join_impl.hpp index 7d4418e..79d9877 100644 --- a/libyasmine/include_impl/join_impl.hpp +++ b/libyasmine/include_impl/join_impl.hpp @@ -1,42 +1,42 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef JOIN_IMPL_18BD2E66_59C9_4BB1_B5A9_5B444B6CFE1E -#define JOIN_IMPL_18BD2E66_59C9_4BB1_B5A9_5B444B6CFE1E - - -#include "join.hpp" -#include "region_pseudostate_impl.hpp" - -namespace sxy -{ - - -class join_impl SX_FINAL: - public virtual join, public region_pseudostate_impl -{ -public: - explicit join_impl( const std::string& _name ); - virtual ~join_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(join_impl) - virtual bool check_if_all_source_states_of_incoming_transitions_are_active() const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JOIN_IMPL_18BD2E66_59C9_4BB1_B5A9_5B444B6CFE1E +#define JOIN_IMPL_18BD2E66_59C9_4BB1_B5A9_5B444B6CFE1E + + +#include "join.hpp" +#include "region_pseudostate_impl.hpp" + +namespace sxy +{ + + +class join_impl SX_FINAL: + public virtual join, public region_pseudostate_impl +{ +public: + explicit join_impl( const std::string& _name ); + virtual ~join_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(join_impl) + virtual bool check_if_all_source_states_of_incoming_transitions_are_active() const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/junction_impl.hpp b/libyasmine/include_impl/junction_impl.hpp index e7b1b46..26ce3cf 100644 --- a/libyasmine/include_impl/junction_impl.hpp +++ b/libyasmine/include_impl/junction_impl.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef JUNCTION_IMPL_9BB5CE53_8B97_444D_8548_FDF175AB929C -#define JUNCTION_IMPL_9BB5CE53_8B97_444D_8548_FDF175AB929C - - -#include "junction.hpp" -#include "region_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class junction_impl SX_FINAL: - public virtual junction, public region_pseudostate_impl -{ -public: - explicit junction_impl( const std::string& _name ); - virtual ~junction_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(junction_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef JUNCTION_IMPL_9BB5CE53_8B97_444D_8548_FDF175AB929C +#define JUNCTION_IMPL_9BB5CE53_8B97_444D_8548_FDF175AB929C + + +#include "junction.hpp" +#include "region_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class junction_impl SX_FINAL: + public virtual junction, public region_pseudostate_impl +{ +public: + explicit junction_impl( const std::string& _name ); + virtual ~junction_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(junction_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/pseudostate_impl.hpp b/libyasmine/include_impl/pseudostate_impl.hpp index fc58f99..7685ff6 100644 --- a/libyasmine/include_impl/pseudostate_impl.hpp +++ b/libyasmine/include_impl/pseudostate_impl.hpp @@ -1,38 +1,38 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef PSEUDOSTATE_IMPL_5DF69044_2EB3_4226_92B4_A04674AB02CF -#define PSEUDOSTATE_IMPL_5DF69044_2EB3_4226_92B4_A04674AB02CF - - -#include "pseudostate.hpp" -#include "vertex_impl.hpp" - - -namespace sxy -{ - - -class pseudostate_impl: - public virtual pseudostate, public vertex_impl -{ -public: - explicit pseudostate_impl( const std::string& _name ); - virtual ~pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(pseudostate_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PSEUDOSTATE_IMPL_5DF69044_2EB3_4226_92B4_A04674AB02CF +#define PSEUDOSTATE_IMPL_5DF69044_2EB3_4226_92B4_A04674AB02CF + + +#include "pseudostate.hpp" +#include "vertex_impl.hpp" + + +namespace sxy +{ + + +class pseudostate_impl: + public virtual pseudostate, public vertex_impl +{ +public: + explicit pseudostate_impl( const std::string& _name ); + virtual ~pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(pseudostate_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/pseudostate_visitor.hpp b/libyasmine/include_impl/pseudostate_visitor.hpp index e9993d1..0c615f2 100644 --- a/libyasmine/include_impl/pseudostate_visitor.hpp +++ b/libyasmine/include_impl/pseudostate_visitor.hpp @@ -1,64 +1,64 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef PSEUDOSTATE_VISITOR_6250307A_E61E_4175_B03E_6C113149B5F2 -#define PSEUDOSTATE_VISITOR_6250307A_E61E_4175_B03E_6C113149B5F2 - - -namespace sxy -{ - - -class choice; -class deep_history; -class entry_point; -class exit_point; -class fork; -class initial_pseudostate; -class join; -class junction; -class shallow_history; -class terminate_pseudostate; - - -class pseudostate_visitor -{ -public: - pseudostate_visitor() - { - // Nothing to do... - } - - - virtual ~pseudostate_visitor() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(pseudostate_visitor) - virtual void visit( const initial_pseudostate& _initial_pseudostate ) = 0; - virtual void visit( const choice& _choice ) = 0; - virtual void visit( const junction& _junction ) = 0; - virtual void visit( const join& _join ) = 0; - virtual void visit( const fork& _fork ) = 0; - virtual void visit( const entry_point& _entry_point ) = 0; - virtual void visit( const exit_point& _exit_point ) = 0; - virtual void visit( const deep_history& _deep_history ) = 0; - virtual void visit( const shallow_history& _shallow_history ) = 0; - virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef PSEUDOSTATE_VISITOR_6250307A_E61E_4175_B03E_6C113149B5F2 +#define PSEUDOSTATE_VISITOR_6250307A_E61E_4175_B03E_6C113149B5F2 + + +namespace sxy +{ + + +class choice; +class deep_history; +class entry_point; +class exit_point; +class fork; +class initial_pseudostate; +class join; +class junction; +class shallow_history; +class terminate_pseudostate; + + +class pseudostate_visitor +{ +public: + pseudostate_visitor() + { + // Nothing to do... + } + + + virtual ~pseudostate_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(pseudostate_visitor) + virtual void visit( const initial_pseudostate& _initial_pseudostate ) = 0; + virtual void visit( const choice& _choice ) = 0; + virtual void visit( const junction& _junction ) = 0; + virtual void visit( const join& _join ) = 0; + virtual void visit( const fork& _fork ) = 0; + virtual void visit( const entry_point& _entry_point ) = 0; + virtual void visit( const exit_point& _exit_point ) = 0; + virtual void visit( const deep_history& _deep_history ) = 0; + virtual void visit( const shallow_history& _shallow_history ) = 0; + virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/region_impl.hpp b/libyasmine/include_impl/region_impl.hpp index ff63f1a..8d14410 100644 --- a/libyasmine/include_impl/region_impl.hpp +++ b/libyasmine/include_impl/region_impl.hpp @@ -1,128 +1,128 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef REGION_IMPL_DDA92905_6CBE_4061_8DA1_4E6C1E98E11A -#define REGION_IMPL_DDA92905_6CBE_4061_8DA1_4E6C1E98E11A - - -#include "region.hpp" -#include "state_machine_element_impl.hpp" - - -namespace sxy -{ - - -class region_impl SX_FINAL: - public virtual region, public state_machine_element_impl -{ -public: - explicit region_impl( const std::string& _name ); - virtual ~region_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(region_impl) - void set_parent_state( composite_state* const _composite_state ) SX_OVERRIDE; - virtual raw_const_states get_states() const SX_OVERRIDE; - virtual const composite_state& get_parent_state() const SX_OVERRIDE; - virtual composite_state& get_parent_state() SX_OVERRIDE; - virtual vertex* get_vertex( const std::string& _vertex_name ) const SX_OVERRIDE; - virtual size_t get_pseudostate_count() const SX_OVERRIDE; - virtual vertex* get_pseudostate( const std::string& _name ) const SX_OVERRIDE; - virtual raw_const_pseudostates get_pseudostates() const SX_OVERRIDE; - virtual initial_pseudostate* get_initial_pseudostate() const SX_OVERRIDE; - virtual size_t get_state_count() const SX_OVERRIDE; - virtual state* get_state( const std::string& _name ) const SX_OVERRIDE; - virtual const state* get_active_state() const SX_OVERRIDE; - virtual state* get_active_state() SX_OVERRIDE; - virtual void set_active_state( state* const _active_state ) SX_OVERRIDE; - virtual void set_state_was_active( state* const _active_state ) SX_OVERRIDE; - virtual const state* get_last_active_state() const SX_OVERRIDE; - virtual state* get_last_active_state() SX_OVERRIDE; - virtual initial_pseudostate& add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) SX_OVERRIDE; - - //!\brief Creates an initial pseudostate with the given name and adds it to the parent region. - //!\param _initial_state_name Name of the initial pseudostate. - //!\return A reference to the newly created initial pseudostate. - virtual initial_pseudostate& add_initial_pseudostate( const std::string& _initial_state_name ) SX_OVERRIDE; - virtual state& add_state( state_uptr _state ) SX_OVERRIDE; - virtual simple_state& add_simple_state( const std::string& _simple_state_name, - const behavior_function& _behavior = behavior_function(), - const behavior_function& _entry_behavior = behavior_function(), - const behavior_function& _exit_behavior = behavior_function() ) SX_OVERRIDE; - virtual simple_state& add_simple_state( const std::string& _simple_state_name, const event_ids& _deferred_events, - const behavior_function& _behavior = behavior_function(), - const behavior_function& _entry_behavior = behavior_function(), - const behavior_function& _exit_behavior = behavior_function(), - event_sptr _error_event = event_sptr() ) SX_OVERRIDE; - virtual simple_state& add_async_simple_state( const std::string& _async_simple_state_name, - const event_ids& _deferred_events, async_behavior_uptr _do_action = async_behavior_uptr(), - const behavior_function& _entry_behavior = behavior_function(), - const behavior_function& _exit_behavior = behavior_function(), - event_sptr _error_event = event_sptr() ) SX_OVERRIDE; - virtual composite_state& add_composite_state( const std::string& _composite_state_name, - const behavior_function& _entry_action = behavior_function(), - const behavior_function& _exit_action = behavior_function() ) SX_OVERRIDE; - virtual composite_state& add_composite_state( const std::string& _composite_state_name, - const event_ids& _deferred_events, const behavior_function& _entry_action = behavior_function(), - const behavior_function& _exit_action = behavior_function() ) SX_OVERRIDE; - virtual final_state& add_final_state( const std::string& _name ) SX_OVERRIDE; - virtual choice& add_choice( choice_uptr _choice ) SX_OVERRIDE; - - //!\brief Creates a choice with the given name and adds it to the parent region. - //!\param _choice_name Name of the choice. - //!\return A reference to the newly created choice. - virtual choice& add_choice( const std::string& _choice_name ) SX_OVERRIDE; - virtual fork& add_fork( fork_uptr _fork ) SX_OVERRIDE; - - //!\brief Creates a fork with the given name and adds it to the parent region. - //!\param _fork_name Name of the fork. - //!\return A reference to the newly created fork. - virtual fork& add_fork( const std::string& _fork_name ) SX_OVERRIDE; - virtual join& add_join( join_uptr _join ) SX_OVERRIDE; - - //!\brief Creates a join with the given name and adds it to the parent region. - //!\param _join_name Name of the join. - //!\return A reference to the newly created join. - virtual join& add_join( const std::string& _join_name ) SX_OVERRIDE; - virtual junction& add_junction( junction_uptr _junction ) SX_OVERRIDE; - - //!\brief Creates a junction with the given name and adds it to the parent region. - //!\param _junction_name Name of the junction. - //!\return A reference to the newly created junction. - virtual junction& add_junction( const std::string& _junction_name ) SX_OVERRIDE; - virtual terminate_pseudostate& add_terminate_pseudostate( - terminate_pseudostate_uptr _terminate_pseudostate ) SX_OVERRIDE; - - //!\brief Creates a terminate pseudostate with the given name and adds it to the parent region. - //!\param _terminate_pseudostate_name Name of the terminate pseudostate. - //!\return A reference to the newly created terminate pseudostate. - virtual terminate_pseudostate& add_terminate_pseudostate( - const std::string& _terminate_pseudostate_name ) SX_OVERRIDE; - uri get_uri() const SX_OVERRIDE; - void add_ancestor_uri ( uri& _uri ) const SX_OVERRIDE; - virtual bool is_active_state_final () const SX_OVERRIDE; - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual const state_machine_element * get_parent() const SX_OVERRIDE; - - -private: - composite_state* parent_state_; - states states_; - pseudostates pseudostates_; - initial_pseudostate* initial_pseudostate_; - state* active_state_; - state* last_active_state_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_IMPL_DDA92905_6CBE_4061_8DA1_4E6C1E98E11A +#define REGION_IMPL_DDA92905_6CBE_4061_8DA1_4E6C1E98E11A + + +#include "region.hpp" +#include "state_machine_element_impl.hpp" + + +namespace sxy +{ + + +class region_impl SX_FINAL: + public virtual region, public state_machine_element_impl +{ +public: + explicit region_impl( const std::string& _name ); + virtual ~region_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(region_impl) + void set_parent_state( composite_state* const _composite_state ) SX_OVERRIDE; + virtual raw_const_states get_states() const SX_OVERRIDE; + virtual const composite_state& get_parent_state() const SX_OVERRIDE; + virtual composite_state& get_parent_state() SX_OVERRIDE; + virtual vertex* get_vertex( const std::string& _vertex_name ) const SX_OVERRIDE; + virtual size_t get_pseudostate_count() const SX_OVERRIDE; + virtual vertex* get_pseudostate( const std::string& _name ) const SX_OVERRIDE; + virtual raw_const_pseudostates get_pseudostates() const SX_OVERRIDE; + virtual initial_pseudostate* get_initial_pseudostate() const SX_OVERRIDE; + virtual size_t get_state_count() const SX_OVERRIDE; + virtual state* get_state( const std::string& _name ) const SX_OVERRIDE; + virtual const state* get_active_state() const SX_OVERRIDE; + virtual state* get_active_state() SX_OVERRIDE; + virtual void set_active_state( state* const _active_state ) SX_OVERRIDE; + virtual void set_state_was_active( state* const _active_state ) SX_OVERRIDE; + virtual const state* get_last_active_state() const SX_OVERRIDE; + virtual state* get_last_active_state() SX_OVERRIDE; + virtual initial_pseudostate& add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) SX_OVERRIDE; + + //!\brief Creates an initial pseudostate with the given name and adds it to the parent region. + //!\param _initial_state_name Name of the initial pseudostate. + //!\return A reference to the newly created initial pseudostate. + virtual initial_pseudostate& add_initial_pseudostate( const std::string& _initial_state_name ) SX_OVERRIDE; + virtual state& add_state( state_uptr _state ) SX_OVERRIDE; + virtual simple_state& add_simple_state( const std::string& _simple_state_name, + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function() ) SX_OVERRIDE; + virtual simple_state& add_simple_state( const std::string& _simple_state_name, const event_ids& _deferred_events, + const behavior_function& _behavior = behavior_function(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function(), + event_sptr _error_event = event_sptr() ) SX_OVERRIDE; + virtual simple_state& add_async_simple_state( const std::string& _async_simple_state_name, + const event_ids& _deferred_events, async_behavior_uptr _do_action = async_behavior_uptr(), + const behavior_function& _entry_behavior = behavior_function(), + const behavior_function& _exit_behavior = behavior_function(), + event_sptr _error_event = event_sptr() ) SX_OVERRIDE; + virtual composite_state& add_composite_state( const std::string& _composite_state_name, + const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) SX_OVERRIDE; + virtual composite_state& add_composite_state( const std::string& _composite_state_name, + const event_ids& _deferred_events, const behavior_function& _entry_action = behavior_function(), + const behavior_function& _exit_action = behavior_function() ) SX_OVERRIDE; + virtual final_state& add_final_state( const std::string& _name ) SX_OVERRIDE; + virtual choice& add_choice( choice_uptr _choice ) SX_OVERRIDE; + + //!\brief Creates a choice with the given name and adds it to the parent region. + //!\param _choice_name Name of the choice. + //!\return A reference to the newly created choice. + virtual choice& add_choice( const std::string& _choice_name ) SX_OVERRIDE; + virtual fork& add_fork( fork_uptr _fork ) SX_OVERRIDE; + + //!\brief Creates a fork with the given name and adds it to the parent region. + //!\param _fork_name Name of the fork. + //!\return A reference to the newly created fork. + virtual fork& add_fork( const std::string& _fork_name ) SX_OVERRIDE; + virtual join& add_join( join_uptr _join ) SX_OVERRIDE; + + //!\brief Creates a join with the given name and adds it to the parent region. + //!\param _join_name Name of the join. + //!\return A reference to the newly created join. + virtual join& add_join( const std::string& _join_name ) SX_OVERRIDE; + virtual junction& add_junction( junction_uptr _junction ) SX_OVERRIDE; + + //!\brief Creates a junction with the given name and adds it to the parent region. + //!\param _junction_name Name of the junction. + //!\return A reference to the newly created junction. + virtual junction& add_junction( const std::string& _junction_name ) SX_OVERRIDE; + virtual terminate_pseudostate& add_terminate_pseudostate( + terminate_pseudostate_uptr _terminate_pseudostate ) SX_OVERRIDE; + + //!\brief Creates a terminate pseudostate with the given name and adds it to the parent region. + //!\param _terminate_pseudostate_name Name of the terminate pseudostate. + //!\return A reference to the newly created terminate pseudostate. + virtual terminate_pseudostate& add_terminate_pseudostate( + const std::string& _terminate_pseudostate_name ) SX_OVERRIDE; + sxe::uri get_uri() const SX_OVERRIDE; + void add_ancestor_uri ( sxe::uri& _uri ) const SX_OVERRIDE; + virtual bool is_active_state_final () const SX_OVERRIDE; + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + + +private: + composite_state* parent_state_; + states states_; + pseudostates pseudostates_; + initial_pseudostate* initial_pseudostate_; + state* active_state_; + state* last_active_state_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/region_pseudostate_impl.hpp b/libyasmine/include_impl/region_pseudostate_impl.hpp index 85c1536..ba8938a 100644 --- a/libyasmine/include_impl/region_pseudostate_impl.hpp +++ b/libyasmine/include_impl/region_pseudostate_impl.hpp @@ -1,55 +1,55 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef REGION_PSEUDOSTATE_IMPL_4F059791_948F_4CB6_9EDA_5CD4338F2255 -#define REGION_PSEUDOSTATE_IMPL_4F059791_948F_4CB6_9EDA_5CD4338F2255 - - -#include "region_pseudostate.hpp" -#include "pseudostate_impl.hpp" -#include "optimization.hpp" - - -namespace sxy -{ - - -class region_pseudostate_impl: - public virtual region_pseudostate, public pseudostate_impl -{ -public: - explicit region_pseudostate_impl( const std::string& _name ); - virtual ~region_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; - virtual const state_machine_element * get_parent() const SX_OVERRIDE; - virtual region * get_parent_region() const SX_OVERRIDE; - virtual void set_parent_region( region* const _parent_region ) SX_OVERRIDE; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, - bool _include_final_ancestor = true ) const SX_OVERRIDE; - virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; - - -private: - void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const; - void collect_ancestors_as_regions( raw_regions& _ancestor_regions ) const; - - - region* parent_; - -#ifdef Y_OPTIMIZE_4_SPEED - mutable raw_composite_states ancestors_; - mutable raw_regions ancestors_as_regions_; -#endif -}; - - -} - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef REGION_PSEUDOSTATE_IMPL_4F059791_948F_4CB6_9EDA_5CD4338F2255 +#define REGION_PSEUDOSTATE_IMPL_4F059791_948F_4CB6_9EDA_5CD4338F2255 + + +#include "region_pseudostate.hpp" +#include "pseudostate_impl.hpp" +#include "optimization.hpp" + + +namespace sxy +{ + + +class region_pseudostate_impl: + public virtual region_pseudostate, public pseudostate_impl +{ +public: + explicit region_pseudostate_impl( const std::string& _name ); + virtual ~region_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + virtual region * get_parent_region() const SX_OVERRIDE; + virtual void set_parent_region( region* const _parent_region ) SX_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const SX_OVERRIDE; + virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; + + +private: + void collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const; + void collect_ancestors_as_regions( raw_regions& _ancestor_regions ) const; + + + region* parent_; + +#ifdef Y_OPTIMIZE_4_SPEED + mutable raw_composite_states ancestors_; + mutable raw_regions ancestors_as_regions_; +#endif +}; + + +} + +#endif diff --git a/libyasmine/include_impl/shallow_history_impl.hpp b/libyasmine/include_impl/shallow_history_impl.hpp index 7bc6f01..28adab7 100644 --- a/libyasmine/include_impl/shallow_history_impl.hpp +++ b/libyasmine/include_impl/shallow_history_impl.hpp @@ -1,41 +1,41 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SHALLOW_HISTORY_IMPL_42D1E208_B814_4D2E_9963_375AFE37F3A4 -#define SHALLOW_HISTORY_IMPL_42D1E208_B814_4D2E_9963_375AFE37F3A4 - - -#include "shallow_history.hpp" -#include "history_impl.hpp" - - -namespace sxy -{ - - -class shallow_history_impl: - public virtual shallow_history, public history_impl -{ -public: - explicit shallow_history_impl( const std::string& _name ); - virtual ~shallow_history_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(shallow_history_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SHALLOW_HISTORY_IMPL_42D1E208_B814_4D2E_9963_375AFE37F3A4 +#define SHALLOW_HISTORY_IMPL_42D1E208_B814_4D2E_9963_375AFE37F3A4 + + +#include "shallow_history.hpp" +#include "history_impl.hpp" + + +namespace sxy +{ + + +class shallow_history_impl: + public virtual shallow_history, public history_impl +{ +public: + explicit shallow_history_impl( const std::string& _name ); + virtual ~shallow_history_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(shallow_history_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/simple_state_impl.hpp b/libyasmine/include_impl/simple_state_impl.hpp index 1ef7470..fcadb7c 100644 --- a/libyasmine/include_impl/simple_state_impl.hpp +++ b/libyasmine/include_impl/simple_state_impl.hpp @@ -1,45 +1,45 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SIMPLE_STATE_IMPL_F53AD7D0_4393_4F4A_9FB4_4D865E93C724 -#define SIMPLE_STATE_IMPL_F53AD7D0_4393_4F4A_9FB4_4D865E93C724 - - -#include "simple_state_base.hpp" - - -namespace sxy -{ - - -class simple_state_impl SX_FINAL: - public simple_state_base -{ -public: - 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() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(simple_state_impl) - void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const SX_OVERRIDE; - -private: - const behavior * get_do() const; - - behavior_uptr do_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SIMPLE_STATE_IMPL_F53AD7D0_4393_4F4A_9FB4_4D865E93C724 +#define SIMPLE_STATE_IMPL_F53AD7D0_4393_4F4A_9FB4_4D865E93C724 + + +#include "simple_state_base.hpp" + + +namespace sxy +{ + + +class simple_state_impl SX_FINAL: + public simple_state_base +{ +public: + 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() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(simple_state_impl) + void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const SX_OVERRIDE; + +private: + const behavior * get_do() const; + + behavior_uptr do_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/simple_transition_step.hpp b/libyasmine/include_impl/simple_transition_step.hpp index e034d8b..ef0dea1 100644 --- a/libyasmine/include_impl/simple_transition_step.hpp +++ b/libyasmine/include_impl/simple_transition_step.hpp @@ -1,52 +1,52 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef SIMPLE_TRANSITION_STEP_12297D2C_C792_4163_B87A_1CB896808779 -#define SIMPLE_TRANSITION_STEP_12297D2C_C792_4163_B87A_1CB896808779 - - -#include "transition_step.hpp" - - -namespace sxy -{ - - -class transition; -class state; - - -class simple_transition_step SX_FINAL: - public transition_step -{ -public: - explicit simple_transition_step( transition& _transition ); - virtual ~simple_transition_step() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(simple_transition_step) - virtual const raw_transitions& get_transitions() const SX_OVERRIDE; - virtual const vertex& get_unique_source() const SX_OVERRIDE; - virtual const vertex& get_unique_target() const SX_OVERRIDE; - virtual const exit_point * get_exit_point() const SX_OVERRIDE; - virtual const entry_point * get_entry_point() const SX_OVERRIDE; - virtual const raw_const_vertices get_target_vertices() SX_OVERRIDE; - void execute_transition_behaviors( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; - - -private: - transition& transition_; - raw_transitions transition_step_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef SIMPLE_TRANSITION_STEP_12297D2C_C792_4163_B87A_1CB896808779 +#define SIMPLE_TRANSITION_STEP_12297D2C_C792_4163_B87A_1CB896808779 + + +#include "transition_step.hpp" + + +namespace sxy +{ + + +class transition; +class state; + + +class simple_transition_step SX_FINAL: + public transition_step +{ +public: + explicit simple_transition_step( transition& _transition ); + virtual ~simple_transition_step() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(simple_transition_step) + virtual const raw_transitions& get_transitions() const SX_OVERRIDE; + virtual const vertex& get_unique_source() const SX_OVERRIDE; + virtual const vertex& get_unique_target() const SX_OVERRIDE; + virtual const exit_point * get_exit_point() const SX_OVERRIDE; + virtual const entry_point * get_entry_point() const SX_OVERRIDE; + virtual const raw_const_vertices get_target_vertices() SX_OVERRIDE; + void execute_transition_behaviors( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; + + +private: + transition& transition_; + raw_transitions transition_step_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/state_pseudostate_impl.hpp b/libyasmine/include_impl/state_pseudostate_impl.hpp index dc51d7a..2642d83 100644 --- a/libyasmine/include_impl/state_pseudostate_impl.hpp +++ b/libyasmine/include_impl/state_pseudostate_impl.hpp @@ -1,56 +1,56 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_PSEUDOSTATE_IMPL_2EA11FC4_EEC5_430E_AB7B_27E54A1202A0 -#define STATE_PSEUDOSTATE_IMPL_2EA11FC4_EEC5_430E_AB7B_27E54A1202A0 - - -#include "state_pseudostate.hpp" -#include "pseudostate_impl.hpp" -#include "optimization.hpp" - - -namespace sxy -{ - - -class state_pseudostate_impl: - public virtual state_pseudostate, public pseudostate_impl -{ -public: - explicit state_pseudostate_impl( const std::string& _name ); - virtual ~state_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(state_pseudostate_impl) - virtual const state_machine_element * get_parent() const SX_OVERRIDE; - virtual composite_state& get_parent_state() const SX_OVERRIDE; - virtual void set_parent_state( composite_state* const _parent_state ) SX_OVERRIDE; - virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, - bool _include_final_ancestor = true ) const SX_OVERRIDE; - virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; - - -private: - 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 - mutable raw_composite_states ancestors_; - mutable raw_regions ancestors_as_regions_; -#endif - -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_PSEUDOSTATE_IMPL_2EA11FC4_EEC5_430E_AB7B_27E54A1202A0 +#define STATE_PSEUDOSTATE_IMPL_2EA11FC4_EEC5_430E_AB7B_27E54A1202A0 + + +#include "state_pseudostate.hpp" +#include "pseudostate_impl.hpp" +#include "optimization.hpp" + + +namespace sxy +{ + + +class state_pseudostate_impl: + public virtual state_pseudostate, public pseudostate_impl +{ +public: + explicit state_pseudostate_impl( const std::string& _name ); + virtual ~state_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(state_pseudostate_impl) + virtual const state_machine_element * get_parent() const SX_OVERRIDE; + virtual composite_state& get_parent_state() const SX_OVERRIDE; + virtual void set_parent_state( composite_state* const _parent_state ) SX_OVERRIDE; + virtual raw_composite_states get_ancestors( composite_state* const _final_ancestor, + bool _include_final_ancestor = true ) const SX_OVERRIDE; + virtual raw_regions get_ancestors_as_regions() const SX_OVERRIDE; + + +private: + 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 + mutable raw_composite_states ancestors_; + mutable raw_regions ancestors_as_regions_; +#endif + +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/state_visitor.hpp b/libyasmine/include_impl/state_visitor.hpp index c96fd2e..2e1b912 100644 --- a/libyasmine/include_impl/state_visitor.hpp +++ b/libyasmine/include_impl/state_visitor.hpp @@ -1,50 +1,50 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATE_VISITOR_74B7FD7D_C18E_4F6E_B278_00268B0CFCD7 -#define STATE_VISITOR_74B7FD7D_C18E_4F6E_B278_00268B0CFCD7 - - -namespace sxy -{ - - -class composite_state; -class final_state; -class simple_state; - - -class state_visitor -{ -public: - state_visitor() - { - // Nothing to do... - } - - - virtual ~state_visitor() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(state_visitor) - virtual void visit( const composite_state& _composite_state ) = 0; - virtual void visit( const simple_state& _simple_state ) = 0; - virtual void visit( const final_state& _final_state ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATE_VISITOR_74B7FD7D_C18E_4F6E_B278_00268B0CFCD7 +#define STATE_VISITOR_74B7FD7D_C18E_4F6E_B278_00268B0CFCD7 + + +namespace sxy +{ + + +class composite_state; +class final_state; +class simple_state; + + +class state_visitor +{ +public: + state_visitor() + { + // Nothing to do... + } + + + virtual ~state_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(state_visitor) + virtual void visit( const composite_state& _composite_state ) = 0; + virtual void visit( const simple_state& _simple_state ) = 0; + virtual void visit( const final_state& _final_state ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/states_to_enter_visitor_impl.hpp b/libyasmine/include_impl/states_to_enter_visitor_impl.hpp index 1dd8847..f3a4275 100644 --- a/libyasmine/include_impl/states_to_enter_visitor_impl.hpp +++ b/libyasmine/include_impl/states_to_enter_visitor_impl.hpp @@ -1,71 +1,71 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef STATES_TO_ENTER_VISITOR_IMPL_7DBD7D6E_B4AB_4156_83B3_3193383C141E -#define STATES_TO_ENTER_VISITOR_IMPL_7DBD7D6E_B4AB_4156_83B3_3193383C141E - - -#include "vertex_visitor.hpp" -#include "state_fwd.hpp" -#include "region_fwd.hpp" - - -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, - const vertex& _source_of_transition ); - virtual ~states_to_enter_visitor_impl() SX_NOEXCEPT SX_OVERRIDE; - - SX_NO_COPY(states_to_enter_visitor_impl) - virtual void visit( composite_state& _composite_state ) SX_OVERRIDE; - virtual void visit( simple_state& _simple_state ) SX_OVERRIDE; - virtual void visit( final_state& _final_state ) SX_OVERRIDE; - virtual void visit( initial_pseudostate& _initial_pseudostate ) SX_OVERRIDE; - virtual void visit( choice& _choice ) SX_OVERRIDE; - virtual void visit( junction& _junction ) SX_OVERRIDE; - virtual void visit( join& _join ) SX_OVERRIDE; - virtual void visit( fork& _fork ) SX_OVERRIDE; - virtual void visit( entry_point& _entry_point ) SX_OVERRIDE; - virtual void visit( exit_point& _exit_point ) SX_OVERRIDE; - virtual void visit( deep_history& _deep_history ) SX_OVERRIDE; - virtual void visit( shallow_history& _shallow_history ) SX_OVERRIDE; - virtual void visit( terminate_pseudostate& _terminate_pseudostate ) SX_OVERRIDE; - - -private: - 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 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_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef STATES_TO_ENTER_VISITOR_IMPL_7DBD7D6E_B4AB_4156_83B3_3193383C141E +#define STATES_TO_ENTER_VISITOR_IMPL_7DBD7D6E_B4AB_4156_83B3_3193383C141E + + +#include "vertex_visitor.hpp" +#include "state_fwd.hpp" +#include "region_fwd.hpp" + + +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, + const vertex& _source_of_transition ); + virtual ~states_to_enter_visitor_impl() SX_NOEXCEPT SX_OVERRIDE; + + SX_NO_COPY(states_to_enter_visitor_impl) + virtual void visit( composite_state& _composite_state ) SX_OVERRIDE; + virtual void visit( simple_state& _simple_state ) SX_OVERRIDE; + virtual void visit( final_state& _final_state ) SX_OVERRIDE; + virtual void visit( initial_pseudostate& _initial_pseudostate ) SX_OVERRIDE; + virtual void visit( choice& _choice ) SX_OVERRIDE; + virtual void visit( junction& _junction ) SX_OVERRIDE; + virtual void visit( join& _join ) SX_OVERRIDE; + virtual void visit( fork& _fork ) SX_OVERRIDE; + virtual void visit( entry_point& _entry_point ) SX_OVERRIDE; + virtual void visit( exit_point& _exit_point ) SX_OVERRIDE; + virtual void visit( deep_history& _deep_history ) SX_OVERRIDE; + virtual void visit( shallow_history& _shallow_history ) SX_OVERRIDE; + virtual void visit( terminate_pseudostate& _terminate_pseudostate ) SX_OVERRIDE; + + +private: + 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 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_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/terminate_pseudostate_impl.hpp b/libyasmine/include_impl/terminate_pseudostate_impl.hpp index ea2ab6a..b49b82b 100644 --- a/libyasmine/include_impl/terminate_pseudostate_impl.hpp +++ b/libyasmine/include_impl/terminate_pseudostate_impl.hpp @@ -1,42 +1,42 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TERMINATE_PSEUDOSTATE_IMPL_8A849A3E_D15E_4C67_9BA0_77470C0F6683 -#define TERMINATE_PSEUDOSTATE_IMPL_8A849A3E_D15E_4C67_9BA0_77470C0F6683 - - -#include "terminate_pseudostate.hpp" -#include "region_pseudostate_impl.hpp" - - -namespace sxy -{ - - -class terminate_pseudostate_impl SX_FINAL: - public virtual terminate_pseudostate, public region_pseudostate_impl -{ -public: - explicit terminate_pseudostate_impl( const std::string& _name ); - virtual ~terminate_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(terminate_pseudostate_impl) - virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; - virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; - virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; - virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TERMINATE_PSEUDOSTATE_IMPL_8A849A3E_D15E_4C67_9BA0_77470C0F6683 +#define TERMINATE_PSEUDOSTATE_IMPL_8A849A3E_D15E_4C67_9BA0_77470C0F6683 + + +#include "terminate_pseudostate.hpp" +#include "region_pseudostate_impl.hpp" + + +namespace sxy +{ + + +class terminate_pseudostate_impl SX_FINAL: + public virtual terminate_pseudostate, public region_pseudostate_impl +{ +public: + explicit terminate_pseudostate_impl( const std::string& _name ); + virtual ~terminate_pseudostate_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(terminate_pseudostate_impl) + virtual bool check( state_machine_defects& _defects ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( const_vertex_visitor& _visitor ) const SX_OVERRIDE; + virtual void accept_vertex_visitor( vertex_visitor& _visitor ) SX_OVERRIDE; + virtual void accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const SX_OVERRIDE; + virtual void add_outgoing_transition( transition& _outgoing_transition ) SX_OVERRIDE; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/transition_controller.hpp b/libyasmine/include_impl/transition_controller.hpp index 3505615..052162e 100644 --- a/libyasmine/include_impl/transition_controller.hpp +++ b/libyasmine/include_impl/transition_controller.hpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_CONTROLLER_FDB88C02_ECF6_4BB5_B99A_3F45813BF357 -#define TRANSITION_CONTROLLER_FDB88C02_ECF6_4BB5_B99A_3F45813BF357 - - -#include "essentials/non_copyable.hpp" - -#include "choice_fwd.hpp" -#include "compound_transition_fwd.hpp" -#include "event_id.hpp" -#include "behavior_exception_fwd.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -class composite_state; -class event_processing_callback; -class async_event_handler; -class event_collector; -class interruptible; - - -class transition_controller SX_FINAL -{ -public: - transition_controller(); - ~transition_controller() SX_NOEXCEPT; - SX_NO_COPY(transition_controller) - static bool process_event( const event& _event, const composite_state& _main_composite_state, - event_processing_callback* const _event_processing_callback, bool& _event_is_deferred, - async_event_handler* const _async_event_handler, event_collector& _event_collector, - const interruptible& _interruptible ); - static bool start_state_machine( const composite_state& _main_composite_state, - event_processing_callback* const _event_processing_callback, async_event_handler* const _async_event_handler, - event_collector& _event_collector, const interruptible& _interruptible ); - - -private: - 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, event_collector& _event_collector, - const interruptible& _interruptible ); - 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, event_collector& _event_collector, - const interruptible& _interruptible ); - static void search_choice_transitions( const raw_const_choices& _choices, - compound_transitions& compound_transitions, const event& _event, event_collector& _event_collector ); - static void search_completion_event_transitions( const composite_state& _main_composite_state, - compound_transitions& compound_transitions, event_collector& _event_collector ); -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_CONTROLLER_FDB88C02_ECF6_4BB5_B99A_3F45813BF357 +#define TRANSITION_CONTROLLER_FDB88C02_ECF6_4BB5_B99A_3F45813BF357 + + +#include "essentials/non_copyable.hpp" + +#include "choice_fwd.hpp" +#include "compound_transition_fwd.hpp" +#include "event_id.hpp" +#include "behavior_exception_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +class composite_state; +class event_processing_callback; +class async_event_handler; +class event_collector; +class interruptible; + + +class transition_controller SX_FINAL +{ +public: + transition_controller(); + ~transition_controller() SX_NOEXCEPT; + SX_NO_COPY(transition_controller) + static bool process_event( const event& _event, const composite_state& _main_composite_state, + event_processing_callback* const _event_processing_callback, bool& _event_is_deferred, + async_event_handler* const _async_event_handler, event_collector& _event_collector, + const interruptible& _interruptible ); + static bool start_state_machine( const composite_state& _main_composite_state, + event_processing_callback* const _event_processing_callback, async_event_handler* const _async_event_handler, + event_collector& _event_collector, const interruptible& _interruptible ); + + +private: + 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, event_collector& _event_collector, + const interruptible& _interruptible ); + 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, event_collector& _event_collector, + const interruptible& _interruptible ); + static void search_choice_transitions( const raw_const_choices& _choices, + compound_transitions& compound_transitions, const event& _event, event_collector& _event_collector ); + static void search_completion_event_transitions( const composite_state& _main_composite_state, + compound_transitions& compound_transitions, event_collector& _event_collector ); +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/transition_executor.hpp b/libyasmine/include_impl/transition_executor.hpp index 461c955..35d3006 100644 --- a/libyasmine/include_impl/transition_executor.hpp +++ b/libyasmine/include_impl/transition_executor.hpp @@ -1,63 +1,63 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_EXECUTOR_H_2521E4B8_B89E_4CCE_9751_F5B6BD515AD5 -#define TRANSITION_EXECUTOR_H_2521E4B8_B89E_4CCE_9751_F5B6BD515AD5 - - -#include "essentials/non_copyable.hpp" - -#include "choice_fwd.hpp" -#include "compound_transition_fwd.hpp" -#include "behavior_exception_fwd.hpp" -#include "event_fwd.hpp" - - -namespace sxy -{ - - -namespace impl -{ - -class transition_executor_impl; - -} - - -class composite_state; -class event_processing_callback; -class async_event_handler; -class event_collector; -class interruptible; - - -class transition_executor SX_FINAL -{ -public: - transition_executor(); - ~transition_executor() SX_NOEXCEPT; - SX_NO_COPY(transition_executor) - bool check_sort_and_execute_transitions( const compound_transitions& _compound_transitions, - raw_const_choices& _verices, event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector, const interruptible& _interruptible ); - - -private: - impl::transition_executor_impl* transition_executor_impl_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_EXECUTOR_H_2521E4B8_B89E_4CCE_9751_F5B6BD515AD5 +#define TRANSITION_EXECUTOR_H_2521E4B8_B89E_4CCE_9751_F5B6BD515AD5 + + +#include "essentials/non_copyable.hpp" + +#include "choice_fwd.hpp" +#include "compound_transition_fwd.hpp" +#include "behavior_exception_fwd.hpp" +#include "event_fwd.hpp" + + +namespace sxy +{ + + +namespace impl +{ + +class transition_executor_impl; + +} + + +class composite_state; +class event_processing_callback; +class async_event_handler; +class event_collector; +class interruptible; + + +class transition_executor SX_FINAL +{ +public: + transition_executor(); + ~transition_executor() SX_NOEXCEPT; + SX_NO_COPY(transition_executor) + bool check_sort_and_execute_transitions( const compound_transitions& _compound_transitions, + raw_const_choices& _verices, event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector, const interruptible& _interruptible ); + + +private: + impl::transition_executor_impl* transition_executor_impl_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/transition_executor_impl.hpp b/libyasmine/include_impl/transition_executor_impl.hpp index 479fa62..d868389 100644 --- a/libyasmine/include_impl/transition_executor_impl.hpp +++ b/libyasmine/include_impl/transition_executor_impl.hpp @@ -1,109 +1,109 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_EXECUTOR_IMPL_D556EFC8_A5CE_4750_96D9_BDDBF8FFF10A -#define TRANSITION_EXECUTOR_IMPL_D556EFC8_A5CE_4750_96D9_BDDBF8FFF10A - - -#include "essentials/non_copyable.hpp" - -#include "state_fwd.hpp" -#include "region_fwd.hpp" -#include "choice_fwd.hpp" -#include "compound_transition_fwd.hpp" -#include "transition_step_fwd.hpp" -#include "execution_step_fwd.hpp" -#include "behavior_exception_fwd.hpp" -#include "event_fwd.hpp" -#include "transition_kind.hpp" - - -namespace sxy -{ - - -class event_processing_callback; -class composite_state; -class async_event_handler; -class choice; -class vertex; -class event_collector; - - -namespace impl -{ - - -class transition_executor_impl -{ -public: - transition_executor_impl(); - virtual ~transition_executor_impl() SX_NOEXCEPT; - SX_NO_COPY(transition_executor_impl) - void get_active_states_from_region( region& _region, raw_states_by_nesting_level_ascending& _states ); - void get_active_states_from_regions( const state* const _state, - raw_states_by_nesting_level_ascending& _states ); - void get_all_states_to_enter_from_regions_that_are_not_explicitly_entered( - compound_transition_consumer& _compound_transition, raw_const_region_set& _entered_regions, - raw_states_by_nesting_level& _states_to_enter, const event& _event, event_collector& _event_collector ); - void merge_transitions_steps_with_exit_state_steps( execution_steps& _execution_steps, - compound_transition_consumer& _compound_transition, - const raw_states_by_nesting_level_ascending& _states_to_exit, - transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ); - void merge_transitions_steps_with_enter_states_steps( execution_steps& _execution_steps, - compound_transition_consumer& _compound_transition, const raw_states_by_nesting_level& _states_to_enter, - transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ); - void calculate_execution_steps( compound_transition_consumer& _compound_transition, - const raw_states_by_nesting_level_ascending& _states_to_exit, - const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps, - raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ); - static bool run_execution_steps( const execution_steps& _execution_steps, - event_processing_callback* const _event_processing_callback, const event& _event, - events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector ); - void conflict_check( const compound_transitions& _compound_transitions ) const; - static raw_compound_transitions sort_compound_transitions( - const compound_transitions& _unsorted_compound_transitions ); - void find_all_states_to_exit( compound_transition_consumer& _compound_transition, - raw_states_by_nesting_level_ascending& _states_to_exit ); - void find_all_states_to_enter( compound_transition_consumer& _compound_transition, - raw_states_by_nesting_level& _states_to_enter, raw_const_region_set& _regions_to_enter, const event& _event, - event_collector& _event_collector ); - void add_remaining_states_to_enter( const raw_states_by_nesting_level::const_iterator _state_start, - const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps ); - void add_remaining_states_to_exit( const raw_states_by_nesting_level_ascending::const_iterator _state_start, - const raw_states_by_nesting_level_ascending& _states, execution_steps& _execution_steps ); - 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_already_entered_regions( compound_transition& new_compound_transition, - raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ); - void find_states_to_enter_and_to_exit_and_calculate_execution_steps( - compound_transition_consumer& compound_transition, execution_steps& _execution_steps, - raw_const_region_set& _entered_regions, const event& _event, bool _find_states_to_exit, - event_collector& _event_collector ); - 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 +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_EXECUTOR_IMPL_D556EFC8_A5CE_4750_96D9_BDDBF8FFF10A +#define TRANSITION_EXECUTOR_IMPL_D556EFC8_A5CE_4750_96D9_BDDBF8FFF10A + + +#include "essentials/non_copyable.hpp" + +#include "state_fwd.hpp" +#include "region_fwd.hpp" +#include "choice_fwd.hpp" +#include "compound_transition_fwd.hpp" +#include "transition_step_fwd.hpp" +#include "execution_step_fwd.hpp" +#include "behavior_exception_fwd.hpp" +#include "event_fwd.hpp" +#include "transition_kind.hpp" + + +namespace sxy +{ + + +class event_processing_callback; +class composite_state; +class async_event_handler; +class choice; +class vertex; +class event_collector; + + +namespace impl +{ + + +class transition_executor_impl +{ +public: + transition_executor_impl(); + virtual ~transition_executor_impl() SX_NOEXCEPT; + SX_NO_COPY(transition_executor_impl) + void get_active_states_from_region( region& _region, raw_states_by_nesting_level_ascending& _states ); + void get_active_states_from_regions( const state* const _state, + raw_states_by_nesting_level_ascending& _states ); + void get_all_states_to_enter_from_regions_that_are_not_explicitly_entered( + compound_transition_consumer& _compound_transition, raw_const_region_set& _entered_regions, + raw_states_by_nesting_level& _states_to_enter, const event& _event, event_collector& _event_collector ); + void merge_transitions_steps_with_exit_state_steps( execution_steps& _execution_steps, + compound_transition_consumer& _compound_transition, + const raw_states_by_nesting_level_ascending& _states_to_exit, + transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ); + void merge_transitions_steps_with_enter_states_steps( execution_steps& _execution_steps, + compound_transition_consumer& _compound_transition, const raw_states_by_nesting_level& _states_to_enter, + transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ); + void calculate_execution_steps( compound_transition_consumer& _compound_transition, + const raw_states_by_nesting_level_ascending& _states_to_exit, + const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps, + raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ); + static bool run_execution_steps( const execution_steps& _execution_steps, + event_processing_callback* const _event_processing_callback, const event& _event, + events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector ); + void conflict_check( const compound_transitions& _compound_transitions ) const; + static raw_compound_transitions sort_compound_transitions( + const compound_transitions& _unsorted_compound_transitions ); + void find_all_states_to_exit( compound_transition_consumer& _compound_transition, + raw_states_by_nesting_level_ascending& _states_to_exit ); + void find_all_states_to_enter( compound_transition_consumer& _compound_transition, + raw_states_by_nesting_level& _states_to_enter, raw_const_region_set& _regions_to_enter, const event& _event, + event_collector& _event_collector ); + void add_remaining_states_to_enter( const raw_states_by_nesting_level::const_iterator _state_start, + const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps ); + void add_remaining_states_to_exit( const raw_states_by_nesting_level_ascending::const_iterator _state_start, + const raw_states_by_nesting_level_ascending& _states, execution_steps& _execution_steps ); + 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_already_entered_regions( compound_transition& new_compound_transition, + raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ); + void find_states_to_enter_and_to_exit_and_calculate_execution_steps( + compound_transition_consumer& compound_transition, execution_steps& _execution_steps, + raw_const_region_set& _entered_regions, const event& _event, bool _find_states_to_exit, + event_collector& _event_collector ); + 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/libyasmine/include_impl/transition_finder.hpp b/libyasmine/include_impl/transition_finder.hpp index 9463471..30912e7 100644 --- a/libyasmine/include_impl/transition_finder.hpp +++ b/libyasmine/include_impl/transition_finder.hpp @@ -1,62 +1,62 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_FINDER_FDB88C02_ECF9_4BB5_B99C_3F45813BF357 -#define TRANSITION_FINDER_FDB88C02_ECF9_4BB5_B99C_3F45813BF357 - - -#include "essentials/non_copyable.hpp" - -#include "choice_fwd.hpp" -#include "compound_transition_fwd.hpp" - - -namespace sxy -{ - - -class state; -class composite_state; -class transition; -class event_processing_callback; -class event; -class event_collector; - - -class transition_finder SX_FINAL -{ -public: - transition_finder(); - ~transition_finder() SX_NOEXCEPT; - SX_NO_COPY(transition_finder) - void search_for_enabled_transitions_in_all_regions( const state& _current_state, const event& _event, - compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, - event_collector& _event_collector ) const; - void search_for_enabled_completion_transitions_in_all_regions( const state& _current_state, - compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, - event_collector& _event_collector ) const; - static void search_initial_transitions( const composite_state& _state, - compound_transitions& _compound_transitions, event_collector& _event_collector ); - static void search_choice_transitions( const raw_const_choices& _choices, - compound_transitions& _compound_transitions, const event& _event, event_collector& _event_collector ); - - -private: - static transition* search_completion_transition( const state& _state, event_collector& _event_collector ); - bool search_for_transition( const state& _current_state, compound_transitions& _enabled_compound_transitions, - const event& _event, bool& _event_is_deferred, event_collector& _event_collector ) const; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_FINDER_FDB88C02_ECF9_4BB5_B99C_3F45813BF357 +#define TRANSITION_FINDER_FDB88C02_ECF9_4BB5_B99C_3F45813BF357 + + +#include "essentials/non_copyable.hpp" + +#include "choice_fwd.hpp" +#include "compound_transition_fwd.hpp" + + +namespace sxy +{ + + +class state; +class composite_state; +class transition; +class event_processing_callback; +class event; +class event_collector; + + +class transition_finder SX_FINAL +{ +public: + transition_finder(); + ~transition_finder() SX_NOEXCEPT; + SX_NO_COPY(transition_finder) + void search_for_enabled_transitions_in_all_regions( const state& _current_state, const event& _event, + compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, + event_collector& _event_collector ) const; + void search_for_enabled_completion_transitions_in_all_regions( const state& _current_state, + compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, + event_collector& _event_collector ) const; + static void search_initial_transitions( const composite_state& _state, + compound_transitions& _compound_transitions, event_collector& _event_collector ); + static void search_choice_transitions( const raw_const_choices& _choices, + compound_transitions& _compound_transitions, const event& _event, event_collector& _event_collector ); + + +private: + static transition* search_completion_transition( const state& _state, event_collector& _event_collector ); + bool search_for_transition( const state& _current_state, compound_transitions& _enabled_compound_transitions, + const event& _event, bool& _event_is_deferred, event_collector& _event_collector ) const; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/transition_priority.hpp b/libyasmine/include_impl/transition_priority.hpp index 0ffc886..559b87a 100644 --- a/libyasmine/include_impl/transition_priority.hpp +++ b/libyasmine/include_impl/transition_priority.hpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_PRIORITY_FDB88A02_ECF6_4BB5_B95A_3F45813BF357 -#define TRANSITION_PRIORITY_FDB88A02_ECF6_4BB5_B95A_3F45813BF357 - - -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class compound_transition; - - -class transition_priority SX_FINAL -{ -public: - explicit transition_priority( compound_transition& _compound_transition ); - ~transition_priority() SX_NOEXCEPT; - std::size_t get_priority() const; - compound_transition& get_compound_transition() const; - bool operator<( const transition_priority& _compare_member ) const; - - -private: - // Objects of this class have to be copied, so we cannot have a reference member. - compound_transition* compound_transition_; - std::size_t priority_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_PRIORITY_FDB88A02_ECF6_4BB5_B95A_3F45813BF357 +#define TRANSITION_PRIORITY_FDB88A02_ECF6_4BB5_B95A_3F45813BF357 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class compound_transition; + + +class transition_priority SX_FINAL +{ +public: + explicit transition_priority( compound_transition& _compound_transition ); + ~transition_priority() SX_NOEXCEPT; + std::size_t get_priority() const; + compound_transition& get_compound_transition() const; + bool operator<( const transition_priority& _compare_member ) const; + + +private: + // Objects of this class have to be copied, so we cannot have a reference member. + compound_transition* compound_transition_; + std::size_t priority_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/transition_step.hpp b/libyasmine/include_impl/transition_step.hpp index bfca973..d0c35c4 100644 --- a/libyasmine/include_impl/transition_step.hpp +++ b/libyasmine/include_impl/transition_step.hpp @@ -1,62 +1,62 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_STEP_6023D41F_1644_441E_8A49_E2BE433910AF -#define TRANSITION_STEP_6023D41F_1644_441E_8A49_E2BE433910AF - - -#include "essentials/non_copyable.hpp" - -#include "vertex_fwd.hpp" -#include "transition_fwd.hpp" -#include "transition_step_fwd.hpp" - - -namespace sxy -{ - - -class entry_point; -class exit_point; -class event; -class event_collector; - - -class transition_step -{ -public: - transition_step() - { - // Nothing to do... - } - - - virtual ~transition_step() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(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_behaviors( const event& _event, event_collector& _event_collector ) 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; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_STEP_6023D41F_1644_441E_8A49_E2BE433910AF +#define TRANSITION_STEP_6023D41F_1644_441E_8A49_E2BE433910AF + + +#include "essentials/non_copyable.hpp" + +#include "vertex_fwd.hpp" +#include "transition_fwd.hpp" +#include "transition_step_fwd.hpp" + + +namespace sxy +{ + + +class entry_point; +class exit_point; +class event; +class event_collector; + + +class transition_step +{ +public: + transition_step() + { + // Nothing to do... + } + + + virtual ~transition_step() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(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_behaviors( const event& _event, event_collector& _event_collector ) 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; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/transition_step_fwd.hpp b/libyasmine/include_impl/transition_step_fwd.hpp index 3fe7a04..d95680e 100644 --- a/libyasmine/include_impl/transition_step_fwd.hpp +++ b/libyasmine/include_impl/transition_step_fwd.hpp @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRANSITION_STEP_FWD_EE67C572_F92D_481C_AC2C_0F8214399FC4 -#define TRANSITION_STEP_FWD_EE67C572_F92D_481C_AC2C_0F8214399FC4 - - -#include -#include - -#include "essentials/compatibility/compatibility.hpp" - - -namespace sxy -{ - - -class transition_step; -typedef sxe::SX_UNIQUE_PTR< transition_step > transition_step_uptr; -typedef std::vector< transition_step_uptr > transition_steps; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_STEP_FWD_EE67C572_F92D_481C_AC2C_0F8214399FC4 +#define TRANSITION_STEP_FWD_EE67C572_F92D_481C_AC2C_0F8214399FC4 + + +#include +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +class transition_step; +typedef sxe::SX_UNIQUE_PTR< transition_step > transition_step_uptr; +typedef std::vector< transition_step_uptr > transition_steps; + + +} + + +#endif diff --git a/libyasmine/include_impl/try_to_build_compound_transition_visitor.hpp b/libyasmine/include_impl/try_to_build_compound_transition_visitor.hpp index c27b555..6d96c40 100644 --- a/libyasmine/include_impl/try_to_build_compound_transition_visitor.hpp +++ b/libyasmine/include_impl/try_to_build_compound_transition_visitor.hpp @@ -1,72 +1,72 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef TRY_TO_BUILD_COMPOUND_TRANSITION_VISITOR_92B11137_6B55_4D84_9ABB_7EE0FB784120 -#define TRY_TO_BUILD_COMPOUND_TRANSITION_VISITOR_92B11137_6B55_4D84_9ABB_7EE0FB784120 - - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "compound_transition_fwd.hpp" - - -namespace sxy -{ - - -class transition; -class event; -class event_collector; - - -class try_to_build_compound_transition_visitor: - public virtual const_vertex_visitor -{ -public: - try_to_build_compound_transition_visitor( transition& _enabled_transition, - compound_transitions& _enabled_compound_transitions, bool& _is_built, const event& _event, - event_collector& _event_collector ); - virtual ~try_to_build_compound_transition_visitor() SX_NOEXCEPT SX_OVERRIDE; - SX_NO_COPY(try_to_build_compound_transition_visitor) - virtual void visit( const composite_state& _composite_state ) SX_OVERRIDE; - virtual void visit( const simple_state& _simple_state ) SX_OVERRIDE; - virtual void visit( const final_state& _final_state ) SX_OVERRIDE; - virtual void visit( const initial_pseudostate& _initial_pseudostate ) SX_OVERRIDE; - virtual void visit( const choice& _choice ) SX_OVERRIDE; - virtual void visit( const junction& _junction ) SX_OVERRIDE; - virtual void visit( const join& _join ) SX_OVERRIDE; - virtual void visit( const fork& _fork ) SX_OVERRIDE; - virtual void visit( const entry_point& _entry_point ) SX_OVERRIDE; - virtual void visit( const exit_point& _exit_point ) SX_OVERRIDE; - virtual void visit( const deep_history& _deep_history ) SX_OVERRIDE; - virtual void visit( const shallow_history& _shallow_history ) SX_OVERRIDE; - virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) SX_OVERRIDE; - - -private: - void build_compound_transition_and_insert_in_container(); - void check_if_join_is_active_and_was_not_processed_yet( const join& _join ); - static bool check_if_transition_was_already_used( const transition& _transition, - compound_transitions& _compound_transitions ); - - - transition& enabled_transition_; - compound_transitions& enabled_compound_transitions_; - bool& is_built_; - const event& event_; - event_collector& event_collector_; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRY_TO_BUILD_COMPOUND_TRANSITION_VISITOR_92B11137_6B55_4D84_9ABB_7EE0FB784120 +#define TRY_TO_BUILD_COMPOUND_TRANSITION_VISITOR_92B11137_6B55_4D84_9ABB_7EE0FB784120 + + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "compound_transition_fwd.hpp" + + +namespace sxy +{ + + +class transition; +class event; +class event_collector; + + +class try_to_build_compound_transition_visitor: + public virtual const_vertex_visitor +{ +public: + try_to_build_compound_transition_visitor( transition& _enabled_transition, + compound_transitions& _enabled_compound_transitions, bool& _is_built, const event& _event, + event_collector& _event_collector ); + virtual ~try_to_build_compound_transition_visitor() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY(try_to_build_compound_transition_visitor) + virtual void visit( const composite_state& _composite_state ) SX_OVERRIDE; + virtual void visit( const simple_state& _simple_state ) SX_OVERRIDE; + virtual void visit( const final_state& _final_state ) SX_OVERRIDE; + virtual void visit( const initial_pseudostate& _initial_pseudostate ) SX_OVERRIDE; + virtual void visit( const choice& _choice ) SX_OVERRIDE; + virtual void visit( const junction& _junction ) SX_OVERRIDE; + virtual void visit( const join& _join ) SX_OVERRIDE; + virtual void visit( const fork& _fork ) SX_OVERRIDE; + virtual void visit( const entry_point& _entry_point ) SX_OVERRIDE; + virtual void visit( const exit_point& _exit_point ) SX_OVERRIDE; + virtual void visit( const deep_history& _deep_history ) SX_OVERRIDE; + virtual void visit( const shallow_history& _shallow_history ) SX_OVERRIDE; + virtual void visit( const terminate_pseudostate& _terminate_pseudostate ) SX_OVERRIDE; + + +private: + void build_compound_transition_and_insert_in_container(); + void check_if_join_is_active_and_was_not_processed_yet( const join& _join ); + static bool check_if_transition_was_already_used( const transition& _transition, + compound_transitions& _compound_transitions ); + + + transition& enabled_transition_; + compound_transitions& enabled_compound_transitions_; + bool& is_built_; + const event& event_; + event_collector& event_collector_; +}; + + +} + + +#endif diff --git a/libyasmine/include_impl/vertex_visitor.hpp b/libyasmine/include_impl/vertex_visitor.hpp index ea53a76..236a885 100644 --- a/libyasmine/include_impl/vertex_visitor.hpp +++ b/libyasmine/include_impl/vertex_visitor.hpp @@ -1,73 +1,73 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef VERTEX_VISITOR_D71F9484_F3C5_4DEF_BC94_F273B6223268 -#define VERTEX_VISITOR_D71F9484_F3C5_4DEF_BC94_F273B6223268 - - -#include "essentials/non_copyable.hpp" - - -namespace sxy -{ - - -class composite_state; -class final_state; -class simple_state; -class choice; -class deep_history; -class entry_point; -class exit_point; -class fork; -class initial_pseudostate; -class join; -class junction; -class shallow_history; -class terminate_pseudostate; - - -class vertex_visitor -{ -public: - vertex_visitor() - { - // Nothing to do... - } - - - virtual ~vertex_visitor() SX_NOEXCEPT - { - // Nothing to do... - } - - - SX_NO_COPY(vertex_visitor) - virtual void visit( composite_state& _composite_state ) = 0; - virtual void visit( simple_state& _simple_state ) = 0; - virtual void visit( final_state& _final_state ) = 0; - virtual void visit( initial_pseudostate& _initial_pseudostate ) = 0; - virtual void visit( choice& _choice ) = 0; - virtual void visit( junction& _junction ) = 0; - virtual void visit( join& _join ) = 0; - virtual void visit( fork& _fork ) = 0; - virtual void visit( entry_point& _entry_point ) = 0; - virtual void visit( exit_point& _exit_point ) = 0; - virtual void visit( deep_history& _deep_history ) = 0; - virtual void visit( shallow_history& _shallow_history ) = 0; - virtual void visit( terminate_pseudostate& _terminate_pseudostate ) = 0; -}; - - -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERTEX_VISITOR_D71F9484_F3C5_4DEF_BC94_F273B6223268 +#define VERTEX_VISITOR_D71F9484_F3C5_4DEF_BC94_F273B6223268 + + +#include "essentials/non_copyable.hpp" + + +namespace sxy +{ + + +class composite_state; +class final_state; +class simple_state; +class choice; +class deep_history; +class entry_point; +class exit_point; +class fork; +class initial_pseudostate; +class join; +class junction; +class shallow_history; +class terminate_pseudostate; + + +class vertex_visitor +{ +public: + vertex_visitor() + { + // Nothing to do... + } + + + virtual ~vertex_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY(vertex_visitor) + virtual void visit( composite_state& _composite_state ) = 0; + virtual void visit( simple_state& _simple_state ) = 0; + virtual void visit( final_state& _final_state ) = 0; + virtual void visit( initial_pseudostate& _initial_pseudostate ) = 0; + virtual void visit( choice& _choice ) = 0; + virtual void visit( junction& _junction ) = 0; + virtual void visit( join& _join ) = 0; + virtual void visit( fork& _fork ) = 0; + virtual void visit( entry_point& _entry_point ) = 0; + virtual void visit( exit_point& _exit_point ) = 0; + virtual void visit( deep_history& _deep_history ) = 0; + virtual void visit( shallow_history& _shallow_history ) = 0; + virtual void visit( terminate_pseudostate& _terminate_pseudostate ) = 0; +}; + + +} + + +#endif diff --git a/libyasmine/libyasmine.vcxproj b/libyasmine/libyasmine.vcxproj index 1687b73..ca048de 100644 --- a/libyasmine/libyasmine.vcxproj +++ b/libyasmine/libyasmine.vcxproj @@ -1,849 +1,849 @@ - - - - - Debug - C++ 03 - Win32 - - - Debug - C++ 03 - x64 - - - Debug - Clang - Win32 - - - Debug - Clang - x64 - - - Debug - VS 2013 - x64 - - - Debug - x64 - - - Release - C++ 03 - Win32 - - - Release - C++ 03 - x64 - - - Release - Clang - Win32 - - - Debug - VS 2013 - Win32 - - - Debug - Win32 - - - Release - Clang - x64 - - - Release - VS 2013 - Win32 - - - Release - VS 2013 - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {A728DDFB-BE51-49B5-8593-4E89E024A500} - Win32Proj - libyasmine - 8.1 - - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - true - v140_clang_c2 - Unicode - - - StaticLibrary - true - v140_clang_c2 - Unicode - - - StaticLibrary - true - v140_clang_c2 - Unicode - - - StaticLibrary - true - v140_Clang_3_7 - Unicode - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - $(Platform)\$(Configuration)\ - - - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - $(SolutionDir)$(Platform)\$(Configuration)\$(TargetName)$(TargetExt) - MachineX86 - - - - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - $(SolutionDir)$(Platform)\$(Configuration)\$(TargetName)$(TargetExt) - - - - - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - None - MaxSpeed - false - - - Windows - false - - - - - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - None - MaxSpeed - false - - - Windows - false - - - - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - Windows - true - - - - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - Windows - true - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - None - - - Windows - true - true - true - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - NotSet - - - Windows - true - true - true - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - Clang + Win32 + + + Debug - Clang + x64 + + + Debug - VS 2013 + x64 + + + Debug + x64 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - Clang + Win32 + + + Debug - VS 2013 + Win32 + + + Debug + Win32 + + + Release - Clang + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {A728DDFB-BE51-49B5-8593-4E89E024A500} + Win32Proj + libyasmine + 8.1 + + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + true + v140_clang_c2 + Unicode + + + StaticLibrary + true + v140_clang_c2 + Unicode + + + StaticLibrary + true + v140_clang_c2 + Unicode + + + StaticLibrary + true + v140_Clang_3_7 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + $(Platform)\$(Configuration)\ + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + $(SolutionDir)$(Platform)\$(Configuration)\$(TargetName)$(TargetExt) + MachineX86 + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + $(SolutionDir)$(Platform)\$(Configuration)\$(TargetName)$(TargetExt) + + + + + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + None + MaxSpeed + false + + + Windows + false + + + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + None + MaxSpeed + false + + + Windows + false + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ProgramDatabase + + + Windows + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ProgramDatabase + + + Windows + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + None + + + Windows + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + NotSet + + + Windows + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + \ No newline at end of file diff --git a/libyasmine/libyasmine.vcxproj.filters b/libyasmine/libyasmine.vcxproj.filters index 214f1d0..16d3d2e 100644 --- a/libyasmine/libyasmine.vcxproj.filters +++ b/libyasmine/libyasmine.vcxproj.filters @@ -1,951 +1,951 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {f0d68c57-ca54-4f39-b7c4-9efa5a425b43} - - - {8fbbf8be-400b-4900-a8c9-a202768d53c2} - - - {56a553a9-c84f-42ad-9f23-fd242c06d8cb} - - - {cad0287a-4a4f-42bd-ad2c-1f404ff0339f} - - - {8aa9ad44-df67-4c70-ac7c-3bf75abf39e1} - - - {552c9f9a-b2bb-4f84-9cbf-571de6444e35} - - - {5fe76966-a9cf-495b-8dfc-b55d4876bfe5} - - - {a4b70c10-4574-434a-9973-954216bcf83e} - - - {6f9006a1-f985-4488-9cbf-05074c158bf5} - - - {c48c2f2e-231f-41ba-add9-44d18cd93305} - - - {c3bd0da5-253a-485f-ba77-1b0111e519cb} - - - {198c7254-7fa9-465c-9dc7-75a2bb20553d} - - - {ef3a0c93-a676-4ae3-8a7e-cda72d797230} - - - {54f50b7b-a871-4024-bfc5-e0f7cb9fac02} - - - {77d625ae-5e35-4435-8d29-043f8c716f40} - - - {a6a9febe-675d-44f7-9465-1fab2c6d8c15} - - - {b8c81cc5-b016-458f-83d6-9bd2c6aa7094} - - - {c6ba97a5-92cf-41d3-afbc-b5cabe478ce6} - - - {1c3623f5-a6ab-4ca2-ad31-1bce2fee6768} - - - {385b9a6d-0246-4e4b-b5e4-9f610d3aa8e6} - - - {4f4478b6-d50f-4559-94ca-f88b67c0dd22} - - - {743742f9-ce11-4d46-9159-801d736c1ff9} - - - {e1c2f833-17b2-4ec0-b1b5-f231b0227d1a} - - - {7ac0239c-b556-416b-88cc-0f2328a4aad1} - - - {97b22894-84bd-43d3-827b-fc398c6da086} - - - {3e59d28f-bca5-462b-bc6f-7a47a56cf43a} - - - {7cd4914e-9b7a-4b21-b5a7-17995179c5bb} - - - {379a7d53-fd21-4572-90f3-1a6f5a6c810e} - - - {d1970c82-da3c-46f6-a38f-f77442a46e09} - - - {187a568e-a493-404b-b5fa-ca2330993817} - - - {0438a931-1d02-4bce-8d43-a94af9835b4b} - - - {28a1ace0-8cdf-40f3-ba5d-75f3bbf56c3e} - - - {5a7d55f5-d26d-4ec4-89ef-c0130ddbc9d9} - - - {ec79268c-5b43-45ea-bea5-6627d17fd363} - - - {3fba89b8-2b01-4eec-92d1-74140dc91589} - - - {300a4103-75a9-433d-8fb0-a35791d8b2f5} - - - {89ff470c-dd9c-4284-bc52-275caa35c0d5} - - - {0dc53fda-1061-474b-8825-e13872f8ddca} - - - {913833e0-01d4-48dd-8653-e64e51a760ab} - - - {19cda7e2-3e79-406b-b75f-5317e322840d} - - - {545fa18b-8716-46ed-a927-815ac91d2529} - - - {7ac2a40a-81b8-48a6-aeca-8d3c40566748} - - - {fc016843-b9e5-4795-bd00-2638aa1487cf} - - - - - 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\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\infrastructure - - - Headerdateien - - - Headerdateien - - - Headerdateien\core\state machine\element - - - Headerdateien\core\state machine - - - Headerdateien\core\state machine\element - - - Headerdateien\core\algorithm - - - Headerdateien\infrastructure - - - 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 - - - Headerdateien\core\state machine - - - Headerdateien\core\state machine - - - Headerdateien\core\state machine - - - Headerdateien\core\state machine\caller - - - Headerdateien\core\state machine\caller - - - Headerdateien\core\state machine\caller - - - Headerdateien\core\state machine\caller - - - Headerdateien\core\state machine\caller - - - Headerdateien\infrastructure - - - Headerdateien\external\essentials\compatibility - - - Headerdateien\external\essentials\compatibility - - - Headerdateien\external\essentials\compatibility - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - Headerdateien\infrastructure - - - Headerdateien\infrastructure - - - Headerdateien\external\essentials - - - Headerdateien\external\essentials - - - Headerdateien\external\hermes - - - Headerdateien\external\hermes - - - - - 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\algorithm\transition executor\impl - - - Quelldateien\core\state machine - - - 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\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 - - - Quelldateien\core\state machine - - - Quelldateien\core\state machine - - - Quelldateien\core\state machine - - - Quelldateien\core\state machine - - - Quelldateien\external\essentials - - - Quelldateien\external\essentials - - - Quelldateien\external\essentials - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\hermes - - - Quelldateien\external\essentials - - - Quelldateien\external\hermes - - - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {f0d68c57-ca54-4f39-b7c4-9efa5a425b43} + + + {8fbbf8be-400b-4900-a8c9-a202768d53c2} + + + {56a553a9-c84f-42ad-9f23-fd242c06d8cb} + + + {cad0287a-4a4f-42bd-ad2c-1f404ff0339f} + + + {8aa9ad44-df67-4c70-ac7c-3bf75abf39e1} + + + {552c9f9a-b2bb-4f84-9cbf-571de6444e35} + + + {5fe76966-a9cf-495b-8dfc-b55d4876bfe5} + + + {a4b70c10-4574-434a-9973-954216bcf83e} + + + {6f9006a1-f985-4488-9cbf-05074c158bf5} + + + {c48c2f2e-231f-41ba-add9-44d18cd93305} + + + {c3bd0da5-253a-485f-ba77-1b0111e519cb} + + + {198c7254-7fa9-465c-9dc7-75a2bb20553d} + + + {ef3a0c93-a676-4ae3-8a7e-cda72d797230} + + + {54f50b7b-a871-4024-bfc5-e0f7cb9fac02} + + + {77d625ae-5e35-4435-8d29-043f8c716f40} + + + {a6a9febe-675d-44f7-9465-1fab2c6d8c15} + + + {b8c81cc5-b016-458f-83d6-9bd2c6aa7094} + + + {c6ba97a5-92cf-41d3-afbc-b5cabe478ce6} + + + {1c3623f5-a6ab-4ca2-ad31-1bce2fee6768} + + + {385b9a6d-0246-4e4b-b5e4-9f610d3aa8e6} + + + {4f4478b6-d50f-4559-94ca-f88b67c0dd22} + + + {743742f9-ce11-4d46-9159-801d736c1ff9} + + + {e1c2f833-17b2-4ec0-b1b5-f231b0227d1a} + + + {7ac0239c-b556-416b-88cc-0f2328a4aad1} + + + {97b22894-84bd-43d3-827b-fc398c6da086} + + + {3e59d28f-bca5-462b-bc6f-7a47a56cf43a} + + + {7cd4914e-9b7a-4b21-b5a7-17995179c5bb} + + + {379a7d53-fd21-4572-90f3-1a6f5a6c810e} + + + {d1970c82-da3c-46f6-a38f-f77442a46e09} + + + {187a568e-a493-404b-b5fa-ca2330993817} + + + {0438a931-1d02-4bce-8d43-a94af9835b4b} + + + {28a1ace0-8cdf-40f3-ba5d-75f3bbf56c3e} + + + {5a7d55f5-d26d-4ec4-89ef-c0130ddbc9d9} + + + {ec79268c-5b43-45ea-bea5-6627d17fd363} + + + {3fba89b8-2b01-4eec-92d1-74140dc91589} + + + {300a4103-75a9-433d-8fb0-a35791d8b2f5} + + + {89ff470c-dd9c-4284-bc52-275caa35c0d5} + + + {0dc53fda-1061-474b-8825-e13872f8ddca} + + + {913833e0-01d4-48dd-8653-e64e51a760ab} + + + {19cda7e2-3e79-406b-b75f-5317e322840d} + + + {545fa18b-8716-46ed-a927-815ac91d2529} + + + {7ac2a40a-81b8-48a6-aeca-8d3c40566748} + + + {fc016843-b9e5-4795-bd00-2638aa1487cf} + + + + + 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\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\infrastructure + + + Headerdateien + + + Headerdateien + + + Headerdateien\core\state machine\element + + + Headerdateien\core\state machine + + + Headerdateien\core\state machine\element + + + Headerdateien\core\algorithm + + + Headerdateien\infrastructure + + + 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 + + + Headerdateien\core\state machine + + + Headerdateien\core\state machine + + + Headerdateien\core\state machine + + + Headerdateien\core\state machine\caller + + + Headerdateien\core\state machine\caller + + + Headerdateien\core\state machine\caller + + + Headerdateien\core\state machine\caller + + + Headerdateien\core\state machine\caller + + + Headerdateien\infrastructure + + + Headerdateien\external\essentials\compatibility + + + Headerdateien\external\essentials\compatibility + + + Headerdateien\external\essentials\compatibility + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\infrastructure + + + Headerdateien\infrastructure + + + Headerdateien\external\essentials + + + Headerdateien\external\essentials + + + Headerdateien\external\hermes + + + Headerdateien\external\hermes + + + Headerdateien\external\essentials + + + + + 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\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\algorithm\transition executor\impl + + + Quelldateien\core\state machine + + + 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\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 + + + Quelldateien\core\state machine + + + Quelldateien\core\state machine + + + Quelldateien\core\state machine + + + Quelldateien\core\state machine + + + Quelldateien\external\essentials + + + Quelldateien\external\essentials + + + Quelldateien\external\essentials + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\hermes + + + Quelldateien\external\essentials + + + Quelldateien\external\hermes + + + Quelldateien\external\essentials + + + + + \ No newline at end of file diff --git a/libyasmine/source/algorithm_parameters.cpp b/libyasmine/source/algorithm_parameters.cpp index f250111..97e9d20 100644 --- a/libyasmine/source/algorithm_parameters.cpp +++ b/libyasmine/source/algorithm_parameters.cpp @@ -1,39 +1,39 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "algorithm_parameters.hpp" - - -namespace sxy -{ - - -const int TRANSITION_PRIORITIES_VECTOR_SIZE = 16; -const int EXECUTION_STEPS_VECTOR_SIZE = 128; -const int TRANSITION_STEPS_VECTOR_SIZE = 128; -const int COMPOUND_TRANSITIONS_VECTOR_SIZE = 8; -const int EXCEPTION_EVENTS_VECTOR_SIZE = 8; -const int CHOICES_VECTOR_SIZE = 8; -const int ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE = 16; -const int DEFERRED_EVENTS_VECTOR_SIZE = 16; -const int DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE = 8; -const int ENTRY_POINTS_VECTOR_SIZE = 8; -const int EXIT_POINTS_VECTOR_SIZE = 8; -const int PSEUDOSTETS_IN_REGION_VECTOR_SIZE = 16; -const int ANCESTORS_VECTOR_SIZE = 64; -const int ASCENDING_PATH_ANCESTORS_VECTOR_SIZE = 64; -const int REGIONS_OF_FINAL_STATE = 0; -const int REGIONS_OF_SIMPLE_STATE = 0; -const int ANCESTORS_REGION_VECTOR_SIZE = 64; -const int ACTIVE_STATE_CONFIGRATION_VECTOR_SIZE = 32; - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "algorithm_parameters.hpp" + + +namespace sxy +{ + + +const int TRANSITION_PRIORITIES_VECTOR_SIZE = 16; +const int EXECUTION_STEPS_VECTOR_SIZE = 128; +const int TRANSITION_STEPS_VECTOR_SIZE = 128; +const int COMPOUND_TRANSITIONS_VECTOR_SIZE = 8; +const int EXCEPTION_EVENTS_VECTOR_SIZE = 8; +const int CHOICES_VECTOR_SIZE = 8; +const int ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE = 16; +const int DEFERRED_EVENTS_VECTOR_SIZE = 16; +const int DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE = 8; +const int ENTRY_POINTS_VECTOR_SIZE = 8; +const int EXIT_POINTS_VECTOR_SIZE = 8; +const int PSEUDOSTETS_IN_REGION_VECTOR_SIZE = 16; +const int ANCESTORS_VECTOR_SIZE = 64; +const int ASCENDING_PATH_ANCESTORS_VECTOR_SIZE = 64; +const int REGIONS_OF_FINAL_STATE = 0; +const int REGIONS_OF_SIMPLE_STATE = 0; +const int ANCESTORS_REGION_VECTOR_SIZE = 64; +const int ACTIVE_STATE_CONFIGRATION_VECTOR_SIZE = 32; + + +} diff --git a/libyasmine/source/async_behavior.cpp b/libyasmine/source/async_behavior.cpp index fdb6a13..1ed4ccb 100644 --- a/libyasmine/source/async_behavior.cpp +++ b/libyasmine/source/async_behavior.cpp @@ -1,118 +1,118 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "async_behavior.hpp" - -#include "hermes/log.hpp" - -#include "behavior_exception.hpp" -#include "simple_state_base.hpp" -#include "async_event_handler.hpp" -#include "event.hpp" - - -namespace sxy -{ - - -async_behavior::async_behavior() - : worker_(), - mutex_(), - run_(false) -{ - // Nothing to do... -} - - -async_behavior::~async_behavior() SX_NOEXCEPT -{ - SX_ASSERT( !run_, "Thread is still running! It was not stopped." ); - SX_ASSERT( !worker_, "The thread still exists!" ); -} - - -void async_behavior::run( const event& _event, event_collector& _event_collector, - const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) -{ - run_ = true; - - worker_ = SX_MAKE_UNIQUE< sxe::thread >( sxe::bind( &async_behavior::work, this, sxe::ref( _event ), - sxe::ref( _event_collector ), sxe::ref( _simple_state ), sxe::ref( _async_event_handler ) ) ); -} - - -void async_behavior::halt_and_join() -{ - { - sxe::lock_guard< sxe::mutex > lock( mutex_ ); - run_ = false; - notify_should_stop(); - } - - join(); -} - - -bool async_behavior::should_stop() const -{ - sxe::lock_guard< sxe::mutex > lock( mutex_ ); - return( !run_ ); -} - - -void async_behavior::notify_should_stop() -{ - // Nothing to do... -} - - -void async_behavior::work( const event& _event, event_collector& _event_collector, - const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) -{ - try - { - run_impl( _event, _event_collector, _async_event_handler ); - } - catch( const sxy::behavior_exception& exception ) - { - SX_LOG( hermes::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 ) - { - SX_LOG( hermes::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 - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception while running async_behavior!" ); - throw; - } - } - catch( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception while running async_behavior!" ); - throw; - } -} - - -void async_behavior::join() -{ - SX_ASSERT( worker_->joinable(), "Async behavior thread is not joinable!" ); - worker_->join(); - worker_.reset(); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "async_behavior.hpp" + +#include "hermes/log.hpp" + +#include "behavior_exception.hpp" +#include "simple_state_base.hpp" +#include "async_event_handler.hpp" +#include "event.hpp" + + +namespace sxy +{ + + +async_behavior::async_behavior() + : worker_(), + mutex_(), + run_(false) +{ + // Nothing to do... +} + + +async_behavior::~async_behavior() SX_NOEXCEPT +{ + SX_ASSERT( !run_, "Thread is still running! It was not stopped." ); + SX_ASSERT( !worker_, "The thread still exists!" ); +} + + +void async_behavior::run( const event& _event, event_collector& _event_collector, + const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) +{ + run_ = true; + + worker_ = SX_MAKE_UNIQUE< sxe::thread >( sxe::bind( &async_behavior::work, this, sxe::ref( _event ), + sxe::ref( _event_collector ), sxe::ref( _simple_state ), sxe::ref( _async_event_handler ) ) ); +} + + +void async_behavior::halt_and_join() +{ + { + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + run_ = false; + notify_should_stop(); + } + + join(); +} + + +bool async_behavior::should_stop() const +{ + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + return( !run_ ); +} + + +void async_behavior::notify_should_stop() +{ + // Nothing to do... +} + + +void async_behavior::work( const event& _event, event_collector& _event_collector, + const simple_state_base& _simple_state, async_event_handler& _async_event_handler ) +{ + try + { + run_impl( _event, _event_collector, _async_event_handler ); + } + catch( const sxy::behavior_exception& exception ) + { + SX_LOG( hermes::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 ) + { + SX_LOG( hermes::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 + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception while running async_behavior!" ); + throw; + } + } + catch( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception while running async_behavior!" ); + throw; + } +} + + +void async_behavior::join() +{ + SX_ASSERT( worker_->joinable(), "Async behavior thread is not joinable!" ); + worker_->join(); + worker_.reset(); +} + + +} diff --git a/libyasmine/source/async_simple_state_impl.cpp b/libyasmine/source/async_simple_state_impl.cpp index ec4b81a..bfdf03b 100644 --- a/libyasmine/source/async_simple_state_impl.cpp +++ b/libyasmine/source/async_simple_state_impl.cpp @@ -1,69 +1,69 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "async_simple_state_impl.hpp" - -#include "essentials/base.hpp" - -#include "async_behavior.hpp" - - -namespace sxy -{ - - -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, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events, - _error_event ), - do_( sxe::move( _do_action ) ) -{ - SX_ASSERT( do_, "Async simple state must have an 'async do behavior' asigned!" ); -} - - -async_simple_state_impl::~async_simple_state_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void async_simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const -{ - const async_behavior* const behavior = do_.get(); - if( behavior ) - { - do_->run( _event, _event_collector, *this, *_async_event_handler ); - } -} - - -void async_simple_state_impl::execute_exit_behavior( const event& _event, event_collector& _event_collector ) const -{ - stop_do_behavior(); - - complex_state_impl::execute_exit_behavior( _event, _event_collector ); -} - - -void async_simple_state_impl::stop_do_behavior() const -{ - const async_behavior* const behavior = do_.get(); - if( behavior ) - { - do_->halt_and_join(); - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "async_simple_state_impl.hpp" + +#include "essentials/base.hpp" + +#include "async_behavior.hpp" + + +namespace sxy +{ + + +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, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events, + _error_event ), + do_( sxe::move( _do_action ) ) +{ + SX_ASSERT( do_, "Async simple state must have an 'async do behavior' asigned!" ); +} + + +async_simple_state_impl::~async_simple_state_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void async_simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const +{ + const async_behavior* const behavior = do_.get(); + if( behavior ) + { + do_->run( _event, _event_collector, *this, *_async_event_handler ); + } +} + + +void async_simple_state_impl::execute_exit_behavior( const event& _event, event_collector& _event_collector ) const +{ + stop_do_behavior(); + + complex_state_impl::execute_exit_behavior( _event, _event_collector ); +} + + +void async_simple_state_impl::stop_do_behavior() const +{ + const async_behavior* const behavior = do_.get(); + if( behavior ) + { + do_->halt_and_join(); + } +} + + +} diff --git a/libyasmine/source/async_state_machine.cpp b/libyasmine/source/async_state_machine.cpp index 096c7e5..2e03de7 100644 --- a/libyasmine/source/async_state_machine.cpp +++ b/libyasmine/source/async_state_machine.cpp @@ -1,302 +1,302 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "async_state_machine.hpp" - -#include -#include - -#include "essentials/base.hpp" -#include "hermes/log_and_throw.hpp" - -#include "event_impl.hpp" - - -namespace sxy -{ - - -async_state_machine::async_state_machine( const std::string& _name, - event_processing_callback* const _event_processing_callback ) - : state_machine_base( _name, _event_processing_callback ), - status_( state_machine_status::NEW ), - run_and_event_mutex_(), - run_and_event_condition_(), - terminated_condition_(), - worker_thread_(), - event_list_() -{ - SX_LOG( hermes::log_level::LL_TRACE, "Creating async state_machine '%'.", _name ); - // Nothing to do... - SX_LOG( hermes::log_level::LL_TRACE, "Created async state_machine '%'.", _name ); -} - - -async_state_machine::~async_state_machine() SX_NOEXCEPT -{ - SX_LOG( hermes::log_level::LL_TRACE, "Destroying async state_machine '%'.", get_name() ); - - SX_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), - "Status is neither 'NEW' nor 'STOPPED' on destruction!" ); - - SX_LOG( hermes::log_level::LL_TRACE, "Destroyed async state_machine '%'.", get_name() ); -} - - -bool async_state_machine::fire_event( const event_sptr& _event ) -{ - bool event_fired = false; - if( !is_interrupted() ) - { - event_fired = insert( _event ); - } - return( event_fired ); -} - - -bool async_state_machine::run() -{ - SX_LOG( hermes::log_level::LL_INFO, "Starting async state machine '%'.", get_name() ); - - const bool state_machine_started = state_machine_base::run( this ); - if( state_machine_started ) - { - start_state_machine(); - } - else - { - SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate was reached in %.", get_name() ); - status_ = state_machine_status::STOPPED; - } - - SX_LOG( hermes::log_level::LL_INFO, "Started async state machine '%'.", get_name() ); - - return( state_machine_started ); -} - - -void async_state_machine::halt_and_join() -{ - SX_LOG( hermes::log_level::LL_INFO, "Stopping and joining async state machine '%'.", get_name() ); - - halt(); - join(); - - SX_LOG( hermes::log_level::LL_INFO, "Stopped and joined async state machine '%'.", get_name() ); -} - - -void async_state_machine::halt() -{ - SX_LOG( hermes::log_level::LL_TRACE, "Stopping async state machine '%'.", get_name() ); - - { - sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); - SX_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(); - - SX_LOG( hermes::log_level::LL_TRACE, "Stopped state machine '%'.", get_name() ); -} - - -void async_state_machine::join() -{ - SX_LOG( hermes::log_level::LL_TRACE, "Joining state machine '%'.", get_name() ); - - { - sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); - SX_ASSERT( ( state_machine_status::STOP_REQUESTED == status_ ) || ( state_machine_status::TERMINATED == status_ ), - "Status is not 'STOP_REQUESTED' or 'TERMNINATED' when joining!" ); - } - - worker_thread_->join(); - worker_thread_.reset(); - status_ = state_machine_status::STOPPED; - state_machine_base::halt(); - - SX_LOG( hermes::log_level::LL_TRACE, "Joined state machine '%'.", get_name() ); -} - - -bool async_state_machine::wait( const sxe::milliseconds _timeoutInMs ) const -{ - SX_LOG( hermes::log_level::LL_INFO, "Waiting for async state machine '%' to terminate. Timeout: %ms", get_name(), _timeoutInMs.count() ); - { - sxe::unique_lock lock( run_and_event_mutex_ ); - terminated_condition_.wait_for( lock, _timeoutInMs, sxe::bind( &async_state_machine::wait_stop_condition, this ) ); - } - SX_LOG( hermes::log_level::LL_INFO, "Waited for async state machine '%' to terminate.", get_name() ); - return( terminated() ); -} - - -void async_state_machine::wait() const -{ - SX_LOG( hermes::log_level::LL_INFO, "Waiting for async state machine '%' to terminate.", get_name() ); - { - sxe::unique_lock lock( run_and_event_mutex_ ); - terminated_condition_.wait( lock, sxe::bind( &async_state_machine::wait_stop_condition, this ) ); - } - SX_LOG( hermes::log_level::LL_INFO, "Waited for async state machine '%' to terminate.", get_name() ); -} - - -bool async_state_machine::terminated() const -{ - sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); - return( ( state_machine_status::TERMINATED == status_ ) || ( state_machine_status::STOPPED == status_ ) ); -} - - - -bool async_state_machine::push( const event_sptr& _event ) -{ - return( fire_event( _event ) ); -} - - -void async_state_machine::start_state_machine() -{ - SX_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), - "Status is neither 'NEW' nor 'STOPPED' on start!" ); - - status_ = state_machine_status::STARTED; - worker_thread_ = SX_MAKE_UNIQUE< sxe::thread >( &async_state_machine::work, this ); -} - - -bool async_state_machine::insert( const event_sptr& _event ) -{ - SX_ASSERT( _event, "_event is nullptr!" ); - - bool event_added = false; - { - sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); - if( status_ == state_machine_status::STARTED ) - { - insert_impl( _event ); - event_added = true; - } - else - { - SX_LOG( hermes::log_level::LL_WARN, "Event '%' was not inserted in the queue of events! State machine is not running.", _event->get_name() ); - } - } - if( event_added ) - { - run_and_event_condition_.notify_one(); - } - - return( event_added ); -} - - -void async_state_machine::insert_impl( const event_sptr& _event ) -{ - if( event_list_.empty() ) - { - event_list_.push_back( _event ); - } - else - if( event_list_.back()->get_priority() >= _event->get_priority() ) - { - event_list_.push_back( _event ); - } - else - { - std::list< event_sptr >::iterator position = event_list_.begin(); - while( position != event_list_.end() ) - { - if (_event->operator>(**position)) - { - break; - } - ++position; - } - SX_ASSERT( position != event_list_.end(), "No element found before which to insert!" ); - 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( ( state_machine_status::TERMINATED == status_ ) || ( state_machine_status::STOPPED == status_ ) ); -} - - -void async_state_machine::work() -{ - try - { - while( true ) - { - event_sptr event; - { - sxe::unique_lock< sxe::mutex > lock( run_and_event_mutex_ ); - run_and_event_condition_.wait( lock, sxe::bind( &async_state_machine::wait_predicate, this ) ); - if( !( status_ == state_machine_status::STARTED ) && ( event_list_.empty() || is_interrupted() ) ) - { - break; - } - SX_ASSERT( !event_list_.empty(), "Event list is empty!" ); - event = event_list_.front(); - event_list_.pop_front(); - } - if( process_event( event, this ) ) - { - break; - } - } - } - catch ( const std::exception& exception ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); - status_ = state_machine_status::STOPPED; - } - catch ( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); - status_ = state_machine_status::STOPPED; - } - - { - sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); - status_ = state_machine_status::TERMINATED; - } - - terminated_condition_.notify_all(); - SX_LOG( hermes::log_level::LL_INFO, "Async state machine '%' terminated.", get_name() ); -} - - -void async_state_machine::on_event( const event_sptr& _event ) -{ - insert( _event ); -} - - -void async_state_machine::interrupt_impl() -{ - halt(); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "async_state_machine.hpp" + +#include +#include + +#include "essentials/base.hpp" +#include "hermes/log_and_throw.hpp" + +#include "event_impl.hpp" + + +namespace sxy +{ + + +async_state_machine::async_state_machine( const std::string& _name, + event_processing_callback* const _event_processing_callback ) + : state_machine_base( _name, _event_processing_callback ), + status_( state_machine_status::NEW ), + run_and_event_mutex_(), + run_and_event_condition_(), + terminated_condition_(), + worker_thread_(), + event_list_() +{ + SX_LOG( hermes::log_level::LL_TRACE, "Creating async state_machine '%'.", _name ); + // Nothing to do... + SX_LOG( hermes::log_level::LL_TRACE, "Created async state_machine '%'.", _name ); +} + + +async_state_machine::~async_state_machine() SX_NOEXCEPT +{ + SX_LOG( hermes::log_level::LL_TRACE, "Destroying async state_machine '%'.", get_name() ); + + SX_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), + "Status is neither 'NEW' nor 'STOPPED' on destruction!" ); + + SX_LOG( hermes::log_level::LL_TRACE, "Destroyed async state_machine '%'.", get_name() ); +} + + +bool async_state_machine::fire_event( const event_sptr& _event ) +{ + bool event_fired = false; + if( !is_interrupted() ) + { + event_fired = insert( _event ); + } + return( event_fired ); +} + + +bool async_state_machine::run() +{ + SX_LOG( hermes::log_level::LL_INFO, "Starting async state machine '%'.", get_name() ); + + const bool state_machine_started = state_machine_base::run( this ); + if( state_machine_started ) + { + start_state_machine(); + } + else + { + SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate was reached in %.", get_name() ); + status_ = state_machine_status::STOPPED; + } + + SX_LOG( hermes::log_level::LL_INFO, "Started async state machine '%'.", get_name() ); + + return( state_machine_started ); +} + + +void async_state_machine::halt_and_join() +{ + SX_LOG( hermes::log_level::LL_INFO, "Stopping and joining async state machine '%'.", get_name() ); + + halt(); + join(); + + SX_LOG( hermes::log_level::LL_INFO, "Stopped and joined async state machine '%'.", get_name() ); +} + + +void async_state_machine::halt() +{ + SX_LOG( hermes::log_level::LL_TRACE, "Stopping async state machine '%'.", get_name() ); + + { + sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); + SX_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(); + + SX_LOG( hermes::log_level::LL_TRACE, "Stopped state machine '%'.", get_name() ); +} + + +void async_state_machine::join() +{ + SX_LOG( hermes::log_level::LL_TRACE, "Joining state machine '%'.", get_name() ); + + { + sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); + SX_ASSERT( ( state_machine_status::STOP_REQUESTED == status_ ) || ( state_machine_status::TERMINATED == status_ ), + "Status is not 'STOP_REQUESTED' or 'TERMNINATED' when joining!" ); + } + + worker_thread_->join(); + worker_thread_.reset(); + status_ = state_machine_status::STOPPED; + state_machine_base::halt(); + + SX_LOG( hermes::log_level::LL_TRACE, "Joined state machine '%'.", get_name() ); +} + + +bool async_state_machine::wait( const sxe::milliseconds _timeoutInMs ) const +{ + SX_LOG( hermes::log_level::LL_INFO, "Waiting for async state machine '%' to terminate. Timeout: %ms", get_name(), _timeoutInMs.count() ); + { + sxe::unique_lock lock( run_and_event_mutex_ ); + terminated_condition_.wait_for( lock, _timeoutInMs, sxe::bind( &async_state_machine::wait_stop_condition, this ) ); + } + SX_LOG( hermes::log_level::LL_INFO, "Waited for async state machine '%' to terminate.", get_name() ); + return( terminated() ); +} + + +void async_state_machine::wait() const +{ + SX_LOG( hermes::log_level::LL_INFO, "Waiting for async state machine '%' to terminate.", get_name() ); + { + sxe::unique_lock lock( run_and_event_mutex_ ); + terminated_condition_.wait( lock, sxe::bind( &async_state_machine::wait_stop_condition, this ) ); + } + SX_LOG( hermes::log_level::LL_INFO, "Waited for async state machine '%' to terminate.", get_name() ); +} + + +bool async_state_machine::terminated() const +{ + sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); + return( ( state_machine_status::TERMINATED == status_ ) || ( state_machine_status::STOPPED == status_ ) ); +} + + + +bool async_state_machine::push( const event_sptr& _event ) +{ + return( fire_event( _event ) ); +} + + +void async_state_machine::start_state_machine() +{ + SX_ASSERT( ( state_machine_status::NEW == status_ ) || ( state_machine_status::STOPPED == status_ ), + "Status is neither 'NEW' nor 'STOPPED' on start!" ); + + status_ = state_machine_status::STARTED; + worker_thread_ = SX_MAKE_UNIQUE< sxe::thread >( &async_state_machine::work, this ); +} + + +bool async_state_machine::insert( const event_sptr& _event ) +{ + SX_ASSERT( _event, "_event is nullptr!" ); + + bool event_added = false; + { + sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); + if( status_ == state_machine_status::STARTED ) + { + insert_impl( _event ); + event_added = true; + } + else + { + SX_LOG( hermes::log_level::LL_WARN, "Event '%' was not inserted in the queue of events! State machine is not running.", _event->get_name() ); + } + } + if( event_added ) + { + run_and_event_condition_.notify_one(); + } + + return( event_added ); +} + + +void async_state_machine::insert_impl( const event_sptr& _event ) +{ + if( event_list_.empty() ) + { + event_list_.push_back( _event ); + } + else + if( event_list_.back()->get_priority() >= _event->get_priority() ) + { + event_list_.push_back( _event ); + } + else + { + std::list< event_sptr >::iterator position = event_list_.begin(); + while( position != event_list_.end() ) + { + if (_event->operator>(**position)) + { + break; + } + ++position; + } + SX_ASSERT( position != event_list_.end(), "No element found before which to insert!" ); + 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( ( state_machine_status::TERMINATED == status_ ) || ( state_machine_status::STOPPED == status_ ) ); +} + + +void async_state_machine::work() +{ + try + { + while( true ) + { + event_sptr event; + { + sxe::unique_lock< sxe::mutex > lock( run_and_event_mutex_ ); + run_and_event_condition_.wait( lock, sxe::bind( &async_state_machine::wait_predicate, this ) ); + if( !( status_ == state_machine_status::STARTED ) && ( event_list_.empty() || is_interrupted() ) ) + { + break; + } + SX_ASSERT( !event_list_.empty(), "Event list is empty!" ); + event = event_list_.front(); + event_list_.pop_front(); + } + if( process_event( event, this ) ) + { + break; + } + } + } + catch ( const std::exception& exception ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unhandled exception: '%'.", exception.what() ); + status_ = state_machine_status::STOPPED; + } + catch ( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception!" ); + status_ = state_machine_status::STOPPED; + } + + { + sxe::lock_guard< sxe::mutex > lock( run_and_event_mutex_ ); + status_ = state_machine_status::TERMINATED; + } + + terminated_condition_.notify_all(); + SX_LOG( hermes::log_level::LL_INFO, "Async state machine '%' terminated.", get_name() ); +} + + +void async_state_machine::on_event( const event_sptr& _event ) +{ + insert( _event ); +} + + +void async_state_machine::interrupt_impl() +{ + halt(); +} + + +} diff --git a/libyasmine/source/behavior_exception.cpp b/libyasmine/source/behavior_exception.cpp index 97f2066..7509c94 100644 --- a/libyasmine/source/behavior_exception.cpp +++ b/libyasmine/source/behavior_exception.cpp @@ -1,39 +1,39 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "behavior_exception.hpp" - - -namespace sxy -{ - - -behavior_exception::behavior_exception( const event_sptr& _event ) - : exception("Error handle exception."), - error_event_( _event ) -{ - // Nothing to do... -} - - -behavior_exception::~behavior_exception() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const event_sptr behavior_exception::get_error_event() const -{ - return( error_event_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "behavior_exception.hpp" + + +namespace sxy +{ + + +behavior_exception::behavior_exception( const event_sptr& _event ) + : exception("Error handle exception."), + error_event_( _event ) +{ + // Nothing to do... +} + + +behavior_exception::~behavior_exception() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const event_sptr behavior_exception::get_error_event() const +{ + return( error_event_ ); +} + + +} diff --git a/libyasmine/source/behavior_impl.cpp b/libyasmine/source/behavior_impl.cpp index cda51ad..4e7e0c1 100644 --- a/libyasmine/source/behavior_impl.cpp +++ b/libyasmine/source/behavior_impl.cpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "behavior_impl.hpp" -#include "event_impl.hpp" - - -namespace sxy -{ - - - behavior_impl::behavior_impl( const behavior_function& _function ) - : function_( _function ) -{ - // Nothing to do... -} - - - behavior_impl::~behavior_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void behavior_impl::operator()( const event& _event, event_collector& _event_collector) const -{ - if( function_ ) - { - function_( _event, _event_collector ); - } -} - - -behavior_uptr behavior_impl::create_behavior( const behavior_function& _function ) -{ - return( SX_MAKE_UNIQUE< sxy::behavior_impl >( _function ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "behavior_impl.hpp" +#include "event_impl.hpp" + + +namespace sxy +{ + + + behavior_impl::behavior_impl( const behavior_function& _function ) + : function_( _function ) +{ + // Nothing to do... +} + + + behavior_impl::~behavior_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void behavior_impl::operator()( const event& _event, event_collector& _event_collector) const +{ + if( function_ ) + { + function_( _event, _event_collector ); + } +} + + +behavior_uptr behavior_impl::create_behavior( const behavior_function& _function ) +{ + return( SX_MAKE_UNIQUE< sxy::behavior_impl >( _function ) ); +} + + +} diff --git a/libyasmine/source/build_transition_steps_visitor.cpp b/libyasmine/source/build_transition_steps_visitor.cpp index 7c3c6d9..1eb328a 100644 --- a/libyasmine/source/build_transition_steps_visitor.cpp +++ b/libyasmine/source/build_transition_steps_visitor.cpp @@ -1,302 +1,302 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "build_transition_steps_visitor.hpp" - -#include "essentials/base.hpp" -#include "hermes/log_and_throw.hpp" - -#include "algorithm_parameters.hpp" -#include "composite_state.hpp" -#include "join.hpp" -#include "fork.hpp" -#include "shallow_history.hpp" -#include "deep_history.hpp" -#include "junction.hpp" -#include "entry_point.hpp" -#include "exit_point.hpp" -#include "transition.hpp" -#include "simple_transition_step.hpp" -#include "compound_transition_step.hpp" -#include "simple_state.hpp" -#include "final_state.hpp" -#include "initial_pseudostate.hpp" -#include "choice.hpp" -#include "terminate_pseudostate.hpp" - - -namespace sxy -{ - - -build_transition_steps_visitor::build_transition_steps_visitor( transition& _current_transition, - transition_steps& _transitions_steps, const event& _event, event_collector& _event_collector ) - : const_vertex_visitor(), - current_transition_( _current_transition ), - transition_steps_( _transitions_steps ), - next_transition_( SX_NULLPTR ), - reached_end_of_transition_( true ), - event_( _event ), - event_collector_ ( _event_collector ) -{ - // Nothing to do... -} - - -build_transition_steps_visitor::~build_transition_steps_visitor() SX_NOEXCEPT -{ - // Nothing to do -} - - -void build_transition_steps_visitor::visit( const composite_state& _composite_state ) -{ - SX_UNUSED_PARAMETER( _composite_state ); - create_simple_transition_step(); -} - - -void build_transition_steps_visitor::visit( const simple_state& _simple_state ) -{ - SX_UNUSED_PARAMETER( _simple_state ); - create_simple_transition_step(); -} - - -void build_transition_steps_visitor::visit( const final_state& _final_state ) -{ - SX_UNUSED_PARAMETER( _final_state ); - create_simple_transition_step(); -} - - -void build_transition_steps_visitor::visit( const initial_pseudostate& _initial_pseudostate ) -{ - SX_UNUSED_PARAMETER( _initial_pseudostate ); - SX_ASSERT( false, "An initial pseudo state cannot be the target of a transition!" ); -} - - -void build_transition_steps_visitor::visit( const choice& _choice ) -{ - SX_UNUSED_PARAMETER( _choice ); - create_simple_transition_step(); -} - - -void build_transition_steps_visitor::visit( const junction& _junction ) -{ - handle_as_junction( _junction ); -} - - -void build_transition_steps_visitor::visit( const join& _join ) -{ - handle_as_join( _join ); -} - - -void build_transition_steps_visitor::visit( const fork& _fork ) -{ - handle_as_fork( _fork ); -} - - -void build_transition_steps_visitor::visit( const entry_point& _entry_point ) -{ - handle_entry_point( _entry_point ); -} - - -void build_transition_steps_visitor::visit( const exit_point& _exit_point ) -{ - handle_exit_point( _exit_point ); -} - - -void build_transition_steps_visitor::visit( const deep_history& _deep_history ) -{ - handle_history_pseudostate( _deep_history ); -} - - -void build_transition_steps_visitor::visit( const shallow_history& _shallow_history ) -{ - handle_history_pseudostate( _shallow_history ); -} - - -void build_transition_steps_visitor::visit( const terminate_pseudostate& _terminate_pseudostate ) -{ - SX_UNUSED_PARAMETER( _terminate_pseudostate ); - sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = - SX_MAKE_UNIQUE< simple_transition_step >( sxe::ref( current_transition_ ) ); - transition_steps_.push_back( sxe::move( simple_step ) ); -} - - -transition* build_transition_steps_visitor::get_next_transition() const -{ - return( next_transition_ ); -} - - -bool build_transition_steps_visitor::reached_end_of_transition() const -{ - return( reached_end_of_transition_ ); -} - - -transition* build_transition_steps_visitor::find_next_transition( const pseudostate& _target_pseudostate, - const event& _event ) -{ - transition* enabled_transition = SX_NULLPTR; - const raw_transitions& transitions = _target_pseudostate.get_outgoing_transitions(); - - SX_FOR( transition* const transition, transitions ) - { - const bool guard_is_ok = transition->check_guard( _event, event_collector_ ); - if( guard_is_ok ) - { - enabled_transition = transition; - break; - } - } - - if( SX_NULLPTR == enabled_transition ) - { - reached_end_of_transition_ = false; - } - - return( enabled_transition ); -} - - -raw_transitions build_transition_steps_visitor::get_default_transition_if_state_was_not_active_before( - const history& _history ) -{ - raw_transitions default_transitions; - default_transitions.reserve( DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE ); - const bool state_was_active_before = _history.check_if_state_was_active_before(); - if( !state_was_active_before ) - { - default_transitions = _history.get_default_transitions(); - if( default_transitions.empty() ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "History pseudostate '%' has no default transition!", - _history.get_name() ); - } - } - - return( default_transitions ); -} - - -void build_transition_steps_visitor::handle_history_pseudostate( const history& _history ) -{ - sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = - SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); - transition_steps_.push_back( sxe::move( simple_step ) ); - const raw_transitions& default_transitions = get_default_transition_if_state_was_not_active_before( _history ); - if( !default_transitions.empty() ) - { - SX_FOR( transition* const default_transition, default_transitions ) - { - sxe::SX_UNIQUE_PTR< simple_transition_step > default_step = - SX_MAKE_UNIQUE< simple_transition_step >( sxe::ref( *default_transition) ); - transition_steps_.push_back( sxe::move( default_step ) ); - } - } -} - - -void build_transition_steps_visitor::handle_as_junction( const pseudostate& _pseudostate ) -{ - sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = - SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); - transition_steps_.push_back( sxe::move( simple_step ) ); - next_transition_ = find_next_transition( _pseudostate, event_ ); - if( !next_transition_ ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is no enabled transition for the junction '%'!", - _pseudostate.get_name() ); - } -} - - -void build_transition_steps_visitor::handle_as_fork( const pseudostate& _pseudostate ) const -{ - sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = - SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); - transition_steps_.push_back( sxe::move( simple_step ) ); - const raw_transitions& exiting_transitions = _pseudostate.get_outgoing_transitions(); - raw_transitions transitions_of_fork; - transitions_of_fork.reserve( exiting_transitions.size() ); - - SX_FOR( transition* const& transition, exiting_transitions ) - { - transitions_of_fork.push_back( transition ); - } - - sxe::SX_UNIQUE_PTR< compound_transition_step > final_step = - SX_MAKE_UNIQUE< compound_transition_step >( transitions_of_fork ); - transition_steps_.push_back( sxe::move( final_step ) ); -} - - -void build_transition_steps_visitor::handle_as_join( const pseudostate& _pseudostate ) -{ - const raw_transitions& incoming_transitions = _pseudostate.get_incoming_transitions(); - sxe::SX_UNIQUE_PTR< compound_transition_step > step = SX_MAKE_UNIQUE< compound_transition_step >( incoming_transitions ); - transition_steps_.push_back( sxe::move( step ) ); - next_transition_ = find_next_transition( _pseudostate, event_ ); -} - - -void build_transition_steps_visitor::handle_entry_point( const entry_point& _entry_point ) -{ - const composite_state& parent_state = _entry_point.get_parent_state(); - const bool is_orthogonal = parent_state.is_orthogonal(); - if( is_orthogonal ) - { - handle_as_fork( _entry_point ); - } - else - { - handle_as_junction( _entry_point ); - } -} - - -void build_transition_steps_visitor::handle_exit_point( const exit_point& _exit_point ) -{ - const composite_state& parent_state = _exit_point.get_parent_state(); - const bool is_orthogonal = parent_state.is_orthogonal(); - if( is_orthogonal ) - { - handle_as_join( _exit_point ); - } - else - { - handle_as_junction( _exit_point ); - } -} - - -void build_transition_steps_visitor::create_simple_transition_step() -{ - sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = - SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); - transition_steps_.push_back( sxe::move( simple_step ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "build_transition_steps_visitor.hpp" + +#include "essentials/base.hpp" +#include "hermes/log_and_throw.hpp" + +#include "algorithm_parameters.hpp" +#include "composite_state.hpp" +#include "join.hpp" +#include "fork.hpp" +#include "shallow_history.hpp" +#include "deep_history.hpp" +#include "junction.hpp" +#include "entry_point.hpp" +#include "exit_point.hpp" +#include "transition.hpp" +#include "simple_transition_step.hpp" +#include "compound_transition_step.hpp" +#include "simple_state.hpp" +#include "final_state.hpp" +#include "initial_pseudostate.hpp" +#include "choice.hpp" +#include "terminate_pseudostate.hpp" + + +namespace sxy +{ + + +build_transition_steps_visitor::build_transition_steps_visitor( transition& _current_transition, + transition_steps& _transitions_steps, const event& _event, event_collector& _event_collector ) + : const_vertex_visitor(), + current_transition_( _current_transition ), + transition_steps_( _transitions_steps ), + next_transition_( SX_NULLPTR ), + reached_end_of_transition_( true ), + event_( _event ), + event_collector_ ( _event_collector ) +{ + // Nothing to do... +} + + +build_transition_steps_visitor::~build_transition_steps_visitor() SX_NOEXCEPT +{ + // Nothing to do +} + + +void build_transition_steps_visitor::visit( const composite_state& _composite_state ) +{ + SX_UNUSED_PARAMETER( _composite_state ); + create_simple_transition_step(); +} + + +void build_transition_steps_visitor::visit( const simple_state& _simple_state ) +{ + SX_UNUSED_PARAMETER( _simple_state ); + create_simple_transition_step(); +} + + +void build_transition_steps_visitor::visit( const final_state& _final_state ) +{ + SX_UNUSED_PARAMETER( _final_state ); + create_simple_transition_step(); +} + + +void build_transition_steps_visitor::visit( const initial_pseudostate& _initial_pseudostate ) +{ + SX_UNUSED_PARAMETER( _initial_pseudostate ); + SX_ASSERT( false, "An initial pseudo state cannot be the target of a transition!" ); +} + + +void build_transition_steps_visitor::visit( const choice& _choice ) +{ + SX_UNUSED_PARAMETER( _choice ); + create_simple_transition_step(); +} + + +void build_transition_steps_visitor::visit( const junction& _junction ) +{ + handle_as_junction( _junction ); +} + + +void build_transition_steps_visitor::visit( const join& _join ) +{ + handle_as_join( _join ); +} + + +void build_transition_steps_visitor::visit( const fork& _fork ) +{ + handle_as_fork( _fork ); +} + + +void build_transition_steps_visitor::visit( const entry_point& _entry_point ) +{ + handle_entry_point( _entry_point ); +} + + +void build_transition_steps_visitor::visit( const exit_point& _exit_point ) +{ + handle_exit_point( _exit_point ); +} + + +void build_transition_steps_visitor::visit( const deep_history& _deep_history ) +{ + handle_history_pseudostate( _deep_history ); +} + + +void build_transition_steps_visitor::visit( const shallow_history& _shallow_history ) +{ + handle_history_pseudostate( _shallow_history ); +} + + +void build_transition_steps_visitor::visit( const terminate_pseudostate& _terminate_pseudostate ) +{ + SX_UNUSED_PARAMETER( _terminate_pseudostate ); + sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = + SX_MAKE_UNIQUE< simple_transition_step >( sxe::ref( current_transition_ ) ); + transition_steps_.push_back( sxe::move( simple_step ) ); +} + + +transition* build_transition_steps_visitor::get_next_transition() const +{ + return( next_transition_ ); +} + + +bool build_transition_steps_visitor::reached_end_of_transition() const +{ + return( reached_end_of_transition_ ); +} + + +transition* build_transition_steps_visitor::find_next_transition( const pseudostate& _target_pseudostate, + const event& _event ) +{ + transition* enabled_transition = SX_NULLPTR; + const raw_transitions& transitions = _target_pseudostate.get_outgoing_transitions(); + + SX_FOR( transition* const transition, transitions ) + { + const bool guard_is_ok = transition->check_guard( _event, event_collector_ ); + if( guard_is_ok ) + { + enabled_transition = transition; + break; + } + } + + if( SX_NULLPTR == enabled_transition ) + { + reached_end_of_transition_ = false; + } + + return( enabled_transition ); +} + + +raw_transitions build_transition_steps_visitor::get_default_transition_if_state_was_not_active_before( + const history& _history ) +{ + raw_transitions default_transitions; + default_transitions.reserve( DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE ); + const bool state_was_active_before = _history.check_if_state_was_active_before(); + if( !state_was_active_before ) + { + default_transitions = _history.get_default_transitions(); + if( default_transitions.empty() ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "History pseudostate '%' has no default transition!", + _history.get_name() ); + } + } + + return( default_transitions ); +} + + +void build_transition_steps_visitor::handle_history_pseudostate( const history& _history ) +{ + sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = + SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); + transition_steps_.push_back( sxe::move( simple_step ) ); + const raw_transitions& default_transitions = get_default_transition_if_state_was_not_active_before( _history ); + if( !default_transitions.empty() ) + { + SX_FOR( transition* const default_transition, default_transitions ) + { + sxe::SX_UNIQUE_PTR< simple_transition_step > default_step = + SX_MAKE_UNIQUE< simple_transition_step >( sxe::ref( *default_transition) ); + transition_steps_.push_back( sxe::move( default_step ) ); + } + } +} + + +void build_transition_steps_visitor::handle_as_junction( const pseudostate& _pseudostate ) +{ + sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = + SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); + transition_steps_.push_back( sxe::move( simple_step ) ); + next_transition_ = find_next_transition( _pseudostate, event_ ); + if( !next_transition_ ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is no enabled transition for the junction '%'!", + _pseudostate.get_name() ); + } +} + + +void build_transition_steps_visitor::handle_as_fork( const pseudostate& _pseudostate ) const +{ + sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = + SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); + transition_steps_.push_back( sxe::move( simple_step ) ); + const raw_transitions& exiting_transitions = _pseudostate.get_outgoing_transitions(); + raw_transitions transitions_of_fork; + transitions_of_fork.reserve( exiting_transitions.size() ); + + SX_FOR( transition* const& transition, exiting_transitions ) + { + transitions_of_fork.push_back( transition ); + } + + sxe::SX_UNIQUE_PTR< compound_transition_step > final_step = + SX_MAKE_UNIQUE< compound_transition_step >( transitions_of_fork ); + transition_steps_.push_back( sxe::move( final_step ) ); +} + + +void build_transition_steps_visitor::handle_as_join( const pseudostate& _pseudostate ) +{ + const raw_transitions& incoming_transitions = _pseudostate.get_incoming_transitions(); + sxe::SX_UNIQUE_PTR< compound_transition_step > step = SX_MAKE_UNIQUE< compound_transition_step >( incoming_transitions ); + transition_steps_.push_back( sxe::move( step ) ); + next_transition_ = find_next_transition( _pseudostate, event_ ); +} + + +void build_transition_steps_visitor::handle_entry_point( const entry_point& _entry_point ) +{ + const composite_state& parent_state = _entry_point.get_parent_state(); + const bool is_orthogonal = parent_state.is_orthogonal(); + if( is_orthogonal ) + { + handle_as_fork( _entry_point ); + } + else + { + handle_as_junction( _entry_point ); + } +} + + +void build_transition_steps_visitor::handle_exit_point( const exit_point& _exit_point ) +{ + const composite_state& parent_state = _exit_point.get_parent_state(); + const bool is_orthogonal = parent_state.is_orthogonal(); + if( is_orthogonal ) + { + handle_as_join( _exit_point ); + } + else + { + handle_as_junction( _exit_point ); + } +} + + +void build_transition_steps_visitor::create_simple_transition_step() +{ + sxe::SX_UNIQUE_PTR< simple_transition_step > simple_step = + SX_MAKE_UNIQUE< simple_transition_step >(sxe::ref( current_transition_ ) ); + transition_steps_.push_back( sxe::move( simple_step ) ); +} + + +} diff --git a/libyasmine/source/caller.cpp b/libyasmine/source/caller.cpp index d6aee11..0e31349 100644 --- a/libyasmine/source/caller.cpp +++ b/libyasmine/source/caller.cpp @@ -1,35 +1,35 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "caller.hpp" - - -namespace sxy -{ - -// cppcheck-suppress unusedFunction -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - SX_UNUSED_PARAMETER( _event ); - SX_UNUSED_PARAMETER( _event_collector ); - _method(); -} - - -void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - SX_UNUSED_PARAMETER( _event ); - _method( _event_collector ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "caller.hpp" + + +namespace sxy +{ + +// cppcheck-suppress unusedFunction +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event ); + SX_UNUSED_PARAMETER( _event_collector ); + _method(); +} + + +void behavior_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event ); + _method( _event_collector ); +} + + +} diff --git a/libyasmine/source/caller_adapter.cpp b/libyasmine/source/caller_adapter.cpp index ca59b29..9804915 100644 --- a/libyasmine/source/caller_adapter.cpp +++ b/libyasmine/source/caller_adapter.cpp @@ -1,61 +1,61 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_CPP03_BOOST - - -#include "caller_adapter.hpp" - -#include "essentials/base.hpp" - - -sxe::function adapt_function( void( *_function )( ) ) -{ - return( [ _function ]() - { - ( *_function )(); - } - ); -} - - -sxe::function adapt_function( bool( *_function )() ) -{ - return( [_function]() - { - return( ( *_function )() ); - } - ); -} - - -// cppcheck-suppress unusedFunction -sxe::function adapt_function( - void( *_function )( sxy::event_collector& ) ) -{ - return( [_function]( sxy::event_collector& _event_collector ) - { - ( *_function )( _event_collector ); - } - ); -} - - -sxe::function adapt_function( bool( *_function )( sxy::event_collector& ) ) -{ - return( [_function]( sxy::event_collector& _event_collector ) - { - return( ( *_function )( _event_collector ) ); - } - ); -} - - -#endif +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SX_CPP03_BOOST + + +#include "caller_adapter.hpp" + +#include "essentials/base.hpp" + + +sxe::function adapt_function( void( *_function )( ) ) +{ + return( [ _function ]() + { + ( *_function )(); + } + ); +} + + +sxe::function adapt_function( bool( *_function )() ) +{ + return( [_function]() + { + return( ( *_function )() ); + } + ); +} + + +// cppcheck-suppress unusedFunction +sxe::function adapt_function( + void( *_function )( sxy::event_collector& ) ) +{ + return( [_function]( sxy::event_collector& _event_collector ) + { + ( *_function )( _event_collector ); + } + ); +} + + +sxe::function adapt_function( bool( *_function )( sxy::event_collector& ) ) +{ + return( [_function]( sxy::event_collector& _event_collector ) + { + return( ( *_function )( _event_collector ) ); + } + ); +} + + +#endif diff --git a/libyasmine/source/check_if_all_incoming_transitions_sources_are_active_visitor.cpp b/libyasmine/source/check_if_all_incoming_transitions_sources_are_active_visitor.cpp index 10cacc6..d078829 100644 --- a/libyasmine/source/check_if_all_incoming_transitions_sources_are_active_visitor.cpp +++ b/libyasmine/source/check_if_all_incoming_transitions_sources_are_active_visitor.cpp @@ -1,57 +1,57 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "check_if_all_incoming_transitions_sources_are_active_visitor.hpp" - -#include "composite_state.hpp" -#include "simple_state.hpp" - - -namespace sxy -{ - - -check_if_all_incoming_transitions_sources_are_active_visitor::check_if_all_incoming_transitions_sources_are_active_visitor(): - complex_state_visitor(), source_is_finished_( false ) -{ - // Nothing to do... -} - - -check_if_all_incoming_transitions_sources_are_active_visitor::~check_if_all_incoming_transitions_sources_are_active_visitor() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void check_if_all_incoming_transitions_sources_are_active_visitor::visit( const composite_state& _composite_state ) -{ - source_is_finished_ = _composite_state.is_active(); - if( source_is_finished_ ) - { - source_is_finished_ = _composite_state.check_if_regions_are_completed(); - } -} - - -void check_if_all_incoming_transitions_sources_are_active_visitor::visit( const simple_state& _simple_state ) -{ - source_is_finished_ = _simple_state.is_active(); -} - - -bool check_if_all_incoming_transitions_sources_are_active_visitor::get_result() const -{ - return( source_is_finished_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "check_if_all_incoming_transitions_sources_are_active_visitor.hpp" + +#include "composite_state.hpp" +#include "simple_state.hpp" + + +namespace sxy +{ + + +check_if_all_incoming_transitions_sources_are_active_visitor::check_if_all_incoming_transitions_sources_are_active_visitor(): + complex_state_visitor(), source_is_finished_( false ) +{ + // Nothing to do... +} + + +check_if_all_incoming_transitions_sources_are_active_visitor::~check_if_all_incoming_transitions_sources_are_active_visitor() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void check_if_all_incoming_transitions_sources_are_active_visitor::visit( const composite_state& _composite_state ) +{ + source_is_finished_ = _composite_state.is_active(); + if( source_is_finished_ ) + { + source_is_finished_ = _composite_state.check_if_regions_are_completed(); + } +} + + +void check_if_all_incoming_transitions_sources_are_active_visitor::visit( const simple_state& _simple_state ) +{ + source_is_finished_ = _simple_state.is_active(); +} + + +bool check_if_all_incoming_transitions_sources_are_active_visitor::get_result() const +{ + return( source_is_finished_ ); +} + + +} diff --git a/libyasmine/source/choice_impl.cpp b/libyasmine/source/choice_impl.cpp index ae6a9ec..e1af185 100644 --- a/libyasmine/source/choice_impl.cpp +++ b/libyasmine/source/choice_impl.cpp @@ -1,119 +1,119 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "choice_impl.hpp" - -#include "hermes/log.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "state_machine_defect.hpp" -#include "region.hpp" -#include "transition.hpp" - - -namespace sxy -{ - - -choice_impl::choice_impl( const std::string& _name ) - : region_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -choice_impl::~choice_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool choice_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.8 Pseudostate -> Constraint [8]: Choice must have at least 1 incoming and 1 outgoing transition. - SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has incoming transition(s).", get_name() ); - if( get_incoming_transitions().empty() ) - { - _defects.push_back( state_machine_defect( *this, "Choice '%' has no incoming transitions!", - get_name() ) ); - check_ok = false; - } - - SX_LOG( hermes::log_level::LL_SPAM, "Choice '%' has % incoming transition(s).", get_name(), - get_incoming_transitions().size() ); - SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has outgoing transition(s).", get_name() ); - if( get_outgoing_transitions().empty() ) - { - _defects.push_back( state_machine_defect( *this, "Choice '%' has no outgoing transitions!", - get_name() ) ); - check_ok = false; - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Choice '%' has % outgoing transition(s).", get_name(), - get_outgoing_transitions().size() ); - SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has more than one outgoing transition with no guard.", - get_name() ); - uint8_t number_of_transitions_with_no_guard = 0; - - SX_FOR( const transition* const transition, get_outgoing_transitions() ) - { - if( !transition->get_guard() ) - { - ++number_of_transitions_with_no_guard; - } - } - - if( number_of_transitions_with_no_guard > 1 ) - { - _defects.push_back( state_machine_defect( *this, - "Choice '%' has more than one outgoing transition with no guard! It has % transitions with no guard.", - get_name(), number_of_transitions_with_no_guard ) ); - check_ok = false; - } - - SX_LOG( hermes::log_level::LL_SPAM, "Choice '%' has % outgoing transition(s) with no guard.", - get_name(), number_of_transitions_with_no_guard ); - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - return( check_ok ); -} - - -void choice_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void choice_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void choice_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "choice_impl.hpp" + +#include "hermes/log.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "state_machine_defect.hpp" +#include "region.hpp" +#include "transition.hpp" + + +namespace sxy +{ + + +choice_impl::choice_impl( const std::string& _name ) + : region_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +choice_impl::~choice_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool choice_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.8 Pseudostate -> Constraint [8]: Choice must have at least 1 incoming and 1 outgoing transition. + SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has incoming transition(s).", get_name() ); + if( get_incoming_transitions().empty() ) + { + _defects.push_back( state_machine_defect( *this, "Choice '%' has no incoming transitions!", + get_name() ) ); + check_ok = false; + } + + SX_LOG( hermes::log_level::LL_SPAM, "Choice '%' has % incoming transition(s).", get_name(), + get_incoming_transitions().size() ); + SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has outgoing transition(s).", get_name() ); + if( get_outgoing_transitions().empty() ) + { + _defects.push_back( state_machine_defect( *this, "Choice '%' has no outgoing transitions!", + get_name() ) ); + check_ok = false; + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Choice '%' has % outgoing transition(s).", get_name(), + get_outgoing_transitions().size() ); + SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has more than one outgoing transition with no guard.", + get_name() ); + uint8_t number_of_transitions_with_no_guard = 0; + + SX_FOR( const transition* const transition, get_outgoing_transitions() ) + { + if( !transition->get_guard() ) + { + ++number_of_transitions_with_no_guard; + } + } + + if( number_of_transitions_with_no_guard > 1 ) + { + _defects.push_back( state_machine_defect( *this, + "Choice '%' has more than one outgoing transition with no guard! It has % transitions with no guard.", + get_name(), number_of_transitions_with_no_guard ) ); + check_ok = false; + } + + SX_LOG( hermes::log_level::LL_SPAM, "Choice '%' has % outgoing transition(s) with no guard.", + get_name(), number_of_transitions_with_no_guard ); + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + return( check_ok ); +} + + +void choice_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void choice_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void choice_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +} diff --git a/libyasmine/source/completion_event.cpp b/libyasmine/source/completion_event.cpp index 7c3bb1e..e183f5a 100644 --- a/libyasmine/source/completion_event.cpp +++ b/libyasmine/source/completion_event.cpp @@ -1,37 +1,37 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef SX_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 +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef SX_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/libyasmine/source/complex_state_impl.cpp b/libyasmine/source/complex_state_impl.cpp index 52ec460..0711726 100644 --- a/libyasmine/source/complex_state_impl.cpp +++ b/libyasmine/source/complex_state_impl.cpp @@ -1,87 +1,87 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "complex_state_impl.hpp" - -#include - -#include "essentials/base.hpp" - -#include "transition.hpp" - - -namespace sxy -{ - - -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_( sxe::move( _entry_behavior ) ), - exit_( sxe::move( _exit_behavior ) ), - deferred_events_( _deferred_events ) -{ - // Nothing to do... -} - - -complex_state_impl::~complex_state_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -behavior* complex_state_impl::get_entry_behavior() const -{ - return( entry_.get() ); -} - - -behavior* complex_state_impl::get_exit_behavior() const -{ - return( exit_.get() ); -} - - -bool complex_state_impl::is_event_deferred( const event_id& _event_id ) const -{ - const bool found = - std::find( deferred_events_.begin(), deferred_events_.end(), _event_id ) != deferred_events_.end(); - return( found ); -} - - -bool complex_state_impl::check_if_one_of_the_deferred_events_triggers_a_transition() const -{ - bool deferred_event_trigger_a_transition = false; - - SX_FOR( const event_id deferred_event, deferred_events_ ) - { - SX_FOR( const transition* const transition, get_outgoing_transitions() ) - { - deferred_event_trigger_a_transition = transition->can_accept_event( deferred_event ); - if( deferred_event_trigger_a_transition ) - { - break; - } - } - - if( deferred_event_trigger_a_transition ) - { - break; - } - } - - return( deferred_event_trigger_a_transition ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "complex_state_impl.hpp" + +#include + +#include "essentials/base.hpp" + +#include "transition.hpp" + + +namespace sxy +{ + + +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_( sxe::move( _entry_behavior ) ), + exit_( sxe::move( _exit_behavior ) ), + deferred_events_( _deferred_events ) +{ + // Nothing to do... +} + + +complex_state_impl::~complex_state_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +behavior* complex_state_impl::get_entry_behavior() const +{ + return( entry_.get() ); +} + + +behavior* complex_state_impl::get_exit_behavior() const +{ + return( exit_.get() ); +} + + +bool complex_state_impl::is_event_deferred( const event_id& _event_id ) const +{ + const bool found = + std::find( deferred_events_.begin(), deferred_events_.end(), _event_id ) != deferred_events_.end(); + return( found ); +} + + +bool complex_state_impl::check_if_one_of_the_deferred_events_triggers_a_transition() const +{ + bool deferred_event_trigger_a_transition = false; + + SX_FOR( const event_id deferred_event, deferred_events_ ) + { + SX_FOR( const transition* const transition, get_outgoing_transitions() ) + { + deferred_event_trigger_a_transition = transition->can_accept_event( deferred_event ); + if( deferred_event_trigger_a_transition ) + { + break; + } + } + + if( deferred_event_trigger_a_transition ) + { + break; + } + } + + return( deferred_event_trigger_a_transition ); +} + + +} diff --git a/libyasmine/source/composite_state_impl.cpp b/libyasmine/source/composite_state_impl.cpp index 694e13f..91f6aaa 100644 --- a/libyasmine/source/composite_state_impl.cpp +++ b/libyasmine/source/composite_state_impl.cpp @@ -1,449 +1,449 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "composite_state_impl.hpp" - -#include - -#include "hermes/log_and_throw.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "state_visitor.hpp" -#include "complex_state_visitor.hpp" -#include "region_impl.hpp" -#include "deep_history_impl.hpp" -#include "shallow_history_impl.hpp" -#include "exit_point_impl.hpp" -#include "entry_point_impl.hpp" -#include "behavior.hpp" -#include "state_machine_defect.hpp" -#include "uri.hpp" - - -namespace sxy -{ - - -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, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events ), - regions_(), - deep_history_(deep_history_uptr()), - shallow_history_(shallow_history_uptr()), - entry_points_(), - exit_points_() -{ - // Nothing to do... -} - - -composite_state_impl::~composite_state_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -region& composite_state_impl::add_region( region_uptr _region ) -{ - _region->set_parent_state( this ); - region& new_region = *_region; - regions_.push_back( sxe::move( _region ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Region '%' was added to composite state'%'.", _region->get_name(), get_name() ); - return( new_region ); -} - - -region& composite_state_impl::add_region( const std::string& _region_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::region_impl > region = SX_MAKE_UNIQUE< sxy::region_impl >( _region_name ); - region->set_parent_state( this ); - region_impl& new_region = *region; - regions_.push_back( sxe::move( region ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Region '%' was added to composite state'%'.", _region_name, get_name() ); - return( new_region ); -} - - -const regions& composite_state_impl::get_regions() const -{ - return( regions_ ); -} - - -regions& composite_state_impl::get_regions() -{ - return( regions_ ); -} - - -region* composite_state_impl::get_region( const std::string& _region_name ) const -{ - region* found_region = SX_NULLPTR; - - SX_FOR( const region_uptr& region, get_regions() ) - { - if( region->get_name() == _region_name ) - { - found_region = region.get(); - break; - } - } - - return( found_region ); -} - - -bool composite_state_impl::is_complete() const -{ - return( check_if_regions_are_completed() ); -} - - -const deep_history* composite_state_impl::get_deep_history() const -{ - return( deep_history_.get() ); -} - - -deep_history& composite_state_impl::add_deep_history( deep_history_uptr _deep_history ) -{ - if( deep_history_ ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "There already is a deep history in the composite state '%'!", get_name() ); - } - - _deep_history->set_parent_state( this ); - deep_history_ = sxe::move( _deep_history ); - SX_LOG( hermes::log_level::LL_TRACE, "Deep history '%' was added to composite state'%'.", _deep_history->get_name(), - get_name() ); - return( *deep_history_ ); -} - - -deep_history& composite_state_impl::add_deep_history( const std::string& _deep_history_name ) -{ - if( deep_history_ ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is already a deep history in the composite state '%'!", get_name() ); - } - - sxe::SX_UNIQUE_PTR< sxy::deep_history_impl > deep_history = - SX_MAKE_UNIQUE< sxy::deep_history_impl >( _deep_history_name ); - deep_history->set_parent_state( this ); - deep_history_ = sxe::move( deep_history ); - SX_LOG( hermes::log_level::LL_TRACE, "Deep history '%' was added to composite state'%'.", _deep_history_name, get_name() ); - return( *deep_history_ ); -} - - -shallow_history* composite_state_impl::get_shallow_history() const -{ - return( shallow_history_.get() ); -} - - -shallow_history& composite_state_impl::add_shallow_history( shallow_history_uptr _shallow_history ) -{ - if( shallow_history_ ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is already a shallow history in the composite state '%'!", get_name() ); - } - - _shallow_history->set_parent_state( this ); - shallow_history_ = sxe::move( _shallow_history ); - SX_LOG( hermes::log_level::LL_TRACE, "Shallow history '%' was added to composite state'%'.", _shallow_history->get_name(), - get_name() ); - return( *shallow_history_ ); -} - - -shallow_history& composite_state_impl::add_shallow_history( const std::string& _shallow_history_name ) -{ - if( shallow_history_ ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is already a shallow history in the composite state '%'!", - get_name() ); - } - - sxe::SX_UNIQUE_PTR< sxy::shallow_history_impl > shallow_history = - SX_MAKE_UNIQUE< sxy::shallow_history_impl >( _shallow_history_name ); - shallow_history->set_parent_state( this ); - shallow_history_ = sxe::move( shallow_history ); - SX_LOG( hermes::log_level::LL_TRACE, "Shallow history '%' was added to composite state'%'.", _shallow_history_name, - get_name() ); - return( *shallow_history_ ); -} - - -const raw_const_entry_points composite_state_impl::get_entry_points() const -{ - raw_const_entry_points entry_points; - entry_points.reserve( entry_points_.size() ); - - SX_FOR( const entry_point_uptr& entry_point, entry_points_ ) - { - entry_points.push_back( entry_point.get() ); - } - - return( entry_points ); -} - - -entry_point& composite_state_impl::add_entry_point( entry_point_uptr _entry_point ) -{ - _entry_point->set_parent_state( this ); - entry_points_.push_back( sxe::move( _entry_point ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Entry point '%' was added to composite state'%'.", _entry_point->get_name(), get_name() ); - return( *entry_points_.back() ); -} - - -entry_point& composite_state_impl::add_entry_point( const std::string& _entry_point_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::entry_point_impl > entry_point = - SX_MAKE_UNIQUE< sxy::entry_point_impl >( _entry_point_name ); - entry_point->set_parent_state( this ); - entry_points_.push_back( sxe::move( entry_point ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Entry point '%' was added to composite state'%'.", _entry_point_name, get_name() ); - return( *entry_points_.back() ); -} - - -const raw_const_exit_points composite_state_impl::get_exit_points() const -{ - raw_const_exit_points exit_points; - exit_points.reserve( exit_points_.size() ); - - SX_FOR( const exit_point_uptr& exit_point, exit_points_ ) - { - exit_points.push_back( exit_point.get() ); - } - - return( exit_points ); -} - - -exit_point& composite_state_impl::add_exit_point( exit_point_uptr _exit_point ) -{ - _exit_point->set_parent_state( this ); - exit_points_.push_back( sxe::move( _exit_point ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Exit point '%' was added to composite state'%'.", _exit_point->get_name(), get_name() ); - return( *exit_points_.back() ); -} - - -exit_point& composite_state_impl::add_exit_point( const std::string& _exit_point_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::exit_point_impl > exit_point = SX_MAKE_UNIQUE< sxy::exit_point_impl >( _exit_point_name ); - exit_point->set_parent_state( this ); - exit_points_.push_back( sxe::move( exit_point ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Entry point '%' was added to composite state'%'.", _exit_point_name, get_name() ); - return( *exit_points_.back() ); -} - - -vertex* composite_state_impl::get_pseudostate( const std::string& _name_of_pseudostate ) const -{ - vertex* found_vertex = SX_NULLPTR; - if( deep_history_ && ( deep_history_->get_name() == _name_of_pseudostate ) ) - { - found_vertex = deep_history_.get(); - } - else - if( shallow_history_ && ( shallow_history_->get_name() == _name_of_pseudostate ) ) - { - found_vertex = shallow_history_.get(); - } - else - { - SX_FOR( const entry_point_uptr& entry_point, entry_points_ ) - { - if( entry_point->get_name() == _name_of_pseudostate ) - { - found_vertex = entry_point.get(); - break; - } - } - - if( !found_vertex ) - { - SX_FOR( const exit_point_uptr& exit_point, exit_points_ ) - { - if( exit_point->get_name() == _name_of_pseudostate ) - { - found_vertex = exit_point.get(); - break; - } - } - } - } - - return( found_vertex ); -} - - -size_t composite_state_impl::get_region_index( const region* const _region ) const -{ - regions::const_iterator element = - std::find_if( regions_.begin(), regions_.end(), sxe::bind( &composite_state_impl::regions_are_equal, _region, sxe::_1 ) ); - const size_t index = element - regions_.begin(); - return( index ); -} - - -size_t composite_state_impl::get_parent_region_index() const -{ - size_t index = 0; - const region* const parent_region = get_parent_region(); - if( parent_region ) - { - const composite_state& parent_state = parent_region->get_parent_state(); - index = parent_state.get_region_index( parent_region ); - } - - return( index ); -} - - -bool composite_state_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.11 State -> Constraint [5]: A composite state is a state with at least one region. - if( get_regions().empty() ) - { - _defects.push_back( state_machine_defect( *this, "Composite state '%' has no regions!", - get_name() ) ); - check_ok = false; - } - - // 15.3.11 State -> Constraint [5]: An orthogonal state is a composite state with at least 2 regions. - // Not reason to check this. For yasmine this is not relevant. - - SX_FOR( const region_uptr& region, get_regions() ) - { - if( !region->check( _defects ) ) - { - check_ok = false; - } - } - - SX_FOR( const entry_point* const entry_point, get_entry_points() ) - { - if( !entry_point->check( _defects ) ) - { - check_ok = false; - } - } - - SX_FOR( const exit_point* const exit_point, get_exit_points() ) - { - if( !exit_point->check( _defects ) ) - { - check_ok = false; - } - } - - const deep_history* const deep_history = get_deep_history(); - if( deep_history ) - { - if( !deep_history->check( _defects ) ) - { - check_ok = false; - } - } - - const shallow_history* const shallow_history = get_shallow_history(); - if( shallow_history ) - { - if( !shallow_history->check( _defects ) ) - { - check_ok = false; - } - } - - // a state cannot defer an event that triggers a transition - if( complex_state_impl::check_if_one_of_the_deferred_events_triggers_a_transition() ) - { - _defects.push_back( state_machine_defect( *this, - "Simple state '%' defer event that triggers a outgoing transition!", get_name() ) ); - check_ok = false; - } - - return( check_ok ); -} - - -void composite_state_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void composite_state_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void composite_state_impl::accept_complex_state_visitor( complex_state_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void composite_state_impl::accept_state_visitor( state_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -bool composite_state_impl::is_orthogonal() const -{ - bool is_orthogonal = false; - - if( get_regions().size() > 1 ) - { - is_orthogonal = true; - } - - return( is_orthogonal ); -} - - -bool composite_state_impl::check_if_regions_are_completed() const -{ - bool regions_are_completed = true; - - SX_FOR( const region_uptr& region, get_regions() ) - { - if( !region->is_active_state_final() ) - { - regions_are_completed = false; - SX_LOG( hermes::log_level::LL_SPAM, "Region '%' is not completed.", region->get_name() ); - break; - } - - SX_LOG( hermes::log_level::LL_SPAM, "Region '%' is completed.", region->get_name() ); - } - - return( regions_are_completed ); -} - - -bool composite_state_impl::regions_are_equal(const region* const _region, const region_uptr& _vector_element_region) -{ - return( _region == _vector_element_region.get() ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "composite_state_impl.hpp" + +#include + +#include "essentials/uri.hpp" +#include "hermes/log_and_throw.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "state_visitor.hpp" +#include "complex_state_visitor.hpp" +#include "region_impl.hpp" +#include "deep_history_impl.hpp" +#include "shallow_history_impl.hpp" +#include "exit_point_impl.hpp" +#include "entry_point_impl.hpp" +#include "behavior.hpp" +#include "state_machine_defect.hpp" + + +namespace sxy +{ + + +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, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events ), + regions_(), + deep_history_(deep_history_uptr()), + shallow_history_(shallow_history_uptr()), + entry_points_(), + exit_points_() +{ + // Nothing to do... +} + + +composite_state_impl::~composite_state_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +region& composite_state_impl::add_region( region_uptr _region ) +{ + _region->set_parent_state( this ); + region& new_region = *_region; + regions_.push_back( sxe::move( _region ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Region '%' was added to composite state'%'.", _region->get_name(), get_name() ); + return( new_region ); +} + + +region& composite_state_impl::add_region( const std::string& _region_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::region_impl > region = SX_MAKE_UNIQUE< sxy::region_impl >( _region_name ); + region->set_parent_state( this ); + region_impl& new_region = *region; + regions_.push_back( sxe::move( region ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Region '%' was added to composite state'%'.", _region_name, get_name() ); + return( new_region ); +} + + +const regions& composite_state_impl::get_regions() const +{ + return( regions_ ); +} + + +regions& composite_state_impl::get_regions() +{ + return( regions_ ); +} + + +region* composite_state_impl::get_region( const std::string& _region_name ) const +{ + region* found_region = SX_NULLPTR; + + SX_FOR( const region_uptr& region, get_regions() ) + { + if( region->get_name() == _region_name ) + { + found_region = region.get(); + break; + } + } + + return( found_region ); +} + + +bool composite_state_impl::is_complete() const +{ + return( check_if_regions_are_completed() ); +} + + +const deep_history* composite_state_impl::get_deep_history() const +{ + return( deep_history_.get() ); +} + + +deep_history& composite_state_impl::add_deep_history( deep_history_uptr _deep_history ) +{ + if( deep_history_ ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "There already is a deep history in the composite state '%'!", get_name() ); + } + + _deep_history->set_parent_state( this ); + deep_history_ = sxe::move( _deep_history ); + SX_LOG( hermes::log_level::LL_TRACE, "Deep history '%' was added to composite state'%'.", _deep_history->get_name(), + get_name() ); + return( *deep_history_ ); +} + + +deep_history& composite_state_impl::add_deep_history( const std::string& _deep_history_name ) +{ + if( deep_history_ ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is already a deep history in the composite state '%'!", get_name() ); + } + + sxe::SX_UNIQUE_PTR< sxy::deep_history_impl > deep_history = + SX_MAKE_UNIQUE< sxy::deep_history_impl >( _deep_history_name ); + deep_history->set_parent_state( this ); + deep_history_ = sxe::move( deep_history ); + SX_LOG( hermes::log_level::LL_TRACE, "Deep history '%' was added to composite state'%'.", _deep_history_name, get_name() ); + return( *deep_history_ ); +} + + +shallow_history* composite_state_impl::get_shallow_history() const +{ + return( shallow_history_.get() ); +} + + +shallow_history& composite_state_impl::add_shallow_history( shallow_history_uptr _shallow_history ) +{ + if( shallow_history_ ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is already a shallow history in the composite state '%'!", get_name() ); + } + + _shallow_history->set_parent_state( this ); + shallow_history_ = sxe::move( _shallow_history ); + SX_LOG( hermes::log_level::LL_TRACE, "Shallow history '%' was added to composite state'%'.", _shallow_history->get_name(), + get_name() ); + return( *shallow_history_ ); +} + + +shallow_history& composite_state_impl::add_shallow_history( const std::string& _shallow_history_name ) +{ + if( shallow_history_ ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "There is already a shallow history in the composite state '%'!", + get_name() ); + } + + sxe::SX_UNIQUE_PTR< sxy::shallow_history_impl > shallow_history = + SX_MAKE_UNIQUE< sxy::shallow_history_impl >( _shallow_history_name ); + shallow_history->set_parent_state( this ); + shallow_history_ = sxe::move( shallow_history ); + SX_LOG( hermes::log_level::LL_TRACE, "Shallow history '%' was added to composite state'%'.", _shallow_history_name, + get_name() ); + return( *shallow_history_ ); +} + + +const raw_const_entry_points composite_state_impl::get_entry_points() const +{ + raw_const_entry_points entry_points; + entry_points.reserve( entry_points_.size() ); + + SX_FOR( const entry_point_uptr& entry_point, entry_points_ ) + { + entry_points.push_back( entry_point.get() ); + } + + return( entry_points ); +} + + +entry_point& composite_state_impl::add_entry_point( entry_point_uptr _entry_point ) +{ + _entry_point->set_parent_state( this ); + entry_points_.push_back( sxe::move( _entry_point ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Entry point '%' was added to composite state'%'.", _entry_point->get_name(), get_name() ); + return( *entry_points_.back() ); +} + + +entry_point& composite_state_impl::add_entry_point( const std::string& _entry_point_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::entry_point_impl > entry_point = + SX_MAKE_UNIQUE< sxy::entry_point_impl >( _entry_point_name ); + entry_point->set_parent_state( this ); + entry_points_.push_back( sxe::move( entry_point ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Entry point '%' was added to composite state'%'.", _entry_point_name, get_name() ); + return( *entry_points_.back() ); +} + + +const raw_const_exit_points composite_state_impl::get_exit_points() const +{ + raw_const_exit_points exit_points; + exit_points.reserve( exit_points_.size() ); + + SX_FOR( const exit_point_uptr& exit_point, exit_points_ ) + { + exit_points.push_back( exit_point.get() ); + } + + return( exit_points ); +} + + +exit_point& composite_state_impl::add_exit_point( exit_point_uptr _exit_point ) +{ + _exit_point->set_parent_state( this ); + exit_points_.push_back( sxe::move( _exit_point ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Exit point '%' was added to composite state'%'.", _exit_point->get_name(), get_name() ); + return( *exit_points_.back() ); +} + + +exit_point& composite_state_impl::add_exit_point( const std::string& _exit_point_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::exit_point_impl > exit_point = SX_MAKE_UNIQUE< sxy::exit_point_impl >( _exit_point_name ); + exit_point->set_parent_state( this ); + exit_points_.push_back( sxe::move( exit_point ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Entry point '%' was added to composite state'%'.", _exit_point_name, get_name() ); + return( *exit_points_.back() ); +} + + +vertex* composite_state_impl::get_pseudostate( const std::string& _name_of_pseudostate ) const +{ + vertex* found_vertex = SX_NULLPTR; + if( deep_history_ && ( deep_history_->get_name() == _name_of_pseudostate ) ) + { + found_vertex = deep_history_.get(); + } + else + if( shallow_history_ && ( shallow_history_->get_name() == _name_of_pseudostate ) ) + { + found_vertex = shallow_history_.get(); + } + else + { + SX_FOR( const entry_point_uptr& entry_point, entry_points_ ) + { + if( entry_point->get_name() == _name_of_pseudostate ) + { + found_vertex = entry_point.get(); + break; + } + } + + if( !found_vertex ) + { + SX_FOR( const exit_point_uptr& exit_point, exit_points_ ) + { + if( exit_point->get_name() == _name_of_pseudostate ) + { + found_vertex = exit_point.get(); + break; + } + } + } + } + + return( found_vertex ); +} + + +size_t composite_state_impl::get_region_index( const region* const _region ) const +{ + regions::const_iterator element = + std::find_if( regions_.begin(), regions_.end(), sxe::bind( &composite_state_impl::regions_are_equal, _region, sxe::_1 ) ); + const size_t index = element - regions_.begin(); + return( index ); +} + + +size_t composite_state_impl::get_parent_region_index() const +{ + size_t index = 0; + const region* const parent_region = get_parent_region(); + if( parent_region ) + { + const composite_state& parent_state = parent_region->get_parent_state(); + index = parent_state.get_region_index( parent_region ); + } + + return( index ); +} + + +bool composite_state_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.11 State -> Constraint [5]: A composite state is a state with at least one region. + if( get_regions().empty() ) + { + _defects.push_back( state_machine_defect( *this, "Composite state '%' has no regions!", + get_name() ) ); + check_ok = false; + } + + // 15.3.11 State -> Constraint [5]: An orthogonal state is a composite state with at least 2 regions. + // Not reason to check this. For yasmine this is not relevant. + + SX_FOR( const region_uptr& region, get_regions() ) + { + if( !region->check( _defects ) ) + { + check_ok = false; + } + } + + SX_FOR( const entry_point* const entry_point, get_entry_points() ) + { + if( !entry_point->check( _defects ) ) + { + check_ok = false; + } + } + + SX_FOR( const exit_point* const exit_point, get_exit_points() ) + { + if( !exit_point->check( _defects ) ) + { + check_ok = false; + } + } + + const deep_history* const deep_history = get_deep_history(); + if( deep_history ) + { + if( !deep_history->check( _defects ) ) + { + check_ok = false; + } + } + + const shallow_history* const shallow_history = get_shallow_history(); + if( shallow_history ) + { + if( !shallow_history->check( _defects ) ) + { + check_ok = false; + } + } + + // a state cannot defer an event that triggers a transition + if( complex_state_impl::check_if_one_of_the_deferred_events_triggers_a_transition() ) + { + _defects.push_back( state_machine_defect( *this, + "Simple state '%' defer event that triggers a outgoing transition!", get_name() ) ); + check_ok = false; + } + + return( check_ok ); +} + + +void composite_state_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void composite_state_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void composite_state_impl::accept_complex_state_visitor( complex_state_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void composite_state_impl::accept_state_visitor( state_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +bool composite_state_impl::is_orthogonal() const +{ + bool is_orthogonal = false; + + if( get_regions().size() > 1 ) + { + is_orthogonal = true; + } + + return( is_orthogonal ); +} + + +bool composite_state_impl::check_if_regions_are_completed() const +{ + bool regions_are_completed = true; + + SX_FOR( const region_uptr& region, get_regions() ) + { + if( !region->is_active_state_final() ) + { + regions_are_completed = false; + SX_LOG( hermes::log_level::LL_SPAM, "Region '%' is not completed.", region->get_name() ); + break; + } + + SX_LOG( hermes::log_level::LL_SPAM, "Region '%' is completed.", region->get_name() ); + } + + return( regions_are_completed ); +} + + +bool composite_state_impl::regions_are_equal(const region* const _region, const region_uptr& _vector_element_region) +{ + return( _region == _vector_element_region.get() ); +} + + +} diff --git a/libyasmine/source/compound_transition_builder.cpp b/libyasmine/source/compound_transition_builder.cpp index a39be01..32033c1 100644 --- a/libyasmine/source/compound_transition_builder.cpp +++ b/libyasmine/source/compound_transition_builder.cpp @@ -1,76 +1,76 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "compound_transition_builder.hpp" - -#include "hermes/log.hpp" - -#include "vertex.hpp" -#include "transition.hpp" -#include "compound_transition_impl.hpp" -#include "try_to_build_compound_transition_visitor.hpp" -#include "event_impl.hpp" - - -namespace sxy -{ - - -bool try_to_build_compound_transition( transition& _enabled_transition, - compound_transitions& _enabled_compound_transitions, const event& _event, event_collector& _event_collector ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Trying to build compound transition for transition '%'.", - _enabled_transition.get_name() ); - bool built = false; - try_to_build_compound_transition_visitor try_to_build_compound_transition_visitor( _enabled_transition, - _enabled_compound_transitions, built, _event, _event_collector ); - const vertex& target_vertex = _enabled_transition.get_target(); - SX_LOG( hermes::log_level::LL_SPAM, "Target vertex of transition '%' is '%'.", - _enabled_transition.get_name(), target_vertex.get_name() ); - target_vertex.accept_vertex_visitor( try_to_build_compound_transition_visitor ); - if( built ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Compound transition built for target vertex '%'.", target_vertex.get_name() ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Compound transition not built for target vertex '%'.", target_vertex.get_name() ); - } - - return( built ); -} - - -compound_transition_uptr build_compound_transition( transition& _first_transition, const event& _event, - event_collector& _event_collector ) -{ - sxe::SX_UNIQUE_PTR< compound_transition_impl > new_compound_transition = SX_MAKE_UNIQUE< compound_transition_impl >(); - - SX_LOG( hermes::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, - _event, _event_collector ); - if( !built_compound_transition ) - { - new_compound_transition.reset(); - SX_LOG( hermes::log_level::LL_SPAM, "Create and check transition path for transition '%' failed.", - _first_transition.get_name() ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Create and check transition path for transition '%' succeeded.", - _first_transition.get_name() ); - } - - return( sxe::move( new_compound_transition ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "compound_transition_builder.hpp" + +#include "hermes/log.hpp" + +#include "vertex.hpp" +#include "transition.hpp" +#include "compound_transition_impl.hpp" +#include "try_to_build_compound_transition_visitor.hpp" +#include "event_impl.hpp" + + +namespace sxy +{ + + +bool try_to_build_compound_transition( transition& _enabled_transition, + compound_transitions& _enabled_compound_transitions, const event& _event, event_collector& _event_collector ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Trying to build compound transition for transition '%'.", + _enabled_transition.get_name() ); + bool built = false; + try_to_build_compound_transition_visitor try_to_build_compound_transition_visitor( _enabled_transition, + _enabled_compound_transitions, built, _event, _event_collector ); + const vertex& target_vertex = _enabled_transition.get_target(); + SX_LOG( hermes::log_level::LL_SPAM, "Target vertex of transition '%' is '%'.", + _enabled_transition.get_name(), target_vertex.get_name() ); + target_vertex.accept_vertex_visitor( try_to_build_compound_transition_visitor ); + if( built ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Compound transition built for target vertex '%'.", target_vertex.get_name() ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Compound transition not built for target vertex '%'.", target_vertex.get_name() ); + } + + return( built ); +} + + +compound_transition_uptr build_compound_transition( transition& _first_transition, const event& _event, + event_collector& _event_collector ) +{ + sxe::SX_UNIQUE_PTR< compound_transition_impl > new_compound_transition = SX_MAKE_UNIQUE< compound_transition_impl >(); + + SX_LOG( hermes::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, + _event, _event_collector ); + if( !built_compound_transition ) + { + new_compound_transition.reset(); + SX_LOG( hermes::log_level::LL_SPAM, "Create and check transition path for transition '%' failed.", + _first_transition.get_name() ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Create and check transition path for transition '%' succeeded.", + _first_transition.get_name() ); + } + + return( sxe::move( new_compound_transition ) ); +} + + +} diff --git a/libyasmine/source/compound_transition_impl.cpp b/libyasmine/source/compound_transition_impl.cpp index e5b532a..86b3cc9 100644 --- a/libyasmine/source/compound_transition_impl.cpp +++ b/libyasmine/source/compound_transition_impl.cpp @@ -1,141 +1,141 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "compound_transition_impl.hpp" - -#include "vertex.hpp" -#include "transition.hpp" -#include "transition_step.hpp" -#include "build_transition_steps_visitor.hpp" -#include "algorithm_parameters.hpp" - - -namespace sxy -{ - - -compound_transition_impl::compound_transition_impl() - : transition_steps_(), - sub_compound_transitions_() -{ - transition_steps_.reserve( TRANSITION_STEPS_VECTOR_SIZE ); - sub_compound_transitions_.reserve( COMPOUND_TRANSITIONS_VECTOR_SIZE ); -} - - -compound_transition_impl::~compound_transition_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -transition_steps& compound_transition_impl::get_transition_steps() -{ - return( transition_steps_ ); -} - - -const vertex& compound_transition_impl::get_last_target() const -{ - const transition_step_uptr& last_step = transition_steps_.back(); - const raw_transitions& transitions = last_step->get_transitions(); - const transition* const last_transition = transitions.front(); - const vertex& target_vertex = last_transition->get_target(); - return( target_vertex ); -} - - -const compound_transitions& compound_transition_impl::get_sub_compound_transitions() const -{ - return( sub_compound_transitions_ ); -} - - -void compound_transition_impl::add_sub_compound_transition( compound_transition_uptr _sub_compound_transition ) -{ - sub_compound_transitions_.push_back( sxe::move( _sub_compound_transition ) ); -} - - -region* compound_transition_impl::get_LCA_region() -{ - const transition_step* const step1 = transition_steps_.front().get(); - const transition* const transition1 = step1->get_transitions().front(); - const vertex& source = transition1->get_source(); - const transition_step_uptr& step2 = transition_steps_.back(); - const transition* const transition2 = step2->get_transitions().back(); - const vertex& target = transition2->get_target(); - return( source.LCA_region( target ) ); -} - - -composite_state* compound_transition_impl::get_LCA_composite_state() -{ - const transition_step* const step1 = transition_steps_.front().get(); - const transition* const transition1 = step1->get_transitions().front(); - const vertex& source = transition1->get_source(); - const transition_step_uptr& step2 = transition_steps_.back(); - const transition* const transition2 = step2->get_transitions().back(); - const vertex& target = transition2->get_target(); - return( source.LCA_composite_state( target ) ); -} - - -transition_kind compound_transition_impl::get_transition_kind() -{ - const transition* const transition = get_transition_steps().back()->get_transitions().back(); - return( transition->get_kind() ); -} - - -bool compound_transition_impl::check_if_starts_with( const transition& _transition ) -{ - bool start_with = false; - const transition_steps& transition_steps = get_transition_steps(); - if( !transition_steps.empty() ) - { - const transition_step_uptr& first_step = transition_steps.front(); - const raw_transitions& transitions = first_step->get_transitions(); - - SX_FOR( const transition* const transition, transitions ) - { - if( transition == &_transition ) - { - start_with = true; - break; - } - } - } - - return( start_with ); -} - - -bool compound_transition_impl::create_and_check_transition_path( transition& _start_transition, - const event& _event, event_collector& _event_collector ) -{ - transition* current_transition = &_start_transition; - bool reached_end_of_transition = true; - while( current_transition != SX_NULLPTR ) - { - const vertex& target = current_transition->get_target(); - build_transition_steps_visitor build_transition_steps_visitor( *current_transition, transition_steps_, _event, - _event_collector ); - target.accept_vertex_visitor( build_transition_steps_visitor ); - current_transition = build_transition_steps_visitor.get_next_transition(); - reached_end_of_transition = build_transition_steps_visitor.reached_end_of_transition(); - } - - return( reached_end_of_transition ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "compound_transition_impl.hpp" + +#include "vertex.hpp" +#include "transition.hpp" +#include "transition_step.hpp" +#include "build_transition_steps_visitor.hpp" +#include "algorithm_parameters.hpp" + + +namespace sxy +{ + + +compound_transition_impl::compound_transition_impl() + : transition_steps_(), + sub_compound_transitions_() +{ + transition_steps_.reserve( TRANSITION_STEPS_VECTOR_SIZE ); + sub_compound_transitions_.reserve( COMPOUND_TRANSITIONS_VECTOR_SIZE ); +} + + +compound_transition_impl::~compound_transition_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +transition_steps& compound_transition_impl::get_transition_steps() +{ + return( transition_steps_ ); +} + + +const vertex& compound_transition_impl::get_last_target() const +{ + const transition_step_uptr& last_step = transition_steps_.back(); + const raw_transitions& transitions = last_step->get_transitions(); + const transition* const last_transition = transitions.front(); + const vertex& target_vertex = last_transition->get_target(); + return( target_vertex ); +} + + +const compound_transitions& compound_transition_impl::get_sub_compound_transitions() const +{ + return( sub_compound_transitions_ ); +} + + +void compound_transition_impl::add_sub_compound_transition( compound_transition_uptr _sub_compound_transition ) +{ + sub_compound_transitions_.push_back( sxe::move( _sub_compound_transition ) ); +} + + +region* compound_transition_impl::get_LCA_region() +{ + const transition_step* const step1 = transition_steps_.front().get(); + const transition* const transition1 = step1->get_transitions().front(); + const vertex& source = transition1->get_source(); + const transition_step_uptr& step2 = transition_steps_.back(); + const transition* const transition2 = step2->get_transitions().back(); + const vertex& target = transition2->get_target(); + return( source.LCA_region( target ) ); +} + + +composite_state* compound_transition_impl::get_LCA_composite_state() +{ + const transition_step* const step1 = transition_steps_.front().get(); + const transition* const transition1 = step1->get_transitions().front(); + const vertex& source = transition1->get_source(); + const transition_step_uptr& step2 = transition_steps_.back(); + const transition* const transition2 = step2->get_transitions().back(); + const vertex& target = transition2->get_target(); + return( source.LCA_composite_state( target ) ); +} + + +transition_kind compound_transition_impl::get_transition_kind() +{ + const transition* const transition = get_transition_steps().back()->get_transitions().back(); + return( transition->get_kind() ); +} + + +bool compound_transition_impl::check_if_starts_with( const transition& _transition ) +{ + bool start_with = false; + const transition_steps& transition_steps = get_transition_steps(); + if( !transition_steps.empty() ) + { + const transition_step_uptr& first_step = transition_steps.front(); + const raw_transitions& transitions = first_step->get_transitions(); + + SX_FOR( const transition* const transition, transitions ) + { + if( transition == &_transition ) + { + start_with = true; + break; + } + } + } + + return( start_with ); +} + + +bool compound_transition_impl::create_and_check_transition_path( transition& _start_transition, + const event& _event, event_collector& _event_collector ) +{ + transition* current_transition = &_start_transition; + bool reached_end_of_transition = true; + while( current_transition != SX_NULLPTR ) + { + const vertex& target = current_transition->get_target(); + build_transition_steps_visitor build_transition_steps_visitor( *current_transition, transition_steps_, _event, + _event_collector ); + target.accept_vertex_visitor( build_transition_steps_visitor ); + current_transition = build_transition_steps_visitor.get_next_transition(); + reached_end_of_transition = build_transition_steps_visitor.reached_end_of_transition(); + } + + return( reached_end_of_transition ); +} + + +} diff --git a/libyasmine/source/compound_transition_step.cpp b/libyasmine/source/compound_transition_step.cpp index f58f110..4735609 100644 --- a/libyasmine/source/compound_transition_step.cpp +++ b/libyasmine/source/compound_transition_step.cpp @@ -1,97 +1,97 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "compound_transition_step.hpp" - -#include "transition.hpp" -#include "entry_point.hpp" -#include "exit_point.hpp" - - -namespace sxy -{ - - -compound_transition_step::compound_transition_step( const raw_transitions& _transitions ) - : transition_step(), - transitions_( _transitions ) -{ - // Nothing to do... -} - - -compound_transition_step::~compound_transition_step() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const raw_transitions& compound_transition_step::get_transitions() const -{ - return( transitions_ ); -} - - -const vertex& compound_transition_step::get_unique_source() const -{ - const transition* const unique_transition = transitions_.front(); - const vertex& source_vertex = unique_transition->get_source(); - return( source_vertex ); -} - - -const vertex& compound_transition_step::get_unique_target() const -{ - const transition* const unique_transition = transitions_.front(); - const vertex& target_vertex = unique_transition->get_target(); - return( target_vertex ); -} - - -const exit_point* compound_transition_step::get_exit_point() const -{ - const exit_point* const l_exit_point = dynamic_cast< const exit_point* >( &get_unique_target() ); - return( l_exit_point ); -} - - -const entry_point* compound_transition_step::get_entry_point() const -{ - const entry_point* const l_entry_point = dynamic_cast< const entry_point* >( &get_unique_source() ); - return( l_entry_point ); -} - - -const raw_const_vertices compound_transition_step::get_target_vertices() -{ - raw_const_vertices target_vertices; - target_vertices.reserve( transitions_.size() ); - - SX_FOR( const transition* const transition, transitions_ ) - { - const vertex& target_vertex = transition->get_source(); - target_vertices.push_back( &target_vertex ); - } - - return( target_vertices ); -} - - -void compound_transition_step::execute_transition_behaviors( const event& _event, event_collector& _event_collector ) const -{ - SX_FOR( const transition* const transition, transitions_ ) - { - transition->on_transition_behavior( _event, _event_collector ); - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "compound_transition_step.hpp" + +#include "transition.hpp" +#include "entry_point.hpp" +#include "exit_point.hpp" + + +namespace sxy +{ + + +compound_transition_step::compound_transition_step( const raw_transitions& _transitions ) + : transition_step(), + transitions_( _transitions ) +{ + // Nothing to do... +} + + +compound_transition_step::~compound_transition_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const raw_transitions& compound_transition_step::get_transitions() const +{ + return( transitions_ ); +} + + +const vertex& compound_transition_step::get_unique_source() const +{ + const transition* const unique_transition = transitions_.front(); + const vertex& source_vertex = unique_transition->get_source(); + return( source_vertex ); +} + + +const vertex& compound_transition_step::get_unique_target() const +{ + const transition* const unique_transition = transitions_.front(); + const vertex& target_vertex = unique_transition->get_target(); + return( target_vertex ); +} + + +const exit_point* compound_transition_step::get_exit_point() const +{ + const exit_point* const l_exit_point = dynamic_cast< const exit_point* >( &get_unique_target() ); + return( l_exit_point ); +} + + +const entry_point* compound_transition_step::get_entry_point() const +{ + const entry_point* const l_entry_point = dynamic_cast< const entry_point* >( &get_unique_source() ); + return( l_entry_point ); +} + + +const raw_const_vertices compound_transition_step::get_target_vertices() +{ + raw_const_vertices target_vertices; + target_vertices.reserve( transitions_.size() ); + + SX_FOR( const transition* const transition, transitions_ ) + { + const vertex& target_vertex = transition->get_source(); + target_vertices.push_back( &target_vertex ); + } + + return( target_vertices ); +} + + +void compound_transition_step::execute_transition_behaviors( const event& _event, event_collector& _event_collector ) const +{ + SX_FOR( const transition* const transition, transitions_ ) + { + transition->on_transition_behavior( _event, _event_collector ); + } +} + + +} diff --git a/libyasmine/source/constraint_impl.cpp b/libyasmine/source/constraint_impl.cpp index ed65187..be43acd 100644 --- a/libyasmine/source/constraint_impl.cpp +++ b/libyasmine/source/constraint_impl.cpp @@ -1,45 +1,45 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "constraint_impl.hpp" - - -namespace sxy -{ - - -constraint_impl::constraint_impl( const constraint_function& _function ) - : constraint(), - function_( _function ) -{ - // Nothing to do. -} - - -constraint_impl::~constraint_impl() SX_NOEXCEPT -{ - // Nothing to do. -} - - -bool constraint_impl::operator()( const event& _event, event_collector& _event_collector ) const -{ - return( function_( _event, _event_collector ) ); -} - - -constraint_uptr constraint_impl::create( const constraint_function& _function ) -{ - return( SX_MAKE_UNIQUE< sxy::constraint_impl >( _function ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "constraint_impl.hpp" + + +namespace sxy +{ + + +constraint_impl::constraint_impl( const constraint_function& _function ) + : constraint(), + function_( _function ) +{ + // Nothing to do. +} + + +constraint_impl::~constraint_impl() SX_NOEXCEPT +{ + // Nothing to do. +} + + +bool constraint_impl::operator()( const event& _event, event_collector& _event_collector ) const +{ + return( function_( _event, _event_collector ) ); +} + + +constraint_uptr constraint_impl::create( const constraint_function& _function ) +{ + return( SX_MAKE_UNIQUE< sxy::constraint_impl >( _function ) ); +} + + +} diff --git a/libyasmine/source/deep_history_impl.cpp b/libyasmine/source/deep_history_impl.cpp index b7a4a89..bb3cff3 100644 --- a/libyasmine/source/deep_history_impl.cpp +++ b/libyasmine/source/deep_history_impl.cpp @@ -1,93 +1,93 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "deep_history_impl.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "state_machine_defect.hpp" -#include "composite_state.hpp" -#include "transition.hpp" -#include "region.hpp" - - -namespace sxy -{ - - -deep_history_impl::deep_history_impl( const std::string& _name ) - : history_impl( _name ) -{ - // Nothing to do... -} - - -deep_history_impl::~deep_history_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool deep_history_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // check if all default transitions having target in distinct regions - std::set< const region* > target_regions; - - SX_FOR( const transition* const default_transition, get_default_transitions() ) - { - const state_machine_element* const target_region = default_transition->get_target().get_parent(); - const region* const l_region = dynamic_cast< const region* >( target_region ); - if( l_region ) - { - std::pair::const_iterator, bool > result = target_regions.insert(l_region); - if( !result.second ) - { - _defects.push_back( state_machine_defect( *this, - "Deep history '%' has default transition(s) that has(have) the same target region '%'.", get_name(), - l_region->get_name() ) ); - check_ok = false; - break; - } - } - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - return( check_ok ); -} - - -void deep_history_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void deep_history_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void deep_history_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "deep_history_impl.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "state_machine_defect.hpp" +#include "composite_state.hpp" +#include "transition.hpp" +#include "region.hpp" + + +namespace sxy +{ + + +deep_history_impl::deep_history_impl( const std::string& _name ) + : history_impl( _name ) +{ + // Nothing to do... +} + + +deep_history_impl::~deep_history_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool deep_history_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // check if all default transitions having target in distinct regions + std::set< const region* > target_regions; + + SX_FOR( const transition* const default_transition, get_default_transitions() ) + { + const state_machine_element* const target_region = default_transition->get_target().get_parent(); + const region* const l_region = dynamic_cast< const region* >( target_region ); + if( l_region ) + { + std::pair::const_iterator, bool > result = target_regions.insert(l_region); + if( !result.second ) + { + _defects.push_back( state_machine_defect( *this, + "Deep history '%' has default transition(s) that has(have) the same target region '%'.", get_name(), + l_region->get_name() ) ); + check_ok = false; + break; + } + } + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + return( check_ok ); +} + + +void deep_history_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void deep_history_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void deep_history_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +} diff --git a/libyasmine/source/entry_point_impl.cpp b/libyasmine/source/entry_point_impl.cpp index 139561a..0f0f0da 100644 --- a/libyasmine/source/entry_point_impl.cpp +++ b/libyasmine/source/entry_point_impl.cpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "entry_point_impl.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" - - -namespace sxy -{ - - -entry_point_impl::entry_point_impl( const std::string& _name ) - : state_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -entry_point_impl::~entry_point_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool entry_point_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - return( check_ok ); -} - - -void entry_point_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void entry_point_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void entry_point_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "entry_point_impl.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" + + +namespace sxy +{ + + +entry_point_impl::entry_point_impl( const std::string& _name ) + : state_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +entry_point_impl::~entry_point_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool entry_point_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + return( check_ok ); +} + + +void entry_point_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void entry_point_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void entry_point_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +} diff --git a/libyasmine/source/event_creation_request.cpp b/libyasmine/source/event_creation_request.cpp index 832b7b0..cc63fc7 100644 --- a/libyasmine/source/event_creation_request.cpp +++ b/libyasmine/source/event_creation_request.cpp @@ -1,83 +1,83 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "event_creation_request.hpp" - -#include - -#include "hermes/log.hpp" - -#include "event.hpp" - - -namespace sxy -{ - - -event_creation_request::event_creation_request( - const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event, const handle_type _handle ) - : time_( _time ), - event_( _event ), - handle_( _handle ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Event creation request for event '%' (%) @ %.", _event->get_name(), _event->get_id(), - _time.time_since_epoch().count() ); -} - - -event_creation_request::~event_creation_request() SX_NOEXCEPT -{ - // Nothing to do... -} - - -#ifndef SX_CPP03_BOOST -event_creation_request::event_creation_request( event_creation_request&& _event_creation_request ) - : time_(sxe::move( _event_creation_request.time_)), - event_(sxe::move(_event_creation_request.event_)), - handle_(sxe::move(_event_creation_request.handle_)) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Event creation request for event '%' (%) @ %.", event_->get_name(), event_->get_id(), - time_.time_since_epoch().count() ); -} - - -event_creation_request& event_creation_request::operator=( event_creation_request&& _event_creation_request ) -{ - time_ = sxe::move( _event_creation_request.time_ ); - event_ = sxe::move( _event_creation_request.event_ ); - handle_ = sxe::move( _event_creation_request.handle_ ); - SX_LOG( hermes::log_level::LL_TRACE, "Event creation request for event '%' (%) @ %.", event_->get_name(), event_->get_id(), - time_.time_since_epoch().count() ); - return( *this ); -} -#endif - - -sxe::time_point< sxe::system_clock > event_creation_request::get_time() const -{ - return( time_ ); -} - - -handle_type event_creation_request::get_handle() const -{ - return( handle_ ); -} - - -event_sptr event_creation_request::get_event() const -{ - return( event_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "event_creation_request.hpp" + +#include + +#include "hermes/log.hpp" + +#include "event.hpp" + + +namespace sxy +{ + + +event_creation_request::event_creation_request( + const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event, const handle_type _handle ) + : time_( _time ), + event_( _event ), + handle_( _handle ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Event creation request for event '%' (%) @ %.", _event->get_name(), _event->get_id(), + _time.time_since_epoch().count() ); +} + + +event_creation_request::~event_creation_request() SX_NOEXCEPT +{ + // Nothing to do... +} + + +#ifndef SX_CPP03_BOOST +event_creation_request::event_creation_request( event_creation_request&& _event_creation_request ) + : time_(sxe::move( _event_creation_request.time_)), + event_(sxe::move(_event_creation_request.event_)), + handle_(sxe::move(_event_creation_request.handle_)) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Event creation request for event '%' (%) @ %.", event_->get_name(), event_->get_id(), + time_.time_since_epoch().count() ); +} + + +event_creation_request& event_creation_request::operator=( event_creation_request&& _event_creation_request ) +{ + time_ = sxe::move( _event_creation_request.time_ ); + event_ = sxe::move( _event_creation_request.event_ ); + handle_ = sxe::move( _event_creation_request.handle_ ); + SX_LOG( hermes::log_level::LL_TRACE, "Event creation request for event '%' (%) @ %.", event_->get_name(), event_->get_id(), + time_.time_since_epoch().count() ); + return( *this ); +} +#endif + + +sxe::time_point< sxe::system_clock > event_creation_request::get_time() const +{ + return( time_ ); +} + + +handle_type event_creation_request::get_handle() const +{ + return( handle_ ); +} + + +event_sptr event_creation_request::get_event() const +{ + return( event_ ); +} + + +} diff --git a/libyasmine/source/event_creation_request_time_comparer.cpp b/libyasmine/source/event_creation_request_time_comparer.cpp index 090b9a9..fbd5ed0 100644 --- a/libyasmine/source/event_creation_request_time_comparer.cpp +++ b/libyasmine/source/event_creation_request_time_comparer.cpp @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "event_creation_request_time_comparer.hpp" - -#include "event_creation_request.hpp" - - -namespace sxy -{ - - -bool event_creation_request_time_comparer::operator()( const event_creation_request& _lhs, - const event_creation_request& _rhs ) const -{ - return( ( &_lhs )->get_time() < ( &_rhs )->get_time() ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "event_creation_request_time_comparer.hpp" + +#include "event_creation_request.hpp" + + +namespace sxy +{ + + +bool event_creation_request_time_comparer::operator()( const event_creation_request& _lhs, + const event_creation_request& _rhs ) const +{ + return( ( &_lhs )->get_time() < ( &_rhs )->get_time() ); +} + + +} diff --git a/libyasmine/source/event_handle.cpp b/libyasmine/source/event_handle.cpp index ba2d888..572d962 100644 --- a/libyasmine/source/event_handle.cpp +++ b/libyasmine/source/event_handle.cpp @@ -1,24 +1,24 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "event_handle.hpp" - - -namespace sxy -{ - -#ifndef SX_CPP03_BOOST - const handle_type Y_INVALID_EVENT_CREATION_REQUEST_HANDLE = std::numeric_limits< handle_type >::max(); -#endif - - const handle_type Y_DEFAULT_HANDLE = 0; - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "event_handle.hpp" + + +namespace sxy +{ + +#ifndef SX_CPP03_BOOST + const handle_type Y_INVALID_EVENT_CREATION_REQUEST_HANDLE = std::numeric_limits< handle_type >::max(); +#endif + + const handle_type Y_DEFAULT_HANDLE = 0; + +} diff --git a/libyasmine/source/event_impl.cpp b/libyasmine/source/event_impl.cpp index c84c54c..20b70e1 100644 --- a/libyasmine/source/event_impl.cpp +++ b/libyasmine/source/event_impl.cpp @@ -1,69 +1,69 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "event_impl.hpp" - -#include - -#include "essentials/exception.hpp" -#include "essentials/conversion.hpp" - - -namespace sxy -{ - - -event_impl::event_impl( const event_id _event_id, const event_priority _event_priority ) - : event(), - event_id_( _event_id ), - event_priority_( _event_priority) -{ - // Nothing to do... -} - - -event_impl::~event_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -event_id event_impl::get_id() const -{ - return( event_id_ ); -} - - -std::string event_impl::get_name() const -{ - return ( sxe::to_string( event_id_ ) ); -} - - -event_priority event_impl::get_priority() const -{ - return( event_priority_ ); -} - - -bool event_impl::operator>(const event& _rhs) const -{ - return( get_priority() > _rhs.get_priority() ); -} - - -event_sptr event_impl::create( const event_id _event_id, const event_priority _event_priority ) -{ - return( SX_MAKE_SHARED< sxy::event_impl >( _event_id, _event_priority ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "event_impl.hpp" + +#include + +#include "essentials/exception.hpp" +#include "essentials/conversion.hpp" + + +namespace sxy +{ + + +event_impl::event_impl( const event_id _event_id, const event_priority _event_priority ) + : event(), + event_id_( _event_id ), + event_priority_( _event_priority) +{ + // Nothing to do... +} + + +event_impl::~event_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +event_id event_impl::get_id() const +{ + return( event_id_ ); +} + + +std::string event_impl::get_name() const +{ + return ( sxe::to_string( event_id_ ) ); +} + + +event_priority event_impl::get_priority() const +{ + return( event_priority_ ); +} + + +bool event_impl::operator>(const event& _rhs) const +{ + return( get_priority() > _rhs.get_priority() ); +} + + +event_sptr event_impl::create( const event_id _event_id, const event_priority _event_priority ) +{ + return( SX_MAKE_SHARED< sxy::event_impl >( _event_id, _event_priority ) ); +} + + +} diff --git a/libyasmine/source/execution_state_do_step.cpp b/libyasmine/source/execution_state_do_step.cpp index 004c011..6c73451 100644 --- a/libyasmine/source/execution_state_do_step.cpp +++ b/libyasmine/source/execution_state_do_step.cpp @@ -1,94 +1,94 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "execution_state_do_step.hpp" - -#include "hermes/log.hpp" - -#include "state.hpp" -#include "event_processing_callback.hpp" -#include "execution_step_visitor.hpp" -#include "behavior_exception.hpp" - - - -namespace sxy -{ - - -execution_state_do_step::execution_state_do_step( const state& _state ) - : execution_step(), - state_( _state ) -{ - // Nothing to do... -} - - -execution_state_do_step::~execution_state_do_step() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool execution_state_do_step::execute_behavior( event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector ) const -{ - SX_LOG( hermes::log_level::LL_TRACE, "Executing do behavior of state '%'.", state_.get_name() ); - if( _event_processing_callback ) - { - _event_processing_callback->before_do( state_ ); - } - - try - { - state_.execute_do_behavior(_event, _async_event_handler, _event_collector ); - } - catch (const sxy::behavior_exception& exception) - { - _exception_events.push_back(exception.get_error_event()); - } - catch (const std::exception& exception) - { - SX_UNUSED_PARAMETER(exception); - if (state_.has_error_event()) - { - _exception_events.push_back(state_.get_error_event()); - } - else - { - throw; - } - } - - - if( _event_processing_callback ) - { - _event_processing_callback->after_do( state_ ); - } - - SX_LOG( hermes::log_level::LL_TRACE, "'do behavior' of state '%' executed.", state_.get_name() ); - return( false ); -} - - -void execution_state_do_step::accept( execution_step_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -const state& execution_state_do_step::get_state() const -{ - return( state_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "execution_state_do_step.hpp" + +#include "hermes/log.hpp" + +#include "state.hpp" +#include "event_processing_callback.hpp" +#include "execution_step_visitor.hpp" +#include "behavior_exception.hpp" + + + +namespace sxy +{ + + +execution_state_do_step::execution_state_do_step( const state& _state ) + : execution_step(), + state_( _state ) +{ + // Nothing to do... +} + + +execution_state_do_step::~execution_state_do_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool execution_state_do_step::execute_behavior( event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, event_collector& _event_collector ) const +{ + SX_LOG( hermes::log_level::LL_TRACE, "Executing do behavior of state '%'.", state_.get_name() ); + if( _event_processing_callback ) + { + _event_processing_callback->before_do( state_ ); + } + + try + { + state_.execute_do_behavior(_event, _async_event_handler, _event_collector ); + } + catch (const sxy::behavior_exception& exception) + { + _exception_events.push_back(exception.get_error_event()); + } + catch (const std::exception& exception) + { + SX_UNUSED_PARAMETER(exception); + if (state_.has_error_event()) + { + _exception_events.push_back(state_.get_error_event()); + } + else + { + throw; + } + } + + + if( _event_processing_callback ) + { + _event_processing_callback->after_do( state_ ); + } + + SX_LOG( hermes::log_level::LL_TRACE, "'do behavior' of state '%' executed.", state_.get_name() ); + return( false ); +} + + +void execution_state_do_step::accept( execution_step_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +const state& execution_state_do_step::get_state() const +{ + return( state_ ); +} + + +} diff --git a/libyasmine/source/execution_state_enter_step.cpp b/libyasmine/source/execution_state_enter_step.cpp index e49b9ae..7d59c1b 100644 --- a/libyasmine/source/execution_state_enter_step.cpp +++ b/libyasmine/source/execution_state_enter_step.cpp @@ -1,75 +1,75 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "execution_state_enter_step.hpp" - -#include "hermes/log.hpp" - -#include "state.hpp" -#include "event_processing_callback.hpp" -#include "execution_step_visitor.hpp" - - -namespace sxy -{ - - -execution_state_enter_step::execution_state_enter_step( state& _state ) - : execution_step(), - state_( _state ) -{ - // Nothing to do... -} - - -execution_state_enter_step::~execution_state_enter_step() SX_NOEXCEPT -{ - // Nothing to do... -} - - -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, - event_collector& _event_collector ) const -{ - SX_UNUSED_PARAMETER( _exception_events ); - SX_UNUSED_PARAMETER( _async_event_handler ); - SX_LOG( hermes::log_level::LL_TRACE, "Entering state '%'.", state_.get_name() ); - if( _event_processing_callback ) - { - _event_processing_callback->before_enter( state_ ); - } - - state_.enter_state( _event, _event_collector ); - - if( _event_processing_callback ) - { - _event_processing_callback->after_enter( state_ ); - } - - SX_LOG( hermes::log_level::LL_TRACE, "Entered state '%'.", state_.get_name() ); - return( false ); -} - - -void execution_state_enter_step::accept( execution_step_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -const state& execution_state_enter_step::get_state() const -{ - return( state_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "execution_state_enter_step.hpp" + +#include "hermes/log.hpp" + +#include "state.hpp" +#include "event_processing_callback.hpp" +#include "execution_step_visitor.hpp" + + +namespace sxy +{ + + +execution_state_enter_step::execution_state_enter_step( state& _state ) + : execution_step(), + state_( _state ) +{ + // Nothing to do... +} + + +execution_state_enter_step::~execution_state_enter_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +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, + event_collector& _event_collector ) const +{ + SX_UNUSED_PARAMETER( _exception_events ); + SX_UNUSED_PARAMETER( _async_event_handler ); + SX_LOG( hermes::log_level::LL_TRACE, "Entering state '%'.", state_.get_name() ); + if( _event_processing_callback ) + { + _event_processing_callback->before_enter( state_ ); + } + + state_.enter_state( _event, _event_collector ); + + if( _event_processing_callback ) + { + _event_processing_callback->after_enter( state_ ); + } + + SX_LOG( hermes::log_level::LL_TRACE, "Entered state '%'.", state_.get_name() ); + return( false ); +} + + +void execution_state_enter_step::accept( execution_step_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +const state& execution_state_enter_step::get_state() const +{ + return( state_ ); +} + + +} diff --git a/libyasmine/source/execution_state_exit_step.cpp b/libyasmine/source/execution_state_exit_step.cpp index 1b4c79a..6d48c0e 100644 --- a/libyasmine/source/execution_state_exit_step.cpp +++ b/libyasmine/source/execution_state_exit_step.cpp @@ -1,75 +1,75 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "execution_state_exit_step.hpp" - -#include "hermes/log.hpp" - -#include "state.hpp" -#include "event_processing_callback.hpp" -#include "execution_step_visitor.hpp" - - -namespace sxy -{ - - -execution_state_exit_step::execution_state_exit_step( state& _state ) - : execution_step(), - state_( _state ) -{ - // Nothing to do... -} - - -execution_state_exit_step::~execution_state_exit_step() SX_NOEXCEPT -{ - // Nothing to do... -} - - -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, - event_collector& _event_collector ) const -{ - SX_UNUSED_PARAMETER( _exception_events ); - SX_UNUSED_PARAMETER( _async_event_handler ); - SX_LOG( hermes::log_level::LL_TRACE, "Exiting state '%'.", state_.get_name() ); - if( _event_processing_callback ) - { - _event_processing_callback->before_exit( state_ ); - } - - state_.exit_state( _event, _event_collector ); - - if( _event_processing_callback ) - { - _event_processing_callback->after_exit( state_ ); - } - - SX_LOG( hermes::log_level::LL_TRACE, "Exited state '%'.", state_.get_name() ); - return( false ); -} - - -void execution_state_exit_step::accept( execution_step_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -const state& execution_state_exit_step::get_state() const -{ - return( state_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "execution_state_exit_step.hpp" + +#include "hermes/log.hpp" + +#include "state.hpp" +#include "event_processing_callback.hpp" +#include "execution_step_visitor.hpp" + + +namespace sxy +{ + + +execution_state_exit_step::execution_state_exit_step( state& _state ) + : execution_step(), + state_( _state ) +{ + // Nothing to do... +} + + +execution_state_exit_step::~execution_state_exit_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +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, + event_collector& _event_collector ) const +{ + SX_UNUSED_PARAMETER( _exception_events ); + SX_UNUSED_PARAMETER( _async_event_handler ); + SX_LOG( hermes::log_level::LL_TRACE, "Exiting state '%'.", state_.get_name() ); + if( _event_processing_callback ) + { + _event_processing_callback->before_exit( state_ ); + } + + state_.exit_state( _event, _event_collector ); + + if( _event_processing_callback ) + { + _event_processing_callback->after_exit( state_ ); + } + + SX_LOG( hermes::log_level::LL_TRACE, "Exited state '%'.", state_.get_name() ); + return( false ); +} + + +void execution_state_exit_step::accept( execution_step_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +const state& execution_state_exit_step::get_state() const +{ + return( state_ ); +} + + +} diff --git a/libyasmine/source/execution_transition_step.cpp b/libyasmine/source/execution_transition_step.cpp index 954e2d9..efbc946 100644 --- a/libyasmine/source/execution_transition_step.cpp +++ b/libyasmine/source/execution_transition_step.cpp @@ -1,87 +1,87 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "execution_transition_step.hpp" - -#include "essentials/base.hpp" - -#include "terminate_pseudostate.hpp" -#include "transition.hpp" -#include "transition_step.hpp" -#include "event_processing_callback.hpp" -#include "execution_step_visitor.hpp" - - -namespace sxy -{ - - -execution_transition_step::execution_transition_step( transition_step& _transition_step ) - : execution_step(), - transition_step_( _transition_step ) -{ - // Nothing to do... -} - - -execution_transition_step::~execution_transition_step() SX_NOEXCEPT -{ - // Nothing to do... -} - - -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, - event_collector& _event_collector ) const -{ - SX_UNUSED_PARAMETER( _exception_events ); - SX_UNUSED_PARAMETER( _async_event_handler ); - bool reached_terminate_pseudostate = false; - const raw_transitions& transitions = transition_step_.get_transitions(); - - SX_FOR(const transition* transition, transitions) - { - if( _event_processing_callback ) - { - _event_processing_callback->before_transition( *transition ); - } - - transition->on_transition_behavior( _event, _event_collector ); - - if( _event_processing_callback ) - { - _event_processing_callback->after_transition( *transition ); - } - - if( dynamic_cast< const terminate_pseudostate* >( &transition->get_target() ) ) - { - reached_terminate_pseudostate = true; - break; - } - } - - return( reached_terminate_pseudostate ); -} - - -void execution_transition_step::accept( execution_step_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -const transition_step& execution_transition_step::get_transition_step() const -{ - return( transition_step_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "execution_transition_step.hpp" + +#include "essentials/base.hpp" + +#include "terminate_pseudostate.hpp" +#include "transition.hpp" +#include "transition_step.hpp" +#include "event_processing_callback.hpp" +#include "execution_step_visitor.hpp" + + +namespace sxy +{ + + +execution_transition_step::execution_transition_step( transition_step& _transition_step ) + : execution_step(), + transition_step_( _transition_step ) +{ + // Nothing to do... +} + + +execution_transition_step::~execution_transition_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +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, + event_collector& _event_collector ) const +{ + SX_UNUSED_PARAMETER( _exception_events ); + SX_UNUSED_PARAMETER( _async_event_handler ); + bool reached_terminate_pseudostate = false; + const raw_transitions& transitions = transition_step_.get_transitions(); + + SX_FOR(const transition* transition, transitions) + { + if( _event_processing_callback ) + { + _event_processing_callback->before_transition( *transition ); + } + + transition->on_transition_behavior( _event, _event_collector ); + + if( _event_processing_callback ) + { + _event_processing_callback->after_transition( *transition ); + } + + if( dynamic_cast< const terminate_pseudostate* >( &transition->get_target() ) ) + { + reached_terminate_pseudostate = true; + break; + } + } + + return( reached_terminate_pseudostate ); +} + + +void execution_transition_step::accept( execution_step_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +const transition_step& execution_transition_step::get_transition_step() const +{ + return( transition_step_ ); +} + + +} diff --git a/libyasmine/source/exit_point_impl.cpp b/libyasmine/source/exit_point_impl.cpp index 0af1f30..c52eac7 100644 --- a/libyasmine/source/exit_point_impl.cpp +++ b/libyasmine/source/exit_point_impl.cpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "exit_point_impl.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" - - -namespace sxy -{ - - -exit_point_impl::exit_point_impl( const std::string& _name ) - : state_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -exit_point_impl::~exit_point_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool exit_point_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - return( check_ok ); -} - - -void exit_point_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void exit_point_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void exit_point_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "exit_point_impl.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" + + +namespace sxy +{ + + +exit_point_impl::exit_point_impl( const std::string& _name ) + : state_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +exit_point_impl::~exit_point_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool exit_point_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + return( check_ok ); +} + + +void exit_point_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void exit_point_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void exit_point_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +} diff --git a/libyasmine/source/final_state_impl.cpp b/libyasmine/source/final_state_impl.cpp index 748fd7f..8eeb1ca 100644 --- a/libyasmine/source/final_state_impl.cpp +++ b/libyasmine/source/final_state_impl.cpp @@ -1,135 +1,135 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "final_state_impl.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "state_visitor.hpp" -#include "region.hpp" -#include "state_machine_defect.hpp" - - -namespace sxy -{ - - -final_state_impl::final_state_impl( const std::string& _name ) - : state_impl( _name ) -{ - // Nothing to do... -} - - -final_state_impl::~final_state_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -behavior* final_state_impl::get_entry_behavior() const -{ - return( SX_NULLPTR ); -} - - -behavior* final_state_impl::get_exit_behavior() const -{ - return( SX_NULLPTR ); -} - - -const regions& final_state_impl::get_regions() const -{ - static const regions regions; - return( regions ); -} - - -regions& final_state_impl::get_regions() -{ - static regions regions; - return( regions ); -} - - -bool final_state_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.2 Final State -> Constraint [1]: A final state cannot have any outgoing transitions. - if( !get_outgoing_transitions().empty() ) - { - _defects.push_back( state_machine_defect( *this, - "Final state '%' has '%' outgoing transitions!", get_name(), get_outgoing_transitions().size() ) ); - check_ok = false; - } - - // 15.3.2 Final State -> Constraint [2]: A final state cannot have regions. - if( !get_regions().empty() ) - { - _defects.push_back( state_machine_defect( *this, "Final state '%' has '%' region(s)!", - get_name(), get_regions().size() ) ); - check_ok = false; - } - - // 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 behavior. - if( get_entry_behavior() ) - { - _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 behavior. - if( get_exit_behavior() ) - { - _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) behavior. - // Enforced by design. - return( check_ok ); -} - - -void final_state_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void final_state_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void final_state_impl::accept_state_visitor( state_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -bool final_state_impl::is_event_deferred( const event_id& _event_id ) const -{ - SX_UNUSED_PARAMETER( _event_id ); - return( false ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "final_state_impl.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "state_visitor.hpp" +#include "region.hpp" +#include "state_machine_defect.hpp" + + +namespace sxy +{ + + +final_state_impl::final_state_impl( const std::string& _name ) + : state_impl( _name ) +{ + // Nothing to do... +} + + +final_state_impl::~final_state_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +behavior* final_state_impl::get_entry_behavior() const +{ + return( SX_NULLPTR ); +} + + +behavior* final_state_impl::get_exit_behavior() const +{ + return( SX_NULLPTR ); +} + + +const regions& final_state_impl::get_regions() const +{ + static const regions regions; + return( regions ); +} + + +regions& final_state_impl::get_regions() +{ + static regions regions; + return( regions ); +} + + +bool final_state_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.2 Final State -> Constraint [1]: A final state cannot have any outgoing transitions. + if( !get_outgoing_transitions().empty() ) + { + _defects.push_back( state_machine_defect( *this, + "Final state '%' has '%' outgoing transitions!", get_name(), get_outgoing_transitions().size() ) ); + check_ok = false; + } + + // 15.3.2 Final State -> Constraint [2]: A final state cannot have regions. + if( !get_regions().empty() ) + { + _defects.push_back( state_machine_defect( *this, "Final state '%' has '%' region(s)!", + get_name(), get_regions().size() ) ); + check_ok = false; + } + + // 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 behavior. + if( get_entry_behavior() ) + { + _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 behavior. + if( get_exit_behavior() ) + { + _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) behavior. + // Enforced by design. + return( check_ok ); +} + + +void final_state_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void final_state_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void final_state_impl::accept_state_visitor( state_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +bool final_state_impl::is_event_deferred( const event_id& _event_id ) const +{ + SX_UNUSED_PARAMETER( _event_id ); + return( false ); +} + + +} diff --git a/libyasmine/source/fork_impl.cpp b/libyasmine/source/fork_impl.cpp index 795a50f..30fa567 100644 --- a/libyasmine/source/fork_impl.cpp +++ b/libyasmine/source/fork_impl.cpp @@ -1,163 +1,163 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// - -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "fork_impl.hpp" - -#include - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "transition_impl.hpp" -#include "state.hpp" -#include "state_machine_defect.hpp" -#include "region.hpp" - - -namespace sxy -{ - - -fork_impl::fork_impl( const std::string& _name ) - : region_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -fork_impl::~fork_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool fork_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.8 Pseudostate -> Constraint [5]: Fork must have at least 2 outgoing transitions and exactly 1 incoming - // transition. - if( get_outgoing_transitions().size() < 2 ) - { - _defects.push_back( state_machine_defect( *this, - "Fork '%' has too few outgoing transitions! It has % transition(s).", get_name(), - get_outgoing_transitions().size() ) ); - check_ok = false; - } - - if( get_incoming_transitions().size() != 1 ) - { - _defects.push_back( state_machine_defect( *this, - "Fork '%' does not have exactly 1 incoming transition! It has % transition(s),", get_name(), - get_outgoing_transitions().size() ) ); - check_ok = false; - } - - // 15.3.8 Pseudostate -> Constraint [6]: All transitions outgoing a fork vertex must target states in different - // regions of an state. - // This check is not mandatory. The last LCA is the state machine itself. -> Jira[104] / Jira[103] - // 15.3.14 Transition -> Constraint [1]: A fork segment must not have guards or triggers. - SX_FOR( const transition * const transition, get_outgoing_transitions() ) - { - if( transition->get_guard() ) - { - _defects.push_back( state_machine_defect( *this, "Outgoing transition '%' of fork '%' has guard!", - transition->get_name(), get_name() ) ); - check_ok = false; - } - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - // 15.3.14 Transition -> Constraint [3]: A fork segment must always target a state. - SX_FOR( const transition * const transition, get_outgoing_transitions() ) - { - const state* const target_vertex = dynamic_cast< const state* >( &transition->get_target() ); - if( !target_vertex ) - { - _defects.push_back( state_machine_defect( *this, - "Fork '%' has outgoing transition ('%') that hasn't a state as target! Target vertex is '%'.", get_name(), - transition->get_name(), transition->get_target().get_name()) ); - check_ok = false; - } - else - { - target_vertex->check( _defects ); - } - } - - // 2 outgoing transitions cannot enter the same region - std::set< const region* > target_regions; - SX_FOR( const transition * const transition, get_outgoing_transitions() ) - { - const state_machine_element* const target_region = transition->get_target().get_parent(); - const region* const l_region = dynamic_cast< const region* >( target_region ); - if( l_region ) - { - std::pair< std::set< const region* >::const_iterator, bool > result = target_regions.insert( l_region ); - if( !result.second ) - { - _defects.push_back( state_machine_defect( *this, - "Fork '%' has outgoing transition(s) that has(have) the same target region '%'.", get_name(), - l_region->get_name() ) ); - check_ok = false; - break; - } - } - } - const transition_kind transitions_kind = get_outgoing_transitions().front()->get_kind(); - SX_FOR( const transition * const transition, get_outgoing_transitions() ) - { - if( !(transitions_kind == transition->get_kind()) ) - { - _defects.push_back( state_machine_defect( *this, "Outgoing transitions of fork '%' have different kinds!", - get_name() ) ); - check_ok = false; - break; - } - } - return( check_ok ); -} - - -void fork_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void fork_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void fork_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void fork_impl::add_incoming_transition( transition& _incoming_transition ) -{ - SX_ASSERT( vertex_impl::get_incoming_transitions().size() < 1, "Fork cannot have more than 1 incoming transition!" ); - vertex_impl::add_incoming_transition( _incoming_transition ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// + +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "fork_impl.hpp" + +#include + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "transition_impl.hpp" +#include "state.hpp" +#include "state_machine_defect.hpp" +#include "region.hpp" + + +namespace sxy +{ + + +fork_impl::fork_impl( const std::string& _name ) + : region_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +fork_impl::~fork_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool fork_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.8 Pseudostate -> Constraint [5]: Fork must have at least 2 outgoing transitions and exactly 1 incoming + // transition. + if( get_outgoing_transitions().size() < 2 ) + { + _defects.push_back( state_machine_defect( *this, + "Fork '%' has too few outgoing transitions! It has % transition(s).", get_name(), + get_outgoing_transitions().size() ) ); + check_ok = false; + } + + if( get_incoming_transitions().size() != 1 ) + { + _defects.push_back( state_machine_defect( *this, + "Fork '%' does not have exactly 1 incoming transition! It has % transition(s),", get_name(), + get_outgoing_transitions().size() ) ); + check_ok = false; + } + + // 15.3.8 Pseudostate -> Constraint [6]: All transitions outgoing a fork vertex must target states in different + // regions of an state. + // This check is not mandatory. The last LCA is the state machine itself. -> Jira[104] / Jira[103] + // 15.3.14 Transition -> Constraint [1]: A fork segment must not have guards or triggers. + SX_FOR( const transition * const transition, get_outgoing_transitions() ) + { + if( transition->get_guard() ) + { + _defects.push_back( state_machine_defect( *this, "Outgoing transition '%' of fork '%' has guard!", + transition->get_name(), get_name() ) ); + check_ok = false; + } + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + // 15.3.14 Transition -> Constraint [3]: A fork segment must always target a state. + SX_FOR( const transition * const transition, get_outgoing_transitions() ) + { + const state* const target_vertex = dynamic_cast< const state* >( &transition->get_target() ); + if( !target_vertex ) + { + _defects.push_back( state_machine_defect( *this, + "Fork '%' has outgoing transition ('%') that hasn't a state as target! Target vertex is '%'.", get_name(), + transition->get_name(), transition->get_target().get_name()) ); + check_ok = false; + } + else + { + target_vertex->check( _defects ); + } + } + + // 2 outgoing transitions cannot enter the same region + std::set< const region* > target_regions; + SX_FOR( const transition * const transition, get_outgoing_transitions() ) + { + const state_machine_element* const target_region = transition->get_target().get_parent(); + const region* const l_region = dynamic_cast< const region* >( target_region ); + if( l_region ) + { + std::pair< std::set< const region* >::const_iterator, bool > result = target_regions.insert( l_region ); + if( !result.second ) + { + _defects.push_back( state_machine_defect( *this, + "Fork '%' has outgoing transition(s) that has(have) the same target region '%'.", get_name(), + l_region->get_name() ) ); + check_ok = false; + break; + } + } + } + const transition_kind transitions_kind = get_outgoing_transitions().front()->get_kind(); + SX_FOR( const transition * const transition, get_outgoing_transitions() ) + { + if( !(transitions_kind == transition->get_kind()) ) + { + _defects.push_back( state_machine_defect( *this, "Outgoing transitions of fork '%' have different kinds!", + get_name() ) ); + check_ok = false; + break; + } + } + return( check_ok ); +} + + +void fork_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void fork_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void fork_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void fork_impl::add_incoming_transition( transition& _incoming_transition ) +{ + SX_ASSERT( vertex_impl::get_incoming_transitions().size() < 1, "Fork cannot have more than 1 incoming transition!" ); + vertex_impl::add_incoming_transition( _incoming_transition ); +} + + +} diff --git a/libyasmine/source/guard_caller.cpp b/libyasmine/source/guard_caller.cpp index ec3784b..de1beb3 100644 --- a/libyasmine/source/guard_caller.cpp +++ b/libyasmine/source/guard_caller.cpp @@ -1,38 +1,38 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "guard_caller.hpp" - - -namespace sxy -{ - - -// cppcheck-suppress unusedFunction -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - SX_UNUSED_PARAMETER( _event ); - SX_UNUSED_PARAMETER( _event_collector ); - const bool enabled = _method(); - return( enabled ); -} - - -bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, - sxe::function _method ) -{ - SX_UNUSED_PARAMETER( _event ); - const bool enabled = _method( _event_collector ); - return( enabled ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "guard_caller.hpp" + + +namespace sxy +{ + + +// cppcheck-suppress unusedFunction +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event ); + SX_UNUSED_PARAMETER( _event_collector ); + const bool enabled = _method(); + return( enabled ); +} + + +bool guard_caller( const sxy::event& _event, sxy::event_collector& _event_collector, + sxe::function _method ) +{ + SX_UNUSED_PARAMETER( _event ); + const bool enabled = _method( _event_collector ); + return( enabled ); +} + + +} diff --git a/libyasmine/source/history_impl.cpp b/libyasmine/source/history_impl.cpp index c5ad6f7..8ee77cb 100644 --- a/libyasmine/source/history_impl.cpp +++ b/libyasmine/source/history_impl.cpp @@ -1,56 +1,56 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "history_impl.hpp" - -#include "essentials/base.hpp" - -#include "composite_state.hpp" - - -namespace sxy -{ - - -history_impl::history_impl( const std::string& _name ) - : state_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -history_impl::~history_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -raw_transitions history_impl::get_default_transitions() const -{ - return( vertex_impl::get_outgoing_transitions() ); -} - - -void history_impl::add_default_transition( transition& _default_transition ) -{ - vertex_impl::add_outgoing_transition( _default_transition ); -} - - -bool history_impl::check_if_state_was_active_before() const -{ - const composite_state& parent_state = get_parent_state(); - const bool state_was_active = parent_state.was_active(); - return( state_was_active ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "history_impl.hpp" + +#include "essentials/base.hpp" + +#include "composite_state.hpp" + + +namespace sxy +{ + + +history_impl::history_impl( const std::string& _name ) + : state_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +history_impl::~history_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +raw_transitions history_impl::get_default_transitions() const +{ + return( vertex_impl::get_outgoing_transitions() ); +} + + +void history_impl::add_default_transition( transition& _default_transition ) +{ + vertex_impl::add_outgoing_transition( _default_transition ); +} + + +bool history_impl::check_if_state_was_active_before() const +{ + const composite_state& parent_state = get_parent_state(); + const bool state_was_active = parent_state.was_active(); + return( state_was_active ); +} + + +} diff --git a/libyasmine/source/initial_pseudostate_impl.cpp b/libyasmine/source/initial_pseudostate_impl.cpp index 067f0f2..ca1e11a 100644 --- a/libyasmine/source/initial_pseudostate_impl.cpp +++ b/libyasmine/source/initial_pseudostate_impl.cpp @@ -1,118 +1,118 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "initial_pseudostate_impl.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "transition.hpp" -#include "state_machine_defect.hpp" - - -namespace sxy -{ - - -initial_pseudostate_impl::initial_pseudostate_impl( const std::string& _name ) - : region_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -initial_pseudostate_impl::~initial_pseudostate_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool initial_pseudostate_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.8 Pseudostate -> Constraint [1]: An initial vertex can have at most one outgoing transition. - if( get_outgoing_transitions().size() > 1 ) - { - _defects.push_back( state_machine_defect( *this, - "Initial pseudostate '%' has more than 1 outgoing transition! It has '%' transitions.", get_name(), - get_outgoing_transitions().size() ) ); - check_ok = false; - } - - // check exactly 1 outgoing transition - if( get_outgoing_transitions().size() != 1 ) - { - _defects.push_back( state_machine_defect( *this, - "Initial pseudostate '%' doesn't have exactly 1 outgoing transition! It has % transition(s).", get_name(), - get_outgoing_transitions().size() ) ); - check_ok = false; - } - - // 15.3.8 Pseudostate -> Constraint [9]: Outgoing transition from an initial vertex may have a behavior, but not a - // trigger or guard. - SX_FOR( const transition* const transition, get_outgoing_transitions() ) - { - if( transition->get_guard() ) - { - _defects.push_back( state_machine_defect( *this, - "Outgoing transition '%' of initial pseudostate '%' has a guard!", transition->get_name(), get_name() ) ); - check_ok = false; - } - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - - return( check_ok ); -} - - -void initial_pseudostate_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void initial_pseudostate_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void initial_pseudostate_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -transition* initial_pseudostate_impl::get_transition() const -{ - const raw_transitions& transitions = get_outgoing_transitions(); - SX_ASSERT( !transitions.empty(), "There are no transitions!" ); - return( transitions.front() ); -} - - -void initial_pseudostate_impl::add_incoming_transition( transition& _incoming_transition ) -{ - SX_UNUSED_PARAMETER( _incoming_transition ); - SX_ASSERT( vertex_impl::get_incoming_transitions().empty(), "Initial pseudostate cannot have incoming transitions!" ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "initial_pseudostate_impl.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "transition.hpp" +#include "state_machine_defect.hpp" + + +namespace sxy +{ + + +initial_pseudostate_impl::initial_pseudostate_impl( const std::string& _name ) + : region_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +initial_pseudostate_impl::~initial_pseudostate_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool initial_pseudostate_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.8 Pseudostate -> Constraint [1]: An initial vertex can have at most one outgoing transition. + if( get_outgoing_transitions().size() > 1 ) + { + _defects.push_back( state_machine_defect( *this, + "Initial pseudostate '%' has more than 1 outgoing transition! It has '%' transitions.", get_name(), + get_outgoing_transitions().size() ) ); + check_ok = false; + } + + // check exactly 1 outgoing transition + if( get_outgoing_transitions().size() != 1 ) + { + _defects.push_back( state_machine_defect( *this, + "Initial pseudostate '%' doesn't have exactly 1 outgoing transition! It has % transition(s).", get_name(), + get_outgoing_transitions().size() ) ); + check_ok = false; + } + + // 15.3.8 Pseudostate -> Constraint [9]: Outgoing transition from an initial vertex may have a behavior, but not a + // trigger or guard. + SX_FOR( const transition* const transition, get_outgoing_transitions() ) + { + if( transition->get_guard() ) + { + _defects.push_back( state_machine_defect( *this, + "Outgoing transition '%' of initial pseudostate '%' has a guard!", transition->get_name(), get_name() ) ); + check_ok = false; + } + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + + return( check_ok ); +} + + +void initial_pseudostate_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void initial_pseudostate_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void initial_pseudostate_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +transition* initial_pseudostate_impl::get_transition() const +{ + const raw_transitions& transitions = get_outgoing_transitions(); + SX_ASSERT( !transitions.empty(), "There are no transitions!" ); + return( transitions.front() ); +} + + +void initial_pseudostate_impl::add_incoming_transition( transition& _incoming_transition ) +{ + SX_UNUSED_PARAMETER( _incoming_transition ); + SX_ASSERT( vertex_impl::get_incoming_transitions().empty(), "Initial pseudostate cannot have incoming transitions!" ); +} + + +} diff --git a/libyasmine/source/join_impl.cpp b/libyasmine/source/join_impl.cpp index ab4c6b2..1e36445 100644 --- a/libyasmine/source/join_impl.cpp +++ b/libyasmine/source/join_impl.cpp @@ -1,172 +1,172 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "join_impl.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "complex_state.hpp" -#include "transition.hpp" -#include "check_if_all_incoming_transitions_sources_are_active_visitor.hpp" -#include "state_machine_defect.hpp" -#include "composite_state.hpp" - - -namespace sxy -{ - - -join_impl::join_impl( const std::string& _name ) - : region_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -join_impl::~join_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool join_impl::check_if_all_source_states_of_incoming_transitions_are_active() const -{ - bool all_incoming_transitions_srouces_are_active = true; - const raw_transitions& incoming_transitions = get_incoming_transitions(); - - SX_FOR( const transition* const transition, incoming_transitions ) - { - const vertex& source = transition->get_source(); - const complex_state* const l_complex_state = dynamic_cast< const complex_state* >( &source ); - SX_ASSERT( l_complex_state, "Incoming transitions into join must originate from complex_state!" ); - check_if_all_incoming_transitions_sources_are_active_visitor check_if_all_incoming_transitions_sources_are_active_visitor; - l_complex_state->accept_complex_state_visitor( check_if_all_incoming_transitions_sources_are_active_visitor ); - all_incoming_transitions_srouces_are_active = - check_if_all_incoming_transitions_sources_are_active_visitor.get_result(); - if( !all_incoming_transitions_srouces_are_active ) - { - break; - } - } - - return( all_incoming_transitions_srouces_are_active ); -} - - -void join_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void join_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void join_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -bool join_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.8 Pseudostate -> Constraint [3]: A join vertex must have at least two incoming transitions and exactly one - // outgoing transition. - if( get_incoming_transitions().size() < 2 ) - { - _defects.push_back( state_machine_defect( *this, - "Join has too few incoming transitions!" ) ); - check_ok = false; - } - - if( get_outgoing_transitions().size() != 1 ) - { - _defects.push_back( state_machine_defect( *this, - "Join does not have exactly 1 outgoing transition!" ) ); - check_ok = false; - } - - // 15.3.8 Pseudostate -> Constraint [4]: All transitions incoming a join vertex must originate in (math formula - // contains no "different") regions of an orthogonal state. - // 2 incoming transitions cannot leave the same region - std::set< const composite_state* > lca_composite_states; - const raw_transitions& transitions = get_incoming_transitions(); - - for(raw_transitions::const_iterator iterator_1 = transitions.begin(); iterator_1 < transitions.end(); ++iterator_1 ) - { - for(raw_transitions::const_iterator iterator_2 = iterator_1 + 1; iterator_2 < transitions.end(); ++iterator_2 ) - { - const vertex& source_1 = ( *iterator_1 )->get_source(); - const vertex& source_2 = ( *iterator_2 )->get_source(); - const composite_state* const lca = source_1.LCA_composite_state( source_2 ); - const region* const lca_region = source_1.LCA_region( source_2 ); - if( lca_region != lca->get_parent_region() ) - { - _defects.push_back( state_machine_defect( *this, - "Join '%' has incoming transitions that originate in same region of a composite state!", get_name() ) ); - check_ok = false; - break; - } - } - } - - // 15.3.14 Transition -> Constraint [2]: A join segment must not have guards or triggers. - SX_FOR( const transition* const transition, get_incoming_transitions() ) - { - if( transition->get_guard() ) - { - _defects.push_back( state_machine_defect( *this, "Join has guard!" ) ); - check_ok = false; - } - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - // 15.3.14 Transition -> Contraint [4]: A join segment must always originate from a state. - SX_FOR( const transition* const transition, get_incoming_transitions() ) - { - const state* const source_vertex = dynamic_cast< const state* >( &transition->get_source() ); - if( !source_vertex ) - { - _defects.push_back( state_machine_defect( *this, - "Join segment does not originate from a state!" ) ); - check_ok = false; - } - else - { - source_vertex->check( _defects ); - } - } - - return( check_ok ); -} - - -void join_impl::add_outgoing_transition( transition& _outgoing_transition ) -{ - SX_ASSERT( vertex_impl::get_outgoing_transitions().size() < 1, "Join cannot have more than 1 outgoing transition!" ); - vertex_impl::add_outgoing_transition( _outgoing_transition ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "join_impl.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "complex_state.hpp" +#include "transition.hpp" +#include "check_if_all_incoming_transitions_sources_are_active_visitor.hpp" +#include "state_machine_defect.hpp" +#include "composite_state.hpp" + + +namespace sxy +{ + + +join_impl::join_impl( const std::string& _name ) + : region_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +join_impl::~join_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool join_impl::check_if_all_source_states_of_incoming_transitions_are_active() const +{ + bool all_incoming_transitions_srouces_are_active = true; + const raw_transitions& incoming_transitions = get_incoming_transitions(); + + SX_FOR( const transition* const transition, incoming_transitions ) + { + const vertex& source = transition->get_source(); + const complex_state* const l_complex_state = dynamic_cast< const complex_state* >( &source ); + SX_ASSERT( l_complex_state, "Incoming transitions into join must originate from complex_state!" ); + check_if_all_incoming_transitions_sources_are_active_visitor check_if_all_incoming_transitions_sources_are_active_visitor; + l_complex_state->accept_complex_state_visitor( check_if_all_incoming_transitions_sources_are_active_visitor ); + all_incoming_transitions_srouces_are_active = + check_if_all_incoming_transitions_sources_are_active_visitor.get_result(); + if( !all_incoming_transitions_srouces_are_active ) + { + break; + } + } + + return( all_incoming_transitions_srouces_are_active ); +} + + +void join_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void join_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void join_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +bool join_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.8 Pseudostate -> Constraint [3]: A join vertex must have at least two incoming transitions and exactly one + // outgoing transition. + if( get_incoming_transitions().size() < 2 ) + { + _defects.push_back( state_machine_defect( *this, + "Join has too few incoming transitions!" ) ); + check_ok = false; + } + + if( get_outgoing_transitions().size() != 1 ) + { + _defects.push_back( state_machine_defect( *this, + "Join does not have exactly 1 outgoing transition!" ) ); + check_ok = false; + } + + // 15.3.8 Pseudostate -> Constraint [4]: All transitions incoming a join vertex must originate in (math formula + // contains no "different") regions of an orthogonal state. + // 2 incoming transitions cannot leave the same region + std::set< const composite_state* > lca_composite_states; + const raw_transitions& transitions = get_incoming_transitions(); + + for(raw_transitions::const_iterator iterator_1 = transitions.begin(); iterator_1 < transitions.end(); ++iterator_1 ) + { + for(raw_transitions::const_iterator iterator_2 = iterator_1 + 1; iterator_2 < transitions.end(); ++iterator_2 ) + { + const vertex& source_1 = ( *iterator_1 )->get_source(); + const vertex& source_2 = ( *iterator_2 )->get_source(); + const composite_state* const lca = source_1.LCA_composite_state( source_2 ); + const region* const lca_region = source_1.LCA_region( source_2 ); + if( lca_region != lca->get_parent_region() ) + { + _defects.push_back( state_machine_defect( *this, + "Join '%' has incoming transitions that originate in same region of a composite state!", get_name() ) ); + check_ok = false; + break; + } + } + } + + // 15.3.14 Transition -> Constraint [2]: A join segment must not have guards or triggers. + SX_FOR( const transition* const transition, get_incoming_transitions() ) + { + if( transition->get_guard() ) + { + _defects.push_back( state_machine_defect( *this, "Join has guard!" ) ); + check_ok = false; + } + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + // 15.3.14 Transition -> Contraint [4]: A join segment must always originate from a state. + SX_FOR( const transition* const transition, get_incoming_transitions() ) + { + const state* const source_vertex = dynamic_cast< const state* >( &transition->get_source() ); + if( !source_vertex ) + { + _defects.push_back( state_machine_defect( *this, + "Join segment does not originate from a state!" ) ); + check_ok = false; + } + else + { + source_vertex->check( _defects ); + } + } + + return( check_ok ); +} + + +void join_impl::add_outgoing_transition( transition& _outgoing_transition ) +{ + SX_ASSERT( vertex_impl::get_outgoing_transitions().size() < 1, "Join cannot have more than 1 outgoing transition!" ); + vertex_impl::add_outgoing_transition( _outgoing_transition ); +} + + +} diff --git a/libyasmine/source/junction_impl.cpp b/libyasmine/source/junction_impl.cpp index 6ee9f86..cede9e3 100644 --- a/libyasmine/source/junction_impl.cpp +++ b/libyasmine/source/junction_impl.cpp @@ -1,119 +1,119 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "junction_impl.hpp" - -#include "hermes/log.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "state_machine_defect.hpp" -#include "transition.hpp" - - -namespace sxy -{ - - -junction_impl::junction_impl( const std::string& _name ) - : region_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -junction_impl::~junction_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool junction_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.8 Pseudostate -> Constraint [7]: A junction vertex must have at least one incoming and one outgoing - // transition. - SX_LOG( hermes::log_level::LL_SPAM, "Checking if junction '%' has incoming transition(s).", get_name() ); - if( get_incoming_transitions().empty() ) - { - _defects.push_back( state_machine_defect( *this, - "Junction has too few incoming transitions!" ) ); - check_ok = false; - } - - SX_LOG( hermes::log_level::LL_SPAM, "Junction '%' has % incoming transition(s).", get_name(), - get_incoming_transitions().size() ); - SX_LOG( hermes::log_level::LL_SPAM, "Checking if junction '%' has outgoing transition(s).", get_name() ); - if( get_outgoing_transitions().empty() ) - { - _defects.push_back( state_machine_defect( *this, - "Junction '%' has no outgoing transitions!", get_name() ) ); - check_ok = false; - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Junction '%' has % outgoing transition(s).", get_name(), - get_incoming_transitions().size() ); - SX_LOG( hermes::log_level::LL_SPAM, "Checking if junction '%' has more than one outgoing transition with no guard.", - get_name() ); - sxe::uint8_t number_of_transitions_with_no_guards = 0; - - SX_FOR( const transition* const transition, get_outgoing_transitions() ) - { - if( !transition->get_guard() ) - { - ++number_of_transitions_with_no_guards; - } - } - - if( number_of_transitions_with_no_guards > 1 ) - { - _defects.push_back( state_machine_defect( *this, - "Junction '%' has more than one outgoing transition with no guard! It has '%' transitions with no guards.", - get_name(), number_of_transitions_with_no_guards ) ); - check_ok = false; - } - - SX_LOG( hermes::log_level::LL_SPAM, "Junction '%' has % outgoing transition(s) with no guard.", get_name(), - number_of_transitions_with_no_guards ); - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - return( check_ok ); -} - - -void junction_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void junction_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void junction_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "junction_impl.hpp" + +#include "hermes/log.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "state_machine_defect.hpp" +#include "transition.hpp" + + +namespace sxy +{ + + +junction_impl::junction_impl( const std::string& _name ) + : region_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +junction_impl::~junction_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool junction_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.8 Pseudostate -> Constraint [7]: A junction vertex must have at least one incoming and one outgoing + // transition. + SX_LOG( hermes::log_level::LL_SPAM, "Checking if junction '%' has incoming transition(s).", get_name() ); + if( get_incoming_transitions().empty() ) + { + _defects.push_back( state_machine_defect( *this, + "Junction has too few incoming transitions!" ) ); + check_ok = false; + } + + SX_LOG( hermes::log_level::LL_SPAM, "Junction '%' has % incoming transition(s).", get_name(), + get_incoming_transitions().size() ); + SX_LOG( hermes::log_level::LL_SPAM, "Checking if junction '%' has outgoing transition(s).", get_name() ); + if( get_outgoing_transitions().empty() ) + { + _defects.push_back( state_machine_defect( *this, + "Junction '%' has no outgoing transitions!", get_name() ) ); + check_ok = false; + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Junction '%' has % outgoing transition(s).", get_name(), + get_incoming_transitions().size() ); + SX_LOG( hermes::log_level::LL_SPAM, "Checking if junction '%' has more than one outgoing transition with no guard.", + get_name() ); + sxe::uint8_t number_of_transitions_with_no_guards = 0; + + SX_FOR( const transition* const transition, get_outgoing_transitions() ) + { + if( !transition->get_guard() ) + { + ++number_of_transitions_with_no_guards; + } + } + + if( number_of_transitions_with_no_guards > 1 ) + { + _defects.push_back( state_machine_defect( *this, + "Junction '%' has more than one outgoing transition with no guard! It has '%' transitions with no guards.", + get_name(), number_of_transitions_with_no_guards ) ); + check_ok = false; + } + + SX_LOG( hermes::log_level::LL_SPAM, "Junction '%' has % outgoing transition(s) with no guard.", get_name(), + number_of_transitions_with_no_guards ); + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + return( check_ok ); +} + + +void junction_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void junction_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void junction_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +} diff --git a/libyasmine/source/pseudostate_impl.cpp b/libyasmine/source/pseudostate_impl.cpp index 79100bd..ab60c1a 100644 --- a/libyasmine/source/pseudostate_impl.cpp +++ b/libyasmine/source/pseudostate_impl.cpp @@ -1,57 +1,57 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "pseudostate_impl.hpp" - -#include "essentials/base.hpp" - -#include "region.hpp" -#include "transition.hpp" -#include "state_machine_defect.hpp" -#include "completion_event.hpp" - - -namespace sxy -{ - - -pseudostate_impl::pseudostate_impl( const std::string& _name ) - : vertex_impl( _name ) -{ - // Nothing to do... -} - - -pseudostate_impl::~pseudostate_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool pseudostate_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - SX_FOR( const transition* const outgoing_transition, get_outgoing_transitions() ) - { - 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() ) ); - check_ok = false; - } - } - - return( check_ok ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "pseudostate_impl.hpp" + +#include "essentials/base.hpp" + +#include "region.hpp" +#include "transition.hpp" +#include "state_machine_defect.hpp" +#include "completion_event.hpp" + + +namespace sxy +{ + + +pseudostate_impl::pseudostate_impl( const std::string& _name ) + : vertex_impl( _name ) +{ + // Nothing to do... +} + + +pseudostate_impl::~pseudostate_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool pseudostate_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + SX_FOR( const transition* const outgoing_transition, get_outgoing_transitions() ) + { + 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() ) ); + check_ok = false; + } + } + + return( check_ok ); +} + + +} diff --git a/libyasmine/source/region_impl.cpp b/libyasmine/source/region_impl.cpp index 855d7ec..4027c7f 100644 --- a/libyasmine/source/region_impl.cpp +++ b/libyasmine/source/region_impl.cpp @@ -1,545 +1,546 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "region_impl.hpp" - -#include "y_assert.hpp" -#include "state.hpp" -#include "initial_pseudostate_impl.hpp" -#include "choice_impl.hpp" -#include "fork_impl.hpp" -#include "join_impl.hpp" -#include "junction_impl.hpp" -#include "terminate_pseudostate_impl.hpp" -#include "simple_state_impl.hpp" -#include "composite_state_impl.hpp" -#include "final_state_impl.hpp" -#include "behavior_impl.hpp" -#include "async_simple_state_impl.hpp" -#include "async_behavior.hpp" - -#include "state_machine_defect.hpp" -#include "uri.hpp" - - - -namespace sxy -{ - - -region_impl::region_impl( const std::string& _name ) - : state_machine_element_impl( _name ), - parent_state_(), - states_(), - pseudostates_(), - initial_pseudostate_( SX_NULLPTR ), - active_state_( SX_NULLPTR ), - last_active_state_( SX_NULLPTR ) -{ - // Nothing to do... -} - - -region_impl::~region_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void region_impl::set_parent_state( composite_state* const _composite_state ) -{ - parent_state_ = _composite_state; -} - - -raw_const_states region_impl::get_states() const -{ - raw_const_states states; - states.reserve( states_.size() ); - - SX_FOR( const state_uptr& state, states_ ) - { - states.push_back( state.get() ); - } - - return( states ); -} - - -const composite_state& region_impl::get_parent_state() const -{ - return( *parent_state_ ); -} - - -composite_state& region_impl::get_parent_state() -{ - return( *parent_state_ ); -} - - -vertex* region_impl::get_vertex( const std::string& _vertex_name ) const -{ - vertex* found_vertex = SX_NULLPTR; - - SX_FOR( const pseudostate_uptr& pseudostate, pseudostates_ ) - { - if( _vertex_name == pseudostate.get()->get_name() ) - { - found_vertex = pseudostate.get(); - break; - } - } - - SX_FOR( const state_uptr& state, states_ ) - { - if( _vertex_name == state.get()->get_name() ) - { - found_vertex = state.get(); - break; - } - } - - return( found_vertex ); -} - - -size_t region_impl::get_pseudostate_count() const -{ - return( pseudostates_.size() ); -} - - -vertex* region_impl::get_pseudostate( const std::string& _name ) const -{ - vertex* found_vertex = SX_NULLPTR; - - SX_FOR( const pseudostate_uptr& pseudostate, pseudostates_ ) - { - if( _name == pseudostate->get_name() ) - { - found_vertex = pseudostate.get(); - break; - } - } - - return( found_vertex ); -} - - -raw_const_pseudostates region_impl::get_pseudostates() const -{ - raw_const_pseudostates pseudostates; - pseudostates.reserve( pseudostates_.size() ); - - SX_FOR( const pseudostate_uptr& pseudostate, pseudostates_ ) - { - pseudostates.push_back( pseudostate.get() ); - } - - return( pseudostates ); -} - - -initial_pseudostate* region_impl::get_initial_pseudostate() const -{ - return( initial_pseudostate_ ); -} - - -size_t region_impl::get_state_count() const -{ - return( states_.size() ); -} - - -state* region_impl::get_state( const std::string& _name ) const -{ - state* found_vertex = SX_NULLPTR; - - SX_FOR( const state_uptr& state, states_ ) - { - const std::string name_of_state = state->get_name(); - if( _name == state->get_name() ) - { - found_vertex = state.get(); - break; - } - } - - return( found_vertex ); -} - - -const state* region_impl::get_active_state() const -{ - return( active_state_ ); -} - - -state* region_impl::get_active_state() -{ - return( active_state_ ); -} - - -void region_impl::set_active_state( state* const _active_state ) -{ - active_state_ = _active_state; - - if( _active_state ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Set state '%' as 'active state' in region '%'.", _active_state->get_name(), - get_name() ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Set NO active state in region '%'.", get_name() ); - } -} - - -void region_impl::set_state_was_active( state* const _active_state ) -{ - last_active_state_ = _active_state; - SX_LOG( hermes::log_level::LL_SPAM, "Set state '%' as 'was active state' in region '%'.", _active_state->get_name(), - get_name() ); -} - - -const state* region_impl::get_last_active_state() const -{ - return( last_active_state_ ); -} - - -state* region_impl::get_last_active_state() -{ - return( last_active_state_ ); -} - - -initial_pseudostate& region_impl::add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) -{ - Y_ASSERT( !initial_pseudostate_, "There is already an initial pseudostate in the region." ); - _initial_state->set_parent_region( this ); - initial_pseudostate_ = _initial_state.get(); - pseudostates_.push_back( sxe::move( _initial_state ) ); - initial_pseudostate& new_initial_state = *initial_pseudostate_; - SX_LOG( hermes::log_level::LL_TRACE, "Initial pseudostate '%' was added to the region '%'.", _initial_state->get_name(), - get_name() ); - return( new_initial_state ); -} - - -initial_pseudostate& region_impl::add_initial_pseudostate( const std::string& _initial_pseudostate_name ) -{ - Y_ASSERT( !initial_pseudostate_, "There is already an initial pseudostate in the region." ); - sxe::SX_UNIQUE_PTR< sxy::initial_pseudostate_impl > initial_state = - SX_MAKE_UNIQUE< sxy::initial_pseudostate_impl >( _initial_pseudostate_name ); - initial_state->set_parent_region( this ); - initial_pseudostate_ = initial_state.get(); - pseudostates_.push_back( sxe::move( initial_state ) ); - initial_pseudostate& new_initial_state = *initial_pseudostate_; - SX_LOG( hermes::log_level::LL_TRACE, "Initial pseudostate '%' was added to the region '%'.", _initial_pseudostate_name, - get_name() ); - return( new_initial_state ); -} - - -state& region_impl::add_state( state_uptr _state ) -{ - _state->set_parent_region( this ); - state& state = *_state; - states_.push_back( sxe::move( _state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "State '%' was added to the region '%'.", _state->get_name(), get_name() ); - return( state ); -} - - -simple_state& region_impl::add_simple_state( const std::string& _simple_state_name, const behavior_function& _behavior, - const behavior_function& _entry_behavior, const behavior_function& _exit_behavior ) -{ - 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 ); - sxe::SX_UNIQUE_PTR< sxy::simple_state_impl > simple_state = SX_MAKE_UNIQUE< sxy::simple_state_impl >( _simple_state_name, - sxe::move( behavior ), sxe::move( entry_behavior ), sxe::move( exit_behavior ) ); - simple_state->set_parent_region( this ); - simple_state_impl& state = *simple_state; - states_.push_back( sxe::move( simple_state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Simple state '%' was added to the region '%'.", _simple_state_name, get_name() ); - return( state ); -} - - -simple_state& region_impl::add_simple_state( const std::string& _simple_state_name, const event_ids& _deferred_events, - const behavior_function& _behavior, const behavior_function& _entry_behavior, - const behavior_function& _exit_behavior, event_sptr _error_event ) -{ - sxe::SX_UNIQUE_PTR< sxy::simple_state_impl > simple_state = - SX_MAKE_UNIQUE< sxy::simple_state_impl >( _simple_state_name, - ( !_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; - states_.push_back( sxe::move( simple_state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Simple state '%' was added to the region '%'.", _simple_state_name, get_name() ); - return( state ); -} - - -simple_state& region_impl::add_async_simple_state( const std::string& _async_simple_state_name, - const event_ids& _deferred_events, async_behavior_uptr _do_action, const behavior_function& _entry_behavior, - const behavior_function& _exit_behavior, event_sptr _error_event ) -{ - sxe::SX_UNIQUE_PTR< sxy::async_simple_state_impl > simple_state = SX_MAKE_UNIQUE< sxy::async_simple_state_impl >( - _async_simple_state_name, sxe::move( _do_action ), - ( !_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; - states_.push_back( sxe::move( simple_state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Asynchronous simple state '%' was added to the region '%'.", _async_simple_state_name, - get_name() ); - return( state ); -} - - -composite_state& region_impl::add_composite_state( const std::string& _composite_state_name, - const behavior_function& _entry_action, const behavior_function& _exit_action ) -{ - sxe::SX_UNIQUE_PTR< sxy::composite_state_impl > composite_state = - SX_MAKE_UNIQUE< sxy::composite_state_impl >( _composite_state_name, - ( !_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( sxe::move( composite_state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Composite state '%' was added to the region '%'.", _composite_state_name, get_name() ); - return( state ); -} - - -composite_state& region_impl::add_composite_state( const std::string& _composite_state_name, - const event_ids& _deferred_events, const behavior_function& _entry_action, const behavior_function& _exit_action ) -{ - sxe::SX_UNIQUE_PTR< sxy::composite_state_impl > composite_state = - SX_MAKE_UNIQUE< sxy::composite_state_impl >( _composite_state_name, - ( !_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( sxe::move( composite_state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Composite state '%' was added to the region '%'.", _composite_state_name, get_name() ); - return( state ); -} - - -final_state& region_impl::add_final_state( const std::string& _final_state_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::final_state_impl > final_state = SX_MAKE_UNIQUE< sxy::final_state_impl >( _final_state_name ); - final_state->set_parent_region( this ); - final_state_impl& state = *final_state; - states_.push_back( sxe::move( final_state ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Final state '%' was added to the region '%'.", _final_state_name, get_name() ); - return( state ); -} - - -choice& region_impl::add_choice( choice_uptr _choice ) -{ - _choice->set_parent_region( this ); - choice& choice = *_choice.get(); - pseudostates_.push_back( sxe::move( _choice ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Choice '%' was added to the region '%'.", _choice->get_name(), get_name() ); - return( choice ); -} - - -choice& region_impl::add_choice( const std::string& _choice_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::choice_impl > choice = SX_MAKE_UNIQUE< sxy::choice_impl >( _choice_name ); - choice->set_parent_region( this ); - choice_impl& new_choice = *choice.get(); - pseudostates_.push_back( sxe::move( choice ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Choice '%' was added to the region '%'.", _choice_name, get_name() ); - return( new_choice ); -} - - -fork& region_impl::add_fork( fork_uptr _fork ) -{ - _fork->set_parent_region( this ); - fork& fork = *_fork.get(); - pseudostates_.push_back( sxe::move( _fork ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Fork '%' was added to the region '%'.", _fork->get_name(), get_name() ); - return( fork ); -} - - -fork& region_impl::add_fork( const std::string& _fork_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::fork_impl > fork = SX_MAKE_UNIQUE< sxy::fork_impl >( _fork_name ); - fork->set_parent_region( this ); - fork_impl& new_fork = *fork.get(); - pseudostates_.push_back( sxe::move( fork ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Fork '%' was added to the region '%'.", _fork_name, get_name() ); - return( new_fork ); -} - - -join& region_impl::add_join( join_uptr _join ) -{ - _join->set_parent_region( this ); - join& join = *_join.get(); - pseudostates_.push_back( sxe::move( _join ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Join '%' was added to the region '%'.", _join->get_name(), get_name() ); - return( join ); -} - - -join& region_impl::add_join( const std::string& _join_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::join_impl > join = SX_MAKE_UNIQUE< sxy::join_impl >( _join_name ); - join->set_parent_region( this ); - join_impl& new_join = *join.get(); - pseudostates_.push_back( sxe::move( join ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Join '%' was added to the region '%'.", _join_name, get_name() ); - return( new_join ); -} - - -junction& region_impl::add_junction( junction_uptr _junction ) -{ - _junction->set_parent_region( this ); - junction& junction = *_junction.get(); - pseudostates_.push_back( sxe::move( _junction ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Junction '%' was added to the region '%'.", _junction->get_name(), get_name() ); - return( junction ); -} - - -junction& region_impl::add_junction( const std::string& _junction_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::junction_impl > junction = SX_MAKE_UNIQUE< sxy::junction_impl >( _junction_name ); - junction->set_parent_region( this ); - junction_impl& new_junction = *junction.get(); - pseudostates_.push_back( sxe::move( junction ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Junction '%' was added to the region '%'.", _junction_name, get_name() ); - return( new_junction ); -} - -terminate_pseudostate& region_impl::add_terminate_pseudostate( terminate_pseudostate_uptr _terminate_pseudostate ) -{ - _terminate_pseudostate->set_parent_region( this ); - terminate_pseudostate& terminate_pseudostate = *_terminate_pseudostate.get(); - pseudostates_.push_back( sxe::move( _terminate_pseudostate ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Terminate pseudostate '%' was added to the region '%'.", - _terminate_pseudostate->get_name(), get_name() ); - return( terminate_pseudostate ); -} - - -terminate_pseudostate& region_impl::add_terminate_pseudostate( const std::string& _terminate_pseudostate_name ) -{ - sxe::SX_UNIQUE_PTR< sxy::terminate_pseudostate_impl > terminate_pseudostate = - SX_MAKE_UNIQUE< sxy::terminate_pseudostate_impl >( _terminate_pseudostate_name ); - terminate_pseudostate->set_parent_region( this ); - terminate_pseudostate_impl& new_terminate_pseudostate = *terminate_pseudostate.get(); - pseudostates_.push_back( sxe::move( terminate_pseudostate ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Terminate pseudostate '%' was added to the region '%'.", - _terminate_pseudostate_name, get_name() ); - return( new_terminate_pseudostate ); -} - - -uri region_impl::get_uri() const -{ - uri uri( get_name() ); - add_ancestor_uri( uri ); - return( uri ); -} - - -void region_impl::add_ancestor_uri( uri& _uri ) const -{ - const composite_state& parent = get_parent_state(); - _uri.push_front( parent.get_name() ); - parent.add_ancestor_uri( _uri ); -} - - -bool region_impl::is_active_state_final() const -{ - bool active_state_is_final_state = false; - const final_state* const l_final_state = dynamic_cast< const final_state* >( active_state_ ); - if( l_final_state != SX_NULLPTR ) - { - active_state_is_final_state = true; - } - - return( active_state_is_final_state ); -} - - -bool region_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // 15.3.10 Region -> Constraint [1]: A region can have at most one initial vertex. - // Enforced by design. - // 15.3.10 Region -> Constraint [2]: A region can have at most one deep history vertex. -> deep history belongs to - // composite state - // 15.3.10 Region -> Constraint [3]: A region can have at most one shallow history vertex. -> shallow history belongs - // to composite state - // 15.3.10 Region -> Constraint [4]: If a Region is owned by a StateMachine, then it cannot also be owned by a State - // and vice versa. - // Enforced by design. - // 15.3.10 Region -> Constraint [5]: The redefinition context of a region is the nearest containing statemachine. - // Does not apply. - // region must not be empty - if( ( 0 == get_state_count() ) && ( 0 == get_pseudostate_count() ) ) - { - _defects.push_back( state_machine_defect( *this, "Region '%' is empty!", get_name() ) ); - check_ok = false; - } - - SX_FOR( const state* const state, get_states() ) - { - if( !state->check( _defects ) ) - { - check_ok = false; - } - } - - SX_FOR( const pseudostate* const pseudostate, get_pseudostates() ) - { - if( !pseudostate->check( _defects ) ) - { - check_ok = false; - } - } - - return( check_ok ); -} - - -const state_machine_element* region_impl::get_parent() const -{ - return( parent_state_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "region_impl.hpp" + +#include "essentials/uri.hpp" + +#include "y_assert.hpp" +#include "state.hpp" +#include "initial_pseudostate_impl.hpp" +#include "choice_impl.hpp" +#include "fork_impl.hpp" +#include "join_impl.hpp" +#include "junction_impl.hpp" +#include "terminate_pseudostate_impl.hpp" +#include "simple_state_impl.hpp" +#include "composite_state_impl.hpp" +#include "final_state_impl.hpp" +#include "behavior_impl.hpp" +#include "async_simple_state_impl.hpp" +#include "async_behavior.hpp" + +#include "state_machine_defect.hpp" + + + +namespace sxy +{ + + +region_impl::region_impl( const std::string& _name ) + : state_machine_element_impl( _name ), + parent_state_(), + states_(), + pseudostates_(), + initial_pseudostate_( SX_NULLPTR ), + active_state_( SX_NULLPTR ), + last_active_state_( SX_NULLPTR ) +{ + // Nothing to do... +} + + +region_impl::~region_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void region_impl::set_parent_state( composite_state* const _composite_state ) +{ + parent_state_ = _composite_state; +} + + +raw_const_states region_impl::get_states() const +{ + raw_const_states states; + states.reserve( states_.size() ); + + SX_FOR( const state_uptr& state, states_ ) + { + states.push_back( state.get() ); + } + + return( states ); +} + + +const composite_state& region_impl::get_parent_state() const +{ + return( *parent_state_ ); +} + + +composite_state& region_impl::get_parent_state() +{ + return( *parent_state_ ); +} + + +vertex* region_impl::get_vertex( const std::string& _vertex_name ) const +{ + vertex* found_vertex = SX_NULLPTR; + + SX_FOR( const pseudostate_uptr& pseudostate, pseudostates_ ) + { + if( _vertex_name == pseudostate.get()->get_name() ) + { + found_vertex = pseudostate.get(); + break; + } + } + + SX_FOR( const state_uptr& state, states_ ) + { + if( _vertex_name == state.get()->get_name() ) + { + found_vertex = state.get(); + break; + } + } + + return( found_vertex ); +} + + +size_t region_impl::get_pseudostate_count() const +{ + return( pseudostates_.size() ); +} + + +vertex* region_impl::get_pseudostate( const std::string& _name ) const +{ + vertex* found_vertex = SX_NULLPTR; + + SX_FOR( const pseudostate_uptr& pseudostate, pseudostates_ ) + { + if( _name == pseudostate->get_name() ) + { + found_vertex = pseudostate.get(); + break; + } + } + + return( found_vertex ); +} + + +raw_const_pseudostates region_impl::get_pseudostates() const +{ + raw_const_pseudostates pseudostates; + pseudostates.reserve( pseudostates_.size() ); + + SX_FOR( const pseudostate_uptr& pseudostate, pseudostates_ ) + { + pseudostates.push_back( pseudostate.get() ); + } + + return( pseudostates ); +} + + +initial_pseudostate* region_impl::get_initial_pseudostate() const +{ + return( initial_pseudostate_ ); +} + + +size_t region_impl::get_state_count() const +{ + return( states_.size() ); +} + + +state* region_impl::get_state( const std::string& _name ) const +{ + state* found_vertex = SX_NULLPTR; + + SX_FOR( const state_uptr& state, states_ ) + { + const std::string name_of_state = state->get_name(); + if( _name == state->get_name() ) + { + found_vertex = state.get(); + break; + } + } + + return( found_vertex ); +} + + +const state* region_impl::get_active_state() const +{ + return( active_state_ ); +} + + +state* region_impl::get_active_state() +{ + return( active_state_ ); +} + + +void region_impl::set_active_state( state* const _active_state ) +{ + active_state_ = _active_state; + + if( _active_state ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Set state '%' as 'active state' in region '%'.", _active_state->get_name(), + get_name() ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Set NO active state in region '%'.", get_name() ); + } +} + + +void region_impl::set_state_was_active( state* const _active_state ) +{ + last_active_state_ = _active_state; + SX_LOG( hermes::log_level::LL_SPAM, "Set state '%' as 'was active state' in region '%'.", _active_state->get_name(), + get_name() ); +} + + +const state* region_impl::get_last_active_state() const +{ + return( last_active_state_ ); +} + + +state* region_impl::get_last_active_state() +{ + return( last_active_state_ ); +} + + +initial_pseudostate& region_impl::add_initial_pseudostate( initial_pseudostate_uptr _initial_state ) +{ + Y_ASSERT( !initial_pseudostate_, "There is already an initial pseudostate in the region." ); + _initial_state->set_parent_region( this ); + initial_pseudostate_ = _initial_state.get(); + pseudostates_.push_back( sxe::move( _initial_state ) ); + initial_pseudostate& new_initial_state = *initial_pseudostate_; + SX_LOG( hermes::log_level::LL_TRACE, "Initial pseudostate '%' was added to the region '%'.", _initial_state->get_name(), + get_name() ); + return( new_initial_state ); +} + + +initial_pseudostate& region_impl::add_initial_pseudostate( const std::string& _initial_pseudostate_name ) +{ + Y_ASSERT( !initial_pseudostate_, "There is already an initial pseudostate in the region." ); + sxe::SX_UNIQUE_PTR< sxy::initial_pseudostate_impl > initial_state = + SX_MAKE_UNIQUE< sxy::initial_pseudostate_impl >( _initial_pseudostate_name ); + initial_state->set_parent_region( this ); + initial_pseudostate_ = initial_state.get(); + pseudostates_.push_back( sxe::move( initial_state ) ); + initial_pseudostate& new_initial_state = *initial_pseudostate_; + SX_LOG( hermes::log_level::LL_TRACE, "Initial pseudostate '%' was added to the region '%'.", _initial_pseudostate_name, + get_name() ); + return( new_initial_state ); +} + + +state& region_impl::add_state( state_uptr _state ) +{ + _state->set_parent_region( this ); + state& state = *_state; + states_.push_back( sxe::move( _state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "State '%' was added to the region '%'.", _state->get_name(), get_name() ); + return( state ); +} + + +simple_state& region_impl::add_simple_state( const std::string& _simple_state_name, const behavior_function& _behavior, + const behavior_function& _entry_behavior, const behavior_function& _exit_behavior ) +{ + 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 ); + sxe::SX_UNIQUE_PTR< sxy::simple_state_impl > simple_state = SX_MAKE_UNIQUE< sxy::simple_state_impl >( _simple_state_name, + sxe::move( behavior ), sxe::move( entry_behavior ), sxe::move( exit_behavior ) ); + simple_state->set_parent_region( this ); + simple_state_impl& state = *simple_state; + states_.push_back( sxe::move( simple_state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Simple state '%' was added to the region '%'.", _simple_state_name, get_name() ); + return( state ); +} + + +simple_state& region_impl::add_simple_state( const std::string& _simple_state_name, const event_ids& _deferred_events, + const behavior_function& _behavior, const behavior_function& _entry_behavior, + const behavior_function& _exit_behavior, event_sptr _error_event ) +{ + sxe::SX_UNIQUE_PTR< sxy::simple_state_impl > simple_state = + SX_MAKE_UNIQUE< sxy::simple_state_impl >( _simple_state_name, + ( !_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; + states_.push_back( sxe::move( simple_state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Simple state '%' was added to the region '%'.", _simple_state_name, get_name() ); + return( state ); +} + + +simple_state& region_impl::add_async_simple_state( const std::string& _async_simple_state_name, + const event_ids& _deferred_events, async_behavior_uptr _do_action, const behavior_function& _entry_behavior, + const behavior_function& _exit_behavior, event_sptr _error_event ) +{ + sxe::SX_UNIQUE_PTR< sxy::async_simple_state_impl > simple_state = SX_MAKE_UNIQUE< sxy::async_simple_state_impl >( + _async_simple_state_name, sxe::move( _do_action ), + ( !_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; + states_.push_back( sxe::move( simple_state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Asynchronous simple state '%' was added to the region '%'.", _async_simple_state_name, + get_name() ); + return( state ); +} + + +composite_state& region_impl::add_composite_state( const std::string& _composite_state_name, + const behavior_function& _entry_action, const behavior_function& _exit_action ) +{ + sxe::SX_UNIQUE_PTR< sxy::composite_state_impl > composite_state = + SX_MAKE_UNIQUE< sxy::composite_state_impl >( _composite_state_name, + ( !_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( sxe::move( composite_state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Composite state '%' was added to the region '%'.", _composite_state_name, get_name() ); + return( state ); +} + + +composite_state& region_impl::add_composite_state( const std::string& _composite_state_name, + const event_ids& _deferred_events, const behavior_function& _entry_action, const behavior_function& _exit_action ) +{ + sxe::SX_UNIQUE_PTR< sxy::composite_state_impl > composite_state = + SX_MAKE_UNIQUE< sxy::composite_state_impl >( _composite_state_name, + ( !_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( sxe::move( composite_state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Composite state '%' was added to the region '%'.", _composite_state_name, get_name() ); + return( state ); +} + + +final_state& region_impl::add_final_state( const std::string& _final_state_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::final_state_impl > final_state = SX_MAKE_UNIQUE< sxy::final_state_impl >( _final_state_name ); + final_state->set_parent_region( this ); + final_state_impl& state = *final_state; + states_.push_back( sxe::move( final_state ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Final state '%' was added to the region '%'.", _final_state_name, get_name() ); + return( state ); +} + + +choice& region_impl::add_choice( choice_uptr _choice ) +{ + _choice->set_parent_region( this ); + choice& choice = *_choice.get(); + pseudostates_.push_back( sxe::move( _choice ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Choice '%' was added to the region '%'.", _choice->get_name(), get_name() ); + return( choice ); +} + + +choice& region_impl::add_choice( const std::string& _choice_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::choice_impl > choice = SX_MAKE_UNIQUE< sxy::choice_impl >( _choice_name ); + choice->set_parent_region( this ); + choice_impl& new_choice = *choice.get(); + pseudostates_.push_back( sxe::move( choice ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Choice '%' was added to the region '%'.", _choice_name, get_name() ); + return( new_choice ); +} + + +fork& region_impl::add_fork( fork_uptr _fork ) +{ + _fork->set_parent_region( this ); + fork& fork = *_fork.get(); + pseudostates_.push_back( sxe::move( _fork ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Fork '%' was added to the region '%'.", _fork->get_name(), get_name() ); + return( fork ); +} + + +fork& region_impl::add_fork( const std::string& _fork_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::fork_impl > fork = SX_MAKE_UNIQUE< sxy::fork_impl >( _fork_name ); + fork->set_parent_region( this ); + fork_impl& new_fork = *fork.get(); + pseudostates_.push_back( sxe::move( fork ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Fork '%' was added to the region '%'.", _fork_name, get_name() ); + return( new_fork ); +} + + +join& region_impl::add_join( join_uptr _join ) +{ + _join->set_parent_region( this ); + join& join = *_join.get(); + pseudostates_.push_back( sxe::move( _join ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Join '%' was added to the region '%'.", _join->get_name(), get_name() ); + return( join ); +} + + +join& region_impl::add_join( const std::string& _join_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::join_impl > join = SX_MAKE_UNIQUE< sxy::join_impl >( _join_name ); + join->set_parent_region( this ); + join_impl& new_join = *join.get(); + pseudostates_.push_back( sxe::move( join ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Join '%' was added to the region '%'.", _join_name, get_name() ); + return( new_join ); +} + + +junction& region_impl::add_junction( junction_uptr _junction ) +{ + _junction->set_parent_region( this ); + junction& junction = *_junction.get(); + pseudostates_.push_back( sxe::move( _junction ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Junction '%' was added to the region '%'.", _junction->get_name(), get_name() ); + return( junction ); +} + + +junction& region_impl::add_junction( const std::string& _junction_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::junction_impl > junction = SX_MAKE_UNIQUE< sxy::junction_impl >( _junction_name ); + junction->set_parent_region( this ); + junction_impl& new_junction = *junction.get(); + pseudostates_.push_back( sxe::move( junction ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Junction '%' was added to the region '%'.", _junction_name, get_name() ); + return( new_junction ); +} + +terminate_pseudostate& region_impl::add_terminate_pseudostate( terminate_pseudostate_uptr _terminate_pseudostate ) +{ + _terminate_pseudostate->set_parent_region( this ); + terminate_pseudostate& terminate_pseudostate = *_terminate_pseudostate.get(); + pseudostates_.push_back( sxe::move( _terminate_pseudostate ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Terminate pseudostate '%' was added to the region '%'.", + _terminate_pseudostate->get_name(), get_name() ); + return( terminate_pseudostate ); +} + + +terminate_pseudostate& region_impl::add_terminate_pseudostate( const std::string& _terminate_pseudostate_name ) +{ + sxe::SX_UNIQUE_PTR< sxy::terminate_pseudostate_impl > terminate_pseudostate = + SX_MAKE_UNIQUE< sxy::terminate_pseudostate_impl >( _terminate_pseudostate_name ); + terminate_pseudostate->set_parent_region( this ); + terminate_pseudostate_impl& new_terminate_pseudostate = *terminate_pseudostate.get(); + pseudostates_.push_back( sxe::move( terminate_pseudostate ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Terminate pseudostate '%' was added to the region '%'.", + _terminate_pseudostate_name, get_name() ); + return( new_terminate_pseudostate ); +} + + +sxe::uri region_impl::get_uri() const +{ + sxe::uri uri( get_name() ); + add_ancestor_uri( uri ); + return( uri ); +} + + +void region_impl::add_ancestor_uri( sxe::uri& _uri ) const +{ + const composite_state& parent = get_parent_state(); + _uri.push_front( parent.get_name() ); + parent.add_ancestor_uri( _uri ); +} + + +bool region_impl::is_active_state_final() const +{ + bool active_state_is_final_state = false; + const final_state* const l_final_state = dynamic_cast< const final_state* >( active_state_ ); + if( l_final_state != SX_NULLPTR ) + { + active_state_is_final_state = true; + } + + return( active_state_is_final_state ); +} + + +bool region_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // 15.3.10 Region -> Constraint [1]: A region can have at most one initial vertex. + // Enforced by design. + // 15.3.10 Region -> Constraint [2]: A region can have at most one deep history vertex. -> deep history belongs to + // composite state + // 15.3.10 Region -> Constraint [3]: A region can have at most one shallow history vertex. -> shallow history belongs + // to composite state + // 15.3.10 Region -> Constraint [4]: If a Region is owned by a StateMachine, then it cannot also be owned by a State + // and vice versa. + // Enforced by design. + // 15.3.10 Region -> Constraint [5]: The redefinition context of a region is the nearest containing statemachine. + // Does not apply. + // region must not be empty + if( ( 0 == get_state_count() ) && ( 0 == get_pseudostate_count() ) ) + { + _defects.push_back( state_machine_defect( *this, "Region '%' is empty!", get_name() ) ); + check_ok = false; + } + + SX_FOR( const state* const state, get_states() ) + { + if( !state->check( _defects ) ) + { + check_ok = false; + } + } + + SX_FOR( const pseudostate* const pseudostate, get_pseudostates() ) + { + if( !pseudostate->check( _defects ) ) + { + check_ok = false; + } + } + + return( check_ok ); +} + + +const state_machine_element* region_impl::get_parent() const +{ + return( parent_state_ ); +} + + +} diff --git a/libyasmine/source/region_pseudostate_impl.cpp b/libyasmine/source/region_pseudostate_impl.cpp index d280a60..7cbc520 100644 --- a/libyasmine/source/region_pseudostate_impl.cpp +++ b/libyasmine/source/region_pseudostate_impl.cpp @@ -1,162 +1,162 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "region_pseudostate_impl.hpp" - -#include - -#include "essentials/exception.hpp" -#include "hermes/log.hpp" - -#include "region.hpp" -#include "composite_state.hpp" -#include "algorithm_parameters.hpp" - - -namespace sxy -{ - - -region_pseudostate_impl::region_pseudostate_impl( const std::string& _name ) - : pseudostate_impl( _name ), - parent_() -#ifdef Y_OPTIMIZE_4_SPEED - ,ancestors_(), - ancestors_as_regions_() -#endif -{ -#ifdef Y_OPTIMIZE_4_SPEED - ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); - ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); -#endif -} - - -region_pseudostate_impl::~region_pseudostate_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const state_machine_element* region_pseudostate_impl::get_parent() const -{ - return( get_parent_region() ); -} - - -region* region_pseudostate_impl::get_parent_region() const -{ - return( parent_ ); -} - - -void region_pseudostate_impl::set_parent_region( region* const _parent_region ) -{ - SX_LOG( hermes::log_level::LL_SPAM, "Setting '%' as parent region of '%'.", _parent_region->get_name(), get_name() ); - parent_ = _parent_region; -} - - -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() ) - { - collect_ancestors( ancestors_, SX_NULLPTR ); - } - - if( !_final_ancestor ) - { - return( ancestors_ ); - } - else - { - const raw_composite_states::iterator final_ancestor = std::find( ancestors_.begin(), ancestors_.end(), _final_ancestor ); - - if( final_ancestor != ancestors_.end() ) - { - 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 - { - raw_composite_states ancestors; - return ( ancestors ); - } - } -#else - raw_composite_states ancestors; - collect_ancestors( ancestors, _final_ancestor ); - if( !_include_final_ancestor ) - { - ancestors.erase( std::remove( ancestors.begin(), ancestors.end(), _final_ancestor ), ancestors.end() ); - } - return( ancestors ); -#endif -} - - -raw_regions region_pseudostate_impl::get_ancestors_as_regions() const -{ -#ifdef Y_OPTIMIZE_4_SPEED - if( ancestors_as_regions_.empty() ) - { - collect_ancestors_as_regions( ancestors_as_regions_ ); - } - return ( ancestors_as_regions_ ); -#else - raw_regions ancestor_regions; - collect_ancestors_as_regions( ancestor_regions ); - return( ancestor_regions ); -#endif -} - - -void region_pseudostate_impl::collect_ancestors( raw_composite_states& _ancestors, - composite_state* const _final_ancestor ) const -{ - SX_LOG( hermes::log_level::LL_SPAM, "Getting parent region for '%'.", get_name() ); - region* const parent_region = get_parent_region(); - if( parent_region ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Parent region '%' found for '%'.", parent_region->get_name(), get_name() ); - composite_state& parent_state = parent_region->get_parent_state(); - SX_LOG( hermes::log_level::LL_SPAM, "Found parent state '%' for region '%'.", - parent_state.get_name(), parent_region->get_name() ); - _ancestors.push_back( &parent_state ); - SX_LOG( hermes::log_level::LL_SPAM, "Searching for ancestor(s) of '%'.", parent_state.get_name() ); - const raw_composite_states& ancestors_of_parent_state = parent_state.get_ancestors( _final_ancestor ); - SX_LOG( hermes::log_level::LL_SPAM, "Found % ancestor(s) of '%'.", ancestors_of_parent_state.size(), - parent_state.get_name() ); - _ancestors.insert( _ancestors.end(), ancestors_of_parent_state.begin(), ancestors_of_parent_state.end() ); - } -} - - -void region_pseudostate_impl::collect_ancestors_as_regions( raw_regions& _ancestor_regions ) const -{ - region* const parent_region = get_parent_region(); - if( parent_region ) - { - _ancestor_regions.push_back( parent_region ); - const raw_regions& parent_regions_of_parent_region = parent_region->get_parent_state().get_ancestors_as_regions(); - _ancestor_regions.insert( _ancestor_regions.end(), parent_regions_of_parent_region.begin(), - parent_regions_of_parent_region.end() ); - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "region_pseudostate_impl.hpp" + +#include + +#include "essentials/exception.hpp" +#include "hermes/log.hpp" + +#include "region.hpp" +#include "composite_state.hpp" +#include "algorithm_parameters.hpp" + + +namespace sxy +{ + + +region_pseudostate_impl::region_pseudostate_impl( const std::string& _name ) + : pseudostate_impl( _name ), + parent_() +#ifdef Y_OPTIMIZE_4_SPEED + ,ancestors_(), + ancestors_as_regions_() +#endif +{ +#ifdef Y_OPTIMIZE_4_SPEED + ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); + ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); +#endif +} + + +region_pseudostate_impl::~region_pseudostate_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const state_machine_element* region_pseudostate_impl::get_parent() const +{ + return( get_parent_region() ); +} + + +region* region_pseudostate_impl::get_parent_region() const +{ + return( parent_ ); +} + + +void region_pseudostate_impl::set_parent_region( region* const _parent_region ) +{ + SX_LOG( hermes::log_level::LL_SPAM, "Setting '%' as parent region of '%'.", _parent_region->get_name(), get_name() ); + parent_ = _parent_region; +} + + +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() ) + { + collect_ancestors( ancestors_, SX_NULLPTR ); + } + + if( !_final_ancestor ) + { + return( ancestors_ ); + } + else + { + const raw_composite_states::iterator final_ancestor = std::find( ancestors_.begin(), ancestors_.end(), _final_ancestor ); + + if( final_ancestor != ancestors_.end() ) + { + 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 + { + raw_composite_states ancestors; + return ( ancestors ); + } + } +#else + raw_composite_states ancestors; + collect_ancestors( ancestors, _final_ancestor ); + if( !_include_final_ancestor ) + { + ancestors.erase( std::remove( ancestors.begin(), ancestors.end(), _final_ancestor ), ancestors.end() ); + } + return( ancestors ); +#endif +} + + +raw_regions region_pseudostate_impl::get_ancestors_as_regions() const +{ +#ifdef Y_OPTIMIZE_4_SPEED + if( ancestors_as_regions_.empty() ) + { + collect_ancestors_as_regions( ancestors_as_regions_ ); + } + return ( ancestors_as_regions_ ); +#else + raw_regions ancestor_regions; + collect_ancestors_as_regions( ancestor_regions ); + return( ancestor_regions ); +#endif +} + + +void region_pseudostate_impl::collect_ancestors( raw_composite_states& _ancestors, + composite_state* const _final_ancestor ) const +{ + SX_LOG( hermes::log_level::LL_SPAM, "Getting parent region for '%'.", get_name() ); + region* const parent_region = get_parent_region(); + if( parent_region ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Parent region '%' found for '%'.", parent_region->get_name(), get_name() ); + composite_state& parent_state = parent_region->get_parent_state(); + SX_LOG( hermes::log_level::LL_SPAM, "Found parent state '%' for region '%'.", + parent_state.get_name(), parent_region->get_name() ); + _ancestors.push_back( &parent_state ); + SX_LOG( hermes::log_level::LL_SPAM, "Searching for ancestor(s) of '%'.", parent_state.get_name() ); + const raw_composite_states& ancestors_of_parent_state = parent_state.get_ancestors( _final_ancestor ); + SX_LOG( hermes::log_level::LL_SPAM, "Found % ancestor(s) of '%'.", ancestors_of_parent_state.size(), + parent_state.get_name() ); + _ancestors.insert( _ancestors.end(), ancestors_of_parent_state.begin(), ancestors_of_parent_state.end() ); + } +} + + +void region_pseudostate_impl::collect_ancestors_as_regions( raw_regions& _ancestor_regions ) const +{ + region* const parent_region = get_parent_region(); + if( parent_region ) + { + _ancestor_regions.push_back( parent_region ); + const raw_regions& parent_regions_of_parent_region = parent_region->get_parent_state().get_ancestors_as_regions(); + _ancestor_regions.insert( _ancestor_regions.end(), parent_regions_of_parent_region.begin(), + parent_regions_of_parent_region.end() ); + } +} + + +} diff --git a/libyasmine/source/shallow_history_impl.cpp b/libyasmine/source/shallow_history_impl.cpp index 316aaeb..65bd645 100644 --- a/libyasmine/source/shallow_history_impl.cpp +++ b/libyasmine/source/shallow_history_impl.cpp @@ -1,92 +1,92 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "shallow_history_impl.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "state_machine_defect.hpp" -#include "transition.hpp" -#include "region.hpp" - - -namespace sxy -{ - - -shallow_history_impl::shallow_history_impl( const std::string& _name ) - : history_impl( _name ) -{ - // Nothing to do... -} - - -shallow_history_impl::~shallow_history_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool shallow_history_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = true; - - // check if all default transitions having target in distinct regions - std::set< const region* > target_regions; - - SX_FOR( const transition* const default_transition, get_default_transitions() ) - { - const state_machine_element* const target_region = default_transition->get_target().get_parent(); - const region* const l_region = dynamic_cast< const region* >( target_region ); - if( l_region ) - { - std::pair< std::set< const region* >::const_iterator, bool > result = target_regions.insert( l_region ); - if( !result.second ) - { - _defects.push_back( state_machine_defect( *this, - "Shallow history '%' has default transition(s) that has the same target region '%'.", get_name(), - l_region->get_name() ) ); - check_ok = false; - break; - } - } - } - - // transitions exiting pseudostates cannot have a trigger - if( !pseudostate_impl::check( _defects ) ) - { - check_ok = false; - } - - return( check_ok ); -} - - -void shallow_history_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void shallow_history_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void shallow_history_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "shallow_history_impl.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "state_machine_defect.hpp" +#include "transition.hpp" +#include "region.hpp" + + +namespace sxy +{ + + +shallow_history_impl::shallow_history_impl( const std::string& _name ) + : history_impl( _name ) +{ + // Nothing to do... +} + + +shallow_history_impl::~shallow_history_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool shallow_history_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = true; + + // check if all default transitions having target in distinct regions + std::set< const region* > target_regions; + + SX_FOR( const transition* const default_transition, get_default_transitions() ) + { + const state_machine_element* const target_region = default_transition->get_target().get_parent(); + const region* const l_region = dynamic_cast< const region* >( target_region ); + if( l_region ) + { + std::pair< std::set< const region* >::const_iterator, bool > result = target_regions.insert( l_region ); + if( !result.second ) + { + _defects.push_back( state_machine_defect( *this, + "Shallow history '%' has default transition(s) that has the same target region '%'.", get_name(), + l_region->get_name() ) ); + check_ok = false; + break; + } + } + } + + // transitions exiting pseudostates cannot have a trigger + if( !pseudostate_impl::check( _defects ) ) + { + check_ok = false; + } + + return( check_ok ); +} + + +void shallow_history_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void shallow_history_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void shallow_history_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +} diff --git a/libyasmine/source/simple_state_base.cpp b/libyasmine/source/simple_state_base.cpp index ddc592f..79f4b25 100644 --- a/libyasmine/source/simple_state_base.cpp +++ b/libyasmine/source/simple_state_base.cpp @@ -1,113 +1,113 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "simple_state_base.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "state_visitor.hpp" -#include "complex_state_visitor.hpp" -#include "state_machine_defect.hpp" -#include "region.hpp" - - -namespace sxy -{ - - -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, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events ), - error_event_( _error_event ) -{ - // Nothing to do... -} - - -simple_state_base::~simple_state_base() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const regions& simple_state_base::get_regions() const -{ - static const regions regions; - return( regions ); -} - - -regions& simple_state_base::get_regions() -{ - static regions regions; - return( regions ); -} - - -void simple_state_base::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void simple_state_base::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void simple_state_base::accept_complex_state_visitor( complex_state_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void simple_state_base::accept_state_visitor( state_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -bool simple_state_base::check( state_machine_defects& _defects ) const -{ - SX_UNUSED_PARAMETER( _defects ); - bool check_ok = true; - - // 15.3.11 State -> Constraint [4]: A simple state is a state without any regions. - // Enforced by design. - // a state cannot defer an event that triggers a transition - if( complex_state_impl::check_if_one_of_the_deferred_events_triggers_a_transition() ) - { - _defects.push_back( state_machine_defect( *this, - "Simple state '%' defer event that triggers a outgoing transition!", get_name() ) ); - check_ok = false; - } - - return( check_ok ); -} - - -bool simple_state_base::has_error_event() const -{ - const bool state_has_error_event = !!error_event_; - return( state_has_error_event ); -} - - -event_sptr simple_state_base::get_error_event() const -{ - return( error_event_); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "simple_state_base.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "state_visitor.hpp" +#include "complex_state_visitor.hpp" +#include "state_machine_defect.hpp" +#include "region.hpp" + + +namespace sxy +{ + + +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, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events ), + error_event_( _error_event ) +{ + // Nothing to do... +} + + +simple_state_base::~simple_state_base() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const regions& simple_state_base::get_regions() const +{ + static const regions regions; + return( regions ); +} + + +regions& simple_state_base::get_regions() +{ + static regions regions; + return( regions ); +} + + +void simple_state_base::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void simple_state_base::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void simple_state_base::accept_complex_state_visitor( complex_state_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void simple_state_base::accept_state_visitor( state_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +bool simple_state_base::check( state_machine_defects& _defects ) const +{ + SX_UNUSED_PARAMETER( _defects ); + bool check_ok = true; + + // 15.3.11 State -> Constraint [4]: A simple state is a state without any regions. + // Enforced by design. + // a state cannot defer an event that triggers a transition + if( complex_state_impl::check_if_one_of_the_deferred_events_triggers_a_transition() ) + { + _defects.push_back( state_machine_defect( *this, + "Simple state '%' defer event that triggers a outgoing transition!", get_name() ) ); + check_ok = false; + } + + return( check_ok ); +} + + +bool simple_state_base::has_error_event() const +{ + const bool state_has_error_event = !!error_event_; + return( state_has_error_event ); +} + + +event_sptr simple_state_base::get_error_event() const +{ + return( error_event_); +} + + +} diff --git a/libyasmine/source/simple_state_impl.cpp b/libyasmine/source/simple_state_impl.cpp index cd5a74d..6e841da 100644 --- a/libyasmine/source/simple_state_impl.cpp +++ b/libyasmine/source/simple_state_impl.cpp @@ -1,60 +1,60 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "simple_state_impl.hpp" - -#include "hermes/log.hpp" - -#include "behavior.hpp" - - -namespace sxy -{ - - -simple_state_impl::simple_state_impl( const std::string& _name, behavior_uptr _do_action, behavior_uptr _entry_action, - behavior_uptr _exit_action, const event_ids& _deferred_events, event_sptr _error_event ) - : simple_state_base( _name, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events, - _error_event ), - do_( sxe::move( _do_action ) ) -{ - // Nothing to do... -} - - -simple_state_impl::~simple_state_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const -{ - SX_UNUSED_PARAMETER( _async_event_handler ); - const behavior* const behavior = get_do(); - if( behavior ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Executing state's '%' do behavior.", get_name() ); - ( *behavior )( _event, _event_collector ); - } -} - - -const behavior* simple_state_impl::get_do() const -{ - return( do_.get() ); -} - - - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "simple_state_impl.hpp" + +#include "hermes/log.hpp" + +#include "behavior.hpp" + + +namespace sxy +{ + + +simple_state_impl::simple_state_impl( const std::string& _name, behavior_uptr _do_action, behavior_uptr _entry_action, + behavior_uptr _exit_action, const event_ids& _deferred_events, event_sptr _error_event ) + : simple_state_base( _name, sxe::move( _entry_action ), sxe::move( _exit_action ), _deferred_events, + _error_event ), + do_( sxe::move( _do_action ) ) +{ + // Nothing to do... +} + + +simple_state_impl::~simple_state_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void simple_state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const +{ + SX_UNUSED_PARAMETER( _async_event_handler ); + const behavior* const behavior = get_do(); + if( behavior ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Executing state's '%' do behavior.", get_name() ); + ( *behavior )( _event, _event_collector ); + } +} + + +const behavior* simple_state_impl::get_do() const +{ + return( do_.get() ); +} + + + + +} diff --git a/libyasmine/source/simple_transition_step.cpp b/libyasmine/source/simple_transition_step.cpp index 920d542..a346eee 100644 --- a/libyasmine/source/simple_transition_step.cpp +++ b/libyasmine/source/simple_transition_step.cpp @@ -1,90 +1,90 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "simple_transition_step.hpp" - -#include "transition.hpp" -#include "entry_point.hpp" -#include "exit_point.hpp" - - -namespace sxy -{ - - -simple_transition_step::simple_transition_step( transition& _transition ) - : transition_step(), - transition_( _transition ), - transition_step_() -{ - transition_step_.push_back( &transition_ ); -} - - -simple_transition_step::~simple_transition_step() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const raw_transitions& simple_transition_step::get_transitions() const -{ - return( transition_step_ ); -} - - -const vertex& simple_transition_step::get_unique_source() const -{ - const vertex& source_vertex = transition_.get_source(); - return( source_vertex ); -} - - -const vertex& simple_transition_step::get_unique_target() const -{ - const vertex& target_vertex = transition_.get_target(); - return( target_vertex ); -} - - -const exit_point* simple_transition_step::get_exit_point() const -{ - const exit_point* const l_exit_point = dynamic_cast< const exit_point* >( &get_unique_target() ); - return( l_exit_point ); -} - - -const entry_point* simple_transition_step::get_entry_point() const -{ - const entry_point* const vertex = dynamic_cast< const entry_point* >( &get_transitions().front()->get_source() ); - return( vertex ); -} - - -const raw_const_vertices simple_transition_step::get_target_vertices() -{ - raw_const_vertices target_vertices; - target_vertices.push_back( &transition_.get_target() ); - return( target_vertices ); -} - - -void simple_transition_step::execute_transition_behaviors( const event& _event, - event_collector& _event_collector ) const -{ - SX_FOR( const transition* const transition, transition_step_ ) - { - transition->on_transition_behavior( _event, _event_collector ); - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "simple_transition_step.hpp" + +#include "transition.hpp" +#include "entry_point.hpp" +#include "exit_point.hpp" + + +namespace sxy +{ + + +simple_transition_step::simple_transition_step( transition& _transition ) + : transition_step(), + transition_( _transition ), + transition_step_() +{ + transition_step_.push_back( &transition_ ); +} + + +simple_transition_step::~simple_transition_step() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const raw_transitions& simple_transition_step::get_transitions() const +{ + return( transition_step_ ); +} + + +const vertex& simple_transition_step::get_unique_source() const +{ + const vertex& source_vertex = transition_.get_source(); + return( source_vertex ); +} + + +const vertex& simple_transition_step::get_unique_target() const +{ + const vertex& target_vertex = transition_.get_target(); + return( target_vertex ); +} + + +const exit_point* simple_transition_step::get_exit_point() const +{ + const exit_point* const l_exit_point = dynamic_cast< const exit_point* >( &get_unique_target() ); + return( l_exit_point ); +} + + +const entry_point* simple_transition_step::get_entry_point() const +{ + const entry_point* const vertex = dynamic_cast< const entry_point* >( &get_transitions().front()->get_source() ); + return( vertex ); +} + + +const raw_const_vertices simple_transition_step::get_target_vertices() +{ + raw_const_vertices target_vertices; + target_vertices.push_back( &transition_.get_target() ); + return( target_vertices ); +} + + +void simple_transition_step::execute_transition_behaviors( const event& _event, + event_collector& _event_collector ) const +{ + SX_FOR( const transition* const transition, transition_step_ ) + { + transition->on_transition_behavior( _event, _event_collector ); + } +} + + +} diff --git a/libyasmine/source/state_impl.cpp b/libyasmine/source/state_impl.cpp index 5fd1aaf..a92e330 100644 --- a/libyasmine/source/state_impl.cpp +++ b/libyasmine/source/state_impl.cpp @@ -1,339 +1,339 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_impl.hpp" - -#include - -#include "essentials/base.hpp" -#include "essentials/exception.hpp" -#include "hermes/log_and_throw.hpp" - -#include "region.hpp" -#include "composite_state.hpp" -#include "behavior.hpp" -#include "behavior_exception.hpp" -#include "algorithm_parameters.hpp" -#include "event.hpp" -#include "event_collector.hpp" - - -namespace sxy -{ - - -state_impl::state_impl( const std::string& _name ) - : vertex_impl( _name ), - was_active_( false ), - parent_() -#ifdef Y_OPTIMIZE_4_SPEED - , ancestors_(), - ancestors_as_regions_() -#endif -{ -#ifdef Y_OPTIMIZE_4_SPEED - ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); - ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); -#endif -} - - -state_impl::~state_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const state_machine_element* state_impl::get_parent() const -{ - return( get_parent_region() ); -} - - -void state_impl::set_parent_region( region* const _parent_region ) -{ - parent_ = _parent_region; -} - - -region* state_impl::get_parent_region() const -{ - return( parent_ ); -} - - -size_t state_impl::get_parent_region_index() const -{ - size_t index = 0; - const region* const parent_region = get_parent_region(); - if( parent_region ) - { - const composite_state& parent_state = parent_region->get_parent_state(); - index = parent_state.get_region_index( parent_region ); - } - - return( index ); -} - - -region* state_impl::get_region( const std::string& _region_name ) const -{ - SX_UNUSED_PARAMETER( _region_name ); - return( SX_NULLPTR ); -} - - -vertex* state_impl::get_pseudostate( const std::string& _name_of_pseudostate ) const -{ - SX_UNUSED_PARAMETER( _name_of_pseudostate ); - return( SX_NULLPTR ); -} - - -// 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, - bool _include_final_ancestor ) const -{ -#ifdef Y_OPTIMIZE_4_SPEED - if( ancestors_.empty() ) - { - collect_ancestors( ancestors_, SX_NULLPTR ); - } - - if( _final_ancestor == SX_NULLPTR ) - { - return( ancestors_ ); - } - else - { - const raw_composite_states::iterator final_ancestor = - std::find( ancestors_.begin(), ancestors_.end(), _final_ancestor ); - - if( final_ancestor != ancestors_.end() ) - { - raw_composite_states ancestors( ancestors_.begin(), final_ancestor + 1 ); - if( !_include_final_ancestor ) - { - ancestors.erase( final_ancestor ); - } - return( ancestors ); - } - else - { - raw_composite_states ancestors; - return( ancestors ); - } - } -#else - raw_composite_states ancestors; - collect_ancestors( ancestors, _final_ancestor ); - if( !_include_final_ancestor ) - { - ancestors.erase( std::remove( ancestors.begin(), ancestors.end(), _final_ancestor ), ancestors.end() ); - } - return( ancestors ); -#endif -} - - -raw_regions state_impl::get_ancestors_as_regions() const -{ -#ifdef Y_OPTIMIZE_4_SPEED - if( ancestors_as_regions_.empty() ) - { - collect_ancestors_as_regions( ancestors_as_regions_ ); - } - return ( ancestors_as_regions_ ); -#else - raw_regions ancestors_as_regions; - collect_ancestors_as_regions( ancestors_as_regions ); - return( ancestors_as_regions ); -#endif -} - - -std::size_t state_impl::get_nesting_level() const -{ - const raw_composite_states& ancestors = get_ancestors( SX_NULLPTR ); - - // Add one for the state itself. - return( ancestors.size() + 1 ); -} - - -void state_impl::set_was_active() -{ - was_active_ = true; -} - - -bool state_impl::was_active() const -{ - return( was_active_ ); -} - - -void state_impl::set_active() -{ - region* const parent_region = get_parent_region(); - if( parent_region ) - { - parent_region->set_active_state( this ); - parent_region->set_state_was_active( this ); - SX_LOG( hermes::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 ) - { - SX_ASSERT( parent_region, "State has no parent region!" ); - } - } -} - - -void state_impl::set_inactive() -{ - region* const parent_region = get_parent_region(); - parent_region->set_active_state( SX_NULLPTR ); - set_was_active(); - SX_LOG( hermes::log_level::LL_DEBUG, "State '%' is now inactive.", get_uri().to_string() ); -} - - -bool state_impl::is_active() const -{ - bool is_active = false; - const region* const parent_region = get_parent_region(); - if( parent_region ) - { - is_active = parent_region->get_active_state() == this; - } - else - { - is_active = true; - } - - return( is_active ); -} - - -bool state_impl::is_complete() const -{ - return( true ); -} - - -void state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) const -{ - SX_UNUSED_PARAMETER( _event ); - SX_UNUSED_PARAMETER( _async_event_handler ); - SX_UNUSED_PARAMETER( _event_collector ); -} - - -void state_impl::execute_enter_behavior( const event& _event, event_collector& _event_collector ) const -{ - const behavior* const behavior = get_entry_behavior(); - if( behavior ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Executing state's '%' enter behavior.", get_name() ); - ( *behavior )( _event, _event_collector ); - } -} - - -void state_impl::execute_exit_behavior( const event& _event, event_collector& _event_collector ) const -{ - const behavior* const behavior = get_exit_behavior(); - if( behavior ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Executing state's '%' exit behavior.", get_name() ); - ( *behavior )( _event, _event_collector ); - } -} - - -void state_impl::enter_state( const event& _event, event_collector& _event_collector ) -{ - execute_enter_behavior( _event, _event_collector ); - set_active(); - set_was_active(); -} - - -void state_impl::exit_state( const event& _event, event_collector& _event_collector ) -{ - execute_exit_behavior( _event, _event_collector ); - set_inactive(); -} - - -bool state_impl::has_error_event() const -{ - return( false ); -} - - -event_sptr state_impl::get_error_event() const -{ - return( event_sptr() ); -} - - -void state_impl::collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const -{ - if( get_parent_region() != SX_NULLPTR ) - { - const state* current_vertex = this; - while( _final_ancestor != current_vertex ) - { - region* const parent_region = current_vertex->get_parent_region(); - if( parent_region != SX_NULLPTR ) - { - composite_state& parent_state = parent_region->get_parent_state(); - _ancestors.push_back( &parent_state ); - current_vertex = &parent_state; - } - else - { - SX_ASSERT( !_final_ancestor, "The given composite state '%' was not reached in the child-parent chain!" ); - break; - } - } - } -} - - -void state_impl::collect_ancestors_as_regions( raw_regions& _ancestors_as_regions ) const -{ - const state* source_state = this; - while( true ) - { - region* const parent_region = source_state->get_parent_region(); - if( parent_region != SX_NULLPTR ) - { - _ancestors_as_regions.push_back( parent_region ); - const composite_state& previous_state = parent_region->get_parent_state(); - source_state = &previous_state; - } - else - { - break; - } - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_impl.hpp" + +#include + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" +#include "hermes/log_and_throw.hpp" + +#include "region.hpp" +#include "composite_state.hpp" +#include "behavior.hpp" +#include "behavior_exception.hpp" +#include "algorithm_parameters.hpp" +#include "event.hpp" +#include "event_collector.hpp" + + +namespace sxy +{ + + +state_impl::state_impl( const std::string& _name ) + : vertex_impl( _name ), + was_active_( false ), + parent_() +#ifdef Y_OPTIMIZE_4_SPEED + , ancestors_(), + ancestors_as_regions_() +#endif +{ +#ifdef Y_OPTIMIZE_4_SPEED + ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); + ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); +#endif +} + + +state_impl::~state_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const state_machine_element* state_impl::get_parent() const +{ + return( get_parent_region() ); +} + + +void state_impl::set_parent_region( region* const _parent_region ) +{ + parent_ = _parent_region; +} + + +region* state_impl::get_parent_region() const +{ + return( parent_ ); +} + + +size_t state_impl::get_parent_region_index() const +{ + size_t index = 0; + const region* const parent_region = get_parent_region(); + if( parent_region ) + { + const composite_state& parent_state = parent_region->get_parent_state(); + index = parent_state.get_region_index( parent_region ); + } + + return( index ); +} + + +region* state_impl::get_region( const std::string& _region_name ) const +{ + SX_UNUSED_PARAMETER( _region_name ); + return( SX_NULLPTR ); +} + + +vertex* state_impl::get_pseudostate( const std::string& _name_of_pseudostate ) const +{ + SX_UNUSED_PARAMETER( _name_of_pseudostate ); + return( SX_NULLPTR ); +} + + +// Get 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, + bool _include_final_ancestor ) const +{ +#ifdef Y_OPTIMIZE_4_SPEED + if( ancestors_.empty() ) + { + collect_ancestors( ancestors_, SX_NULLPTR ); + } + + if( _final_ancestor == SX_NULLPTR ) + { + return( ancestors_ ); + } + else + { + const raw_composite_states::iterator final_ancestor = + std::find( ancestors_.begin(), ancestors_.end(), _final_ancestor ); + + if( final_ancestor != ancestors_.end() ) + { + raw_composite_states ancestors( ancestors_.begin(), final_ancestor + 1 ); + if( !_include_final_ancestor ) + { + ancestors.erase( final_ancestor ); + } + return( ancestors ); + } + else + { + raw_composite_states ancestors; + return( ancestors ); + } + } +#else + raw_composite_states ancestors; + collect_ancestors( ancestors, _final_ancestor ); + if( !_include_final_ancestor ) + { + ancestors.erase( std::remove( ancestors.begin(), ancestors.end(), _final_ancestor ), ancestors.end() ); + } + return( ancestors ); +#endif +} + + +raw_regions state_impl::get_ancestors_as_regions() const +{ +#ifdef Y_OPTIMIZE_4_SPEED + if( ancestors_as_regions_.empty() ) + { + collect_ancestors_as_regions( ancestors_as_regions_ ); + } + return ( ancestors_as_regions_ ); +#else + raw_regions ancestors_as_regions; + collect_ancestors_as_regions( ancestors_as_regions ); + return( ancestors_as_regions ); +#endif +} + + +std::size_t state_impl::get_nesting_level() const +{ + const raw_composite_states& ancestors = get_ancestors( SX_NULLPTR ); + + // Add one for the state itself. + return( ancestors.size() + 1 ); +} + + +void state_impl::set_was_active() +{ + was_active_ = true; +} + + +bool state_impl::was_active() const +{ + return( was_active_ ); +} + + +void state_impl::set_active() +{ + region* const parent_region = get_parent_region(); + if( parent_region ) + { + parent_region->set_active_state( this ); + parent_region->set_state_was_active( this ); + SX_LOG( hermes::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 ) + { + SX_ASSERT( parent_region, "State has no parent region!" ); + } + } +} + + +void state_impl::set_inactive() +{ + region* const parent_region = get_parent_region(); + parent_region->set_active_state( SX_NULLPTR ); + set_was_active(); + SX_LOG( hermes::log_level::LL_DEBUG, "State '%' is now inactive.", get_uri().to_string() ); +} + + +bool state_impl::is_active() const +{ + bool is_active = false; + const region* const parent_region = get_parent_region(); + if( parent_region ) + { + is_active = parent_region->get_active_state() == this; + } + else + { + is_active = true; + } + + return( is_active ); +} + + +bool state_impl::is_complete() const +{ + return( true ); +} + + +void state_impl::execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) const +{ + SX_UNUSED_PARAMETER( _event ); + SX_UNUSED_PARAMETER( _async_event_handler ); + SX_UNUSED_PARAMETER( _event_collector ); +} + + +void state_impl::execute_enter_behavior( const event& _event, event_collector& _event_collector ) const +{ + const behavior* const behavior = get_entry_behavior(); + if( behavior ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Executing state's '%' enter behavior.", get_name() ); + ( *behavior )( _event, _event_collector ); + } +} + + +void state_impl::execute_exit_behavior( const event& _event, event_collector& _event_collector ) const +{ + const behavior* const behavior = get_exit_behavior(); + if( behavior ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Executing state's '%' exit behavior.", get_name() ); + ( *behavior )( _event, _event_collector ); + } +} + + +void state_impl::enter_state( const event& _event, event_collector& _event_collector ) +{ + execute_enter_behavior( _event, _event_collector ); + set_active(); + set_was_active(); +} + + +void state_impl::exit_state( const event& _event, event_collector& _event_collector ) +{ + execute_exit_behavior( _event, _event_collector ); + set_inactive(); +} + + +bool state_impl::has_error_event() const +{ + return( false ); +} + + +event_sptr state_impl::get_error_event() const +{ + return( event_sptr() ); +} + + +void state_impl::collect_ancestors( raw_composite_states& _ancestors, composite_state* const _final_ancestor ) const +{ + if( get_parent_region() != SX_NULLPTR ) + { + const state* current_vertex = this; + while( _final_ancestor != current_vertex ) + { + region* const parent_region = current_vertex->get_parent_region(); + if( parent_region != SX_NULLPTR ) + { + composite_state& parent_state = parent_region->get_parent_state(); + _ancestors.push_back( &parent_state ); + current_vertex = &parent_state; + } + else + { + SX_ASSERT( !_final_ancestor, "The given composite state '%' was not reached in the child-parent chain!" ); + break; + } + } + } +} + + +void state_impl::collect_ancestors_as_regions( raw_regions& _ancestors_as_regions ) const +{ + const state* source_state = this; + while( true ) + { + region* const parent_region = source_state->get_parent_region(); + if( parent_region != SX_NULLPTR ) + { + _ancestors_as_regions.push_back( parent_region ); + const composite_state& previous_state = parent_region->get_parent_state(); + source_state = &previous_state; + } + else + { + break; + } + } +} + + +} diff --git a/libyasmine/source/state_machine_base.cpp b/libyasmine/source/state_machine_base.cpp index 6c7bac4..0ba85b1 100644 --- a/libyasmine/source/state_machine_base.cpp +++ b/libyasmine/source/state_machine_base.cpp @@ -1,492 +1,492 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_machine_base.hpp" - -#include "essentials/base.hpp" -#include "essentials/exception.hpp" -#include "hermes/log_and_throw.hpp" - -#include "event_processing_callback.hpp" -#include "composite_state_impl.hpp" -#include "event_impl.hpp" -#include "transition_controller.hpp" -#include "uri.hpp" -#include "region.hpp" -#include "behavior_impl.hpp" -#include "constraint_impl.hpp" -#include "transition_impl.hpp" -#include "async_simple_state_impl.hpp" -#include "completion_event.hpp" - - -namespace sxy -{ - - - state_machine_base::state_machine_base( const std::string& _name, event_processing_callback* const _event_processing_callback ) - : name_( _name ), - event_processing_callback_( _event_processing_callback ), - root_state_( SX_MAKE_UNIQUE< composite_state_impl >( _name ) ), - transitions_(), - deferred_events_(), - state_machine_is_running_( false ), - interrupt_(false) -#ifdef Y_PROFILER - , processed_events_( 0 ) -#endif - { - SX_LOG( hermes::log_level::LL_TRACE, "Creating state_machine '%'.", _name ); - if( event_processing_callback_ ) - { - event_processing_callback_->add_state_machine_introspection( *this ); - } - SX_LOG( hermes::log_level::LL_TRACE, "Created state_machine '%'.", _name ); - } - - - state_machine_base::~state_machine_base() SX_NOEXCEPT - { -#ifdef Y_PROFILER - SX_LOG( hermes::log_level::LL_TRACE, "events fired by '%': %.", name_, processed_events_ ); -#endif - - SX_LOG( hermes::log_level::LL_TRACE, "Destroying state_machine '%'.", name_ ); - - SX_ASSERT( !state_machine_is_running_, "State machine is still running!" ); - - SX_LOG( hermes::log_level::LL_TRACE, "Destroyed state_machine '%'.", name_ ); - } - - - composite_state& state_machine_base::get_root_state() const - { - SX_ASSERT( root_state_, "No root state!" ); - return( *root_state_ ); - } - - -#ifdef Y_PROFILER - sxe::uint32_t state_machine_base::get_number_of_processed_events() const - { - return( processed_events_ ); - } -#endif - - - transition& state_machine_base::add_transition( transition_uptr _transition ) - { - transition& transition = *_transition; - transitions_.push_back( sxe::move( _transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, const constraint_function& _guard, const behavior_function& _behavior ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, const constraint_function& _guard, const behavior_function& _behavior ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const constraint_function& _guard, const sxy::transition_kind _kind ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), behavior_uptr() ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const constraint_function& _guard, const sxy::transition_kind _kind ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), behavior_uptr() ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const constraint_function& _guard, const behavior_function& _behavior, const sxy::transition_kind _kind ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const constraint_function& _guard, const behavior_function& _behavior, const sxy::transition_kind _kind ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, - ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), - ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, - const behavior_function& _behavior, const sxy::transition_kind _kind ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, - constraint_uptr(), - ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, - const behavior_function& _behavior, const sxy::transition_kind _kind ) - { - sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = - SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, - constraint_uptr(), - ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); - transition_impl& transition = *l_transition; - transitions_.push_back( sxe::move( l_transition ) ); - return( transition ); - } - - - bool state_machine_base::check( state_machine_defects& _defects ) const - { - - bool check_ok = root_state_->check( _defects ); - if( check_ok ) - { - SX_FOR( const transition_uptr& transition, transitions_ ) - { - if( !transition->check( _defects ) ) - { - check_ok = false; - break; - } - } - } - - return( check_ok ); - } - - - void state_machine_base::halt() - { - SX_LOG( hermes::log_level::LL_INFO, "Stopping state machine '%'.", name_ ); - if( state_machine_is_running_ ) - { - stop_all_async_states( *root_state_ ); - state_machine_is_running_ = false; - } - - SX_LOG( hermes::log_level::LL_INFO, "Stopped state machine '%'.", name_ ); - } - - - void state_machine_base::interrupt() - { - interrupt_ = true; - interrupt_impl(); - } - - - bool state_machine_base::is_interrupted() const - { - return( interrupt_ ); - } - - - std::string state_machine_base::get_name() const - { - return( name_ ); - } - - - bool state_machine_base::run( async_event_handler* const _async_event_handler ) - { - SX_ASSERT( root_state_, "No root state!" ); - bool state_machine_started = false; - state_machine_is_running_ = true; - - interrupt_ = false; - try - { - if( event_processing_callback_ ) - { - event_processing_callback_->before_event( sxy::completion_event::get_event_id() ); - } - - transition_controller transition_controller; - state_machine_started = transition_controller.start_state_machine( *root_state_, event_processing_callback_, - _async_event_handler, *this, *this ); - if( event_processing_callback_ ) - { - event_processing_callback_->after_event( sxy::completion_event::get_event_id() ); - } - - if( !state_machine_started ) - { - SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate reached. The state machine is stopping." ); - state_machine_is_running_ = false; - } - } - catch( const std::exception& exception ) - { - SX_LOG( hermes::log_level::LL_FATAL, "State machine cannot start: %.", exception.what() ); - state_machine_is_running_ = false; - throw; - } - catch( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "State machine can not start: Unknown exception occurred." ); - state_machine_is_running_ = false; - throw; - } - return( state_machine_started ); - } - - bool state_machine_base::process_event( const event_sptr& _event, async_event_handler* const _async_event_handler ) - { -#ifdef Y_PROFILER - ++processed_events_; -#endif - bool terminate_pseudostate_has_been_reached = true; - if( !interrupt_ ) - { - SX_LOG( hermes::log_level::LL_INFO, "'%' is processing event '%' (%) with priority '%'.", get_name(), _event->get_name(), - _event->get_id(), static_cast< sxe::int16_t >( _event->get_priority() ) ); - - SX_ASSERT( state_machine_is_running_, "State machine is not running!" ); - SX_LOG( hermes::log_level::LL_TRACE, "Starting processing of event '%' (%) with priority '%'.", _event->get_name(), _event->get_id(), - static_cast< sxe::int16_t >( _event->get_priority() ) ); - try - { - if( event_processing_callback_ ) - { - event_processing_callback_->before_event( _event->get_id(), _event->get_priority() ); - } - - transition_controller transition_controller; - bool event_is_deferred = false; - terminate_pseudostate_has_been_reached = transition_controller.process_event( *_event, *root_state_, - event_processing_callback_, event_is_deferred, _async_event_handler, *this, *this ); - SX_LOG( hermes::log_level::LL_TRACE, "Event '%' (%) has been processed.", _event->get_name(), _event->get_id() ); - if( event_processing_callback_ ) - { - event_processing_callback_->after_event( _event->get_id() ); - } - - if( terminate_pseudostate_has_been_reached ) - { - SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate has been reached! The state machine '%' is stopping.", get_name() ); - state_machine_is_running_ = false; - } - else - { - if( event_is_deferred ) - { - add_deferred_event( _event ); - } - else - { - terminate_pseudostate_has_been_reached = process_deferred_events( _async_event_handler ); - } - } - - if( terminate_pseudostate_has_been_reached ) - { - SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate has been reached! The state machine '%' is stopping.", get_name() ); - state_machine_is_running_ = false; - } - } - catch( const std::exception& exception ) - { - SX_LOG( hermes::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( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception occurred in state machine '%'!", get_name() ); - state_machine_is_running_ = false; - stop_all_async_states( *root_state_ ); - throw; - } - - SX_LOG( hermes::log_level::LL_INFO, "'%' processed event '%' (%).", get_name(), _event->get_name(), _event->get_id() ); - - } - else - { - terminate_pseudostate_has_been_reached = true; - halt(); - } - - if( terminate_pseudostate_has_been_reached ) - { - stop_all_async_states( *root_state_ ); - } - - return( terminate_pseudostate_has_been_reached ); - } - - - const events& state_machine_base::get_deferred_events() const - { - return( deferred_events_ ); - } - - - raw_const_states state_machine_base::get_active_state_configuration() const - { - raw_const_states active_state_configuration; - const composite_state& root = get_root_state(); - check_regions_for_active_states( active_state_configuration, root ); - return( active_state_configuration ); - } - - - void state_machine_base::get_active_states_from_region( raw_const_states& _active_state_configuration, - const region& _region ) const - { - const state* const active_state = _region.get_active_state(); - if( active_state ) - { - _active_state_configuration.push_back( active_state ); - check_regions_for_active_states( _active_state_configuration, *active_state ); - } - } - - - void state_machine_base::check_regions_for_active_states( raw_const_states& _active_state_configuration, - const state& _state ) const - { - SX_FOR( const region_uptr& region, _state.get_regions() ) - { - get_active_states_from_region( _active_state_configuration, *region ); - } - } - - - void state_machine_base::add_deferred_event( const event_sptr& _event_id ) - { - deferred_events_.push_back( _event_id ); - } - - - bool state_machine_base::process_deferred_events( async_event_handler* const _async_event_handler ) - { - const events deferred_events = deferred_events_; - deferred_events_.clear(); - bool terminate_pseudostate_has_been_reached = false; - transition_controller transition_controller; - - SX_FOR( const event_sptr deferred_event, deferred_events ) - { - if( event_processing_callback_ ) - { - event_processing_callback_->before_event( deferred_event->get_id(), deferred_event->get_priority() ); - } - - bool event_is_deferred = false; - terminate_pseudostate_has_been_reached = transition_controller.process_event( *deferred_event, *root_state_, - event_processing_callback_, event_is_deferred, _async_event_handler, *this, *this ); - if( event_processing_callback_ ) - { - event_processing_callback_->after_event( deferred_event->get_id() ); - } - - if( terminate_pseudostate_has_been_reached ) - { - SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate has been reached! The state machine is stopping." ); - break; - } - else - { - if( event_is_deferred ) - { - deferred_events_.push_back( deferred_event ); - } - } - } - - return( terminate_pseudostate_has_been_reached ); - } - - - void state_machine_base::stop_all_async_states( state& _state ) - { - SX_FOR( region_uptr& region, _state.get_regions() ) - { - stop_all_async_states_from_region( region ); - } - } - - - void state_machine_base::stop_all_async_states_from_region( region_uptr& _region ) - { - state* const active_state = _region->get_active_state(); - if( active_state ) - { - async_simple_state_impl* const async_state = dynamic_cast< async_simple_state_impl* >( active_state ); - if( async_state ) - { - async_state->stop_do_behavior(); - } - else - { - stop_all_async_states( *active_state ); - } - } - } - - - void state_machine_base::interrupt_impl() - { - // Nothing to do... - } - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_base.hpp" + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" +#include "essentials/uri.hpp" +#include "hermes/log_and_throw.hpp" + +#include "event_processing_callback.hpp" +#include "composite_state_impl.hpp" +#include "event_impl.hpp" +#include "transition_controller.hpp" +#include "region.hpp" +#include "behavior_impl.hpp" +#include "constraint_impl.hpp" +#include "transition_impl.hpp" +#include "async_simple_state_impl.hpp" +#include "completion_event.hpp" + + +namespace sxy +{ + + + state_machine_base::state_machine_base( const std::string& _name, event_processing_callback* const _event_processing_callback ) + : name_( _name ), + event_processing_callback_( _event_processing_callback ), + root_state_( SX_MAKE_UNIQUE< composite_state_impl >( _name ) ), + transitions_(), + deferred_events_(), + state_machine_is_running_( false ), + interrupt_(false) +#ifdef Y_PROFILER + , processed_events_( 0 ) +#endif + { + SX_LOG( hermes::log_level::LL_TRACE, "Creating state_machine '%'.", _name ); + if( event_processing_callback_ ) + { + event_processing_callback_->add_state_machine_introspection( *this ); + } + SX_LOG( hermes::log_level::LL_TRACE, "Created state_machine '%'.", _name ); + } + + + state_machine_base::~state_machine_base() SX_NOEXCEPT + { +#ifdef Y_PROFILER + SX_LOG( hermes::log_level::LL_TRACE, "events fired by '%': %.", name_, processed_events_ ); +#endif + + SX_LOG( hermes::log_level::LL_TRACE, "Destroying state_machine '%'.", name_ ); + + SX_ASSERT( !state_machine_is_running_, "State machine is still running!" ); + + SX_LOG( hermes::log_level::LL_TRACE, "Destroyed state_machine '%'.", name_ ); + } + + + composite_state& state_machine_base::get_root_state() const + { + SX_ASSERT( root_state_, "No root state!" ); + return( *root_state_ ); + } + + +#ifdef Y_PROFILER + sxe::uint32_t state_machine_base::get_number_of_processed_events() const + { + return( processed_events_ ); + } +#endif + + + transition& state_machine_base::add_transition( transition_uptr _transition ) + { + transition& transition = *_transition; + transitions_.push_back( sxe::move( _transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const sxy::transition_kind _kind, const constraint_function& _guard, const behavior_function& _behavior ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), + ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const sxy::transition_kind _kind, const constraint_function& _guard, const behavior_function& _behavior ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), + ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const constraint_function& _guard, const sxy::transition_kind _kind ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), behavior_uptr() ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const constraint_function& _guard, const sxy::transition_kind _kind ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), behavior_uptr() ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const constraint_function& _guard, const behavior_function& _behavior, const sxy::transition_kind _kind ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), + ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const constraint_function& _guard, const behavior_function& _behavior, const sxy::transition_kind _kind ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, + ( _guard ? ( constraint_impl::create( _guard ) ) : constraint_uptr() ), + ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_id _event_id, vertex& _source, vertex& _target, + const behavior_function& _behavior, const sxy::transition_kind _kind ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_id, sxe::ref( _source ), sxe::ref( _target ), _kind, + constraint_uptr(), + ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + transition& state_machine_base::add_transition( const event_ids& _event_ids, vertex& _source, vertex& _target, + const behavior_function& _behavior, const sxy::transition_kind _kind ) + { + sxe::SX_UNIQUE_PTR< sxy::transition_impl > l_transition = + SX_MAKE_UNIQUE< sxy::transition_impl >( _event_ids, sxe::ref( _source ), sxe::ref( _target ), _kind, + constraint_uptr(), + ( _behavior ? ( behavior_impl::create_behavior( sxe::ref( _behavior ) ) ) : behavior_uptr() ) ); + transition_impl& transition = *l_transition; + transitions_.push_back( sxe::move( l_transition ) ); + return( transition ); + } + + + bool state_machine_base::check( state_machine_defects& _defects ) const + { + + bool check_ok = root_state_->check( _defects ); + if( check_ok ) + { + SX_FOR( const transition_uptr& transition, transitions_ ) + { + if( !transition->check( _defects ) ) + { + check_ok = false; + break; + } + } + } + + return( check_ok ); + } + + + void state_machine_base::halt() + { + SX_LOG( hermes::log_level::LL_INFO, "Stopping state machine '%'.", name_ ); + if( state_machine_is_running_ ) + { + stop_all_async_states( *root_state_ ); + state_machine_is_running_ = false; + } + + SX_LOG( hermes::log_level::LL_INFO, "Stopped state machine '%'.", name_ ); + } + + + void state_machine_base::interrupt() + { + interrupt_ = true; + interrupt_impl(); + } + + + bool state_machine_base::is_interrupted() const + { + return( interrupt_ ); + } + + + std::string state_machine_base::get_name() const + { + return( name_ ); + } + + + bool state_machine_base::run( async_event_handler* const _async_event_handler ) + { + SX_ASSERT( root_state_, "No root state!" ); + bool state_machine_started = false; + state_machine_is_running_ = true; + + interrupt_ = false; + try + { + if( event_processing_callback_ ) + { + event_processing_callback_->before_event( sxy::completion_event::get_event_id() ); + } + + transition_controller transition_controller; + state_machine_started = transition_controller.start_state_machine( *root_state_, event_processing_callback_, + _async_event_handler, *this, *this ); + if( event_processing_callback_ ) + { + event_processing_callback_->after_event( sxy::completion_event::get_event_id() ); + } + + if( !state_machine_started ) + { + SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate reached. The state machine is stopping." ); + state_machine_is_running_ = false; + } + } + catch( const std::exception& exception ) + { + SX_LOG( hermes::log_level::LL_FATAL, "State machine cannot start: %.", exception.what() ); + state_machine_is_running_ = false; + throw; + } + catch( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "State machine can not start: Unknown exception occurred." ); + state_machine_is_running_ = false; + throw; + } + return( state_machine_started ); + } + + bool state_machine_base::process_event( const event_sptr& _event, async_event_handler* const _async_event_handler ) + { +#ifdef Y_PROFILER + ++processed_events_; +#endif + bool terminate_pseudostate_has_been_reached = true; + if( !interrupt_ ) + { + SX_LOG( hermes::log_level::LL_INFO, "'%' is processing event '%' (%) with priority '%'.", get_name(), _event->get_name(), + _event->get_id(), static_cast< sxe::int16_t >( _event->get_priority() ) ); + + SX_ASSERT( state_machine_is_running_, "State machine is not running!" ); + SX_LOG( hermes::log_level::LL_TRACE, "Starting processing of event '%' (%) with priority '%'.", _event->get_name(), _event->get_id(), + static_cast< sxe::int16_t >( _event->get_priority() ) ); + try + { + if( event_processing_callback_ ) + { + event_processing_callback_->before_event( _event->get_id(), _event->get_priority() ); + } + + transition_controller transition_controller; + bool event_is_deferred = false; + terminate_pseudostate_has_been_reached = transition_controller.process_event( *_event, *root_state_, + event_processing_callback_, event_is_deferred, _async_event_handler, *this, *this ); + SX_LOG( hermes::log_level::LL_TRACE, "Event '%' (%) has been processed.", _event->get_name(), _event->get_id() ); + if( event_processing_callback_ ) + { + event_processing_callback_->after_event( _event->get_id() ); + } + + if( terminate_pseudostate_has_been_reached ) + { + SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate has been reached! The state machine '%' is stopping.", get_name() ); + state_machine_is_running_ = false; + } + else + { + if( event_is_deferred ) + { + add_deferred_event( _event ); + } + else + { + terminate_pseudostate_has_been_reached = process_deferred_events( _async_event_handler ); + } + } + + if( terminate_pseudostate_has_been_reached ) + { + SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate has been reached! The state machine '%' is stopping.", get_name() ); + state_machine_is_running_ = false; + } + } + catch( const std::exception& exception ) + { + SX_LOG( hermes::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( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception occurred in state machine '%'!", get_name() ); + state_machine_is_running_ = false; + stop_all_async_states( *root_state_ ); + throw; + } + + SX_LOG( hermes::log_level::LL_INFO, "'%' processed event '%' (%).", get_name(), _event->get_name(), _event->get_id() ); + + } + else + { + terminate_pseudostate_has_been_reached = true; + halt(); + } + + if( terminate_pseudostate_has_been_reached ) + { + stop_all_async_states( *root_state_ ); + } + + return( terminate_pseudostate_has_been_reached ); + } + + + const events& state_machine_base::get_deferred_events() const + { + return( deferred_events_ ); + } + + + raw_const_states state_machine_base::get_active_state_configuration() const + { + raw_const_states active_state_configuration; + const composite_state& root = get_root_state(); + check_regions_for_active_states( active_state_configuration, root ); + return( active_state_configuration ); + } + + + void state_machine_base::get_active_states_from_region( raw_const_states& _active_state_configuration, + const region& _region ) const + { + const state* const active_state = _region.get_active_state(); + if( active_state ) + { + _active_state_configuration.push_back( active_state ); + check_regions_for_active_states( _active_state_configuration, *active_state ); + } + } + + + void state_machine_base::check_regions_for_active_states( raw_const_states& _active_state_configuration, + const state& _state ) const + { + SX_FOR( const region_uptr& region, _state.get_regions() ) + { + get_active_states_from_region( _active_state_configuration, *region ); + } + } + + + void state_machine_base::add_deferred_event( const event_sptr& _event_id ) + { + deferred_events_.push_back( _event_id ); + } + + + bool state_machine_base::process_deferred_events( async_event_handler* const _async_event_handler ) + { + const events deferred_events = deferred_events_; + deferred_events_.clear(); + bool terminate_pseudostate_has_been_reached = false; + transition_controller transition_controller; + + SX_FOR( const event_sptr deferred_event, deferred_events ) + { + if( event_processing_callback_ ) + { + event_processing_callback_->before_event( deferred_event->get_id(), deferred_event->get_priority() ); + } + + bool event_is_deferred = false; + terminate_pseudostate_has_been_reached = transition_controller.process_event( *deferred_event, *root_state_, + event_processing_callback_, event_is_deferred, _async_event_handler, *this, *this ); + if( event_processing_callback_ ) + { + event_processing_callback_->after_event( deferred_event->get_id() ); + } + + if( terminate_pseudostate_has_been_reached ) + { + SX_LOG( hermes::log_level::LL_INFO, "Terminate pseudostate has been reached! The state machine is stopping." ); + break; + } + else + { + if( event_is_deferred ) + { + deferred_events_.push_back( deferred_event ); + } + } + } + + return( terminate_pseudostate_has_been_reached ); + } + + + void state_machine_base::stop_all_async_states( state& _state ) + { + SX_FOR( region_uptr& region, _state.get_regions() ) + { + stop_all_async_states_from_region( region ); + } + } + + + void state_machine_base::stop_all_async_states_from_region( region_uptr& _region ) + { + state* const active_state = _region->get_active_state(); + if( active_state ) + { + async_simple_state_impl* const async_state = dynamic_cast< async_simple_state_impl* >( active_state ); + if( async_state ) + { + async_state->stop_do_behavior(); + } + else + { + stop_all_async_states( *active_state ); + } + } + } + + + void state_machine_base::interrupt_impl() + { + // Nothing to do... + } + +} diff --git a/libyasmine/source/state_machine_defect.cpp b/libyasmine/source/state_machine_defect.cpp index ebac2c9..5bdeb9f 100644 --- a/libyasmine/source/state_machine_defect.cpp +++ b/libyasmine/source/state_machine_defect.cpp @@ -1,109 +1,109 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_machine_defect.hpp" - -#include "hermes/log.hpp" - - -namespace sxy -{ - - -#ifdef SX_CPP03_BOOST - - - state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message ) - : element_( &_element ), - message_( sxe::sxprintf( _message.c_str() ) ) - { - // Nothing to do... - } - - -state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, - const sxe::value_type& _value ) - : element_( &_element ), - message_( sxe::sxprintf( _message.c_str(), _value ) ) -{ - // Nothing to do... -} - - -state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, - const sxe::value_type& _value1, const sxe::value_type& _value2 ) - : element_( &_element ), - message_( sxe::sxprintf( _message.c_str(), _value1, _value2 ) ) -{ - // Nothing to do... -} - - -state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, - const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3 ) - : element_( &_element ), - message_( sxe::sxprintf( _message.c_str(), _value1, _value2, _value3 ) ) -{ - // Nothing to do... -} - - -state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, - const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4 ) - : element_( &_element ), - message_( sxe::sxprintf( _message.c_str(), _value1, _value2, _value3, _value4 ) ) -{ - // Nothing to do... -} - - -state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, - const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, - const sxe::value_type& _value5 ) - : element_( &_element ), - message_( sxe::sxprintf( _message.c_str(), _value1, _value2, _value3, _value4, _value5 ) ) -{ - // Nothing to do... -} - - -#endif - - -state_machine_defect::~state_machine_defect() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const state_machine_element& state_machine_defect::get_element() const -{ - return( *element_ ); -} - - -const std::string& state_machine_defect::get_message() const -{ - return( message_ ); -} - - -// cppcheck-suppress unusedFunction -void write_defects_to_log( const state_machine_defects& _defects ) -{ - SX_FOR( const state_machine_defect &defect, _defects ) - { - SX_LOG( hermes::log_level::LL_ERROR, defect.get_message() ); - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_defect.hpp" + +#include "hermes/log.hpp" + + +namespace sxy +{ + + +#ifdef SX_CPP03_BOOST + + + state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message ) + : element_( &_element ), + message_( sxe::sxprintf( _message.c_str() ) ) + { + // Nothing to do... + } + + +state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, + const sxe::value_type& _value ) + : element_( &_element ), + message_( sxe::sxprintf( _message.c_str(), _value ) ) +{ + // Nothing to do... +} + + +state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, + const sxe::value_type& _value1, const sxe::value_type& _value2 ) + : element_( &_element ), + message_( sxe::sxprintf( _message.c_str(), _value1, _value2 ) ) +{ + // Nothing to do... +} + + +state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, + const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3 ) + : element_( &_element ), + message_( sxe::sxprintf( _message.c_str(), _value1, _value2, _value3 ) ) +{ + // Nothing to do... +} + + +state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, + const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4 ) + : element_( &_element ), + message_( sxe::sxprintf( _message.c_str(), _value1, _value2, _value3, _value4 ) ) +{ + // Nothing to do... +} + + +state_machine_defect::state_machine_defect( const state_machine_element& _element, const std::string& _message, + const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, + const sxe::value_type& _value5 ) + : element_( &_element ), + message_( sxe::sxprintf( _message.c_str(), _value1, _value2, _value3, _value4, _value5 ) ) +{ + // Nothing to do... +} + + +#endif + + +state_machine_defect::~state_machine_defect() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const state_machine_element& state_machine_defect::get_element() const +{ + return( *element_ ); +} + + +const std::string& state_machine_defect::get_message() const +{ + return( message_ ); +} + + +// cppcheck-suppress unusedFunction +void write_defects_to_log( const state_machine_defects& _defects ) +{ + SX_FOR( const state_machine_defect &defect, _defects ) + { + SX_LOG( hermes::log_level::LL_ERROR, defect.get_message() ); + } +} + + +} diff --git a/libyasmine/source/state_machine_element_impl.cpp b/libyasmine/source/state_machine_element_impl.cpp index 17f6b02..18a7132 100644 --- a/libyasmine/source/state_machine_element_impl.cpp +++ b/libyasmine/source/state_machine_element_impl.cpp @@ -1,38 +1,38 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_machine_element_impl.hpp" - - -namespace sxy -{ - - -state_machine_element_impl::state_machine_element_impl( const std::string& _name ) - : name_( _name ) -{ - // Nothing to do... -} - - -state_machine_element_impl::~state_machine_element_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const std::string& state_machine_element_impl::get_name() const -{ - return( name_ ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_element_impl.hpp" + + +namespace sxy +{ + + +state_machine_element_impl::state_machine_element_impl( const std::string& _name ) + : name_( _name ) +{ + // Nothing to do... +} + + +state_machine_element_impl::~state_machine_element_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const std::string& state_machine_element_impl::get_name() const +{ + return( name_ ); +} + + +} diff --git a/libyasmine/source/state_machine_status.cpp b/libyasmine/source/state_machine_status.cpp index 1651cb6..2e4a737 100644 --- a/libyasmine/source/state_machine_status.cpp +++ b/libyasmine/source/state_machine_status.cpp @@ -1,39 +1,39 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_machine_status.hpp" - - -namespace sxy -{ - - -#ifdef SX_CPP03_BOOST - - - // cppcheck-suppress unusedFunction - 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 - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_machine_status.hpp" + + +namespace sxy +{ + + +#ifdef SX_CPP03_BOOST + + + // cppcheck-suppress unusedFunction + 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/libyasmine/source/state_pseudostate_impl.cpp b/libyasmine/source/state_pseudostate_impl.cpp index 8921b46..6dabccf 100644 --- a/libyasmine/source/state_pseudostate_impl.cpp +++ b/libyasmine/source/state_pseudostate_impl.cpp @@ -1,107 +1,107 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "state_pseudostate_impl.hpp" - -#include "essentials/exception.hpp" - -#include "region.hpp" -#include "algorithm_parameters.hpp" - - -namespace sxy -{ - - -state_pseudostate_impl::state_pseudostate_impl( const std::string& _name ) - : pseudostate_impl( _name ), - parent_() -#ifdef Y_OPTIMIZE_4_SPEED - , ancestors_(), - ancestors_as_regions_() -#endif -{ -#ifdef Y_OPTIMIZE_4_SPEED - ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); - ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); -#endif -} - - -state_pseudostate_impl::~state_pseudostate_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -const state_machine_element* state_pseudostate_impl::get_parent() const -{ - return( &get_parent_state() ); -} - - -composite_state& state_pseudostate_impl::get_parent_state() const -{ - return( *parent_ ); -} - - -void state_pseudostate_impl::set_parent_state( composite_state* const _parent_state ) -{ - parent_ = _parent_state; -} - - -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, _include_final_ancestor ); - } - return( ancestors_ ); -#else - raw_composite_states ancestors; - collect_ancestors( ancestors, _final_ancestor, _include_final_ancestor ); - return( ancestors ); -#endif -} - - -raw_regions state_pseudostate_impl::get_ancestors_as_regions() const -{ -#ifdef Y_OPTIMIZE_4_SPEED - if( ancestors_as_regions_.empty() ) - { - ancestors_as_regions_ = get_parent_state().get_ancestors_as_regions(); - } - return( ancestors_as_regions_ ); -#else - return( get_parent_state().get_ancestors_as_regions() ); -#endif -} - - -void state_pseudostate_impl::collect_ancestors( raw_composite_states& _ancestors, - 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() ); - } -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "state_pseudostate_impl.hpp" + +#include "essentials/exception.hpp" + +#include "region.hpp" +#include "algorithm_parameters.hpp" + + +namespace sxy +{ + + +state_pseudostate_impl::state_pseudostate_impl( const std::string& _name ) + : pseudostate_impl( _name ), + parent_() +#ifdef Y_OPTIMIZE_4_SPEED + , ancestors_(), + ancestors_as_regions_() +#endif +{ +#ifdef Y_OPTIMIZE_4_SPEED + ancestors_as_regions_.reserve( ANCESTORS_VECTOR_SIZE ); + ancestors_.reserve( ANCESTORS_VECTOR_SIZE ); +#endif +} + + +state_pseudostate_impl::~state_pseudostate_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const state_machine_element* state_pseudostate_impl::get_parent() const +{ + return( &get_parent_state() ); +} + + +composite_state& state_pseudostate_impl::get_parent_state() const +{ + return( *parent_ ); +} + + +void state_pseudostate_impl::set_parent_state( composite_state* const _parent_state ) +{ + parent_ = _parent_state; +} + + +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, _include_final_ancestor ); + } + return( ancestors_ ); +#else + raw_composite_states ancestors; + collect_ancestors( ancestors, _final_ancestor, _include_final_ancestor ); + return( ancestors ); +#endif +} + + +raw_regions state_pseudostate_impl::get_ancestors_as_regions() const +{ +#ifdef Y_OPTIMIZE_4_SPEED + if( ancestors_as_regions_.empty() ) + { + ancestors_as_regions_ = get_parent_state().get_ancestors_as_regions(); + } + return( ancestors_as_regions_ ); +#else + return( get_parent_state().get_ancestors_as_regions() ); +#endif +} + + +void state_pseudostate_impl::collect_ancestors( raw_composite_states& _ancestors, + 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/libyasmine/source/states_nesting_comparer.cpp b/libyasmine/source/states_nesting_comparer.cpp index 5d70927..4a65b8f 100644 --- a/libyasmine/source/states_nesting_comparer.cpp +++ b/libyasmine/source/states_nesting_comparer.cpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "states_nesting_comparer.hpp" - -#include "state.hpp" - - -namespace sxy -{ - - -states_nesting_comparer::states_nesting_comparer() -{ - // Nothing to do... -} - - -states_nesting_comparer::~states_nesting_comparer() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool states_nesting_comparer::operator()( const state& _lhs, const state& _rhs ) const -{ - bool lhs_smaller_than_rhs = false; - if( _lhs.get_nesting_level() < _rhs.get_nesting_level() ) - { - lhs_smaller_than_rhs = true; - } - else - if( _lhs.get_nesting_level() > _rhs.get_nesting_level() ) - { - lhs_smaller_than_rhs = false; - } - else - if( _lhs.get_parent_region_index() < _rhs.get_parent_region_index() ) - { - lhs_smaller_than_rhs = true; - } - else - if( _lhs.get_parent_region_index() > _rhs.get_parent_region_index() ) - { - lhs_smaller_than_rhs = false; - } - else - { - lhs_smaller_than_rhs = &_lhs > &_rhs; - } - - return( lhs_smaller_than_rhs ); -} - - -bool states_nesting_comparer::operator()( const state* const _lhs, const state* const _rhs ) const -{ - return( operator()( *_lhs, *_rhs ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "states_nesting_comparer.hpp" + +#include "state.hpp" + + +namespace sxy +{ + + +states_nesting_comparer::states_nesting_comparer() +{ + // Nothing to do... +} + + +states_nesting_comparer::~states_nesting_comparer() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool states_nesting_comparer::operator()( const state& _lhs, const state& _rhs ) const +{ + bool lhs_smaller_than_rhs = false; + if( _lhs.get_nesting_level() < _rhs.get_nesting_level() ) + { + lhs_smaller_than_rhs = true; + } + else + if( _lhs.get_nesting_level() > _rhs.get_nesting_level() ) + { + lhs_smaller_than_rhs = false; + } + else + if( _lhs.get_parent_region_index() < _rhs.get_parent_region_index() ) + { + lhs_smaller_than_rhs = true; + } + else + if( _lhs.get_parent_region_index() > _rhs.get_parent_region_index() ) + { + lhs_smaller_than_rhs = false; + } + else + { + lhs_smaller_than_rhs = &_lhs > &_rhs; + } + + return( lhs_smaller_than_rhs ); +} + + +bool states_nesting_comparer::operator()( const state* const _lhs, const state* const _rhs ) const +{ + return( operator()( *_lhs, *_rhs ) ); +} + + +} diff --git a/libyasmine/source/states_nesting_comparer_ascending.cpp b/libyasmine/source/states_nesting_comparer_ascending.cpp index d5840ff..6d09c13 100644 --- a/libyasmine/source/states_nesting_comparer_ascending.cpp +++ b/libyasmine/source/states_nesting_comparer_ascending.cpp @@ -1,70 +1,70 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "states_nesting_comparer_ascending.hpp" - -#include "state.hpp" - - -namespace sxy -{ - - -states_nesting_comparer_ascending::states_nesting_comparer_ascending() -{ - // Nothing to do... -} - - -states_nesting_comparer_ascending::~states_nesting_comparer_ascending() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool states_nesting_comparer_ascending::operator()( const state& _lhs, const state& _rhs ) const -{ - bool lhs_smaller_than_rhs = false; - if( _lhs.get_nesting_level() > _rhs.get_nesting_level() ) - { - lhs_smaller_than_rhs = true; - } - else - if( _lhs.get_nesting_level() < _rhs.get_nesting_level() ) - { - lhs_smaller_than_rhs = false; - } - else - if( _lhs.get_parent_region_index() > _rhs.get_parent_region_index() ) - { - lhs_smaller_than_rhs = true; - } - else - if( _lhs.get_parent_region_index() < _rhs.get_parent_region_index() ) - { - lhs_smaller_than_rhs = false; - } - else - { - lhs_smaller_than_rhs = &_lhs < &_rhs; - } - - return( lhs_smaller_than_rhs ); -} - - -bool states_nesting_comparer_ascending::operator()( const state* const _lhs, const state* const _rhs ) const -{ - return( operator()( *_lhs, *_rhs ) ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "states_nesting_comparer_ascending.hpp" + +#include "state.hpp" + + +namespace sxy +{ + + +states_nesting_comparer_ascending::states_nesting_comparer_ascending() +{ + // Nothing to do... +} + + +states_nesting_comparer_ascending::~states_nesting_comparer_ascending() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool states_nesting_comparer_ascending::operator()( const state& _lhs, const state& _rhs ) const +{ + bool lhs_smaller_than_rhs = false; + if( _lhs.get_nesting_level() > _rhs.get_nesting_level() ) + { + lhs_smaller_than_rhs = true; + } + else + if( _lhs.get_nesting_level() < _rhs.get_nesting_level() ) + { + lhs_smaller_than_rhs = false; + } + else + if( _lhs.get_parent_region_index() > _rhs.get_parent_region_index() ) + { + lhs_smaller_than_rhs = true; + } + else + if( _lhs.get_parent_region_index() < _rhs.get_parent_region_index() ) + { + lhs_smaller_than_rhs = false; + } + else + { + lhs_smaller_than_rhs = &_lhs < &_rhs; + } + + return( lhs_smaller_than_rhs ); +} + + +bool states_nesting_comparer_ascending::operator()( const state* const _lhs, const state* const _rhs ) const +{ + return( operator()( *_lhs, *_rhs ) ); +} + + +} diff --git a/libyasmine/source/states_to_enter_visitor_impl.cpp b/libyasmine/source/states_to_enter_visitor_impl.cpp index 66ef28e..72c94e9 100644 --- a/libyasmine/source/states_to_enter_visitor_impl.cpp +++ b/libyasmine/source/states_to_enter_visitor_impl.cpp @@ -1,218 +1,218 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "states_to_enter_visitor_impl.hpp" - -#include "essentials/base.hpp" - -#include "simple_state.hpp" -#include "composite_state.hpp" -#include "final_state.hpp" -#include "region.hpp" -#include "deep_history.hpp" -#include "shallow_history.hpp" -#include "initial_pseudostate.hpp" -#include "choice.hpp" -#include "junction.hpp" -#include "join.hpp" -#include "fork.hpp" -#include "entry_point.hpp" -#include "exit_point.hpp" -#include "deep_history.hpp" -#include "shallow_history.hpp" -#include "terminate_pseudostate.hpp" - - -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, - 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 ), - source_of_transition_( _source_of_transition ) -{ - // Nothing to do... -} - - -states_to_enter_visitor_impl::~states_to_enter_visitor_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void states_to_enter_visitor_impl::visit( composite_state& _composite_state ) -{ - insert_states_to_enter( _composite_state ); -} - - -void states_to_enter_visitor_impl::visit( simple_state& _simple_state ) -{ - insert_states_to_enter( _simple_state ); -} - - -void states_to_enter_visitor_impl::visit( final_state& _final_state ) -{ - insert_states_to_enter( _final_state ); -} - - -void states_to_enter_visitor_impl::visit( initial_pseudostate& _initial_pseudostate ) -{ - SX_UNUSED_PARAMETER( _initial_pseudostate ); - SX_ASSERT( false, "A pseudostate cannot be entered!" ); -} - - -void states_to_enter_visitor_impl::visit( choice& _choice ) -{ - get_all_parent_states_to_enter( _choice ); -} - - -void states_to_enter_visitor_impl::visit( junction& _junction ) -{ - SX_UNUSED_PARAMETER( _junction ); - SX_ASSERT( false, "A pseudostate cannot be entered!" ); -} - - -void states_to_enter_visitor_impl::visit( join& _join ) -{ - SX_UNUSED_PARAMETER( _join ); - SX_ASSERT( false, "A pseudostate cannot be entered!" ); -} - - -void states_to_enter_visitor_impl::visit( fork& _fork ) -{ - SX_UNUSED_PARAMETER( _fork ); - SX_ASSERT( false, "A pseudostate cannot be entered!" ); -} - - -void states_to_enter_visitor_impl::visit( entry_point& _entry_point ) -{ - SX_UNUSED_PARAMETER( _entry_point ); - SX_ASSERT( false, "A pseudostate cannot be entered!" ); -} - - -void states_to_enter_visitor_impl::visit( exit_point& _exit_point ) -{ - SX_UNUSED_PARAMETER( _exit_point ); - SX_ASSERT( false, "A pseudostate cannot be entered!" ); -} - - -void states_to_enter_visitor_impl::visit( deep_history& _deep_history ) -{ - composite_state& parent_state = _deep_history.get_parent_state(); - states_to_enter_.insert( &parent_state ); - add_last_active_child_states_to_enter( parent_state ); -} - - -void states_to_enter_visitor_impl::visit( shallow_history& _shallow_history ) -{ - composite_state& parent_state = _shallow_history.get_parent_state(); - states_to_enter_.insert( &parent_state ); - - SX_FOR( const region_uptr& region, parent_state.get_regions() ) - { - state* const last_active_state_of_region = region->get_last_active_state(); - if( last_active_state_of_region ) - { - states_to_enter_.insert( last_active_state_of_region ); - } - - regions_to_enter_.insert( last_active_state_of_region->get_parent_region() ); - } -} - - -void states_to_enter_visitor_impl::visit( terminate_pseudostate& _terminate_pseudostate ) -{ - SX_UNUSED_PARAMETER( _terminate_pseudostate ); -} - - -void states_to_enter_visitor_impl::get_states_up_to_LCA( state& _state ) -{ - const raw_composite_states& ancestors = _state.get_ancestors( &LCA_of_compound_transition_ ); - - SX_FOR( composite_state* const ancestor, ancestors ) - { - if( ancestor != &LCA_of_compound_transition_ ) - { - states_to_enter_.insert( ancestor ); - } - } - - states_to_enter_.insert( &_state ); -} - - -void states_to_enter_visitor_impl::get_regions_up_to_LCA( const state& _state ) -{ - const raw_regions& ancestors_as_regions = _state.get_ancestors_as_regions(); - - SX_FOR( region* const ancestor_as_region, ancestors_as_regions ) - { - if( &ancestor_as_region->get_parent_state() != &LCA_of_compound_transition_ ) - { - regions_to_enter_.insert( ancestor_as_region ); - } - } -} - - -void states_to_enter_visitor_impl::add_last_active_child_states_to_enter( const state& _state ) -{ - SX_FOR( const region_uptr& region, _state.get_regions() ) - { - state* const state = region->get_last_active_state(); - states_to_enter_.insert( state ); - regions_to_enter_.insert( state->get_parent_region() ); - add_last_active_child_states_to_enter( *state ); - } -} - - -void states_to_enter_visitor_impl::insert_states_to_enter( state& _state ) -{ - states_to_enter_.insert( &_state ); - regions_to_enter_.insert( _state.get_parent_region() ); - get_states_up_to_LCA( _state ); - get_regions_up_to_LCA( _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 ); - SX_ASSERT( lca, "There is no last common ancestor for transitions's source and choice!" ); - raw_composite_states ancestors = _choice.get_ancestors( lca, false ); - SX_FOR( composite_state* ancestor, ancestors ) - { - states_to_enter_.insert( ancestor ); - } - -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "states_to_enter_visitor_impl.hpp" + +#include "essentials/base.hpp" + +#include "simple_state.hpp" +#include "composite_state.hpp" +#include "final_state.hpp" +#include "region.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" +#include "initial_pseudostate.hpp" +#include "choice.hpp" +#include "junction.hpp" +#include "join.hpp" +#include "fork.hpp" +#include "entry_point.hpp" +#include "exit_point.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" +#include "terminate_pseudostate.hpp" + + +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, + 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 ), + source_of_transition_( _source_of_transition ) +{ + // Nothing to do... +} + + +states_to_enter_visitor_impl::~states_to_enter_visitor_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void states_to_enter_visitor_impl::visit( composite_state& _composite_state ) +{ + insert_states_to_enter( _composite_state ); +} + + +void states_to_enter_visitor_impl::visit( simple_state& _simple_state ) +{ + insert_states_to_enter( _simple_state ); +} + + +void states_to_enter_visitor_impl::visit( final_state& _final_state ) +{ + insert_states_to_enter( _final_state ); +} + + +void states_to_enter_visitor_impl::visit( initial_pseudostate& _initial_pseudostate ) +{ + SX_UNUSED_PARAMETER( _initial_pseudostate ); + SX_ASSERT( false, "A pseudostate cannot be entered!" ); +} + + +void states_to_enter_visitor_impl::visit( choice& _choice ) +{ + get_all_parent_states_to_enter( _choice ); +} + + +void states_to_enter_visitor_impl::visit( junction& _junction ) +{ + SX_UNUSED_PARAMETER( _junction ); + SX_ASSERT( false, "A pseudostate cannot be entered!" ); +} + + +void states_to_enter_visitor_impl::visit( join& _join ) +{ + SX_UNUSED_PARAMETER( _join ); + SX_ASSERT( false, "A pseudostate cannot be entered!" ); +} + + +void states_to_enter_visitor_impl::visit( fork& _fork ) +{ + SX_UNUSED_PARAMETER( _fork ); + SX_ASSERT( false, "A pseudostate cannot be entered!" ); +} + + +void states_to_enter_visitor_impl::visit( entry_point& _entry_point ) +{ + SX_UNUSED_PARAMETER( _entry_point ); + SX_ASSERT( false, "A pseudostate cannot be entered!" ); +} + + +void states_to_enter_visitor_impl::visit( exit_point& _exit_point ) +{ + SX_UNUSED_PARAMETER( _exit_point ); + SX_ASSERT( false, "A pseudostate cannot be entered!" ); +} + + +void states_to_enter_visitor_impl::visit( deep_history& _deep_history ) +{ + composite_state& parent_state = _deep_history.get_parent_state(); + states_to_enter_.insert( &parent_state ); + add_last_active_child_states_to_enter( parent_state ); +} + + +void states_to_enter_visitor_impl::visit( shallow_history& _shallow_history ) +{ + composite_state& parent_state = _shallow_history.get_parent_state(); + states_to_enter_.insert( &parent_state ); + + SX_FOR( const region_uptr& region, parent_state.get_regions() ) + { + state* const last_active_state_of_region = region->get_last_active_state(); + if( last_active_state_of_region ) + { + states_to_enter_.insert( last_active_state_of_region ); + } + + regions_to_enter_.insert( last_active_state_of_region->get_parent_region() ); + } +} + + +void states_to_enter_visitor_impl::visit( terminate_pseudostate& _terminate_pseudostate ) +{ + SX_UNUSED_PARAMETER( _terminate_pseudostate ); +} + + +void states_to_enter_visitor_impl::get_states_up_to_LCA( state& _state ) +{ + const raw_composite_states& ancestors = _state.get_ancestors( &LCA_of_compound_transition_ ); + + SX_FOR( composite_state* const ancestor, ancestors ) + { + if( ancestor != &LCA_of_compound_transition_ ) + { + states_to_enter_.insert( ancestor ); + } + } + + states_to_enter_.insert( &_state ); +} + + +void states_to_enter_visitor_impl::get_regions_up_to_LCA( const state& _state ) +{ + const raw_regions& ancestors_as_regions = _state.get_ancestors_as_regions(); + + SX_FOR( region* const ancestor_as_region, ancestors_as_regions ) + { + if( &ancestor_as_region->get_parent_state() != &LCA_of_compound_transition_ ) + { + regions_to_enter_.insert( ancestor_as_region ); + } + } +} + + +void states_to_enter_visitor_impl::add_last_active_child_states_to_enter( const state& _state ) +{ + SX_FOR( const region_uptr& region, _state.get_regions() ) + { + state* const state = region->get_last_active_state(); + states_to_enter_.insert( state ); + regions_to_enter_.insert( state->get_parent_region() ); + add_last_active_child_states_to_enter( *state ); + } +} + + +void states_to_enter_visitor_impl::insert_states_to_enter( state& _state ) +{ + states_to_enter_.insert( &_state ); + regions_to_enter_.insert( _state.get_parent_region() ); + get_states_up_to_LCA( _state ); + get_regions_up_to_LCA( _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 ); + SX_ASSERT( lca, "There is no last common ancestor for transitions's source and choice!" ); + raw_composite_states ancestors = _choice.get_ancestors( lca, false ); + SX_FOR( composite_state* ancestor, ancestors ) + { + states_to_enter_.insert( ancestor ); + } + +} + + +} diff --git a/libyasmine/source/sync_state_machine.cpp b/libyasmine/source/sync_state_machine.cpp index 610017c..6b7a59d 100644 --- a/libyasmine/source/sync_state_machine.cpp +++ b/libyasmine/source/sync_state_machine.cpp @@ -1,89 +1,89 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "sync_state_machine.hpp" - -#include "hermes/log.hpp" - - -namespace sxy -{ - - -sync_state_machine::sync_state_machine( const std::string& _name, event_processing_callback* const _event_processing_callback ) - : state_machine_base(_name, _event_processing_callback) -{ - // Nothing to do... -} - - -sync_state_machine::~sync_state_machine() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool sync_state_machine::push( const event_sptr& _event ) -{ - event_list_.push_back( _event ); - return( true ); -} - - -bool sync_state_machine::fire_event( const event_sptr& _event ) -{ - SX_LOG( hermes::log_level::LL_INFO, "Firing & processing event '%' (%) with priority '%'.", _event->get_name(), - _event->get_id(), static_cast< sxe::int16_t >( _event->get_priority() ) ); - bool terminate_pseudostate_has_been_reached = true; - if( !is_interrupted() ) - { - terminate_pseudostate_has_been_reached = process_event( _event, SX_NULLPTR ); - if( !terminate_pseudostate_has_been_reached ) - { - terminate_pseudostate_has_been_reached = process_events_from_queue(); - } - SX_LOG( hermes::log_level::LL_INFO, "Event '%' (%) has been fired & processed.", _event->get_name(), _event->get_id() ); - } - else - { - SX_LOG( hermes::log_level::LL_INFO, "State machine is interrupted and no event can be fired!" ); - } - return( !terminate_pseudostate_has_been_reached ); -} - - -bool sync_state_machine::run() -{ - SX_LOG( hermes::log_level::LL_INFO, "Starting state machine '%'.", get_name() ); - - const bool state_machine_started = state_machine_base::run( SX_NULLPTR ); - - SX_LOG( hermes::log_level::LL_INFO, "Started state machine '%'.", get_name() ); - - - return( state_machine_started ); -} - - -bool sync_state_machine::process_events_from_queue() -{ - bool terminate_pseudostate_has_been_reached = false; - while( !event_list_.empty() && !terminate_pseudostate_has_been_reached ) - { - event_sptr event_to_be_fired = event_list_.front(); - event_list_.pop_front(); - terminate_pseudostate_has_been_reached = process_event( event_to_be_fired, SX_NULLPTR ); - } - return( terminate_pseudostate_has_been_reached ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "sync_state_machine.hpp" + +#include "hermes/log.hpp" + + +namespace sxy +{ + + +sync_state_machine::sync_state_machine( const std::string& _name, event_processing_callback* const _event_processing_callback ) + : state_machine_base(_name, _event_processing_callback) +{ + // Nothing to do... +} + + +sync_state_machine::~sync_state_machine() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool sync_state_machine::push( const event_sptr& _event ) +{ + event_list_.push_back( _event ); + return( true ); +} + + +bool sync_state_machine::fire_event( const event_sptr& _event ) +{ + SX_LOG( hermes::log_level::LL_INFO, "Firing & processing event '%' (%) with priority '%'.", _event->get_name(), + _event->get_id(), static_cast< sxe::int16_t >( _event->get_priority() ) ); + bool terminate_pseudostate_has_been_reached = true; + if( !is_interrupted() ) + { + terminate_pseudostate_has_been_reached = process_event( _event, SX_NULLPTR ); + if( !terminate_pseudostate_has_been_reached ) + { + terminate_pseudostate_has_been_reached = process_events_from_queue(); + } + SX_LOG( hermes::log_level::LL_INFO, "Event '%' (%) has been fired & processed.", _event->get_name(), _event->get_id() ); + } + else + { + SX_LOG( hermes::log_level::LL_INFO, "State machine is interrupted and no event can be fired!" ); + } + return( !terminate_pseudostate_has_been_reached ); +} + + +bool sync_state_machine::run() +{ + SX_LOG( hermes::log_level::LL_INFO, "Starting state machine '%'.", get_name() ); + + const bool state_machine_started = state_machine_base::run( SX_NULLPTR ); + + SX_LOG( hermes::log_level::LL_INFO, "Started state machine '%'.", get_name() ); + + + return( state_machine_started ); +} + + +bool sync_state_machine::process_events_from_queue() +{ + bool terminate_pseudostate_has_been_reached = false; + while( !event_list_.empty() && !terminate_pseudostate_has_been_reached ) + { + event_sptr event_to_be_fired = event_list_.front(); + event_list_.pop_front(); + terminate_pseudostate_has_been_reached = process_event( event_to_be_fired, SX_NULLPTR ); + } + return( terminate_pseudostate_has_been_reached ); +} + + +} diff --git a/libyasmine/source/terminate_pseudostate_impl.cpp b/libyasmine/source/terminate_pseudostate_impl.cpp index 9ab73da..fccb2a4 100644 --- a/libyasmine/source/terminate_pseudostate_impl.cpp +++ b/libyasmine/source/terminate_pseudostate_impl.cpp @@ -1,72 +1,72 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "terminate_pseudostate_impl.hpp" - -#include "essentials/base.hpp" - -#include "const_vertex_visitor.hpp" -#include "vertex_visitor.hpp" -#include "pseudostate_visitor.hpp" -#include "transition.hpp" - - -namespace sxy -{ - - -terminate_pseudostate_impl::terminate_pseudostate_impl( const std::string& _name ) - : region_pseudostate_impl( _name ) -{ - // Nothing to do... -} - - -terminate_pseudostate_impl::~terminate_pseudostate_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool terminate_pseudostate_impl::check( state_machine_defects& _defects ) const -{ - SX_UNUSED_PARAMETER( _defects ); - const bool check_ok = true; - return( check_ok ); -} - - -void terminate_pseudostate_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void terminate_pseudostate_impl::accept_vertex_visitor( vertex_visitor& _visitor ) -{ - _visitor.visit( *this ); -} - - -void terminate_pseudostate_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const -{ - _visitor.visit( *this ); -} - - -void terminate_pseudostate_impl::add_outgoing_transition( transition& _outgoing_transition ) -{ - SX_UNUSED_PARAMETER( _outgoing_transition ); - SX_ASSERT( vertex_impl::get_outgoing_transitions().empty(), "Terminate pseudostate cannot have outgoing transitions!" ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "terminate_pseudostate_impl.hpp" + +#include "essentials/base.hpp" + +#include "const_vertex_visitor.hpp" +#include "vertex_visitor.hpp" +#include "pseudostate_visitor.hpp" +#include "transition.hpp" + + +namespace sxy +{ + + +terminate_pseudostate_impl::terminate_pseudostate_impl( const std::string& _name ) + : region_pseudostate_impl( _name ) +{ + // Nothing to do... +} + + +terminate_pseudostate_impl::~terminate_pseudostate_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool terminate_pseudostate_impl::check( state_machine_defects& _defects ) const +{ + SX_UNUSED_PARAMETER( _defects ); + const bool check_ok = true; + return( check_ok ); +} + + +void terminate_pseudostate_impl::accept_vertex_visitor( const_vertex_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void terminate_pseudostate_impl::accept_vertex_visitor( vertex_visitor& _visitor ) +{ + _visitor.visit( *this ); +} + + +void terminate_pseudostate_impl::accept_pseudostate_visitor( pseudostate_visitor& _visitor ) const +{ + _visitor.visit( *this ); +} + + +void terminate_pseudostate_impl::add_outgoing_transition( transition& _outgoing_transition ) +{ + SX_UNUSED_PARAMETER( _outgoing_transition ); + SX_ASSERT( vertex_impl::get_outgoing_transitions().empty(), "Terminate pseudostate cannot have outgoing transitions!" ); +} + + +} diff --git a/libyasmine/source/timed_event_creator.cpp b/libyasmine/source/timed_event_creator.cpp index bf60004..2f292b7 100644 --- a/libyasmine/source/timed_event_creator.cpp +++ b/libyasmine/source/timed_event_creator.cpp @@ -1,255 +1,255 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "timed_event_creator.hpp" - -#include - -#include "essentials/base.hpp" -#include "hermes/log_and_throw.hpp" - -#include "event_creation_request.hpp" -#include "async_state_machine.hpp" -#include "event_impl.hpp" - - -namespace sxy -{ - - -timed_event_creator::timed_event_creator( async_state_machine& _async_state_machine ) - : state_machine_( _async_state_machine ), - event_creation_requests_(), - worker_(), - mutex_(), - condition_variable_(), - run_( true ), - maximum_handle_ ( 0 ) -{ - // Nothing to do... -} - - -timed_event_creator::~timed_event_creator() SX_NOEXCEPT -{ - SX_ASSERT( !run_, "Thread is still running! It was not stopped." ); - SX_ASSERT( !worker_, "The thread still exists!" ); -} - - -handle_type timed_event_creator::create_event_creation_request( - const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event ) -{ - handle_type handle = Y_DEFAULT_HANDLE; - { - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - if( run_ ) - { - handle = generate_handle(); - event_creation_requests_.insert( event_creation_request( _time, _event, handle ) ); - } - else - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, - "Time based event creator is not running. Event creation requests cannot be created!" ); - } - } - condition_variable_.notify_one(); - return( handle ); -} - - -handle_type timed_event_creator::create_event_creation_request( - const sxe::milliseconds& _time_till_event_is_fired, const event_sptr& _event ) -{ - const handle_type handle = create_event_creation_request( - sxe::system_clock::now() + _time_till_event_is_fired, _event ); - return( handle ); -} - - -bool timed_event_creator::cancel( const handle_type _handle ) -{ - bool cancelled = false; - { - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - const event_queue::iterator found_element_iterator = find_element_by_handle( _handle ); - if( found_element_iterator != event_creation_requests_.end() ) - { - event_creation_requests_.erase( found_element_iterator ); - cancelled = true; - SX_LOG( hermes::log_level::LL_TRACE, "Event with handle '%' was cancelled.", _handle ); - } - else - { - SX_LOG( hermes::log_level::LL_WARN, "Event with handle '%' was NOT found.", _handle ); - } - } - return( cancelled ); -} - - -void timed_event_creator::run() -{ - SX_LOG( hermes::log_level::LL_TRACE, "Event creator is starting." ); - run_ = true; - worker_ = SX_MAKE_UNIQUE< sxe::thread >( sxe::bind( &timed_event_creator::generate_event, this ) ); - SX_LOG( hermes::log_level::LL_TRACE, "Event creator started." ); -} - - -void timed_event_creator::halt() -{ - SX_LOG( hermes::log_level::LL_TRACE, "Event creator is stopping." ); - { - sxe::lock_guard< sxe::mutex > lock( mutex_ ); - run_ = false; - } - condition_variable_.notify_all(); -} - - -void timed_event_creator::join() -{ - SX_ASSERT( worker_->joinable(), "Time event generator thread is not joinable!" ); - worker_->join(); - worker_.reset(); - SX_LOG( hermes::log_level::LL_TRACE, "Event creator stopped." ); -} - - -void timed_event_creator::halt_and_join() -{ - SX_LOG( hermes::log_level::LL_TRACE, "Event creator is stopping." ); - { - sxe::lock_guard< sxe::mutex > lock( mutex_ ); - run_ = false; - } - condition_variable_.notify_all(); - SX_ASSERT( worker_->joinable(), "Time event generator thread is not joinable!" ); - worker_->join(); - worker_.reset(); - SX_LOG( hermes::log_level::LL_TRACE, "Event creator stopped." ); -} - - -handle_type timed_event_creator::generate_handle() -{ - handle_type handle = Y_DEFAULT_HANDLE; - - do - { - handle = maximum_handle_++; - if( maximum_handle_ == Y_INVALID_EVENT_CREATION_REQUEST_HANDLE ) - { - maximum_handle_ = 0; - } - } - while( check_if_handle_exists( handle ) ); - - return( handle ); -} - - -bool timed_event_creator::check_if_handle_exists( const handle_type _handle ) const -{ - bool found = false; - const event_queue::const_iterator found_element_iterator = find_element_by_handle( _handle ); - if( found_element_iterator != event_creation_requests_.end() ) - { - found = true; - } - - return( found ); -} - - -void timed_event_creator::generate_event() -{ - try - { - sxe::unique_lock< sxe::mutex > lock( mutex_ ); - while( run_ ) - { - if( event_creation_requests_.empty() ) - { - condition_variable_.wait( lock, sxe::bind( &timed_event_creator::check_wait_condition, this ) ); - } - else - { - const event_creation_request& event_creation_request = *event_creation_requests_.begin(); - condition_variable_.wait_until( lock, event_creation_request.get_time() ); - if( run_ ) - { - event_queue::const_iterator event_iterator = event_creation_requests_.begin(); - while( event_iterator != event_creation_requests_.end() ) - { - const sxe::time_point< sxe::system_clock > now = sxe::system_clock::now(); - SX_LOG( hermes::log_level::LL_TRACE, "Checking for event @ %.", now.time_since_epoch().count() ); - if( ( *event_iterator ).get_time() <= now ) - { - const event_sptr event = ( *event_iterator ).get_event(); - SX_LOG( hermes::log_level::LL_TRACE, "Try to fire event '%' (%) with handle '%'.", event->get_name(), event->get_id(), - ( *event_iterator ).get_handle() ); - if( !state_machine_.fire_event( event ) ) - { - SX_LOG( hermes::log_level::LL_ERROR, "Event '%' (%) and handle was not fired!", event->get_name(), event->get_id(), - ( *event_iterator ).get_handle() ); - run_ = false; - break; - } - - SX_LOG( hermes::log_level::LL_DEBUG, "Event '%' (%) with handle '%' was fired.", event->get_name(), event->get_id(), - ( *event_iterator ).get_handle() ); - event_creation_requests_.erase( event_iterator ); - event_iterator = event_creation_requests_.begin(); - } - else - { - break; - } - } - } - } - } - } - catch ( const std::exception& exception ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unhandled std::exception when generating time based event: %", exception.what() ); - } - catch ( ... ) - { - SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception when generating time based event!" ); - } -} - - -event_queue::const_iterator timed_event_creator::find_element_by_handle( const handle_type _handle ) const -{ - return( std::find_if(event_creation_requests_.begin(), event_creation_requests_.end(), - sxe::bind( &timed_event_creator::compare_handles, _handle, sxe::_1 ) ) ); -} - - -bool timed_event_creator::check_wait_condition() const -{ - return( !( run_ && event_creation_requests_.empty() ) ); -} - - -bool timed_event_creator::compare_handles( const handle_type _handle, - const event_creation_request& _event_creation_request ) -{ - return ( _event_creation_request.get_handle() == _handle ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "timed_event_creator.hpp" + +#include + +#include "essentials/base.hpp" +#include "hermes/log_and_throw.hpp" + +#include "event_creation_request.hpp" +#include "async_state_machine.hpp" +#include "event_impl.hpp" + + +namespace sxy +{ + + +timed_event_creator::timed_event_creator( async_state_machine& _async_state_machine ) + : state_machine_( _async_state_machine ), + event_creation_requests_(), + worker_(), + mutex_(), + condition_variable_(), + run_( true ), + maximum_handle_ ( 0 ) +{ + // Nothing to do... +} + + +timed_event_creator::~timed_event_creator() SX_NOEXCEPT +{ + SX_ASSERT( !run_, "Thread is still running! It was not stopped." ); + SX_ASSERT( !worker_, "The thread still exists!" ); +} + + +handle_type timed_event_creator::create_event_creation_request( + const sxe::time_point< sxe::system_clock >& _time, const event_sptr _event ) +{ + handle_type handle = Y_DEFAULT_HANDLE; + { + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + if( run_ ) + { + handle = generate_handle(); + event_creation_requests_.insert( event_creation_request( _time, _event, handle ) ); + } + else + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, + "Time based event creator is not running. Event creation requests cannot be created!" ); + } + } + condition_variable_.notify_one(); + return( handle ); +} + + +handle_type timed_event_creator::create_event_creation_request( + const sxe::milliseconds& _time_till_event_is_fired, const event_sptr& _event ) +{ + const handle_type handle = create_event_creation_request( + sxe::system_clock::now() + _time_till_event_is_fired, _event ); + return( handle ); +} + + +bool timed_event_creator::cancel( const handle_type _handle ) +{ + bool cancelled = false; + { + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + const event_queue::iterator found_element_iterator = find_element_by_handle( _handle ); + if( found_element_iterator != event_creation_requests_.end() ) + { + event_creation_requests_.erase( found_element_iterator ); + cancelled = true; + SX_LOG( hermes::log_level::LL_TRACE, "Event with handle '%' was cancelled.", _handle ); + } + else + { + SX_LOG( hermes::log_level::LL_WARN, "Event with handle '%' was NOT found.", _handle ); + } + } + return( cancelled ); +} + + +void timed_event_creator::run() +{ + SX_LOG( hermes::log_level::LL_TRACE, "Event creator is starting." ); + run_ = true; + worker_ = SX_MAKE_UNIQUE< sxe::thread >( sxe::bind( &timed_event_creator::generate_event, this ) ); + SX_LOG( hermes::log_level::LL_TRACE, "Event creator started." ); +} + + +void timed_event_creator::halt() +{ + SX_LOG( hermes::log_level::LL_TRACE, "Event creator is stopping." ); + { + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + run_ = false; + } + condition_variable_.notify_all(); +} + + +void timed_event_creator::join() +{ + SX_ASSERT( worker_->joinable(), "Time event generator thread is not joinable!" ); + worker_->join(); + worker_.reset(); + SX_LOG( hermes::log_level::LL_TRACE, "Event creator stopped." ); +} + + +void timed_event_creator::halt_and_join() +{ + SX_LOG( hermes::log_level::LL_TRACE, "Event creator is stopping." ); + { + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + run_ = false; + } + condition_variable_.notify_all(); + SX_ASSERT( worker_->joinable(), "Time event generator thread is not joinable!" ); + worker_->join(); + worker_.reset(); + SX_LOG( hermes::log_level::LL_TRACE, "Event creator stopped." ); +} + + +handle_type timed_event_creator::generate_handle() +{ + handle_type handle = Y_DEFAULT_HANDLE; + + do + { + handle = maximum_handle_++; + if( maximum_handle_ == Y_INVALID_EVENT_CREATION_REQUEST_HANDLE ) + { + maximum_handle_ = 0; + } + } + while( check_if_handle_exists( handle ) ); + + return( handle ); +} + + +bool timed_event_creator::check_if_handle_exists( const handle_type _handle ) const +{ + bool found = false; + const event_queue::const_iterator found_element_iterator = find_element_by_handle( _handle ); + if( found_element_iterator != event_creation_requests_.end() ) + { + found = true; + } + + return( found ); +} + + +void timed_event_creator::generate_event() +{ + try + { + sxe::unique_lock< sxe::mutex > lock( mutex_ ); + while( run_ ) + { + if( event_creation_requests_.empty() ) + { + condition_variable_.wait( lock, sxe::bind( &timed_event_creator::check_wait_condition, this ) ); + } + else + { + const event_creation_request& event_creation_request = *event_creation_requests_.begin(); + condition_variable_.wait_until( lock, event_creation_request.get_time() ); + if( run_ ) + { + event_queue::const_iterator event_iterator = event_creation_requests_.begin(); + while( event_iterator != event_creation_requests_.end() ) + { + const sxe::time_point< sxe::system_clock > now = sxe::system_clock::now(); + SX_LOG( hermes::log_level::LL_TRACE, "Checking for event @ %.", now.time_since_epoch().count() ); + if( ( *event_iterator ).get_time() <= now ) + { + const event_sptr event = ( *event_iterator ).get_event(); + SX_LOG( hermes::log_level::LL_TRACE, "Try to fire event '%' (%) with handle '%'.", event->get_name(), event->get_id(), + ( *event_iterator ).get_handle() ); + if( !state_machine_.fire_event( event ) ) + { + SX_LOG( hermes::log_level::LL_ERROR, "Event '%' (%) and handle was not fired!", event->get_name(), event->get_id(), + ( *event_iterator ).get_handle() ); + run_ = false; + break; + } + + SX_LOG( hermes::log_level::LL_DEBUG, "Event '%' (%) with handle '%' was fired.", event->get_name(), event->get_id(), + ( *event_iterator ).get_handle() ); + event_creation_requests_.erase( event_iterator ); + event_iterator = event_creation_requests_.begin(); + } + else + { + break; + } + } + } + } + } + } + catch ( const std::exception& exception ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unhandled std::exception when generating time based event: %", exception.what() ); + } + catch ( ... ) + { + SX_LOG( hermes::log_level::LL_FATAL, "Unknown exception when generating time based event!" ); + } +} + + +event_queue::const_iterator timed_event_creator::find_element_by_handle( const handle_type _handle ) const +{ + return( std::find_if(event_creation_requests_.begin(), event_creation_requests_.end(), + sxe::bind( &timed_event_creator::compare_handles, _handle, sxe::_1 ) ) ); +} + + +bool timed_event_creator::check_wait_condition() const +{ + return( !( run_ && event_creation_requests_.empty() ) ); +} + + +bool timed_event_creator::compare_handles( const handle_type _handle, + const event_creation_request& _event_creation_request ) +{ + return ( _event_creation_request.get_handle() == _handle ); +} + + +} diff --git a/libyasmine/source/transition_controller.cpp b/libyasmine/source/transition_controller.cpp index 5c8e81e..8793f08 100644 --- a/libyasmine/source/transition_controller.cpp +++ b/libyasmine/source/transition_controller.cpp @@ -1,224 +1,224 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_controller.hpp" - -#include "essentials/conversion.hpp" -#include "hermes/log.hpp" -#include "hermes/log_and_throw.hpp" - -#include "composite_state.hpp" -#include "transition_finder.hpp" -#include "transition_executor.hpp" -#include "event_impl.hpp" -#include "event_processing_callback.hpp" -#include "compound_transition_impl.hpp" -#include "behavior_exception.hpp" -#include "algorithm_parameters.hpp" -#include "completion_event.hpp" -#include "interruptible.hpp" - - -namespace sxy -{ - - -transition_controller::transition_controller() -{ - // Nothing to do... -} - - -transition_controller::~transition_controller() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool transition_controller::process_event( const event& _event, const composite_state& _main_composite_state, - event_processing_callback* const _event_processing_callback, bool& _event_is_deferred, - async_event_handler* const _async_event_handler, event_collector& _event_collector, - const interruptible& _interruptible ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Begin processing event '%'.", _event.get_id() ); - bool reached_terminate_pseudostate = false; - compound_transitions enabled_compound_transitions; - enabled_compound_transitions.reserve( COMPOUND_TRANSITIONS_VECTOR_SIZE ); - SX_LOG( hermes::log_level::LL_SPAM, "Search for enabled transition(s) for event '%'.", _event.get_id() ); - transition_finder transition_finder; - transition_finder.search_for_enabled_transitions_in_all_regions( _main_composite_state, _event, - enabled_compound_transitions, _event_is_deferred, _event_collector ); - if( enabled_compound_transitions.empty() ) - { - SX_LOG( hermes::log_level::LL_TRACE, "There are no compound transitions to execute for the event '%'.", - _event.get_id() ); - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "Found % enabled transition(s) for event '%'.", - enabled_compound_transitions.size(), _event.get_id() ); - SX_LOG( hermes::log_level::LL_SPAM, "Start executing transition(s) for event '%'.", _event.get_id() ); - reached_terminate_pseudostate = execute_transitions( _main_composite_state, enabled_compound_transitions, - _event_processing_callback, _event, _async_event_handler, _event_collector, _interruptible ); - _event_is_deferred = false; - } - - SX_LOG( hermes::log_level::LL_TRACE, "End of processing event '%'.", _event.get_id() ); - return( reached_terminate_pseudostate ); -} - - -bool transition_controller::start_state_machine( const composite_state& _main_composite_state, - event_processing_callback* const _event_processing_callback, async_event_handler* const _async_event_handler, - event_collector& _event_collector, const interruptible& _interruptible ) -{ - bool terminate_pseudostate_has_been_reached = false; - compound_transitions enabled_compound_transitions; - enabled_compound_transitions.reserve( ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE ); - transition_finder transition_finder; - SX_LOG( hermes::log_level::LL_TRACE, "Searching for initial transitions on state machine start." ); - transition_finder.search_initial_transitions( _main_composite_state, enabled_compound_transitions, _event_collector ); - if( enabled_compound_transitions.empty() ) - { - SX_LOG( hermes::log_level::LL_TRACE, "No initial transitions found." ); - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "Found % compound transition(s) after searching for initial transitions.", - enabled_compound_transitions.size() ); - SX_LOG( hermes::log_level::LL_TRACE, "Executing transitions." ); - if( execute_transitions( _main_composite_state, enabled_compound_transitions, _event_processing_callback, - *completion_event::create(), _async_event_handler, _event_collector, _interruptible ) ) - { - SX_LOG( hermes::log_level::LL_DEBUG, "Terminate pseudostate has been reached." ); - terminate_pseudostate_has_been_reached = true; - } - } - - return( !terminate_pseudostate_has_been_reached ); -} - - -bool transition_controller::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, event_collector& _event_collector, - const interruptible& _interruptible ) -{ - bool terminate_pseudostate_has_been_reached = false; - transition_executor transition_executor; - events exception_events; - exception_events.reserve( EXCEPTION_EVENTS_VECTOR_SIZE ); - - while( !compound_transitions.empty() && !_interruptible.is_interrupted() ) - { - raw_const_choices choices; - choices.reserve( CHOICES_VECTOR_SIZE ); - if( _event_processing_callback ) - { - _event_processing_callback->before_event_processings_stage(); - } - - SX_LOG( hermes::log_level::LL_TRACE, "Check, sort and execute transitions." ); - terminate_pseudostate_has_been_reached = transition_executor.check_sort_and_execute_transitions( - compound_transitions, choices, _event_processing_callback, _event, exception_events, _async_event_handler, - _event_collector, _interruptible ); - if( terminate_pseudostate_has_been_reached ) - { - SX_LOG( hermes::log_level::LL_DEBUG, "Terminate pseudostate has been reached." ); - break; - } - - compound_transitions.clear(); - SX_LOG( hermes::log_level::LL_SPAM, "Search for choice transitions." ); - search_choice_transitions( choices, compound_transitions, _event, _event_collector ); - SX_LOG( hermes::log_level::LL_TRACE, "Found % transition(s) after searched for choice transitions.", - compound_transitions.size() ); - - if( compound_transitions.empty() ) - { - if(!choices.empty() ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "There are choices but no choice transitions!" ); - } - - while(!exception_events.empty()) - { - if( _event_processing_callback ) - { - _event_processing_callback->after_event_processings_stage( choices ); - } - - handle_execution_events( exception_events, _event_processing_callback, _main_composite_state, - compound_transitions, _async_event_handler, _event_collector, _interruptible ); - } - - SX_LOG( hermes::log_level::LL_TRACE, "Searching for completion event transitions." ); - search_completion_event_transitions( _main_composite_state, compound_transitions, _event_collector ); - } - - if( _event_processing_callback ) - { - _event_processing_callback->after_event_processings_stage( choices ); - } - } - - return( terminate_pseudostate_has_been_reached ); -} - - -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, - event_collector& _event_collector, const interruptible& _interruptible ) -{ - 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, _event_collector ); - execute_transitions( _main_composite_state, _compound_transitions, _event_processing_callback, *error_event, - _async_event_handler, _event_collector, _interruptible ); - _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, event_collector& _event_collector ) -{ - transition_finder transition_finder; - transition_finder.search_choice_transitions( _choices, compound_transitions, _event, _event_collector ); -} - - -void transition_controller::search_completion_event_transitions( const composite_state& _main_composite_state, - compound_transitions& compound_transitions, event_collector& _event_collector ) -{ - bool event_is_deferred = false; - transition_finder transition_finder; - transition_finder.search_for_enabled_completion_transitions_in_all_regions( _main_composite_state, - compound_transitions, event_is_deferred, _event_collector ); - SX_ASSERT( !event_is_deferred, "An completion transition was deferred!" ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_controller.hpp" + +#include "essentials/conversion.hpp" +#include "hermes/log.hpp" +#include "hermes/log_and_throw.hpp" + +#include "composite_state.hpp" +#include "transition_finder.hpp" +#include "transition_executor.hpp" +#include "event_impl.hpp" +#include "event_processing_callback.hpp" +#include "compound_transition_impl.hpp" +#include "behavior_exception.hpp" +#include "algorithm_parameters.hpp" +#include "completion_event.hpp" +#include "interruptible.hpp" + + +namespace sxy +{ + + +transition_controller::transition_controller() +{ + // Nothing to do... +} + + +transition_controller::~transition_controller() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool transition_controller::process_event( const event& _event, const composite_state& _main_composite_state, + event_processing_callback* const _event_processing_callback, bool& _event_is_deferred, + async_event_handler* const _async_event_handler, event_collector& _event_collector, + const interruptible& _interruptible ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Begin processing event '%'.", _event.get_id() ); + bool reached_terminate_pseudostate = false; + compound_transitions enabled_compound_transitions; + enabled_compound_transitions.reserve( COMPOUND_TRANSITIONS_VECTOR_SIZE ); + SX_LOG( hermes::log_level::LL_SPAM, "Search for enabled transition(s) for event '%'.", _event.get_id() ); + transition_finder transition_finder; + transition_finder.search_for_enabled_transitions_in_all_regions( _main_composite_state, _event, + enabled_compound_transitions, _event_is_deferred, _event_collector ); + if( enabled_compound_transitions.empty() ) + { + SX_LOG( hermes::log_level::LL_TRACE, "There are no compound transitions to execute for the event '%'.", + _event.get_id() ); + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "Found % enabled transition(s) for event '%'.", + enabled_compound_transitions.size(), _event.get_id() ); + SX_LOG( hermes::log_level::LL_SPAM, "Start executing transition(s) for event '%'.", _event.get_id() ); + reached_terminate_pseudostate = execute_transitions( _main_composite_state, enabled_compound_transitions, + _event_processing_callback, _event, _async_event_handler, _event_collector, _interruptible ); + _event_is_deferred = false; + } + + SX_LOG( hermes::log_level::LL_TRACE, "End of processing event '%'.", _event.get_id() ); + return( reached_terminate_pseudostate ); +} + + +bool transition_controller::start_state_machine( const composite_state& _main_composite_state, + event_processing_callback* const _event_processing_callback, async_event_handler* const _async_event_handler, + event_collector& _event_collector, const interruptible& _interruptible ) +{ + bool terminate_pseudostate_has_been_reached = false; + compound_transitions enabled_compound_transitions; + enabled_compound_transitions.reserve( ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE ); + transition_finder transition_finder; + SX_LOG( hermes::log_level::LL_TRACE, "Searching for initial transitions on state machine start." ); + transition_finder.search_initial_transitions( _main_composite_state, enabled_compound_transitions, _event_collector ); + if( enabled_compound_transitions.empty() ) + { + SX_LOG( hermes::log_level::LL_TRACE, "No initial transitions found." ); + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "Found % compound transition(s) after searching for initial transitions.", + enabled_compound_transitions.size() ); + SX_LOG( hermes::log_level::LL_TRACE, "Executing transitions." ); + if( execute_transitions( _main_composite_state, enabled_compound_transitions, _event_processing_callback, + *completion_event::create(), _async_event_handler, _event_collector, _interruptible ) ) + { + SX_LOG( hermes::log_level::LL_DEBUG, "Terminate pseudostate has been reached." ); + terminate_pseudostate_has_been_reached = true; + } + } + + return( !terminate_pseudostate_has_been_reached ); +} + + +bool transition_controller::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, event_collector& _event_collector, + const interruptible& _interruptible ) +{ + bool terminate_pseudostate_has_been_reached = false; + transition_executor transition_executor; + events exception_events; + exception_events.reserve( EXCEPTION_EVENTS_VECTOR_SIZE ); + + while( !compound_transitions.empty() && !_interruptible.is_interrupted() ) + { + raw_const_choices choices; + choices.reserve( CHOICES_VECTOR_SIZE ); + if( _event_processing_callback ) + { + _event_processing_callback->before_event_processings_stage(); + } + + SX_LOG( hermes::log_level::LL_TRACE, "Check, sort and execute transitions." ); + terminate_pseudostate_has_been_reached = transition_executor.check_sort_and_execute_transitions( + compound_transitions, choices, _event_processing_callback, _event, exception_events, _async_event_handler, + _event_collector, _interruptible ); + if( terminate_pseudostate_has_been_reached ) + { + SX_LOG( hermes::log_level::LL_DEBUG, "Terminate pseudostate has been reached." ); + break; + } + + compound_transitions.clear(); + SX_LOG( hermes::log_level::LL_SPAM, "Search for choice transitions." ); + search_choice_transitions( choices, compound_transitions, _event, _event_collector ); + SX_LOG( hermes::log_level::LL_TRACE, "Found % transition(s) after searched for choice transitions.", + compound_transitions.size() ); + + if( compound_transitions.empty() ) + { + if(!choices.empty() ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "There are choices but no choice transitions!" ); + } + + while(!exception_events.empty()) + { + if( _event_processing_callback ) + { + _event_processing_callback->after_event_processings_stage( choices ); + } + + handle_execution_events( exception_events, _event_processing_callback, _main_composite_state, + compound_transitions, _async_event_handler, _event_collector, _interruptible ); + } + + SX_LOG( hermes::log_level::LL_TRACE, "Searching for completion event transitions." ); + search_completion_event_transitions( _main_composite_state, compound_transitions, _event_collector ); + } + + if( _event_processing_callback ) + { + _event_processing_callback->after_event_processings_stage( choices ); + } + } + + return( terminate_pseudostate_has_been_reached ); +} + + +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, + event_collector& _event_collector, const interruptible& _interruptible ) +{ + 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, _event_collector ); + execute_transitions( _main_composite_state, _compound_transitions, _event_processing_callback, *error_event, + _async_event_handler, _event_collector, _interruptible ); + _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, event_collector& _event_collector ) +{ + transition_finder transition_finder; + transition_finder.search_choice_transitions( _choices, compound_transitions, _event, _event_collector ); +} + + +void transition_controller::search_completion_event_transitions( const composite_state& _main_composite_state, + compound_transitions& compound_transitions, event_collector& _event_collector ) +{ + bool event_is_deferred = false; + transition_finder transition_finder; + transition_finder.search_for_enabled_completion_transitions_in_all_regions( _main_composite_state, + compound_transitions, event_is_deferred, _event_collector ); + SX_ASSERT( !event_is_deferred, "An completion transition was deferred!" ); +} + + +} diff --git a/libyasmine/source/transition_executor.cpp b/libyasmine/source/transition_executor.cpp index c7e74c8..1f6aa02 100644 --- a/libyasmine/source/transition_executor.cpp +++ b/libyasmine/source/transition_executor.cpp @@ -1,101 +1,101 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_executor.hpp" - -#include "hermes/log.hpp" - -#include "transition_executor_impl.hpp" -#include "choice_fwd.hpp" -#include "execution_step.hpp" -#include "region_fwd.hpp" -#include "compound_transition_impl.hpp" -#include "event_processing_callback.hpp" -#include "event.hpp" -#include "algorithm_parameters.hpp" -#include "interruptible.hpp" - - -namespace sxy -{ - - -transition_executor::transition_executor() - : transition_executor_impl_() -{ - // Nothing to do... -} - - -transition_executor::~transition_executor() SX_NOEXCEPT -{ - // Nothing to do... -} - - -bool transition_executor::check_sort_and_execute_transitions( const compound_transitions& _compound_transitions, - raw_const_choices& _vertices, event_processing_callback* const _event_processing_callback, - const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector, const interruptible& _interruptible ) -{ - bool terminate_pseudostate_has_been_reached = false; - SX_LOG( hermes::log_level::LL_TRACE, "Check for transition conflicts." ); - transition_executor_impl_->conflict_check( _compound_transitions ); - SX_LOG( hermes::log_level::LL_TRACE, "Sorting compound transitions." ); - const raw_compound_transitions& sorted_compound_transitions = - transition_executor_impl_->sort_compound_transitions( _compound_transitions ); - SX_LOG( hermes::log_level::LL_TRACE, "Compound transitions sorted." ); - SX_LOG( hermes::log_level::LL_TRACE, "Start calculating execution step(s) for all compound transitions." ); - - SX_FOR( compound_transition* const compound_transition, sorted_compound_transitions ) - { - if( _interruptible.is_interrupted() ) - { - break; - } - - if( _event_processing_callback ) - { - _event_processing_callback->before_compound_transition(); - } - - execution_steps execution_steps; - execution_steps.reserve( EXECUTION_STEPS_VECTOR_SIZE ); - raw_const_region_set entered_regions; - SX_LOG( hermes::log_level::LL_TRACE, "Calculate execution step(s) for one compound transition." ); - transition_executor_impl_->find_states_to_enter_and_to_exit_and_calculate_execution_steps( *compound_transition, - execution_steps, entered_regions, _event, true, _event_collector ); - SX_LOG( hermes::log_level::LL_TRACE, "Found % execution step(s).", execution_steps.size() ); - SX_LOG( hermes::log_level::LL_TRACE, "Start running execution step(s)." ); - terminate_pseudostate_has_been_reached = transition_executor_impl_->run_execution_steps( execution_steps, - _event_processing_callback, _event, _exception_events, _async_event_handler, _event_collector ); - SX_LOG( hermes::log_level::LL_TRACE, "Finished running execution step(s)." ); - if( terminate_pseudostate_has_been_reached ) - { - SX_LOG( hermes::log_level::LL_DEBUG, "Terminate pseudostate has been reached." ); - break; - } - - if( _event_processing_callback ) - { - _event_processing_callback->after_compound_transition(); - } - } - - SX_LOG( hermes::log_level::LL_TRACE, "Finished calculating execution step(s) for all compound transitions." ); - SX_LOG( hermes::log_level::LL_TRACE, "Search for choices." ); - transition_executor_impl_->fill_vector_of_choices( _vertices, _compound_transitions ); - SX_LOG( hermes::log_level::LL_TRACE, "Found % choice(s).", _vertices.size() ); - return( terminate_pseudostate_has_been_reached ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_executor.hpp" + +#include "hermes/log.hpp" + +#include "transition_executor_impl.hpp" +#include "choice_fwd.hpp" +#include "execution_step.hpp" +#include "region_fwd.hpp" +#include "compound_transition_impl.hpp" +#include "event_processing_callback.hpp" +#include "event.hpp" +#include "algorithm_parameters.hpp" +#include "interruptible.hpp" + + +namespace sxy +{ + + +transition_executor::transition_executor() + : transition_executor_impl_() +{ + // Nothing to do... +} + + +transition_executor::~transition_executor() SX_NOEXCEPT +{ + // Nothing to do... +} + + +bool transition_executor::check_sort_and_execute_transitions( const compound_transitions& _compound_transitions, + raw_const_choices& _vertices, event_processing_callback* const _event_processing_callback, + const event& _event, events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector, const interruptible& _interruptible ) +{ + bool terminate_pseudostate_has_been_reached = false; + SX_LOG( hermes::log_level::LL_TRACE, "Check for transition conflicts." ); + transition_executor_impl_->conflict_check( _compound_transitions ); + SX_LOG( hermes::log_level::LL_TRACE, "Sorting compound transitions." ); + const raw_compound_transitions& sorted_compound_transitions = + transition_executor_impl_->sort_compound_transitions( _compound_transitions ); + SX_LOG( hermes::log_level::LL_TRACE, "Compound transitions sorted." ); + SX_LOG( hermes::log_level::LL_TRACE, "Start calculating execution step(s) for all compound transitions." ); + + SX_FOR( compound_transition* const compound_transition, sorted_compound_transitions ) + { + if( _interruptible.is_interrupted() ) + { + break; + } + + if( _event_processing_callback ) + { + _event_processing_callback->before_compound_transition(); + } + + execution_steps execution_steps; + execution_steps.reserve( EXECUTION_STEPS_VECTOR_SIZE ); + raw_const_region_set entered_regions; + SX_LOG( hermes::log_level::LL_TRACE, "Calculate execution step(s) for one compound transition." ); + transition_executor_impl_->find_states_to_enter_and_to_exit_and_calculate_execution_steps( *compound_transition, + execution_steps, entered_regions, _event, true, _event_collector ); + SX_LOG( hermes::log_level::LL_TRACE, "Found % execution step(s).", execution_steps.size() ); + SX_LOG( hermes::log_level::LL_TRACE, "Start running execution step(s)." ); + terminate_pseudostate_has_been_reached = transition_executor_impl_->run_execution_steps( execution_steps, + _event_processing_callback, _event, _exception_events, _async_event_handler, _event_collector ); + SX_LOG( hermes::log_level::LL_TRACE, "Finished running execution step(s)." ); + if( terminate_pseudostate_has_been_reached ) + { + SX_LOG( hermes::log_level::LL_DEBUG, "Terminate pseudostate has been reached." ); + break; + } + + if( _event_processing_callback ) + { + _event_processing_callback->after_compound_transition(); + } + } + + SX_LOG( hermes::log_level::LL_TRACE, "Finished calculating execution step(s) for all compound transitions." ); + SX_LOG( hermes::log_level::LL_TRACE, "Search for choices." ); + transition_executor_impl_->fill_vector_of_choices( _vertices, _compound_transitions ); + SX_LOG( hermes::log_level::LL_TRACE, "Found % choice(s).", _vertices.size() ); + return( terminate_pseudostate_has_been_reached ); +} + + +} diff --git a/libyasmine/source/transition_executor_impl.cpp b/libyasmine/source/transition_executor_impl.cpp index e43dae2..706cc5e 100644 --- a/libyasmine/source/transition_executor_impl.cpp +++ b/libyasmine/source/transition_executor_impl.cpp @@ -1,670 +1,670 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_executor_impl.hpp" - -#include - -#include "hermes/log_and_throw.hpp" - -#include "state.hpp" -#include "region.hpp" -#include "initial_pseudostate.hpp" -#include "composite_state.hpp" -#include "choice.hpp" -#include "exit_point.hpp" -#include "entry_point.hpp" -#include "transition.hpp" -#include "terminate_pseudostate.hpp" -#include "event.hpp" -#include "transition_step.hpp" -#include "compound_transition_impl.hpp" -#include "execution_transition_step.hpp" -#include "execution_state_exit_step.hpp" -#include "execution_state_enter_step.hpp" -#include "execution_state_do_step.hpp" -#include "transition_priority.hpp" -#include "states_to_enter_visitor_impl.hpp" -#include "compound_transition_consumer.hpp" -#include "algorithm_parameters.hpp" - - -namespace sxy -{ - - -namespace impl -{ - - -transition_executor_impl::transition_executor_impl() -{ - // Nothing to do... -} - - -transition_executor_impl::~transition_executor_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void transition_executor_impl::get_active_states_from_region( region& _region, - raw_states_by_nesting_level_ascending& _states ) -{ - SX_LOG( hermes::log_level::LL_SPAM, "Checking for active state in region '%' of state '%'.", - _region.get_name(), _region.get_parent_state().get_name() ); - state* const active_state = _region.get_active_state(); - if( active_state ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Active state '%' found in region '%'.", active_state->get_name(), - _region.get_name() ); - get_active_states_from_regions( active_state, _states ); - _states.insert( active_state ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "No active state found in region '%'.", _region.get_name() ); - } -} - - -void transition_executor_impl::get_active_states_from_regions( const state* const _state, - raw_states_by_nesting_level_ascending& _states ) -{ - SX_FOR(const region_uptr& region, _state->get_regions()) - { - SX_LOG( hermes::log_level::LL_SPAM, "Checking for active state in region '%' of state '%'.", - region->get_name(), _state->get_name() ); - state* const active_state = region->get_active_state(); - if( active_state ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Active state '%' found in region '%'.", - active_state->get_name(), region->get_name() ); - get_active_states_from_regions( active_state, _states ); - _states.insert( active_state ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "No active state found in region '%'.", region->get_name() ); - } - } -} - - -void transition_executor_impl::get_all_states_to_enter_from_regions_that_are_not_explicitly_entered( - compound_transition_consumer& _compound_transition, raw_const_region_set& _entered_regions, - raw_states_by_nesting_level& _states_to_enter, const event& _event, event_collector& _event_collector ) -{ - SX_FOR( const state* const state, _states_to_enter ) - { - SX_FOR( const region_uptr& region, state->get_regions() ) - { - const std::pair inserted_region_iterator = - _entered_regions.insert( region.get() ); - if( false == inserted_region_iterator.second ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Region '%' was already entered.", region->get_name() ); - } - else - { - const initial_pseudostate* const initial_pseudostate = region->get_initial_pseudostate(); - if( initial_pseudostate ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Found initial pseudostate '%' in region '%'.", - initial_pseudostate->get_name(), region->get_name() ); - - sxe::SX_UNIQUE_PTR< compound_transition_impl > new_compound_transition = SX_MAKE_UNIQUE< compound_transition_impl >(); - - SX_LOG( hermes::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( - *initial_pseudostate->get_transition(), _event, _event_collector ); - SX_ASSERT( built_compound_transition, - "Transition of initial pseudostate could not be built in compound transition!" ); - if( built_compound_transition ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Build sub compound transition for '%' transition.", - initial_pseudostate->get_name() ); - find_already_entered_regions( *new_compound_transition, _entered_regions, _event, _event_collector ); - compound_transition_impl* const compound_transition = - dynamic_cast< compound_transition_impl* >( &_compound_transition ); - - compound_transition->add_sub_compound_transition( sxe::move( new_compound_transition ) ); - SX_LOG( hermes::log_level::LL_SPAM, - "New compound transition added to compound transition as a sub compound transition." ); - } - } - } - } - } -} - - -void transition_executor_impl::merge_transitions_steps_with_exit_state_steps( execution_steps& _execution_steps, - compound_transition_consumer& _compound_transition, - const raw_states_by_nesting_level_ascending& _states_to_exit, - transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "There are % states to exit.", _states_to_exit.size() ); - if( !_states_to_exit.empty() ) - { - raw_states_by_nesting_level_ascending::const_iterator state_to_exit_start = _states_to_exit.begin(); - raw_states_by_nesting_level_ascending::const_iterator state_to_exit_end = _states_to_exit.begin(); - while( _transition_end != _compound_transition.get_transition_steps().end() && - state_to_exit_end != _states_to_exit.end() ) - { - const exit_point* const exit_point = _transition_start->get()->get_exit_point(); - if( exit_point ) - { - composite_state& exit_point_parent_state = exit_point->get_parent_state(); - SX_LOG( hermes::log_level::LL_TRACE, "Found exit point '%' with parent state '%'.", - exit_point->get_name(), exit_point_parent_state.get_name() ); - state* state_from_list = *( state_to_exit_end ); - SX_LOG( hermes::log_level::LL_SPAM, "The state from the list of 'states to exit' is '%'", - state_from_list->get_name() ); - while( state_from_list != &exit_point_parent_state ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Add state '%' to execution steps as 'state to exit'.", - state_from_list->get_name() ); - sxe::SX_UNIQUE_PTR< execution_state_exit_step > execution_state_step = - SX_MAKE_UNIQUE< execution_state_exit_step >( sxe::ref( *state_from_list ) ); - _execution_steps.push_back( sxe::move( execution_state_step ) ); - ++state_to_exit_end; - state_from_list = *( state_to_exit_end ); - } - - while( _transition_start != _transition_end ) - { - sxe::SX_UNIQUE_PTR< execution_transition_step > l_execution_transition_step = - SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ); - _execution_steps.push_back( sxe::move( l_execution_transition_step ) ); - ++_transition_start; - } - - state_to_exit_start = state_to_exit_end; - } - else - { - // Nothing to do... - } - - if( _transition_end != _compound_transition.get_transition_steps().end() ) - { - ++_transition_end; - } - } - - add_remaining_states_to_exit( state_to_exit_start, _states_to_exit, _execution_steps ); - } -} - - -void transition_executor_impl::merge_transitions_steps_with_enter_states_steps( execution_steps& _execution_steps, - compound_transition_consumer& _compound_transition, const raw_states_by_nesting_level& _states_to_enter, - transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ) -{ - if( !_states_to_enter.empty() ) - { - raw_states_by_nesting_level::const_iterator state_to_enter_start = _states_to_enter.begin(); - raw_states_by_nesting_level::const_iterator state_to_enter_end = _states_to_enter.begin(); - while( _transition_end != _compound_transition.get_transition_steps().end() && - state_to_enter_end != _states_to_enter.end() ) - { - const entry_point* const entry_point = _transition_end->get()->get_entry_point(); - if( entry_point ) - { - while( _transition_start < _transition_end ) - { - sxe::SX_UNIQUE_PTR< execution_transition_step > l_execution_transition_step = - SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ); - _execution_steps.push_back( sxe::move( l_execution_transition_step ) ); - ++_transition_start; - } - - const composite_state* const parent_state_of_entry_point = &entry_point->get_parent_state(); - state* state_from_list = *( state_to_enter_end ); - while( parent_state_of_entry_point != state_from_list ) - { - sxe::SX_UNIQUE_PTR< execution_state_enter_step > execution_state_step = - SX_MAKE_UNIQUE< execution_state_enter_step >( sxe::ref( *state_from_list ) ); - _execution_steps.push_back( sxe::move( execution_state_step ) ); - sxe::SX_UNIQUE_PTR< execution_state_do_step > l_execution_state_do_step = - SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_from_list ) ); - _execution_steps.push_back( sxe::move( l_execution_state_do_step ) ); - ++state_to_enter_end; - state_from_list = *( state_to_enter_end ); - } - - if( parent_state_of_entry_point == state_from_list ) - { - sxe::SX_UNIQUE_PTR< execution_state_enter_step > execution_state_step = - SX_MAKE_UNIQUE< execution_state_enter_step >( sxe::ref( *state_from_list ) ); - _execution_steps.push_back( sxe::move( execution_state_step ) ); - sxe::SX_UNIQUE_PTR< execution_state_do_step > l_execution_state_do_step = - SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_from_list ) ); - _execution_steps.push_back( sxe::move( l_execution_state_do_step ) ); - } - - state_to_enter_start = ++state_to_enter_end; - } - else - { - // Nothing to do... - } - - ++_transition_end; - } - - add_remained_transitions( _transition_start, _transition_end, _execution_steps ); - add_remaining_states_to_enter( state_to_enter_start, _states_to_enter, _execution_steps ); - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "There are no states to enter." ); - if( _transition_start == _transition_end ) - { - const vertex& target = _transition_end->get()->get_unique_target(); - if( dynamic_cast< const terminate_pseudostate* >( &target ) ) - { - _execution_steps.push_back( SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ) ); - } - else - { - add_remained_transitions( _transition_start, ++_transition_end, _execution_steps ); - transition* const last_transition = _compound_transition.get_transition_steps().back()->get_transitions().back(); - const vertex& last_target = last_transition->get_target(); - const state* state_to_execute = dynamic_cast< const state* >( &last_target ); - if( state_to_execute ) - { - _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_to_execute ) ) ); - } - } - } - } -} - - -void transition_executor_impl::calculate_execution_steps( compound_transition_consumer& _compound_transition, - const raw_states_by_nesting_level_ascending& _states_to_exit, - const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps, - raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ) -{ - SX_LOG( hermes::log_level::LL_SPAM, "Compound transition has % step(s).", - _compound_transition.get_transition_steps().size() ); -#ifndef SX_CPP03_BOOST - transition_steps::const_iterator transition_start = _compound_transition.get_transition_steps().cbegin(); - transition_steps::const_iterator transition_end = _compound_transition.get_transition_steps().cbegin(); -#else - transition_steps::const_iterator transition_start = _compound_transition.get_transition_steps().begin(); - transition_steps::const_iterator transition_end = _compound_transition.get_transition_steps().begin(); -#endif - merge_transitions_steps_with_exit_state_steps( _execution_steps, _compound_transition, _states_to_exit, - transition_start, transition_end ); -#ifndef SX_CPP03_BOOST - if( transition_end == _compound_transition.get_transition_steps().cend() ) -#else - if( transition_end == _compound_transition.get_transition_steps().end() ) -#endif - { - transition_end = transition_start; - } - - merge_transitions_steps_with_enter_states_steps( _execution_steps, _compound_transition, _states_to_enter, - transition_start, transition_end ); - - SX_FOR( const compound_transition_uptr& sub_compound_transition, _compound_transition.get_sub_compound_transitions() ) - { - SX_LOG( hermes::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, false, _event_collector ); - } -} - - -bool transition_executor_impl::run_execution_steps( const execution_steps& _execution_steps, - event_processing_callback* const _event_processing_callback, const event& _event, - events& _exception_events, async_event_handler* const _async_event_handler, - event_collector& _event_collector ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Start executing % steps.", _execution_steps.size() ); - bool run_reached_terminate_pseudostate = false; - - SX_FOR( const execution_step_uptr& execution_step, _execution_steps ) - { - if( execution_step->execute_behavior( _event_processing_callback, _event, _exception_events, _async_event_handler, _event_collector ) ) - { - run_reached_terminate_pseudostate = true; - break; - } - } - - SX_LOG( hermes::log_level::LL_TRACE, "Finished executing % steps.", _execution_steps.size() ); - return( run_reached_terminate_pseudostate ); -} - - -void transition_executor_impl::conflict_check( const compound_transitions& _compound_transitions ) const -{ - raw_const_state_set unique_exit_states; - - SX_FOR( const compound_transition_uptr& compound_transition, _compound_transitions ) - { - const transition_steps& transition_steps = compound_transition->get_transition_steps(); - SX_LOG( hermes::log_level::LL_TRACE, "Found % transition step(s) for compound transition.", transition_steps.size() ); - SX_LOG( hermes::log_level::LL_SPAM, "Getting the source of the compound transition." ); - const transition_step_uptr& transition_step = transition_steps.front(); - const transition*const transition = transition_step->get_transitions().front(); - const vertex& vertex = transition->get_source(); - SX_LOG( hermes::log_level::LL_TRACE, "Source of compound transition is '%'.", vertex.get_name() ); - const state* const l_state = dynamic_cast< const state* >( &vertex ); - if( l_state ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Source of compound transition is a state ( '%' ).", l_state->get_name() ); - const region* LCA_region = compound_transition->get_LCA_region(); - const composite_state* parent_state = SX_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 ); - } - } -} - - -raw_compound_transitions transition_executor_impl::sort_compound_transitions( - const compound_transitions& _unsorted_compound_transitions ) -{ - std::vector< transition_priority > transitions_priorities; - transitions_priorities.reserve( TRANSITION_PRIORITIES_VECTOR_SIZE ); - - SX_FOR( const compound_transition_uptr& compound_transition, _unsorted_compound_transitions ) - { - transition_priority order_object( *compound_transition ); - transitions_priorities.push_back( order_object ); - } - - std::sort( transitions_priorities.begin(), transitions_priorities.end() ); - raw_compound_transitions sorted_compound_transitions; - sorted_compound_transitions.reserve( transitions_priorities.size() ); - - // cppcheck-suppress duplicateExpression - SX_FOR( const transition_priority& transition_priority, transitions_priorities ) - { - compound_transition& compound_transition = transition_priority.get_compound_transition(); - sorted_compound_transitions.push_back( &compound_transition ); - } - - return( sorted_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 ) ) - { - region* LCA_region = _compound_transition.get_LCA_region(); - if( !LCA_region ) - { - 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 - { - SX_LOG( hermes::log_level::LL_SPAM, "Transitions of compound transition are 'INTERNAL'. There are no states to exit." ); - } -} - - -void transition_executor_impl::find_all_states_to_enter( compound_transition_consumer& _compound_transition, - raw_states_by_nesting_level& _states_to_enter, raw_const_region_set& _regions_to_enter, const event& _event, - event_collector& _event_collector ) -{ - const transition_kind compound_transition_kind = _compound_transition.get_transition_kind(); - if( !( transition_kind::INTERNAL == compound_transition_kind ) ) - { - transition_step_uptr& last_transition_step = _compound_transition.get_transition_steps().back(); - - SX_FOR( transition* const transition, last_transition_step->get_transitions() ) - { - vertex& vertex = transition->get_target(); - SX_LOG( hermes::log_level::LL_SPAM, "Target of transition '%' is '%'.", transition->get_name(), vertex.get_name() ); - if( transition_kind::LOCAL == compound_transition_kind ) - { - region* LCA_region = _compound_transition.get_LCA_region(); - composite_state* active_state_as_composite_state = SX_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, - transition->get_source() ); - vertex.accept_vertex_visitor( visitor ); - _states_to_enter.erase( active_state_as_composite_state ); - } - } - else - { - region* LCA_region = _compound_transition.get_LCA_region(); - composite_state* parent_state = SX_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 ); - } - } - - get_all_states_to_enter_from_regions_that_are_not_explicitly_entered( _compound_transition, _regions_to_enter, - _states_to_enter, _event, _event_collector ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Transitions of compound transition are 'INTERNAL'. There are no states to enter." ); - } -} - - -void transition_executor_impl::add_remaining_states_to_enter( - const raw_states_by_nesting_level::const_iterator _state_start, - const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps ) -{ - raw_states_by_nesting_level::const_iterator state_start = _state_start; - while( state_start != _states_to_enter.end() ) - { - state* const state_from_list = *state_start; - SX_LOG( hermes::log_level::LL_SPAM, "State '%' added to execution steps as 'state to enter'.", - state_from_list->get_name() ); - _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_enter_step >( sxe::ref( *state_from_list ) ) ); - _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_from_list ) ) ); - ++state_start; - } -} - - -void transition_executor_impl::add_remaining_states_to_exit( - const raw_states_by_nesting_level_ascending::const_iterator _state_start, - const raw_states_by_nesting_level_ascending& _states, execution_steps& _execution_steps ) -{ - raw_states_by_nesting_level_ascending::const_iterator state_start = _state_start; - while( state_start != _states.end() ) - { - state* const state_from_list = *state_start; - SX_LOG( hermes::log_level::LL_SPAM, "Add remaining state '%' to execution steps as 'state to exit'.", - state_from_list->get_name() ); - _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_exit_step >( sxe::ref( *state_from_list ) ) ); - ++state_start; - } -} - - -void transition_executor_impl::add_remained_transitions( transition_steps::const_iterator& _transition_start, - const transition_steps::const_iterator& _transition_end, execution_steps& _execution_steps ) -{ - while( _transition_start != _transition_end ) - { - sxe::SX_UNIQUE_PTR< execution_transition_step > l_execution_transition_step - = SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ); - _execution_steps.push_back( sxe::move( l_execution_transition_step ) ); - ++_transition_start; - } -} - - -void transition_executor_impl::fill_vector_of_choices( raw_const_choices& _choices, - const compound_transitions& _compound_transitions ) -{ - SX_FOR( const compound_transition_uptr& compound_transition, _compound_transitions ) - { - const choice* const l_choice = dynamic_cast< const choice* >( &compound_transition->get_last_target() ); - if( l_choice ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Found one choice ( '%' ) as target of compound transition.", l_choice->get_name() ); - _choices.push_back( l_choice ); - } - - SX_LOG( hermes::log_level::LL_TRACE, "Fill vector of choices for one compound transition." ); - fill_vector_of_choices( _choices, compound_transition->get_sub_compound_transitions() ); - SX_LOG( hermes::log_level::LL_TRACE, "Found % choice(s) for one compound transition.", _choices.size() ); - } -} - - -void transition_executor_impl::find_already_entered_regions( compound_transition& new_compound_transition, - raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ) -{ - raw_states_by_nesting_level states_to_enter; - find_all_states_to_enter( new_compound_transition, states_to_enter, _entered_regions, _event, _event_collector ); -} - - -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, bool _find_states_to_exit, - event_collector& _event_collector ) -{ - raw_states_by_nesting_level_ascending states_to_exit; - SX_LOG( hermes::log_level::LL_TRACE, "Start searching states to exit." ); - - if( _find_states_to_exit ) - { - find_all_states_to_exit( _compound_transition, states_to_exit ); - SX_LOG( hermes::log_level::LL_TRACE, "Found % state(s) to exit.", states_to_exit.size() ); - } - raw_states_by_nesting_level states_to_enter; - SX_LOG( hermes::log_level::LL_TRACE, "Start searching states to enter." ); - find_all_states_to_enter( _compound_transition, states_to_enter, _entered_regions, _event, _event_collector ); - SX_LOG( hermes::log_level::LL_TRACE, "Found % state(s) to enter.", states_to_enter.size() ); - SX_LOG( hermes::log_level::LL_TRACE, "Calculating the execution steps." ); - calculate_execution_steps( _compound_transition, states_to_exit, states_to_enter, _execution_steps, - _entered_regions, _event, _event_collector ); - SX_LOG( hermes::log_level::LL_TRACE, "% execution step(s) were calculated.", _execution_steps.size() ); -} - - -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 -{ - if( &_state != _LCA ) - { - SX_LOG( hermes::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( hermes::log_level::LL_FATAL, "There are conflicts. The intersection of states '%' and '%' is not empty.", - _state.get_name(), _LCA->get_name() ); - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "There are no conflicts. The intersection of states '%' and '%' is empty.", - _state.get_name(), _LCA->get_name() ); - } - - SX_ASSERT( _state.get_parent_region(), "State has no parent region!" ); - const composite_state& parent_state = _state.get_parent_region()->get_parent_state(); - SX_LOG( hermes::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 - { - // Nothing to check. No conflicts. - } -} - - -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 ) - { - if( _LCA_region->get_parent_state().is_active() ) - { - get_active_states_from_region( *_LCA_region, _states_to_exit ); - SX_LOG( hermes::log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); - } - else - { - SX_LOG( hermes::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 ) - { - SX_FOR( const region_uptr& region, active_state->get_regions() ) - { - get_active_states_from_region( *region, _states_to_exit ); - SX_LOG( hermes::log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); - } - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "Least common ancestor '%' of compound transition, has no active state. .", - _LCA_region->get_name() ); - } - } -} - - -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_executor_impl.hpp" + +#include + +#include "hermes/log_and_throw.hpp" + +#include "state.hpp" +#include "region.hpp" +#include "initial_pseudostate.hpp" +#include "composite_state.hpp" +#include "choice.hpp" +#include "exit_point.hpp" +#include "entry_point.hpp" +#include "transition.hpp" +#include "terminate_pseudostate.hpp" +#include "event.hpp" +#include "transition_step.hpp" +#include "compound_transition_impl.hpp" +#include "execution_transition_step.hpp" +#include "execution_state_exit_step.hpp" +#include "execution_state_enter_step.hpp" +#include "execution_state_do_step.hpp" +#include "transition_priority.hpp" +#include "states_to_enter_visitor_impl.hpp" +#include "compound_transition_consumer.hpp" +#include "algorithm_parameters.hpp" + + +namespace sxy +{ + + +namespace impl +{ + + +transition_executor_impl::transition_executor_impl() +{ + // Nothing to do... +} + + +transition_executor_impl::~transition_executor_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void transition_executor_impl::get_active_states_from_region( region& _region, + raw_states_by_nesting_level_ascending& _states ) +{ + SX_LOG( hermes::log_level::LL_SPAM, "Checking for active state in region '%' of state '%'.", + _region.get_name(), _region.get_parent_state().get_name() ); + state* const active_state = _region.get_active_state(); + if( active_state ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Active state '%' found in region '%'.", active_state->get_name(), + _region.get_name() ); + get_active_states_from_regions( active_state, _states ); + _states.insert( active_state ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "No active state found in region '%'.", _region.get_name() ); + } +} + + +void transition_executor_impl::get_active_states_from_regions( const state* const _state, + raw_states_by_nesting_level_ascending& _states ) +{ + SX_FOR(const region_uptr& region, _state->get_regions()) + { + SX_LOG( hermes::log_level::LL_SPAM, "Checking for active state in region '%' of state '%'.", + region->get_name(), _state->get_name() ); + state* const active_state = region->get_active_state(); + if( active_state ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Active state '%' found in region '%'.", + active_state->get_name(), region->get_name() ); + get_active_states_from_regions( active_state, _states ); + _states.insert( active_state ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "No active state found in region '%'.", region->get_name() ); + } + } +} + + +void transition_executor_impl::get_all_states_to_enter_from_regions_that_are_not_explicitly_entered( + compound_transition_consumer& _compound_transition, raw_const_region_set& _entered_regions, + raw_states_by_nesting_level& _states_to_enter, const event& _event, event_collector& _event_collector ) +{ + SX_FOR( const state* const state, _states_to_enter ) + { + SX_FOR( const region_uptr& region, state->get_regions() ) + { + const std::pair inserted_region_iterator = + _entered_regions.insert( region.get() ); + if( false == inserted_region_iterator.second ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Region '%' was already entered.", region->get_name() ); + } + else + { + const initial_pseudostate* const initial_pseudostate = region->get_initial_pseudostate(); + if( initial_pseudostate ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Found initial pseudostate '%' in region '%'.", + initial_pseudostate->get_name(), region->get_name() ); + + sxe::SX_UNIQUE_PTR< compound_transition_impl > new_compound_transition = SX_MAKE_UNIQUE< compound_transition_impl >(); + + SX_LOG( hermes::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( + *initial_pseudostate->get_transition(), _event, _event_collector ); + SX_ASSERT( built_compound_transition, + "Transition of initial pseudostate could not be built in compound transition!" ); + if( built_compound_transition ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Build sub compound transition for '%' transition.", + initial_pseudostate->get_name() ); + find_already_entered_regions( *new_compound_transition, _entered_regions, _event, _event_collector ); + compound_transition_impl* const compound_transition = + dynamic_cast< compound_transition_impl* >( &_compound_transition ); + + compound_transition->add_sub_compound_transition( sxe::move( new_compound_transition ) ); + SX_LOG( hermes::log_level::LL_SPAM, + "New compound transition added to compound transition as a sub compound transition." ); + } + } + } + } + } +} + + +void transition_executor_impl::merge_transitions_steps_with_exit_state_steps( execution_steps& _execution_steps, + compound_transition_consumer& _compound_transition, + const raw_states_by_nesting_level_ascending& _states_to_exit, + transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "There are % states to exit.", _states_to_exit.size() ); + if( !_states_to_exit.empty() ) + { + raw_states_by_nesting_level_ascending::const_iterator state_to_exit_start = _states_to_exit.begin(); + raw_states_by_nesting_level_ascending::const_iterator state_to_exit_end = _states_to_exit.begin(); + while( _transition_end != _compound_transition.get_transition_steps().end() && + state_to_exit_end != _states_to_exit.end() ) + { + const exit_point* const exit_point = _transition_start->get()->get_exit_point(); + if( exit_point ) + { + composite_state& exit_point_parent_state = exit_point->get_parent_state(); + SX_LOG( hermes::log_level::LL_TRACE, "Found exit point '%' with parent state '%'.", + exit_point->get_name(), exit_point_parent_state.get_name() ); + state* state_from_list = *( state_to_exit_end ); + SX_LOG( hermes::log_level::LL_SPAM, "The state from the list of 'states to exit' is '%'", + state_from_list->get_name() ); + while( state_from_list != &exit_point_parent_state ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Add state '%' to execution steps as 'state to exit'.", + state_from_list->get_name() ); + sxe::SX_UNIQUE_PTR< execution_state_exit_step > execution_state_step = + SX_MAKE_UNIQUE< execution_state_exit_step >( sxe::ref( *state_from_list ) ); + _execution_steps.push_back( sxe::move( execution_state_step ) ); + ++state_to_exit_end; + state_from_list = *( state_to_exit_end ); + } + + while( _transition_start != _transition_end ) + { + sxe::SX_UNIQUE_PTR< execution_transition_step > l_execution_transition_step = + SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ); + _execution_steps.push_back( sxe::move( l_execution_transition_step ) ); + ++_transition_start; + } + + state_to_exit_start = state_to_exit_end; + } + else + { + // Nothing to do... + } + + if( _transition_end != _compound_transition.get_transition_steps().end() ) + { + ++_transition_end; + } + } + + add_remaining_states_to_exit( state_to_exit_start, _states_to_exit, _execution_steps ); + } +} + + +void transition_executor_impl::merge_transitions_steps_with_enter_states_steps( execution_steps& _execution_steps, + compound_transition_consumer& _compound_transition, const raw_states_by_nesting_level& _states_to_enter, + transition_steps::const_iterator& _transition_start, transition_steps::const_iterator& _transition_end ) +{ + if( !_states_to_enter.empty() ) + { + raw_states_by_nesting_level::const_iterator state_to_enter_start = _states_to_enter.begin(); + raw_states_by_nesting_level::const_iterator state_to_enter_end = _states_to_enter.begin(); + while( _transition_end != _compound_transition.get_transition_steps().end() && + state_to_enter_end != _states_to_enter.end() ) + { + const entry_point* const entry_point = _transition_end->get()->get_entry_point(); + if( entry_point ) + { + while( _transition_start < _transition_end ) + { + sxe::SX_UNIQUE_PTR< execution_transition_step > l_execution_transition_step = + SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ); + _execution_steps.push_back( sxe::move( l_execution_transition_step ) ); + ++_transition_start; + } + + const composite_state* const parent_state_of_entry_point = &entry_point->get_parent_state(); + state* state_from_list = *( state_to_enter_end ); + while( parent_state_of_entry_point != state_from_list ) + { + sxe::SX_UNIQUE_PTR< execution_state_enter_step > execution_state_step = + SX_MAKE_UNIQUE< execution_state_enter_step >( sxe::ref( *state_from_list ) ); + _execution_steps.push_back( sxe::move( execution_state_step ) ); + sxe::SX_UNIQUE_PTR< execution_state_do_step > l_execution_state_do_step = + SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_from_list ) ); + _execution_steps.push_back( sxe::move( l_execution_state_do_step ) ); + ++state_to_enter_end; + state_from_list = *( state_to_enter_end ); + } + + if( parent_state_of_entry_point == state_from_list ) + { + sxe::SX_UNIQUE_PTR< execution_state_enter_step > execution_state_step = + SX_MAKE_UNIQUE< execution_state_enter_step >( sxe::ref( *state_from_list ) ); + _execution_steps.push_back( sxe::move( execution_state_step ) ); + sxe::SX_UNIQUE_PTR< execution_state_do_step > l_execution_state_do_step = + SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_from_list ) ); + _execution_steps.push_back( sxe::move( l_execution_state_do_step ) ); + } + + state_to_enter_start = ++state_to_enter_end; + } + else + { + // Nothing to do... + } + + ++_transition_end; + } + + add_remained_transitions( _transition_start, _transition_end, _execution_steps ); + add_remaining_states_to_enter( state_to_enter_start, _states_to_enter, _execution_steps ); + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "There are no states to enter." ); + if( _transition_start == _transition_end ) + { + const vertex& target = _transition_end->get()->get_unique_target(); + if( dynamic_cast< const terminate_pseudostate* >( &target ) ) + { + _execution_steps.push_back( SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ) ); + } + else + { + add_remained_transitions( _transition_start, ++_transition_end, _execution_steps ); + transition* const last_transition = _compound_transition.get_transition_steps().back()->get_transitions().back(); + const vertex& last_target = last_transition->get_target(); + const state* state_to_execute = dynamic_cast< const state* >( &last_target ); + if( state_to_execute ) + { + _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_to_execute ) ) ); + } + } + } + } +} + + +void transition_executor_impl::calculate_execution_steps( compound_transition_consumer& _compound_transition, + const raw_states_by_nesting_level_ascending& _states_to_exit, + const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps, + raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ) +{ + SX_LOG( hermes::log_level::LL_SPAM, "Compound transition has % step(s).", + _compound_transition.get_transition_steps().size() ); +#ifndef SX_CPP03_BOOST + transition_steps::const_iterator transition_start = _compound_transition.get_transition_steps().cbegin(); + transition_steps::const_iterator transition_end = _compound_transition.get_transition_steps().cbegin(); +#else + transition_steps::const_iterator transition_start = _compound_transition.get_transition_steps().begin(); + transition_steps::const_iterator transition_end = _compound_transition.get_transition_steps().begin(); +#endif + merge_transitions_steps_with_exit_state_steps( _execution_steps, _compound_transition, _states_to_exit, + transition_start, transition_end ); +#ifndef SX_CPP03_BOOST + if( transition_end == _compound_transition.get_transition_steps().cend() ) +#else + if( transition_end == _compound_transition.get_transition_steps().end() ) +#endif + { + transition_end = transition_start; + } + + merge_transitions_steps_with_enter_states_steps( _execution_steps, _compound_transition, _states_to_enter, + transition_start, transition_end ); + + SX_FOR( const compound_transition_uptr& sub_compound_transition, _compound_transition.get_sub_compound_transitions() ) + { + SX_LOG( hermes::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, false, _event_collector ); + } +} + + +bool transition_executor_impl::run_execution_steps( const execution_steps& _execution_steps, + event_processing_callback* const _event_processing_callback, const event& _event, + events& _exception_events, async_event_handler* const _async_event_handler, + event_collector& _event_collector ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Start executing % steps.", _execution_steps.size() ); + bool run_reached_terminate_pseudostate = false; + + SX_FOR( const execution_step_uptr& execution_step, _execution_steps ) + { + if( execution_step->execute_behavior( _event_processing_callback, _event, _exception_events, _async_event_handler, _event_collector ) ) + { + run_reached_terminate_pseudostate = true; + break; + } + } + + SX_LOG( hermes::log_level::LL_TRACE, "Finished executing % steps.", _execution_steps.size() ); + return( run_reached_terminate_pseudostate ); +} + + +void transition_executor_impl::conflict_check( const compound_transitions& _compound_transitions ) const +{ + raw_const_state_set unique_exit_states; + + SX_FOR( const compound_transition_uptr& compound_transition, _compound_transitions ) + { + const transition_steps& transition_steps = compound_transition->get_transition_steps(); + SX_LOG( hermes::log_level::LL_TRACE, "Found % transition step(s) for compound transition.", transition_steps.size() ); + SX_LOG( hermes::log_level::LL_SPAM, "Getting the source of the compound transition." ); + const transition_step_uptr& transition_step = transition_steps.front(); + const transition*const transition = transition_step->get_transitions().front(); + const vertex& vertex = transition->get_source(); + SX_LOG( hermes::log_level::LL_TRACE, "Source of compound transition is '%'.", vertex.get_name() ); + const state* const l_state = dynamic_cast< const state* >( &vertex ); + if( l_state ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Source of compound transition is a state ( '%' ).", l_state->get_name() ); + const region* LCA_region = compound_transition->get_LCA_region(); + const composite_state* parent_state = SX_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 ); + } + } +} + + +raw_compound_transitions transition_executor_impl::sort_compound_transitions( + const compound_transitions& _unsorted_compound_transitions ) +{ + std::vector< transition_priority > transitions_priorities; + transitions_priorities.reserve( TRANSITION_PRIORITIES_VECTOR_SIZE ); + + SX_FOR( const compound_transition_uptr& compound_transition, _unsorted_compound_transitions ) + { + transition_priority order_object( *compound_transition ); + transitions_priorities.push_back( order_object ); + } + + std::sort( transitions_priorities.begin(), transitions_priorities.end() ); + raw_compound_transitions sorted_compound_transitions; + sorted_compound_transitions.reserve( transitions_priorities.size() ); + + // cppcheck-suppress duplicateExpression + SX_FOR( const transition_priority& transition_priority, transitions_priorities ) + { + compound_transition& compound_transition = transition_priority.get_compound_transition(); + sorted_compound_transitions.push_back( &compound_transition ); + } + + return( sorted_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 ) ) + { + region* LCA_region = _compound_transition.get_LCA_region(); + if( !LCA_region ) + { + 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 + { + SX_LOG( hermes::log_level::LL_SPAM, "Transitions of compound transition are 'INTERNAL'. There are no states to exit." ); + } +} + + +void transition_executor_impl::find_all_states_to_enter( compound_transition_consumer& _compound_transition, + raw_states_by_nesting_level& _states_to_enter, raw_const_region_set& _regions_to_enter, const event& _event, + event_collector& _event_collector ) +{ + const transition_kind compound_transition_kind = _compound_transition.get_transition_kind(); + if( !( transition_kind::INTERNAL == compound_transition_kind ) ) + { + transition_step_uptr& last_transition_step = _compound_transition.get_transition_steps().back(); + + SX_FOR( transition* const transition, last_transition_step->get_transitions() ) + { + vertex& vertex = transition->get_target(); + SX_LOG( hermes::log_level::LL_SPAM, "Target of transition '%' is '%'.", transition->get_name(), vertex.get_name() ); + if( transition_kind::LOCAL == compound_transition_kind ) + { + region* LCA_region = _compound_transition.get_LCA_region(); + composite_state* active_state_as_composite_state = SX_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, + transition->get_source() ); + vertex.accept_vertex_visitor( visitor ); + _states_to_enter.erase( active_state_as_composite_state ); + } + } + else + { + region* LCA_region = _compound_transition.get_LCA_region(); + composite_state* parent_state = SX_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 ); + } + } + + get_all_states_to_enter_from_regions_that_are_not_explicitly_entered( _compound_transition, _regions_to_enter, + _states_to_enter, _event, _event_collector ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Transitions of compound transition are 'INTERNAL'. There are no states to enter." ); + } +} + + +void transition_executor_impl::add_remaining_states_to_enter( + const raw_states_by_nesting_level::const_iterator _state_start, + const raw_states_by_nesting_level& _states_to_enter, execution_steps& _execution_steps ) +{ + raw_states_by_nesting_level::const_iterator state_start = _state_start; + while( state_start != _states_to_enter.end() ) + { + state* const state_from_list = *state_start; + SX_LOG( hermes::log_level::LL_SPAM, "State '%' added to execution steps as 'state to enter'.", + state_from_list->get_name() ); + _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_enter_step >( sxe::ref( *state_from_list ) ) ); + _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_do_step >( sxe::ref( *state_from_list ) ) ); + ++state_start; + } +} + + +void transition_executor_impl::add_remaining_states_to_exit( + const raw_states_by_nesting_level_ascending::const_iterator _state_start, + const raw_states_by_nesting_level_ascending& _states, execution_steps& _execution_steps ) +{ + raw_states_by_nesting_level_ascending::const_iterator state_start = _state_start; + while( state_start != _states.end() ) + { + state* const state_from_list = *state_start; + SX_LOG( hermes::log_level::LL_SPAM, "Add remaining state '%' to execution steps as 'state to exit'.", + state_from_list->get_name() ); + _execution_steps.push_back( SX_MAKE_UNIQUE< execution_state_exit_step >( sxe::ref( *state_from_list ) ) ); + ++state_start; + } +} + + +void transition_executor_impl::add_remained_transitions( transition_steps::const_iterator& _transition_start, + const transition_steps::const_iterator& _transition_end, execution_steps& _execution_steps ) +{ + while( _transition_start != _transition_end ) + { + sxe::SX_UNIQUE_PTR< execution_transition_step > l_execution_transition_step + = SX_MAKE_UNIQUE< execution_transition_step >( sxe::ref( **_transition_start ) ); + _execution_steps.push_back( sxe::move( l_execution_transition_step ) ); + ++_transition_start; + } +} + + +void transition_executor_impl::fill_vector_of_choices( raw_const_choices& _choices, + const compound_transitions& _compound_transitions ) +{ + SX_FOR( const compound_transition_uptr& compound_transition, _compound_transitions ) + { + const choice* const l_choice = dynamic_cast< const choice* >( &compound_transition->get_last_target() ); + if( l_choice ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Found one choice ( '%' ) as target of compound transition.", l_choice->get_name() ); + _choices.push_back( l_choice ); + } + + SX_LOG( hermes::log_level::LL_TRACE, "Fill vector of choices for one compound transition." ); + fill_vector_of_choices( _choices, compound_transition->get_sub_compound_transitions() ); + SX_LOG( hermes::log_level::LL_TRACE, "Found % choice(s) for one compound transition.", _choices.size() ); + } +} + + +void transition_executor_impl::find_already_entered_regions( compound_transition& new_compound_transition, + raw_const_region_set& _entered_regions, const event& _event, event_collector& _event_collector ) +{ + raw_states_by_nesting_level states_to_enter; + find_all_states_to_enter( new_compound_transition, states_to_enter, _entered_regions, _event, _event_collector ); +} + + +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, bool _find_states_to_exit, + event_collector& _event_collector ) +{ + raw_states_by_nesting_level_ascending states_to_exit; + SX_LOG( hermes::log_level::LL_TRACE, "Start searching states to exit." ); + + if( _find_states_to_exit ) + { + find_all_states_to_exit( _compound_transition, states_to_exit ); + SX_LOG( hermes::log_level::LL_TRACE, "Found % state(s) to exit.", states_to_exit.size() ); + } + raw_states_by_nesting_level states_to_enter; + SX_LOG( hermes::log_level::LL_TRACE, "Start searching states to enter." ); + find_all_states_to_enter( _compound_transition, states_to_enter, _entered_regions, _event, _event_collector ); + SX_LOG( hermes::log_level::LL_TRACE, "Found % state(s) to enter.", states_to_enter.size() ); + SX_LOG( hermes::log_level::LL_TRACE, "Calculating the execution steps." ); + calculate_execution_steps( _compound_transition, states_to_exit, states_to_enter, _execution_steps, + _entered_regions, _event, _event_collector ); + SX_LOG( hermes::log_level::LL_TRACE, "% execution step(s) were calculated.", _execution_steps.size() ); +} + + +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 +{ + if( &_state != _LCA ) + { + SX_LOG( hermes::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( hermes::log_level::LL_FATAL, "There are conflicts. The intersection of states '%' and '%' is not empty.", + _state.get_name(), _LCA->get_name() ); + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "There are no conflicts. The intersection of states '%' and '%' is empty.", + _state.get_name(), _LCA->get_name() ); + } + + SX_ASSERT( _state.get_parent_region(), "State has no parent region!" ); + const composite_state& parent_state = _state.get_parent_region()->get_parent_state(); + SX_LOG( hermes::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 + { + // Nothing to check. No conflicts. + } +} + + +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 ) + { + if( _LCA_region->get_parent_state().is_active() ) + { + get_active_states_from_region( *_LCA_region, _states_to_exit ); + SX_LOG( hermes::log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); + } + else + { + SX_LOG( hermes::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 ) + { + SX_FOR( const region_uptr& region, active_state->get_regions() ) + { + get_active_states_from_region( *region, _states_to_exit ); + SX_LOG( hermes::log_level::LL_TRACE, "Number of states to exit: %.", _states_to_exit.size() ); + } + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "Least common ancestor '%' of compound transition, has no active state. .", + _LCA_region->get_name() ); + } + } +} + + +} + + +} diff --git a/libyasmine/source/transition_finder.cpp b/libyasmine/source/transition_finder.cpp index c9535a6..f8dcc67 100644 --- a/libyasmine/source/transition_finder.cpp +++ b/libyasmine/source/transition_finder.cpp @@ -1,227 +1,227 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_finder.hpp" - -#include "hermes/log_and_throw.hpp" - -#include "composite_state.hpp" -#include "region.hpp" -#include "initial_pseudostate.hpp" -#include "choice.hpp" -#include "transition.hpp" -#include "compound_transition_builder.hpp" -#include "event_impl.hpp" -#include "completion_event.hpp" - - -namespace sxy -{ - - -transition_finder::transition_finder() -{ - // Nothing to do... -} - - -transition_finder::~transition_finder() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void transition_finder::search_for_enabled_transitions_in_all_regions( const state& _current_state, - const event& _event, compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, - event_collector& _event_collector ) const -{ - search_for_transition( _current_state, _enabled_compound_transitions, _event, _event_is_deferred, _event_collector ); -} - - -void transition_finder::search_for_enabled_completion_transitions_in_all_regions( const state& _current_state, - compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, - event_collector& _event_collector ) const -{ - search_for_transition( _current_state, _enabled_compound_transitions, *sxy::completion_event::create(), - _event_is_deferred, _event_collector ); -} - - -void transition_finder::search_initial_transitions( const composite_state& _state, - compound_transitions& _compound_transitions, event_collector& _event_collector ) -{ - SX_FOR( const region_uptr& region, _state.get_regions() ) - { - SX_LOG( hermes::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 ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Initial pseudostate '%' found in region '%'.", - initial_pseudostate->get_name(), region->get_name() ); - transition* const transition = initial_pseudostate->get_transition(); - if( !try_to_build_compound_transition( *transition, _compound_transitions, *sxy::completion_event::create(), _event_collector ) ) - { - std::string message = sxe::sxprintf( - "A compound transition could not be built for the initial transition emitting from the initial pseudostate '%'!", - initial_pseudostate->get_name() ); - SX_ASSERT( false, message.c_str() ); - } - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "No initial pseudostate found in region '%'.", region->get_name() ); - } - } -} - - -void transition_finder::search_choice_transitions( const raw_const_choices& _choices, - compound_transitions& _compound_transitions, const event& _event, event_collector& _event_collector ) -{ - SX_FOR( const choice* const choice, _choices ) - { - SX_ASSERT( choice, "Choice pointer is null. This cannot be a nullptr." ); - SX_LOG( hermes::log_level::LL_SPAM, "Checking outgoing transition(s) of choice '%'. It has % outgoing transitions.", - choice->get_name(), choice->get_outgoing_transitions().size() ); - bool at_least_one_transition_is_enabled = false; - - SX_FOR( transition* const transition, choice->get_outgoing_transitions()) - { - SX_ASSERT(transition->can_accept_event( sxy::completion_event::get_event_id() ), - "Transition leaving choice is not a completion transition!" ); - SX_LOG( hermes::log_level::LL_SPAM, "Checking outgoing transition '%' of choice '%' for guard.", - transition->get_name(), choice->get_name() ); - const bool guard_evaluated_to_true = transition->check_guard( _event, _event_collector ); - if( guard_evaluated_to_true ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Guard of outgoing transition '%' of choice '%' evaluates to true.", - transition->get_name(), choice->get_name() ); - if( !try_to_build_compound_transition( *transition, _compound_transitions, _event, _event_collector ) ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, - "Transition following choice '%' could not be built in compound transition!", choice->get_name() ); - } - else - { - at_least_one_transition_is_enabled = true; - } - - break; - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Guard of outgoing transition '%' of choice '%' evaluates to false.", - transition->get_name(), choice->get_name() ); - } - } - - if( !at_least_one_transition_is_enabled ) - { - LOG_AND_THROW( hermes::log_level::LL_FATAL, "No transition is enabled for choice '%'!", choice->get_name() ); - } - } -} - - -transition* transition_finder::search_completion_transition( const state& _state, event_collector& _event_collector ) -{ - transition* completion_transition = SX_NULLPTR; - if( _state.is_complete() ) - { - SX_LOG( hermes::log_level::LL_SPAM, "State '%' is complete.", _state.get_name() ); - const sxe::shared_ptr< event_impl > completion_event = SX_MAKE_SHARED< event_impl >( sxy::completion_event::get_event_id() ); - completion_transition = _state.search_transition( *completion_event, _event_collector ); - } - - return( completion_transition ); -} - - -bool transition_finder::search_for_transition( const state& _current_state, - compound_transitions& _enabled_compound_transitions, const event& _event, bool& _event_is_deferred, - event_collector& _event_collector ) const -{ - SX_LOG( hermes::log_level::LL_SPAM, "Search for transition in state '%'.", _current_state.get_name() ); - bool found = false; - const regions& regions = _current_state.get_regions(); - - SX_FOR( const region_uptr& region, regions ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Search for active state in region '%'.", region->get_name() ); - const state* const active_state = region->get_active_state(); - if( active_state ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Found active state '%' in region '%'.", active_state->get_name(), - region->get_name() ); - const bool l_found = search_for_transition( *active_state, _enabled_compound_transitions, _event, - _event_is_deferred, _event_collector ); - if( l_found ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Transition found in active state '%'.", active_state->get_name() ); - found = l_found; - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "No transition found in active state '%'.", active_state->get_name() ); - } - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "No active state found in region '%'.", region->get_name() ); - } - } - - if( !found ) - { - transition* transition = SX_NULLPTR; - if( sxy::completion_event::get_event_id() == _event.get_id() ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Search completion transition in state '%'.", _current_state.get_name() ); - transition = search_completion_transition( _current_state, _event_collector ); - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "Search transition with event id % in state '%'.", - _event.get_id(), _current_state.get_name() ); - transition = _current_state.search_transition( _event, _event_collector ); - } - - if( transition ) - { - SX_LOG( hermes::log_level::LL_TRACE, "Transition '%' found in the current state '%'.", - transition->get_name(), _current_state.get_name() ); - found = try_to_build_compound_transition( *transition, _enabled_compound_transitions, _event, _event_collector ); - if( found ) - { - SX_LOG( hermes::log_level::LL_SPAM, "Compound transition was built for transition '%'.", transition->get_name() ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "Compound transition was not built for transition '%'.", transition->get_name() ); - } - } - else - { - SX_LOG( hermes::log_level::LL_TRACE, "No transition found in current state '%'.", _current_state.get_name() ); - if( _current_state.is_event_deferred( _event.get_id() ) ) - { - _event_is_deferred = true; - found = true; - } - } - } - - return( found ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_finder.hpp" + +#include "hermes/log_and_throw.hpp" + +#include "composite_state.hpp" +#include "region.hpp" +#include "initial_pseudostate.hpp" +#include "choice.hpp" +#include "transition.hpp" +#include "compound_transition_builder.hpp" +#include "event_impl.hpp" +#include "completion_event.hpp" + + +namespace sxy +{ + + +transition_finder::transition_finder() +{ + // Nothing to do... +} + + +transition_finder::~transition_finder() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void transition_finder::search_for_enabled_transitions_in_all_regions( const state& _current_state, + const event& _event, compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, + event_collector& _event_collector ) const +{ + search_for_transition( _current_state, _enabled_compound_transitions, _event, _event_is_deferred, _event_collector ); +} + + +void transition_finder::search_for_enabled_completion_transitions_in_all_regions( const state& _current_state, + compound_transitions& _enabled_compound_transitions, bool& _event_is_deferred, + event_collector& _event_collector ) const +{ + search_for_transition( _current_state, _enabled_compound_transitions, *sxy::completion_event::create(), + _event_is_deferred, _event_collector ); +} + + +void transition_finder::search_initial_transitions( const composite_state& _state, + compound_transitions& _compound_transitions, event_collector& _event_collector ) +{ + SX_FOR( const region_uptr& region, _state.get_regions() ) + { + SX_LOG( hermes::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 ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Initial pseudostate '%' found in region '%'.", + initial_pseudostate->get_name(), region->get_name() ); + transition* const transition = initial_pseudostate->get_transition(); + if( !try_to_build_compound_transition( *transition, _compound_transitions, *sxy::completion_event::create(), _event_collector ) ) + { + std::string message = sxe::sxprintf( + "A compound transition could not be built for the initial transition emitting from the initial pseudostate '%'!", + initial_pseudostate->get_name() ); + SX_ASSERT( false, message.c_str() ); + } + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "No initial pseudostate found in region '%'.", region->get_name() ); + } + } +} + + +void transition_finder::search_choice_transitions( const raw_const_choices& _choices, + compound_transitions& _compound_transitions, const event& _event, event_collector& _event_collector ) +{ + SX_FOR( const choice* const choice, _choices ) + { + SX_ASSERT( choice, "Choice pointer is null. This cannot be a nullptr." ); + SX_LOG( hermes::log_level::LL_SPAM, "Checking outgoing transition(s) of choice '%'. It has % outgoing transitions.", + choice->get_name(), choice->get_outgoing_transitions().size() ); + bool at_least_one_transition_is_enabled = false; + + SX_FOR( transition* const transition, choice->get_outgoing_transitions()) + { + SX_ASSERT(transition->can_accept_event( sxy::completion_event::get_event_id() ), + "Transition leaving choice is not a completion transition!" ); + SX_LOG( hermes::log_level::LL_SPAM, "Checking outgoing transition '%' of choice '%' for guard.", + transition->get_name(), choice->get_name() ); + const bool guard_evaluated_to_true = transition->check_guard( _event, _event_collector ); + if( guard_evaluated_to_true ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Guard of outgoing transition '%' of choice '%' evaluates to true.", + transition->get_name(), choice->get_name() ); + if( !try_to_build_compound_transition( *transition, _compound_transitions, _event, _event_collector ) ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, + "Transition following choice '%' could not be built in compound transition!", choice->get_name() ); + } + else + { + at_least_one_transition_is_enabled = true; + } + + break; + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Guard of outgoing transition '%' of choice '%' evaluates to false.", + transition->get_name(), choice->get_name() ); + } + } + + if( !at_least_one_transition_is_enabled ) + { + LOG_AND_THROW( hermes::log_level::LL_FATAL, "No transition is enabled for choice '%'!", choice->get_name() ); + } + } +} + + +transition* transition_finder::search_completion_transition( const state& _state, event_collector& _event_collector ) +{ + transition* completion_transition = SX_NULLPTR; + if( _state.is_complete() ) + { + SX_LOG( hermes::log_level::LL_SPAM, "State '%' is complete.", _state.get_name() ); + const sxe::shared_ptr< event_impl > completion_event = SX_MAKE_SHARED< event_impl >( sxy::completion_event::get_event_id() ); + completion_transition = _state.search_transition( *completion_event, _event_collector ); + } + + return( completion_transition ); +} + + +bool transition_finder::search_for_transition( const state& _current_state, + compound_transitions& _enabled_compound_transitions, const event& _event, bool& _event_is_deferred, + event_collector& _event_collector ) const +{ + SX_LOG( hermes::log_level::LL_SPAM, "Search for transition in state '%'.", _current_state.get_name() ); + bool found = false; + const regions& regions = _current_state.get_regions(); + + SX_FOR( const region_uptr& region, regions ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Search for active state in region '%'.", region->get_name() ); + const state* const active_state = region->get_active_state(); + if( active_state ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Found active state '%' in region '%'.", active_state->get_name(), + region->get_name() ); + const bool l_found = search_for_transition( *active_state, _enabled_compound_transitions, _event, + _event_is_deferred, _event_collector ); + if( l_found ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Transition found in active state '%'.", active_state->get_name() ); + found = l_found; + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "No transition found in active state '%'.", active_state->get_name() ); + } + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "No active state found in region '%'.", region->get_name() ); + } + } + + if( !found ) + { + transition* transition = SX_NULLPTR; + if( sxy::completion_event::get_event_id() == _event.get_id() ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Search completion transition in state '%'.", _current_state.get_name() ); + transition = search_completion_transition( _current_state, _event_collector ); + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "Search transition with event id % in state '%'.", + _event.get_id(), _current_state.get_name() ); + transition = _current_state.search_transition( _event, _event_collector ); + } + + if( transition ) + { + SX_LOG( hermes::log_level::LL_TRACE, "Transition '%' found in the current state '%'.", + transition->get_name(), _current_state.get_name() ); + found = try_to_build_compound_transition( *transition, _enabled_compound_transitions, _event, _event_collector ); + if( found ) + { + SX_LOG( hermes::log_level::LL_SPAM, "Compound transition was built for transition '%'.", transition->get_name() ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "Compound transition was not built for transition '%'.", transition->get_name() ); + } + } + else + { + SX_LOG( hermes::log_level::LL_TRACE, "No transition found in current state '%'.", _current_state.get_name() ); + if( _current_state.is_event_deferred( _event.get_id() ) ) + { + _event_is_deferred = true; + found = true; + } + } + } + + return( found ); +} + + +} diff --git a/libyasmine/source/transition_impl.cpp b/libyasmine/source/transition_impl.cpp index acdb2f4..ee61892 100644 --- a/libyasmine/source/transition_impl.cpp +++ b/libyasmine/source/transition_impl.cpp @@ -1,491 +1,491 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_impl.hpp" - -#include - -#include "hermes/log.hpp" - -#include "vertex.hpp" -#include "behavior.hpp" -#include "constraint.hpp" -#include "event.hpp" -#include "uri.hpp" -#include "state_machine_defect.hpp" -#include "region.hpp" -#include "state.hpp" -#include "pseudostate.hpp" -#include "composite_state.hpp" -#include "initial_pseudostate.hpp" -#include "exit_point.hpp" - - -namespace sxy -{ - - -#ifdef SX_CPP03_BOOST -#pragma warning( push ) -#pragma warning( disable : 4100 ) -#endif - - -#ifdef SX_CPP03_BOOST -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_( sxe::move( _guard ) ), - behavior_( sxe::move( _behavior ) ), - kind_( _kind ) -{ - source_.add_outgoing_transition( *this ); - target_.add_incoming_transition( *this ); -} - -#else - #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_( sxe::move( _guard ) ), - behavior_( sxe::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, sxe::move( _guard ), sxe::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_( sxe::move( _guard ) ), - behavior_( sxe::move( _behavior ) ), - kind_( _kind ) - { - source_.add_outgoing_transition( *this ); - target_.add_incoming_transition( *this ); - } - #endif -#endif - - -#ifdef SX_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, behavior_uptr _behavior ) - : state_machine_element_impl( get_transition_name( _source, _target, _event_ids ) ), - event_ids_( _event_ids ), - source_( _source ), - target_( _target ), - guard_( sxe::move( _guard ) ), - behavior_( sxe::move( _behavior ) ), - kind_( _kind ) -{ - source_.add_outgoing_transition( *this ); - target_.add_incoming_transition( *this ); -} - - -transition_impl::~transition_impl() SX_NOEXCEPT -{ - source_.remove_outgoing_transition( *this ); - target_.remove_incoming_transition( *this ); -} - - -const vertex& transition_impl::get_source() const -{ - return( source_ ); -} - - -const vertex& transition_impl::get_target() const -{ - return( target_ ); -} - - -vertex& transition_impl::get_target() -{ - return( target_ ); -} - - -const constraint* transition_impl::get_guard() const -{ - return( guard_.get() ); -} - - -const behavior* transition_impl::get_behavior() const -{ - return( behavior_.get() ); -} - - -uri transition_impl::get_uri() const -{ - uri uri( get_name() ); - add_ancestor_uri( uri ); - return( uri ); -} - - -const state_machine_element* transition_impl::get_parent() const -{ - return( SX_NULLPTR ); -} - - -sxy::transition_kind transition_impl::get_kind() const -{ - return( kind_ ); -} - - -void transition_impl::add_ancestor_uri( uri& _uri ) const -{ - SX_UNUSED_PARAMETER( _uri ); -} - - -void transition_impl::on_transition_behavior( const event& _event, event_collector& _event_collector ) const -{ - SX_LOG( hermes::log_level::LL_TRACE, "Executing transition '%' from '%' to '%'.", get_name(), get_source().get_name(), - get_target().get_name() ); - const behavior* const behavior = get_behavior(); - if( behavior != SX_NULLPTR ) - { - ( *behavior )( _event, _event_collector ); - } - - SX_LOG( hermes::log_level::LL_TRACE, "Executed transition '%' from '%' to '%'.", get_name(), get_source().get_name(), - get_target().get_name() ); -} - - -bool transition_impl::check_guard( const event& _event, event_collector& _event_collector ) const -{ - bool is_checked = true; - if( guard_ ) - { - is_checked = ( *guard_ )( _event, _event_collector ); - } - - return( is_checked ); -} - - -bool transition_impl::check( state_machine_defects& _defects ) const -{ - bool check_ok = check_for_cross_region_transition( _defects ); - - if( sxy::transition_kind::INTERNAL == get_kind() ) - { - const state* const source_state = dynamic_cast< const state* >( &get_source() ); - if( source_state ) - { - if( get_source().get_uri().to_string() != get_target().get_uri().to_string() ) - { - const std::string message = - "Transition '%' has '%' kind, but it has different states as source and target! (source= '%', target = '%')."; - _defects.push_back( state_machine_defect( *this, message, get_name(), - to_string( get_kind() ), source_.get_name(), target_.get_name() ) ); - check_ok = false; - } - } - else - { - _defects.push_back( state_machine_defect( *this, - "Source '%' of transition '%' (kind: '%') is not a state!", get_source().get_name(), get_name(), - to_string( get_kind() ) ) ); - check_ok = false; - } - } - - // Transition that enters a pseudostate cannot have a transition kind (it must be EXTERNAL). - if( dynamic_cast< const pseudostate* >( &get_target() ) ) - { - if( get_kind() != transition_kind::EXTERNAL ) - { - _defects.push_back( state_machine_defect( *this, - "Transition '%' enters pseudostate '%' but has '%' kind! It is not possible!", get_name(), - get_target().get_name(), to_string( get_kind() ) ) ); - check_ok = false; - } - } - - if( transition_kind::LOCAL == get_kind() ) - { - 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 ); -} - - -bool transition_impl::can_accept_event( const event_id _event ) const -{ - bool accept = false; - if( std::find( event_ids_.begin(), event_ids_.end(), _event ) != event_ids_.end() ) - { - accept = true; - } - - return( accept ); -} - - -bool transition_impl::check_if_source_and_target_are_in_ancestor_relationship( const vertex& _source, - const vertex& _target ) -{ - bool are_in_ancestor_relationship = false; - const composite_state* const target_as_composite_state = dynamic_cast< const composite_state* >( &_target ); - if( target_as_composite_state ) - { - are_in_ancestor_relationship = check_relationship( _source, target_as_composite_state ); - } - - if( !are_in_ancestor_relationship ) - { - const composite_state* const source_as_composite_state = dynamic_cast< const composite_state* >( &_source ); - if( source_as_composite_state ) - { - are_in_ancestor_relationship = check_relationship( _target, source_as_composite_state ); - } - } - - return( are_in_ancestor_relationship ); -} - - - -bool transition_impl::check_relationship( const vertex& _lhs, const composite_state* _rhs ) -{ - bool are_in_relationship = false; - const raw_composite_states& lhs_ancestors = _lhs.get_ancestors( SX_NULLPTR ); - - SX_FOR( const composite_state* const ancestor, lhs_ancestors ) - { - if( ancestor == _rhs ) - { - are_in_relationship = true; - break; - } - } - - return( are_in_relationship ); -} - - - -std::string transition_impl::get_transition_name( vertex& _source, vertex& _target, const event_ids& _event_ids ) -{ - std::string transition_name = _source.get_name() + "->" + _target.get_name(); - if( !_event_ids.empty() ) - { - - std::stringstream ids_as_string; - for( size_t i = 0; i < _event_ids.size(); ++i ) - { - if( i != 0 ) - { - ids_as_string << ","; - } - ids_as_string << _event_ids[ i ]; - } - - transition_name += "(" + ids_as_string.str() + ")"; - } - return( transition_name ); -} - - -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( SX_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; - } - else - { - if( initial->get_parent_region() != initial->LCA_region( *target_state ) ) - { - _defects.push_back( state_machine_defect( *this, - "Transition '%' is targeting a state('%') out of the parent region of the initial pseudostate(source)!", - 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( SX_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 ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_impl.hpp" + +#include + +#include "essentials/uri.hpp" +#include "hermes/log.hpp" + +#include "vertex.hpp" +#include "behavior.hpp" +#include "constraint.hpp" +#include "event.hpp" +#include "state_machine_defect.hpp" +#include "region.hpp" +#include "state.hpp" +#include "pseudostate.hpp" +#include "composite_state.hpp" +#include "initial_pseudostate.hpp" +#include "exit_point.hpp" + + +namespace sxy +{ + + +#ifdef SX_CPP03_BOOST +#pragma warning( push ) +#pragma warning( disable : 4100 ) +#endif + + +#ifdef SX_CPP03_BOOST +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_( sxe::move( _guard ) ), + behavior_( sxe::move( _behavior ) ), + kind_( _kind ) +{ + source_.add_outgoing_transition( *this ); + target_.add_incoming_transition( *this ); +} + +#else + #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_( sxe::move( _guard ) ), + behavior_( sxe::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, sxe::move( _guard ), sxe::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_( sxe::move( _guard ) ), + behavior_( sxe::move( _behavior ) ), + kind_( _kind ) + { + source_.add_outgoing_transition( *this ); + target_.add_incoming_transition( *this ); + } + #endif +#endif + + +#ifdef SX_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, behavior_uptr _behavior ) + : state_machine_element_impl( get_transition_name( _source, _target, _event_ids ) ), + event_ids_( _event_ids ), + source_( _source ), + target_( _target ), + guard_( sxe::move( _guard ) ), + behavior_( sxe::move( _behavior ) ), + kind_( _kind ) +{ + source_.add_outgoing_transition( *this ); + target_.add_incoming_transition( *this ); +} + + +transition_impl::~transition_impl() SX_NOEXCEPT +{ + source_.remove_outgoing_transition( *this ); + target_.remove_incoming_transition( *this ); +} + + +const vertex& transition_impl::get_source() const +{ + return( source_ ); +} + + +const vertex& transition_impl::get_target() const +{ + return( target_ ); +} + + +vertex& transition_impl::get_target() +{ + return( target_ ); +} + + +const constraint* transition_impl::get_guard() const +{ + return( guard_.get() ); +} + + +const behavior* transition_impl::get_behavior() const +{ + return( behavior_.get() ); +} + + +sxe::uri transition_impl::get_uri() const +{ + sxe::uri uri( get_name() ); + add_ancestor_uri( uri ); + return( uri ); +} + + +const state_machine_element* transition_impl::get_parent() const +{ + return( SX_NULLPTR ); +} + + +sxy::transition_kind transition_impl::get_kind() const +{ + return( kind_ ); +} + + +void transition_impl::add_ancestor_uri( sxe::uri& _uri ) const +{ + SX_UNUSED_PARAMETER( _uri ); +} + + +void transition_impl::on_transition_behavior( const event& _event, event_collector& _event_collector ) const +{ + SX_LOG( hermes::log_level::LL_TRACE, "Executing transition '%' from '%' to '%'.", get_name(), get_source().get_name(), + get_target().get_name() ); + const behavior* const behavior = get_behavior(); + if( behavior != SX_NULLPTR ) + { + ( *behavior )( _event, _event_collector ); + } + + SX_LOG( hermes::log_level::LL_TRACE, "Executed transition '%' from '%' to '%'.", get_name(), get_source().get_name(), + get_target().get_name() ); +} + + +bool transition_impl::check_guard( const event& _event, event_collector& _event_collector ) const +{ + bool is_checked = true; + if( guard_ ) + { + is_checked = ( *guard_ )( _event, _event_collector ); + } + + return( is_checked ); +} + + +bool transition_impl::check( state_machine_defects& _defects ) const +{ + bool check_ok = check_for_cross_region_transition( _defects ); + + if( sxy::transition_kind::INTERNAL == get_kind() ) + { + const state* const source_state = dynamic_cast< const state* >( &get_source() ); + if( source_state ) + { + if( get_source().get_uri().to_string() != get_target().get_uri().to_string() ) + { + const std::string message = + "Transition '%' has '%' kind, but it has different states as source and target! (source= '%', target = '%')."; + _defects.push_back( state_machine_defect( *this, message, get_name(), + to_string( get_kind() ), source_.get_name(), target_.get_name() ) ); + check_ok = false; + } + } + else + { + _defects.push_back( state_machine_defect( *this, + "Source '%' of transition '%' (kind: '%') is not a state!", get_source().get_name(), get_name(), + to_string( get_kind() ) ) ); + check_ok = false; + } + } + + // Transition that enters a pseudostate cannot have a transition kind (it must be EXTERNAL). + if( dynamic_cast< const pseudostate* >( &get_target() ) ) + { + if( get_kind() != transition_kind::EXTERNAL ) + { + _defects.push_back( state_machine_defect( *this, + "Transition '%' enters pseudostate '%' but has '%' kind! It is not possible!", get_name(), + get_target().get_name(), to_string( get_kind() ) ) ); + check_ok = false; + } + } + + if( transition_kind::LOCAL == get_kind() ) + { + 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 ); +} + + +bool transition_impl::can_accept_event( const event_id _event ) const +{ + bool accept = false; + if( std::find( event_ids_.begin(), event_ids_.end(), _event ) != event_ids_.end() ) + { + accept = true; + } + + return( accept ); +} + + +bool transition_impl::check_if_source_and_target_are_in_ancestor_relationship( const vertex& _source, + const vertex& _target ) +{ + bool are_in_ancestor_relationship = false; + const composite_state* const target_as_composite_state = dynamic_cast< const composite_state* >( &_target ); + if( target_as_composite_state ) + { + are_in_ancestor_relationship = check_relationship( _source, target_as_composite_state ); + } + + if( !are_in_ancestor_relationship ) + { + const composite_state* const source_as_composite_state = dynamic_cast< const composite_state* >( &_source ); + if( source_as_composite_state ) + { + are_in_ancestor_relationship = check_relationship( _target, source_as_composite_state ); + } + } + + return( are_in_ancestor_relationship ); +} + + + +bool transition_impl::check_relationship( const vertex& _lhs, const composite_state* _rhs ) +{ + bool are_in_relationship = false; + const raw_composite_states& lhs_ancestors = _lhs.get_ancestors( SX_NULLPTR ); + + SX_FOR( const composite_state* const ancestor, lhs_ancestors ) + { + if( ancestor == _rhs ) + { + are_in_relationship = true; + break; + } + } + + return( are_in_relationship ); +} + + + +std::string transition_impl::get_transition_name( vertex& _source, vertex& _target, const event_ids& _event_ids ) +{ + std::string transition_name = _source.get_name() + "->" + _target.get_name(); + if( !_event_ids.empty() ) + { + + std::stringstream ids_as_string; + for( size_t i = 0; i < _event_ids.size(); ++i ) + { + if( i != 0 ) + { + ids_as_string << ","; + } + ids_as_string << _event_ids[ i ]; + } + + transition_name += "(" + ids_as_string.str() + ")"; + } + return( transition_name ); +} + + +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( SX_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; + } + else + { + if( initial->get_parent_region() != initial->LCA_region( *target_state ) ) + { + _defects.push_back( state_machine_defect( *this, + "Transition '%' is targeting a state('%') out of the parent region of the initial pseudostate(source)!", + 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( SX_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/libyasmine/source/transition_kind.cpp b/libyasmine/source/transition_kind.cpp index 0c1ce81..35efbef 100644 --- a/libyasmine/source/transition_kind.cpp +++ b/libyasmine/source/transition_kind.cpp @@ -1,75 +1,75 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_kind.hpp" - - -namespace sxy -{ - - -std::string to_string( const transition_kind _kind ) -{ - std::string kind = ""; - -#ifndef SX_CPP03_BOOST - switch( _kind ) -#else - switch (_kind.value_) -#endif - { - case sxy::transition_kind::EXTERNAL: - kind = "EXTERNAL"; - break; - - case sxy::transition_kind::INTERNAL: - kind = "INTERNAL"; - break; - - case sxy::transition_kind::LOCAL: - kind = "LOCAL"; - break; - - default: - break; - } - - return( kind ); -} - - - -#ifdef SX_CPP03_BOOST - - -bool operator==(const sxy::transition_kind& _lhs, const sxy::transition_kind::inner _rhs) -{ - return( _lhs.value_ == _rhs ); -} - - -bool operator==(const sxy::transition_kind::inner _lhs, const sxy::transition_kind& _rhs) -{ - return( _lhs == _rhs.value_ ); -} - - -// cppcheck-suppress unusedFunction -bool operator<(const sxy::transition_kind _lhs, const sxy::transition_kind _rhs) -{ - return ( _lhs.value_ < _rhs.value_ ); -} - - -#endif - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_kind.hpp" + + +namespace sxy +{ + + +std::string to_string( const transition_kind _kind ) +{ + std::string kind = ""; + +#ifndef SX_CPP03_BOOST + switch( _kind ) +#else + switch (_kind.value_) +#endif + { + case sxy::transition_kind::EXTERNAL: + kind = "EXTERNAL"; + break; + + case sxy::transition_kind::INTERNAL: + kind = "INTERNAL"; + break; + + case sxy::transition_kind::LOCAL: + kind = "LOCAL"; + break; + + default: + break; + } + + return( kind ); +} + + + +#ifdef SX_CPP03_BOOST + + +bool operator==(const sxy::transition_kind& _lhs, const sxy::transition_kind::inner _rhs) +{ + return( _lhs.value_ == _rhs ); +} + + +bool operator==(const sxy::transition_kind::inner _lhs, const sxy::transition_kind& _rhs) +{ + return( _lhs == _rhs.value_ ); +} + + +// cppcheck-suppress unusedFunction +bool operator<(const sxy::transition_kind _lhs, const sxy::transition_kind _rhs) +{ + return ( _lhs.value_ < _rhs.value_ ); +} + + +#endif + + +} diff --git a/libyasmine/source/transition_priority.cpp b/libyasmine/source/transition_priority.cpp index 7f4a50a..d6a4577 100644 --- a/libyasmine/source/transition_priority.cpp +++ b/libyasmine/source/transition_priority.cpp @@ -1,62 +1,62 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "transition_priority.hpp" -#include "compound_transition.hpp" -#include "composite_state_impl.hpp" -#include "transition.hpp" -#include "region.hpp" -#include "deep_history.hpp" -#include "shallow_history.hpp" -#include "behavior.hpp" - - -namespace sxy -{ - - -transition_priority::transition_priority( compound_transition& _compound_transition ) - : compound_transition_( &_compound_transition ), - priority_( 0 ) -{ - const region* const lca_region = _compound_transition.get_LCA_region(); - if( lca_region ) - { - priority_ = lca_region->get_parent_state().get_nesting_level(); - } -} - - -transition_priority::~transition_priority() SX_NOEXCEPT -{ - // Nothing to do... -} - - -std::size_t transition_priority::get_priority() const -{ - return( priority_ ); -} - - -compound_transition& transition_priority::get_compound_transition() const -{ - return( *compound_transition_ ); -} - - -bool transition_priority::operator<( const transition_priority& _compare_member ) const -{ - return( priority_ > _compare_member.get_priority() ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_priority.hpp" +#include "compound_transition.hpp" +#include "composite_state_impl.hpp" +#include "transition.hpp" +#include "region.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" +#include "behavior.hpp" + + +namespace sxy +{ + + +transition_priority::transition_priority( compound_transition& _compound_transition ) + : compound_transition_( &_compound_transition ), + priority_( 0 ) +{ + const region* const lca_region = _compound_transition.get_LCA_region(); + if( lca_region ) + { + priority_ = lca_region->get_parent_state().get_nesting_level(); + } +} + + +transition_priority::~transition_priority() SX_NOEXCEPT +{ + // Nothing to do... +} + + +std::size_t transition_priority::get_priority() const +{ + return( priority_ ); +} + + +compound_transition& transition_priority::get_compound_transition() const +{ + return( *compound_transition_ ); +} + + +bool transition_priority::operator<( const transition_priority& _compare_member ) const +{ + return( priority_ > _compare_member.get_priority() ); +} + + +} diff --git a/libyasmine/source/try_to_build_compound_transition_visitor.cpp b/libyasmine/source/try_to_build_compound_transition_visitor.cpp index bf97920..3486406 100644 --- a/libyasmine/source/try_to_build_compound_transition_visitor.cpp +++ b/libyasmine/source/try_to_build_compound_transition_visitor.cpp @@ -1,201 +1,201 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "try_to_build_compound_transition_visitor.hpp" - -#include "hermes/log.hpp" - -#include "join.hpp" -#include "compound_transition_impl.hpp" -#include "compound_transition_builder.hpp" -#include "event.hpp" -#include "composite_state.hpp" -#include "simple_state.hpp" -#include "final_state.hpp" -#include "initial_pseudostate.hpp" -#include "choice.hpp" -#include "junction.hpp" -#include "join.hpp" -#include "fork.hpp" -#include "entry_point.hpp" -#include "exit_point.hpp" -#include "deep_history.hpp" -#include "shallow_history.hpp" -#include "terminate_pseudostate.hpp" - - -namespace sxy -{ - - -try_to_build_compound_transition_visitor::try_to_build_compound_transition_visitor( transition& _enabled_transition, - compound_transitions& _enabled_compound_transitions, bool& _is_built, const event& _event, - event_collector& _event_collector ) - : enabled_transition_( _enabled_transition ), - enabled_compound_transitions_( _enabled_compound_transitions ), - is_built_( _is_built ), - event_( _event ), - event_collector_( _event_collector ) -{ - is_built_ = false; -} - - -try_to_build_compound_transition_visitor::~try_to_build_compound_transition_visitor() SX_NOEXCEPT -{ - // Nothing to do... -} - - -void try_to_build_compound_transition_visitor::visit( const composite_state& _composite_state ) -{ - SX_UNUSED_PARAMETER( _composite_state ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const simple_state& _simple_state ) -{ - SX_UNUSED_PARAMETER( _simple_state ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const final_state& _final_state ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached final state '%'.", _final_state.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const initial_pseudostate& _initial_pseudostate ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached initial pseudostate '%'.", _initial_pseudostate.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const choice& _choice ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached choice '%'.", _choice.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const junction& _junction ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached junction '%'.", _junction.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const join& _join ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached join '%'.", _join.get_name() ); - check_if_join_is_active_and_was_not_processed_yet( _join ); -} - - -void try_to_build_compound_transition_visitor::visit( const fork& _fork ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached fork '%'.", _fork.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const entry_point& _entry_point ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached entry point '%'.", _entry_point.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const exit_point& _exit_point ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached exit point '%'.", _exit_point.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const deep_history& _deep_history ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached deep history '%'.", _deep_history.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const shallow_history& _shallow_history ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached shallow history '%'.", _shallow_history.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::visit( const terminate_pseudostate& _terminate_pseudostate ) -{ - SX_LOG( hermes::log_level::LL_TRACE, "Reached terminate pseudostate '%'.", _terminate_pseudostate.get_name() ); - build_compound_transition_and_insert_in_container(); -} - - -void try_to_build_compound_transition_visitor::build_compound_transition_and_insert_in_container() -{ - compound_transition_uptr compound_transition = sxy::build_compound_transition( enabled_transition_, event_, event_collector_ ); - if( compound_transition ) - { - enabled_compound_transitions_.push_back( sxe::move( compound_transition ) ); - is_built_ = true; - } -} - - -void try_to_build_compound_transition_visitor::check_if_join_is_active_and_was_not_processed_yet( - const join& _join ) -{ - const bool transition_was_already_used = - check_if_transition_was_already_used( enabled_transition_, enabled_compound_transitions_ ); - - if( !transition_was_already_used ) - { - const bool all_incoming_transitions_enabled - = _join.check_if_all_source_states_of_incoming_transitions_are_active(); - if( all_incoming_transitions_enabled ) - { - build_compound_transition_and_insert_in_container( ); - } - } - else - { - // The compound transition for this join was already built somewhere else. So the transition search has to end in - // this branch. - is_built_ = true; - } -} - - -bool try_to_build_compound_transition_visitor::check_if_transition_was_already_used( - const transition& _transition, compound_transitions& _compound_transitions ) -{ - bool already_used = false; - SX_FOR( const compound_transition_uptr& compound_transition, _compound_transitions ) - { - already_used = compound_transition->check_if_starts_with( _transition ); - if( already_used ) - { - break; - } - } - - return( already_used ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "try_to_build_compound_transition_visitor.hpp" + +#include "hermes/log.hpp" + +#include "join.hpp" +#include "compound_transition_impl.hpp" +#include "compound_transition_builder.hpp" +#include "event.hpp" +#include "composite_state.hpp" +#include "simple_state.hpp" +#include "final_state.hpp" +#include "initial_pseudostate.hpp" +#include "choice.hpp" +#include "junction.hpp" +#include "join.hpp" +#include "fork.hpp" +#include "entry_point.hpp" +#include "exit_point.hpp" +#include "deep_history.hpp" +#include "shallow_history.hpp" +#include "terminate_pseudostate.hpp" + + +namespace sxy +{ + + +try_to_build_compound_transition_visitor::try_to_build_compound_transition_visitor( transition& _enabled_transition, + compound_transitions& _enabled_compound_transitions, bool& _is_built, const event& _event, + event_collector& _event_collector ) + : enabled_transition_( _enabled_transition ), + enabled_compound_transitions_( _enabled_compound_transitions ), + is_built_( _is_built ), + event_( _event ), + event_collector_( _event_collector ) +{ + is_built_ = false; +} + + +try_to_build_compound_transition_visitor::~try_to_build_compound_transition_visitor() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void try_to_build_compound_transition_visitor::visit( const composite_state& _composite_state ) +{ + SX_UNUSED_PARAMETER( _composite_state ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const simple_state& _simple_state ) +{ + SX_UNUSED_PARAMETER( _simple_state ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const final_state& _final_state ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached final state '%'.", _final_state.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const initial_pseudostate& _initial_pseudostate ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached initial pseudostate '%'.", _initial_pseudostate.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const choice& _choice ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached choice '%'.", _choice.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const junction& _junction ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached junction '%'.", _junction.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const join& _join ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached join '%'.", _join.get_name() ); + check_if_join_is_active_and_was_not_processed_yet( _join ); +} + + +void try_to_build_compound_transition_visitor::visit( const fork& _fork ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached fork '%'.", _fork.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const entry_point& _entry_point ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached entry point '%'.", _entry_point.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const exit_point& _exit_point ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached exit point '%'.", _exit_point.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const deep_history& _deep_history ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached deep history '%'.", _deep_history.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const shallow_history& _shallow_history ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached shallow history '%'.", _shallow_history.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::visit( const terminate_pseudostate& _terminate_pseudostate ) +{ + SX_LOG( hermes::log_level::LL_TRACE, "Reached terminate pseudostate '%'.", _terminate_pseudostate.get_name() ); + build_compound_transition_and_insert_in_container(); +} + + +void try_to_build_compound_transition_visitor::build_compound_transition_and_insert_in_container() +{ + compound_transition_uptr compound_transition = sxy::build_compound_transition( enabled_transition_, event_, event_collector_ ); + if( compound_transition ) + { + enabled_compound_transitions_.push_back( sxe::move( compound_transition ) ); + is_built_ = true; + } +} + + +void try_to_build_compound_transition_visitor::check_if_join_is_active_and_was_not_processed_yet( + const join& _join ) +{ + const bool transition_was_already_used = + check_if_transition_was_already_used( enabled_transition_, enabled_compound_transitions_ ); + + if( !transition_was_already_used ) + { + const bool all_incoming_transitions_enabled + = _join.check_if_all_source_states_of_incoming_transitions_are_active(); + if( all_incoming_transitions_enabled ) + { + build_compound_transition_and_insert_in_container( ); + } + } + else + { + // The compound transition for this join was already built somewhere else. So the transition search has to end in + // this branch. + is_built_ = true; + } +} + + +bool try_to_build_compound_transition_visitor::check_if_transition_was_already_used( + const transition& _transition, compound_transitions& _compound_transitions ) +{ + bool already_used = false; + SX_FOR( const compound_transition_uptr& compound_transition, _compound_transitions ) + { + already_used = compound_transition->check_if_starts_with( _transition ); + if( already_used ) + { + break; + } + } + + return( already_used ); +} + + +} diff --git a/libyasmine/source/utils.cpp b/libyasmine/source/utils.cpp index 56ceb63..09af016 100644 --- a/libyasmine/source/utils.cpp +++ b/libyasmine/source/utils.cpp @@ -1,74 +1,74 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "utils.hpp" - - -namespace sxy -{ - - -namespace utils -{ - - -namespace -{ - - -#ifdef WIN32 -const SHORT MAX_ROWS = 9999; -#endif - - -} - - -#ifdef WIN32 - -// cppcheck-suppress unusedFunction -void set_window_size( const SHORT _width, const SHORT _height ) -{ - COORD coord; - coord.X = _width; - coord.Y = MAX_ROWS; - SMALL_RECT rect; - rect.Top = 0; - rect.Left = 0; - rect.Right = _width - 1; - rect.Bottom = _height - 1; - const HANDLE handle = GetStdHandle( STD_OUTPUT_HANDLE ); - SetConsoleScreenBufferSize( handle, coord ); - SetConsoleWindowInfo( handle, TRUE, &rect ); -} - - -// cppcheck-suppress unusedFunction -void maximize_window() -{ - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &info ); - SMALL_RECT rect; - rect.Left = 0; - rect.Top = 0; - rect.Right = min( info.dwMaximumWindowSize.X, info.dwSize.X ) - 1; - rect.Bottom = min( info.dwMaximumWindowSize.Y, info.dwSize.Y ) - 1; - SetConsoleWindowInfo( GetStdHandle( STD_OUTPUT_HANDLE ), true, &rect ); -} - - -#endif - - -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "utils.hpp" + + +namespace sxy +{ + + +namespace utils +{ + + +namespace +{ + + +#ifdef WIN32 +const SHORT MAX_ROWS = 9999; +#endif + + +} + + +#ifdef WIN32 + +// cppcheck-suppress unusedFunction +void set_window_size( const SHORT _width, const SHORT _height ) +{ + COORD coord; + coord.X = _width; + coord.Y = MAX_ROWS; + SMALL_RECT rect; + rect.Top = 0; + rect.Left = 0; + rect.Right = _width - 1; + rect.Bottom = _height - 1; + const HANDLE handle = GetStdHandle( STD_OUTPUT_HANDLE ); + SetConsoleScreenBufferSize( handle, coord ); + SetConsoleWindowInfo( handle, TRUE, &rect ); +} + + +// cppcheck-suppress unusedFunction +void maximize_window() +{ + CONSOLE_SCREEN_BUFFER_INFO info; + GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &info ); + SMALL_RECT rect; + rect.Left = 0; + rect.Top = 0; + rect.Right = min( info.dwMaximumWindowSize.X, info.dwSize.X ) - 1; + rect.Bottom = min( info.dwMaximumWindowSize.Y, info.dwSize.Y ) - 1; + SetConsoleWindowInfo( GetStdHandle( STD_OUTPUT_HANDLE ), true, &rect ); +} + + +#endif + + +} + + +} diff --git a/libyasmine/source/version.cpp b/libyasmine/source/version.cpp index 19b0d32..3a89bf1 100644 --- a/libyasmine/source/version.cpp +++ b/libyasmine/source/version.cpp @@ -1,76 +1,76 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "hermes/log.hpp" -#include "version.hpp" -#include "build_number.hpp" - - -namespace sxy -{ - - -namespace version -{ - - -namespace -{ - - -const sxe::uint16_t VERSION_MAJOR( 1 ); -const sxe::uint16_t VERSION_MINOR( 1 ); -const sxe::uint16_t VERSION_PATCH( 1 ); - - -} - - -#ifndef SX_NO_LOGGING - -// cppcheck-suppress unusedFunction -void log_version() -{ - SX_LOG( hermes::log_level::LL_INFO, "yasmine library version %.%.%.%.", get_major_version(), - get_minor_version(), get_patch_version(), get_build_number() ); -} - - -#endif - -sxe::uint16_t get_major_version() -{ - return( VERSION_MAJOR ); -} - - -sxe::uint16_t get_minor_version() -{ - return( VERSION_MINOR ); -} - - -sxe::uint16_t get_patch_version() -{ - return( VERSION_PATCH ); -} - - -sxe::uint16_t get_build_number() -{ - return( BUILD_NUMBER ); -} - - -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "hermes/log.hpp" +#include "version.hpp" +#include "build_number.hpp" + + +namespace sxy +{ + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 1 ); +const sxe::uint16_t VERSION_MINOR( 1 ); +const sxe::uint16_t VERSION_PATCH( 2 ); + + +} + + +#ifndef SX_NO_LOGGING + + +void log_version() +{ + SX_LOG( hermes::log_level::LL_INFO, "yasmine library version %.%.%.%.", get_major_version(), + get_minor_version(), get_patch_version(), get_build_number() ); +} + + +#endif + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( BUILD_NUMBER ); +} + + +} + + +} diff --git a/libyasmine/source/vertex_impl.cpp b/libyasmine/source/vertex_impl.cpp index 58716c3..de562cd 100644 --- a/libyasmine/source/vertex_impl.cpp +++ b/libyasmine/source/vertex_impl.cpp @@ -1,261 +1,261 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // -// Copyright (C) 2016-2017 Seadex GmbH // -// // -// Licensing information is available in the folder "license" which is part of this distribution. // -// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // -// // -////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#include "vertex_impl.hpp" - -#include -#include - -#include "hermes/log.hpp" - -#include "composite_state.hpp" -#include "region.hpp" -#include "transition.hpp" -#include "uri.hpp" -#include "event.hpp" -#include "constraint.hpp" - - -namespace sxy -{ - - -vertex_impl::vertex_impl( const std::string& _name ) - : state_machine_element_impl( _name ), - outgoing_transitions_(), - incoming_transitions_() -{ - // Nothing to do... -} - - -vertex_impl::~vertex_impl() SX_NOEXCEPT -{ - // Nothing to do... -} - - -composite_state* vertex_impl::get_root_state() -{ - raw_composite_states ancestors = get_ancestors( SX_NULLPTR ); - composite_state* root = SX_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 -{ - raw_composite_states ancestors = get_ancestors( SX_NULLPTR ); - const composite_state* root = SX_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 SX_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 ); - } - } -} - - -void vertex_impl::add_incoming_transition( transition& _incoming_transition ) -{ - incoming_transitions_.push_back( &_incoming_transition ); -} - - -void vertex_impl::remove_outgoing_transition( const transition& _outgoing_transition ) -{ - const raw_transitions::iterator outgoing_transition = std::find( outgoing_transitions_.begin(), - outgoing_transitions_.end(), &_outgoing_transition ); - outgoing_transitions_.erase( outgoing_transition ); -} - - -void vertex_impl::remove_incoming_transition( const transition& _incoming_transition ) -{ - const raw_transitions::iterator incoming_transition = std::find( incoming_transitions_.begin(), - incoming_transitions_.end(), &_incoming_transition ); - incoming_transitions_.erase( incoming_transition ); -} - - -const raw_transitions& vertex_impl::get_outgoing_transitions() const -{ - return( outgoing_transitions_ ); -} - - -const raw_transitions& vertex_impl::get_incoming_transitions() const -{ - return( incoming_transitions_ ); -} - - -uri vertex_impl::get_uri() const -{ - uri uri( get_name() ); - add_ancestor_uri( uri ); - return( uri ); -} - - -transition* vertex_impl::search_transition( const event& _event, event_collector& _event_collector ) const -{ - const raw_transitions& transitions = get_outgoing_transitions(); - transition* found_transition = SX_NULLPTR; - - SX_FOR( transition* const transition, transitions ) - { - if( transition->can_accept_event( _event.get_id() ) ) - { - const bool is_checked = transition->check_guard( _event, _event_collector ); - if( is_checked ) - { - found_transition = transition; - break; - } - } - } - - return( found_transition ); -} - - -region* vertex_impl::LCA_region( const vertex& _rhs ) const -{ - SX_LOG( hermes::log_level::LL_SPAM, "Start calculating LCA_region for '%' and '%'.", get_name(), _rhs.get_name() ); - region* lca = SX_NULLPTR; - const raw_regions& ancestors_of_lhs = get_ancestors_as_regions(); - const raw_regions& ancestors_of_rhs = _rhs.get_ancestors_as_regions(); - if( ancestors_of_lhs.empty() || ancestors_of_rhs.empty() ) - { - SX_LOG( hermes::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] ) - { - lca = ancestors_of_lhs[l_idx]; - if( ( l_idx == 0 ) || ( r_idx == 0 ) ) - { - break; - } - - --r_idx; - --l_idx; - } - SX_LOG( hermes::log_level::LL_SPAM, "LCA region found: '%'.", lca->get_name() ); - } - return( lca ); -} - - -composite_state* vertex_impl::LCA_composite_state( const vertex& _rhs ) const -{ - SX_LOG( hermes::log_level::LL_SPAM, "Start calculating LCA_composite_state for '%' and '%'.", get_name(), _rhs.get_name() ); - composite_state* lca = SX_NULLPTR; - const raw_composite_states& ancestors_of_lhs = get_ancestors( SX_NULLPTR ); - const raw_composite_states& ancestors_of_rhs = _rhs.get_ancestors( SX_NULLPTR ); - SX_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 ) ) - { - break; - } - --r_idx; - --l_idx; - } - - if( lca ) - { - SX_LOG( hermes::log_level::LL_SPAM, "LCA_composite_state found: '%'.", lca->get_name() ); - } - else - { - SX_LOG( hermes::log_level::LL_SPAM, "No LCA_composite_state has been found. LCA is nullptr." ); - } - - return( lca ); -} - - -void vertex_impl::add_ancestor_uri( uri& _uri ) const -{ - const state_machine_element* parent = get_parent(); - while( parent ) - { - _uri.push_front( parent->get_name() ); - parent = parent->get_parent(); - } -} - - -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(), - ( sxe::bind( &vertex_impl::has_no_guard, sxe::_1 ) ) ); - return( found_position ); -} - - -bool vertex_impl::has_no_guard( const transition* const _transition ) -{ - return ( !_transition->get_guard() ); -} - - -} +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "vertex_impl.hpp" + +#include +#include + +#include "essentials/uri.hpp" +#include "hermes/log.hpp" + +#include "composite_state.hpp" +#include "region.hpp" +#include "transition.hpp" +#include "event.hpp" +#include "constraint.hpp" + + +namespace sxy +{ + + +vertex_impl::vertex_impl( const std::string& _name ) + : state_machine_element_impl( _name ), + outgoing_transitions_(), + incoming_transitions_() +{ + // Nothing to do... +} + + +vertex_impl::~vertex_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +composite_state* vertex_impl::get_root_state() +{ + raw_composite_states ancestors = get_ancestors( SX_NULLPTR ); + composite_state* root = SX_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 +{ + raw_composite_states ancestors = get_ancestors( SX_NULLPTR ); + const composite_state* root = SX_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 SX_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 ); + } + } +} + + +void vertex_impl::add_incoming_transition( transition& _incoming_transition ) +{ + incoming_transitions_.push_back( &_incoming_transition ); +} + + +void vertex_impl::remove_outgoing_transition( const transition& _outgoing_transition ) +{ + const raw_transitions::iterator outgoing_transition = std::find( outgoing_transitions_.begin(), + outgoing_transitions_.end(), &_outgoing_transition ); + outgoing_transitions_.erase( outgoing_transition ); +} + + +void vertex_impl::remove_incoming_transition( const transition& _incoming_transition ) +{ + const raw_transitions::iterator incoming_transition = std::find( incoming_transitions_.begin(), + incoming_transitions_.end(), &_incoming_transition ); + incoming_transitions_.erase( incoming_transition ); +} + + +const raw_transitions& vertex_impl::get_outgoing_transitions() const +{ + return( outgoing_transitions_ ); +} + + +const raw_transitions& vertex_impl::get_incoming_transitions() const +{ + return( incoming_transitions_ ); +} + + +sxe::uri vertex_impl::get_uri() const +{ + sxe::uri uri( get_name() ); + add_ancestor_uri( uri ); + return( uri ); +} + + +transition* vertex_impl::search_transition( const event& _event, event_collector& _event_collector ) const +{ + const raw_transitions& transitions = get_outgoing_transitions(); + transition* found_transition = SX_NULLPTR; + + SX_FOR( transition* const transition, transitions ) + { + if( transition->can_accept_event( _event.get_id() ) ) + { + const bool is_checked = transition->check_guard( _event, _event_collector ); + if( is_checked ) + { + found_transition = transition; + break; + } + } + } + + return( found_transition ); +} + + +region* vertex_impl::LCA_region( const vertex& _rhs ) const +{ + SX_LOG( hermes::log_level::LL_SPAM, "Start calculating LCA_region for '%' and '%'.", get_name(), _rhs.get_name() ); + region* lca = SX_NULLPTR; + const raw_regions& ancestors_of_lhs = get_ancestors_as_regions(); + const raw_regions& ancestors_of_rhs = _rhs.get_ancestors_as_regions(); + if( ancestors_of_lhs.empty() || ancestors_of_rhs.empty() ) + { + SX_LOG( hermes::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] ) + { + lca = ancestors_of_lhs[l_idx]; + if( ( l_idx == 0 ) || ( r_idx == 0 ) ) + { + break; + } + + --r_idx; + --l_idx; + } + SX_LOG( hermes::log_level::LL_SPAM, "LCA region found: '%'.", lca->get_name() ); + } + return( lca ); +} + + +composite_state* vertex_impl::LCA_composite_state( const vertex& _rhs ) const +{ + SX_LOG( hermes::log_level::LL_SPAM, "Start calculating LCA_composite_state for '%' and '%'.", get_name(), _rhs.get_name() ); + composite_state* lca = SX_NULLPTR; + const raw_composite_states& ancestors_of_lhs = get_ancestors( SX_NULLPTR ); + const raw_composite_states& ancestors_of_rhs = _rhs.get_ancestors( SX_NULLPTR ); + SX_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 ) ) + { + break; + } + --r_idx; + --l_idx; + } + + if( lca ) + { + SX_LOG( hermes::log_level::LL_SPAM, "LCA_composite_state found: '%'.", lca->get_name() ); + } + else + { + SX_LOG( hermes::log_level::LL_SPAM, "No LCA_composite_state has been found. LCA is nullptr." ); + } + + return( lca ); +} + + +void vertex_impl::add_ancestor_uri( sxe::uri& _uri ) const +{ + const state_machine_element* parent = get_parent(); + while( parent ) + { + _uri.push_front( parent->get_name() ); + parent = parent->get_parent(); + } +} + + +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(), + ( sxe::bind( &vertex_impl::has_no_guard, sxe::_1 ) ) ); + return( found_position ); +} + + +bool vertex_impl::has_no_guard( const transition* const _transition ) +{ + return ( !_transition->get_guard() ); +} + + +} diff --git a/libygen/CMakeLists.txt b/libygen/CMakeLists.txt new file mode 100644 index 0000000..40a7cc3 --- /dev/null +++ b/libygen/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 3.5) + +project(libygen) + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +file(GLOB libygen_SRC "include/*.hpp" "source/*.cpp") + +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 \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") + else() + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") + endif() + +endif() + + +# for release +if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) + #Creates fast code. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") + + #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}") + +include_directories("./include") +include_directories("/usr/include/rapidjson") +include_directories("./../libyasmine" "./../genesis" "./../yasmine_model") +include_directories("./../libyasmine/include" "./../genesis/include" "./../yasmine_model/include") +include_directories("./../externals/essentials/include") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_library(libygen SHARED ${libygen_SRC}) +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_library(libygen STATIC ${libygen_SRC}) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if("${CPP_VERSION}" STREQUAL "03") + target_link_libraries (libygen LINK_PUBLIC libyasmine genesis yasmine_model pthread boost_system boost_thread boost_chrono) + else() + target_link_libraries (libygen LINK_PUBLIC libyasmine genesis yasmine_model pthread) + endif() +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine genesis yasmine_model) +endif() + +install(TARGETS libygen DESTINATION lib) +install(FILES *.hpp DESTINATION include) +set_target_properties(libygen PROPERTIES PREFIX "") \ No newline at end of file diff --git a/libygen/changelog.txt b/libygen/changelog.txt new file mode 100644 index 0000000..526b851 --- /dev/null +++ b/libygen/changelog.txt @@ -0,0 +1,6 @@ +# Change log +All notable changes to this project are documented in this file. + +##[0.1.0] - 2017-04-24 + +• The very first released version of libygen \ No newline at end of file diff --git a/libygen/include/access_operator.hpp b/libygen/include/access_operator.hpp new file mode 100644 index 0000000..cc70a4c --- /dev/null +++ b/libygen/include/access_operator.hpp @@ -0,0 +1,86 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef ACCESS_OPERATOR_9C58972C_7917_4BBD_8CF2_B2DF69D4F0AC +#define ACCESS_OPERATOR_9C58972C_7917_4BBD_8CF2_B2DF69D4F0AC + + +namespace sxy +{ + + +#ifndef SX_CPP03_BOOST + + //!\enum access_operator + //!\brief Enumeration for predefined access operator. + enum class access_operator + { + AO_NO_ACCESS_OPERATOR = 0, AO_THIS_ACCESS = 1, AO_POINTER_ACCESS = 2, AO_REFERENCE_ACCESS = 3, AO_FUNCTION_ACCESS = 4 + }; + + +#else + + + //!\struct access_operator + //!\brief Structure representing a predefined access operator (enum wrapper for C++11 enum class like behavior). + struct access_operator + { + //!\enum access_operator + //!\brief Enumeration for predefined access operator. + enum inner + { + AO_NO_ACCESS_OPERATOR = 0, AO_THIS_ACCESS = 1, AO_POINTER_ACCESS = 2, AO_REFERENCE_ACCESS = 3, AO_FUNCTION_ACCESS = 4 + }; + + + //!\brief Constructor. Default value is no access operator. + access_operator() : value_( AO_NO_ACCESS_OPERATOR ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _value Given access operator value that is represented by the structure. + access_operator( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _access_operator Given access operator structure containing the access operator that is represented by the structure. + access_operator( const access_operator& _access_operator ) : value_( _access_operator.value_ ) + { + // Nothing to do... + } + + + //!\brief Get the access operator value represented by the structure. + operator inner() const + { + return ( value_ ); + } + + + //!\brief Access operator represented by the structure. + inner value_; + + }; + + +#endif + + +} + + +#endif diff --git a/libygen/include/behavior_struct.hpp b/libygen/include/behavior_struct.hpp new file mode 100644 index 0000000..cdb52c4 --- /dev/null +++ b/libygen/include/behavior_struct.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef BEHAVIOR_STRUCT_12B226AB_A03E_4F10_AD6D_52E3F253A776 +#define BEHAVIOR_STRUCT_12B226AB_A03E_4F10_AD6D_52E3F253A776 + + +#include "essentials/non_copyable.hpp" + +#include "state_machine_type.hpp" +#include "access_operator.hpp" + + +namespace sxy +{ + + +struct behavior_struct +{ +public: + behavior_struct(); + ~behavior_struct() SX_NOEXCEPT; + SX_NO_COPY( behavior_struct ) + + + std::string behavior_class_name; + std::string behavior_method_name; + access_operator call_operator; +}; + + +} + + +#endif diff --git a/libygen/include/config.hpp b/libygen/include/config.hpp new file mode 100644 index 0000000..3e38383 --- /dev/null +++ b/libygen/include/config.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef YGEN_CONFIG_FB3FF499_2D1D_437A_8C77_CB6E9422EE10 +#define YGEN_CONFIG_FB3FF499_2D1D_437A_8C77_CB6E9422EE10 + + +#include + +#include "essentials/non_copyable.hpp" + +#include "state_machine_type.hpp" + + +namespace sxy +{ + + +struct config +{ +public: + config(); + ~config() SX_NOEXCEPT; + SX_NO_COPY( config ) + void print() const; + + std::string template_path; + std::string source_template_file; + std::string header_template_file; + std::string source_output_file; + std::string header_output_file; + std::string model_file; + std::string state_machine_name; + state_machine_type sm_type; + std::vector namespaces; + std::vector behavior_classes; +}; + + +} + + +#endif diff --git a/libygen/include/generator.hpp b/libygen/include/generator.hpp new file mode 100644 index 0000000..2470011 --- /dev/null +++ b/libygen/include/generator.hpp @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GENERATOR_023AFC17_B727_4BE0_B7C1_03FAC7192AA6 +#define GENERATOR_023AFC17_B727_4BE0_B7C1_03FAC7192AA6 + + +#include "config.hpp" + + +namespace sxy +{ + + +void generate( const sxy::config& _config ); + + + +} + + +#endif diff --git a/libygen/include/generator_grammar.hpp b/libygen/include/generator_grammar.hpp new file mode 100644 index 0000000..8a5feac --- /dev/null +++ b/libygen/include/generator_grammar.hpp @@ -0,0 +1,101 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GRAMMAR_F628CCE8_06DD_43A9_BEE3_C3EB343AC539 +#define GRAMMAR_F628CCE8_06DD_43A9_BEE3_C3EB343AC539 + + +#include + + +namespace sxy +{ + + + extern const std::string VARIABLE_STATE_MACHINE_NAME_CAPS; + extern const std::string VARIABLE_STATE_MACHINE_NAME; + extern const std::string VARIABLE_STATE_MACHINE_TYPE; + extern const std::string VARIABLE_NAMESPACE_NAME; + extern const std::string LOOP_NAMESPACE_OPEN; + extern const std::string VARIABLE_NAMESPACE_CLOSE; + extern const std::string VARIABLE_BEHAVIOR_CLASS_NAME; + extern const std::string LOOP_BEHAVIOR_CLASSES; + extern const std::string VARIABLE_LAST_BEHAVIOR_CLASS; + extern const std::string LOOP_TRANSITIONS; + extern const std::string VARIABLE_EVENT_ID; + extern const std::string VARIABLE_EVENT_NAME; + extern const std::string VARIABLE_EVENT_PRIORITY; + extern const std::string TRANSITION_EVENT_ID; + extern const std::string VARIABLE_SOURCE_VERTEX; + extern const std::string VARIABLE_TARGET_VERTEX; + extern const std::string VARIABLE_TRANSITION_KIND; + extern const std::string VARIABLE_TRANSITION_KIND_NAMESPACE; + extern const std::string VARIABLE_EMPTY_BEHAVIOR; + extern const std::string VARIABLE_EMPTY_GUARD; + extern const std::string LOOP_REGIONS; + extern const std::string VARIABLE_VERTICES; + extern const std::string LOOP_PSEUDOSTATES; + extern const std::string LOOP_STATE_PSEUDOSTATES; + extern const std::string LOOP_STATES; + extern const std::string VARIABLE_REGION_NAME; + extern const std::string VARIABLE_ROOT_NAME; + extern const std::string VARIABLE_CURRENT_STATE_NAME; + extern const std::string VARIABLE_DATE_TIME; + extern const unsigned int YEAR_1900; + extern const unsigned int WIDTH_YEAR; + extern const unsigned int WIDTH_CLOCK; + extern const char FILL_VALUE; + extern const char SLASH_CHAR; + extern const char COLON_CHAR; + extern const std::string DOUBLE_COLON; + extern const char OPEN_BRACE_CHAR; + extern const char CLOSE_BRACE_CHAR; + extern const char COMMA_CHAR; + extern const char AND_CHAR; + extern const char DOT_CHAR; + extern const char UNDERSCORE_CHAR; + extern const std::string VARIABLE_COMPLETION_EVENT_ID; + extern const std::string CONDITION_IS_COMPOSITE_STATE; + extern const std::string CONDITION_IS_STATE; + extern const std::string LOOP_EVENTS; + extern const std::string VARIABLE_STATE_NAME; + extern const std::string VARIABLE_STATE_TYPE; + extern const std::string VARIABLE_PSEUDOSTATE_NAME; + extern const std::string VARIABLE_PSEUDOSTATE_TYPE; + extern const std::string VARIABLE_STATE_PSEUDOSTATE_NAME; + extern const std::string VARIABLE_STATE_PSEUDOSTATE_TYPE; + extern const std::string SWITCH_ENTER_BEHAVIOR; + extern const std::string SWITCH_DO_BEHAVIOR; + extern const std::string SWITCH_EXIT_BEHAVIOR; + extern const std::string SWITCH_TRANSITION_GUARD; + extern const std::string SWITCH_TRANSITION_BEHAVIOR; + extern const std::string THIS_ACCESS; + extern const std::string POINTER_ACCESS; + extern const std::string REFERENCE_ACCESS; + extern const std::string VARIABLE_GUARD_FUNCTION2; + extern const std::string VARIABLE_GUARD_METHOD2; + extern const std::string VARIABLE_BEHAVIOR_FUNCTION2; + extern const std::string VARIABLE_BEHAVIOR_METHOD2; + extern const std::string VARIABLE_METHOD_NAME; + extern const std::string VARIABLE_CLASS_INSTANCE_NAME; + extern const std::string VARIABLE_SM_SYNC; + extern const std::string VARIABLE_SM_ASYNC; + extern const std::string VARIABLE_SYNC_SM_CLASS; + extern const std::string VARIABLE_ASYNC_SM_CLASS; + extern const char VARIABLE_CLOSE_PARENTHESIS; + extern const char VARIABLE_OPEN_PARENTHESIS; + extern const std::string CONDITION_LAST_PSEUDOSTATE; + extern const int SWITCH_DEFAULT_INDEX; + + +} + + +#endif diff --git a/libygen/include/libygen_build_number.hpp b/libygen/include/libygen_build_number.hpp new file mode 100644 index 0000000..6f79db1 --- /dev/null +++ b/libygen/include/libygen_build_number.hpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_NUMBER_1BF66FE4_331C_4499_B5BE_176C27D599A6 +#define BUILD_NUMBER_1BF66FE4_331C_4499_B5BE_176C27D599A6 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + + + const sxe::uint16_t BUILD_NUMBER( 656 ); + + +} + + +} + + +#endif diff --git a/libygen/include/libygen_version.hpp b/libygen/include/libygen_version.hpp new file mode 100644 index 0000000..6337d6d --- /dev/null +++ b/libygen/include/libygen_version.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LIBYGEN_VERSION_53D2B2F3_5C60_4E6A_8DB5_20E64ED9A906 +#define LIBYGEN_VERSION_53D2B2F3_5C60_4E6A_8DB5_20E64ED9A906 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + + +void log_version(); + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +#endif diff --git a/libygen/include/recipe_callback_impl.hpp b/libygen/include/recipe_callback_impl.hpp new file mode 100644 index 0000000..06f6063 --- /dev/null +++ b/libygen/include/recipe_callback_impl.hpp @@ -0,0 +1,99 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef RECIPE_CALLBACK_IMPL_A5F81CB3_58BB_4506_908B_49FCBF0C519C +#define RECIPE_CALLBACK_IMPL_A5F81CB3_58BB_4506_908B_49FCBF0C519C + + +#include +#include +#include + +#include "recipe_callback.hpp" +#include "behavior_struct.hpp" + + +namespace sxy +{ + + +namespace model +{ + + + class state_machine_model; + class composite_state_model; + class region_model; + class state_model; + + +} + + +class recipe_callback_impl SX_FINAL: + public sx::genesis::recipe_callback +{ +public: + explicit recipe_callback_impl( const sxy::model::state_machine_model& _state_machine_model, + std::vector _namespaces, std::vector _behavior_classes, + std::string _state_machine_name, std::string _state_machine_type ); + virtual ~recipe_callback_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( recipe_callback_impl ) + virtual std::string get_variable_content( const std::string& _variable_name ) SX_OVERRIDE; + virtual void before_loop( const std::string& _loop_name ) SX_OVERRIDE; + virtual void before_loop_iteration( const std::string& _loop_name ) SX_OVERRIDE; + virtual void after_loop_iteration( const std::string& _loop_name ) SX_OVERRIDE; + virtual bool check_loop_condition( const std::string& _loop_name ) const SX_OVERRIDE; + virtual void after_loop( const std::string& _loop_name ) SX_OVERRIDE; + virtual bool check_condition( const std::string& _condition_name ) const SX_OVERRIDE; + virtual void condition_begin( const std::string& _condition_name ) SX_OVERRIDE; + virtual void condition_end( const std::string& _condition_name ) SX_OVERRIDE; + virtual int get_switch_case( const std::string& _switch_name ) SX_OVERRIDE; + + +private: + std::string get_state_property( const std::string& _property ) const; + std::string get_pseudostate_property( const std::string& _property ) const; + std::string get_state_pseudostate_property( const std::string& _property ) const; + std::string get_event_property( const std::string& _property ) const; + std::string get_date_time_string() const; + std::string get_transition_events() const; + void fill_struct( const std::string& _loop_name ); + void fill_one_behavior_struct( behavior_struct& _behavior, const std::string& _behavior_string ); + static int get_index( const behavior_struct& _behavior_struct ); + + + const sxy::model::state_machine_model& state_machine_model_; + std::map map_of_values_; + std::vector namespaces_; + std::vector behavior_classes_; + std::size_t namespace_index_; + std::size_t base_class_index_; + std::size_t behavior_classes_index_; + std::size_t transition_index_; + std::size_t pseudostate_index_; + std::size_t state_pseudostate_index_; + std::stack composite_states_stack_; + std::stack regions_stack_; + std::stack composite_states_index_stack_; + std::stack regions_index_stack_; + std::size_t event_index_; + behavior_struct entry_behavior_; + behavior_struct do_behavior_; + behavior_struct exit_behavior_; + behavior_struct transition_guard_; + std::string active_switch_; +}; + + +} + + +#endif diff --git a/libygen/include/state_machine_type.hpp b/libygen/include/state_machine_type.hpp new file mode 100644 index 0000000..9c24551 --- /dev/null +++ b/libygen/include/state_machine_type.hpp @@ -0,0 +1,94 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MACHINE_TYPE_DF8B2D7E_F25F_43B0_9B98_3A974487574C +#define STATE_MACHINE_TYPE_DF8B2D7E_F25F_43B0_9B98_3A974487574C + +#include + + +namespace sxy +{ + + +#ifndef SX_CPP03_BOOST + + + //!\enum state_machine_type + //!\brief Enumeration for state machine types. + enum class state_machine_type + { + SMT_SYNC = 0, SMT_ASYNC = 1 + }; + + +#else + + + //!\struct state_machine_type + //!\brief Structure representing state machine types (enum wrapper for C++11 enum class like behavior). + struct state_machine_type + { + //!\enum state_machine_type + //!\brief Enumeration for state machine types. + enum inner + { + SMT_SYNC = 0, SMT_ASYNC = 1 + }; + + + //!\brief Constructor. Default value is white. + state_machine_type() : value_( SMT_SYNC ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _value Given state machine type value that is represented by the structure. + state_machine_type( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + //!\brief Constructor + //!\param _state_machine_type Given state machine type structure containing the + //!\state machine type that is represented by the structure. + state_machine_type( const state_machine_type& _state_machine_type ) : value_( _state_machine_type.value_ ) + { + // Nothing to do... + } + + + //!\brief Get the state machine type value represented by the structure. + operator inner() const + { + return ( value_ ); + } + + + //!\brief State machine type represented by the structure. + inner value_; + + }; + +#endif + + state_machine_type sm_type_from_string( const std::string& _type ); + const std::string sm_type_to_string( const state_machine_type& _type ); + const std::string get_state_machine_class_as_string( const state_machine_type& _type ); + std::istream& operator >> ( std::istream& _in_stream, sxy::state_machine_type& _sm_type ); + + +} + + +#endif diff --git a/libygen/libygen.vcxproj b/libygen/libygen.vcxproj new file mode 100644 index 0000000..9291918 --- /dev/null +++ b/libygen/libygen.vcxproj @@ -0,0 +1,304 @@ + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {CED23388-105D-46FA-9EC3-AD923C209AED} + libygen + 8.1 + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libygen/libygen.vcxproj.filters b/libygen/libygen.vcxproj.filters new file mode 100644 index 0000000..7aa5e64 --- /dev/null +++ b/libygen/libygen.vcxproj.filters @@ -0,0 +1,72 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file diff --git a/libygen/source/behavior_struct.cpp b/libygen/source/behavior_struct.cpp new file mode 100644 index 0000000..d322c4f --- /dev/null +++ b/libygen/source/behavior_struct.cpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "behavior_struct.hpp" + + +namespace sxy +{ + + +behavior_struct::behavior_struct(): + behavior_class_name(), + behavior_method_name(), + call_operator() +{ + // Nothing to do... +} + + +behavior_struct::~behavior_struct() SX_NOEXCEPT +{ + // Nothing to do... +} + + +} diff --git a/libygen/source/config.cpp b/libygen/source/config.cpp new file mode 100644 index 0000000..5e0b2fd --- /dev/null +++ b/libygen/source/config.cpp @@ -0,0 +1,80 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "config.hpp" + +#include + + +namespace sxy +{ + + +config::config(): + template_path(), + source_template_file(), + header_template_file(), + source_output_file(), + header_output_file(), + model_file(), + state_machine_name(), + sm_type(), + namespaces(), + behavior_classes() +{ + // Nothing to do... +} + + +config::~config() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void config::print() const +{ + std::cout << "Template directory: " << template_path << std::endl; + std::cout << "Source file template: " << source_template_file << std::endl; + std::cout << "Source file output: " << source_output_file << std::endl; + std::cout << "Header file template: " << header_template_file << std::endl; + std::cout << "Header file output: " << header_output_file << std::endl; + std::cout << "Model file: " << model_file << std::endl; + std::cout << "State machine name: " << state_machine_name << std::endl; + std::cout << "State machine type: " << sm_type_to_string( sm_type ) << std::endl; + if( namespaces.empty() ) + { + std::cout << "No namespace(s)." << std::endl; + } + else + { + std::cout << "Namespace(s):" << std::endl; + SX_FOR( const std::string& one_namespace , namespaces ) + { + std::cout << " " << one_namespace << std::endl; + } + } + + if( behavior_classes.empty() ) + { + std::cout << "No behavior class(es)." << std::endl; + } + else + { + std::cout << "Behavior class(es):" << std::endl; + SX_FOR( const std::string& behavior_class, behavior_classes ) + { + std::cout << " " << behavior_class << std::endl; + } + } +} + + +} diff --git a/libygen/source/generator.cpp b/libygen/source/generator.cpp new file mode 100644 index 0000000..11706be --- /dev/null +++ b/libygen/source/generator.cpp @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "generator.hpp" + +#include + +#include "state_machine_model.hpp" + +#include "config.hpp" +#include "json_reader.hpp" +#include "recipe_callback_impl.hpp" +#include "recipe.hpp" + + +namespace sxy +{ + + +void generate( const sxy::config& _config ) +{ + sxy::json_reader json_reader_( _config.model_file ); + sxy::model::state_machine_model_ptr mymodel = json_reader_.get_model_ptr(); + const std::string template_path = _config.template_path; + + sxy::recipe_callback_impl cb( *mymodel, _config.namespaces, _config.behavior_classes, + _config.state_machine_name, sxy::get_state_machine_class_as_string( _config.sm_type ) ); + + std::cout << "generating header file from the template '" << _config.header_template_file << "'..." << std::endl; + sx::genesis::recipe header_recipe( _config.header_template_file, cb, template_path ); + header_recipe.generate(); + header_recipe.write_to_file( _config.header_output_file ); + std::cout << "Header file generated into file '" << _config.header_output_file << "'." << std::endl; + + std::cout << "generating source file from the template '" << _config.source_template_file << "'..." << std::endl; + sx::genesis::recipe source_recipe( _config.source_template_file, cb, template_path ); + source_recipe.generate(); + source_recipe.write_to_file( _config.source_output_file ); + std::cout << "Source file generated into file '" << _config.source_output_file << "'." << std::endl; +} + + +} diff --git a/libygen/source/generator_grammar.cpp b/libygen/source/generator_grammar.cpp new file mode 100644 index 0000000..01c750b --- /dev/null +++ b/libygen/source/generator_grammar.cpp @@ -0,0 +1,94 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "generator_grammar.hpp" + + +namespace sxy +{ + + +const std::string VARIABLE_STATE_MACHINE_NAME_CAPS = "state_machine_name_caps"; +const std::string VARIABLE_STATE_MACHINE_NAME = "state_machine_name"; +const std::string VARIABLE_STATE_MACHINE_TYPE = "state_machine_type"; +const std::string VARIABLE_NAMESPACE_NAME = "namespace_name"; +const std::string LOOP_NAMESPACE_OPEN = "namespace_open"; +const std::string VARIABLE_NAMESPACE_CLOSE = "namespace_close"; +const std::string VARIABLE_BEHAVIOR_CLASS_NAME = "behavior_class_name"; +const std::string LOOP_BEHAVIOR_CLASSES = "behavior_classes"; +const std::string VARIABLE_LAST_BEHAVIOR_CLASS = "last_behavior_class"; +const std::string LOOP_TRANSITIONS = "transitions"; +const std::string VARIABLE_EVENT_ID = "event_id"; +const std::string VARIABLE_EVENT_NAME = "event_name"; +const std::string VARIABLE_EVENT_PRIORITY = "priority"; +const std::string TRANSITION_EVENT_ID = "transition_event_id"; +const std::string VARIABLE_SOURCE_VERTEX = "source_vertex"; +const std::string VARIABLE_TARGET_VERTEX = "target_vertex"; +const std::string VARIABLE_TRANSITION_KIND = "transition_kind"; +const std::string VARIABLE_TRANSITION_KIND_NAMESPACE = "sxy::transition_kind::"; +const std::string VARIABLE_EMPTY_BEHAVIOR = "Y_EMPTY_BEHAVIOR"; +const std::string VARIABLE_EMPTY_GUARD = "Y_EMPTY_GUARD"; +const std::string LOOP_REGIONS = "regions"; +const std::string VARIABLE_VERTICES = "vertices"; +const std::string LOOP_PSEUDOSTATES = "pseudostates"; +const std::string LOOP_STATE_PSEUDOSTATES = "state_pseudostates"; +const std::string LOOP_STATES = "states"; +const std::string VARIABLE_REGION_NAME = "region_name"; +const std::string VARIABLE_ROOT_NAME = "root_name"; +const std::string VARIABLE_CURRENT_STATE_NAME = "current_state_name"; +const std::string VARIABLE_DATE_TIME = "datetime"; +const unsigned int YEAR_1900( 1900 ); +const unsigned int WIDTH_YEAR( 4 ); +const unsigned int WIDTH_CLOCK( 2 ); +const char FILL_VALUE( '0' ); +const char SLASH_CHAR = '/'; +const char COLON_CHAR = ':'; +const std::string DOUBLE_COLON = "::"; +const char OPEN_BRACE_CHAR = '{'; +const char CLOSE_BRACE_CHAR = '}'; +const char COMMA_CHAR = ','; +const char AND_CHAR = '&'; +const char DOT_CHAR = '.'; +const char UNDERSCORE_CHAR = '_'; +const std::string VARIABLE_COMPLETION_EVENT_ID = "sxy::Y_COMPLETION_EVENT_ID"; +const std::string CONDITION_IS_COMPOSITE_STATE = "is_composite_state"; +const std::string CONDITION_IS_STATE = "is_state"; +const std::string LOOP_EVENTS = "events"; +const std::string VARIABLE_STATE_NAME = "state_name"; +const std::string VARIABLE_STATE_TYPE = "state_type"; +const std::string VARIABLE_PSEUDOSTATE_NAME = "pseudostate_name"; +const std::string VARIABLE_PSEUDOSTATE_TYPE = "pseudostate_type"; +const std::string VARIABLE_STATE_PSEUDOSTATE_NAME = "state_pseudostate_name"; +const std::string VARIABLE_STATE_PSEUDOSTATE_TYPE = "state_pseudostate_type"; +const std::string SWITCH_ENTER_BEHAVIOR = "enter_behavior"; +const std::string SWITCH_DO_BEHAVIOR = "do_behavior"; +const std::string SWITCH_EXIT_BEHAVIOR = "exit_behavior"; +const std::string SWITCH_TRANSITION_GUARD = "transition_guard"; +const std::string SWITCH_TRANSITION_BEHAVIOR = "transition_behavior"; +const std::string THIS_ACCESS = "this->"; +const std::string POINTER_ACCESS = "->"; +const std::string REFERENCE_ACCESS = "."; +const std::string VARIABLE_GUARD_FUNCTION2 = "Y_GUARD_FUNCTION2"; +const std::string VARIABLE_GUARD_METHOD2 = "Y_GUARD_METHOD2"; +const std::string VARIABLE_BEHAVIOR_FUNCTION2 = "Y_BEHAVIOR_FUNCTION2"; +const std::string VARIABLE_BEHAVIOR_METHOD2 = "Y_BEHAVIOR_METHOD2"; +const std::string VARIABLE_METHOD_NAME = "behavior_method_name"; +const std::string VARIABLE_CLASS_INSTANCE_NAME = "class_instance_name"; +const std::string VARIABLE_SM_SYNC = "sync"; +const std::string VARIABLE_SM_ASYNC = "async"; +const std::string VARIABLE_SYNC_SM_CLASS = "sxy::sync_state_machine"; +const std::string VARIABLE_ASYNC_SM_CLASS = "sxy::async_state_machine"; +const char VARIABLE_CLOSE_PARENTHESIS = ')'; +const char VARIABLE_OPEN_PARENTHESIS = '('; +const std::string CONDITION_LAST_PSEUDOSTATE = "last_pseudostate"; +const int SWITCH_DEFAULT_INDEX = -1; + + +} diff --git a/libygen/source/libygen_version.cpp b/libygen/source/libygen_version.cpp new file mode 100644 index 0000000..0daa832 --- /dev/null +++ b/libygen/source/libygen_version.cpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "libygen_version.hpp" + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/sxprintf.hpp" + +#include "libygen_build_number.hpp" + + +namespace sxy +{ + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 0 ); +const sxe::uint16_t VERSION_MINOR( 1 ); +const sxe::uint16_t VERSION_PATCH( 0 ); + + +} + + +void log_version() +{ + std::cout << sxe::sxprintf( "libygen library version %.%.%.%.", get_major_version(), + get_minor_version(), get_patch_version(), get_build_number() ) << std::endl; +} + + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( BUILD_NUMBER ); +} + + +} + + +} diff --git a/libygen/source/recipe_callback_impl.cpp b/libygen/source/recipe_callback_impl.cpp new file mode 100644 index 0000000..648b21f --- /dev/null +++ b/libygen/source/recipe_callback_impl.cpp @@ -0,0 +1,764 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "recipe_callback_impl.hpp" + +#include +#include +#include + +#include "essentials/base.hpp" +#include "generator_grammar.hpp" +#include "essentials/exception.hpp" +#include "event_model_id.hpp" +#include "essentials/conversion.hpp" +#include "state_machine_model.hpp" +#include "composite_state_model_impl.hpp" +#include "region_model.hpp" +#include "state_model_impl.hpp" +#include "pseudostate_model.hpp" + + +namespace sxy +{ + + +recipe_callback_impl::recipe_callback_impl( const sxy::model::state_machine_model& _state_machine_model, + std::vector _namespaces, std::vector _behavior_classes, + std::string _state_machine_name, std::string _state_machine_type ) + : recipe_callback(), + state_machine_model_( _state_machine_model ), + map_of_values_(), + namespaces_( _namespaces ), + behavior_classes_( _behavior_classes ), + namespace_index_( 0 ), + base_class_index_( 0 ), + behavior_classes_index_( 0 ), + transition_index_( 0 ), + pseudostate_index_( 0 ), + state_pseudostate_index_( 0 ), + composite_states_stack_(), + regions_stack_(), + composite_states_index_stack_(), + regions_index_stack_(), + event_index_( 0 ), + entry_behavior_(), + do_behavior_(), + exit_behavior_(), + transition_guard_(), + active_switch_() +{ + const std::string state_machine_name_caps = sxe::to_upper( _state_machine_name ); + map_of_values_.insert( std::make_pair( VARIABLE_STATE_MACHINE_NAME_CAPS, state_machine_name_caps ) ); + map_of_values_.insert( std::make_pair( VARIABLE_STATE_MACHINE_NAME, _state_machine_name ) ); + map_of_values_.insert( std::make_pair( VARIABLE_STATE_MACHINE_TYPE, _state_machine_type ) ); +} + + +recipe_callback_impl::~recipe_callback_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +std::string recipe_callback_impl::get_variable_content( const std::string& _variable_name ) +{ + std::string result( "" ); + if( _variable_name == VARIABLE_NAMESPACE_NAME ) + { + result = namespaces_[namespace_index_]; + } + else if( _variable_name == VARIABLE_BEHAVIOR_CLASS_NAME ) + { + result = behavior_classes_[behavior_classes_index_]; + } + else if( _variable_name == VARIABLE_STATE_MACHINE_NAME_CAPS + || _variable_name == VARIABLE_STATE_MACHINE_NAME || _variable_name == VARIABLE_STATE_MACHINE_TYPE ) + { + result = map_of_values_[_variable_name]; + } + else if( _variable_name == VARIABLE_DATE_TIME ) + { + result = get_date_time_string(); + } + else if( _variable_name == TRANSITION_EVENT_ID ) + { + result = get_transition_events(); + } + else if( _variable_name == VARIABLE_EVENT_ID || _variable_name == VARIABLE_EVENT_NAME ) + { + result = get_event_property( _variable_name ); + } + else if( _variable_name == VARIABLE_SOURCE_VERTEX ) + { + const sxy::model::transition_model* trans = state_machine_model_.get_transitions().at( transition_index_ ); + sxe::uri uri_of_source = trans->get_source(); + result = uri_of_source.get_back(); + } + else if( _variable_name == VARIABLE_TARGET_VERTEX ) + { + const sxy::model::transition_model* trans = state_machine_model_.get_transitions().at( transition_index_ ); + sxe::uri uri_of_target = trans->get_target(); + result = uri_of_target.get_back(); + } + else if( _variable_name == VARIABLE_TRANSITION_KIND ) + { + const sxy::model::transition_model* trans = state_machine_model_.get_transitions().at( transition_index_ ); + result = VARIABLE_TRANSITION_KIND_NAMESPACE + to_string( trans->get_kind() ); + } + else if( _variable_name == VARIABLE_REGION_NAME ) + { + SX_ASSERT( regions_stack_.top(), "There is no region to get the name!" ); + result = regions_stack_.top()->get_name(); + } + else if( _variable_name == VARIABLE_ROOT_NAME ) + { + result = state_machine_model_.get_root_state().get_name(); + } + else if( _variable_name == VARIABLE_CURRENT_STATE_NAME ) + { + SX_ASSERT( composite_states_stack_.top(), "There is no composite state to get the name!" ); + result = composite_states_stack_.top()->get_name(); + } + else if( _variable_name == VARIABLE_STATE_TYPE || _variable_name == VARIABLE_STATE_NAME ) + { + result = get_state_property( _variable_name ); + } + else if( _variable_name == VARIABLE_PSEUDOSTATE_TYPE || _variable_name == VARIABLE_PSEUDOSTATE_NAME ) + { + result = get_pseudostate_property( _variable_name ); + } + else if( _variable_name == VARIABLE_STATE_PSEUDOSTATE_NAME || _variable_name == VARIABLE_STATE_PSEUDOSTATE_TYPE ) + { + result = get_state_pseudostate_property( _variable_name ); + } + else if( _variable_name == VARIABLE_METHOD_NAME ) + { + if( active_switch_ == SWITCH_TRANSITION_BEHAVIOR ) + { + result = do_behavior_.behavior_method_name; + } + else if( active_switch_ == SWITCH_TRANSITION_GUARD ) + { + result = transition_guard_.behavior_method_name; + } + else if( active_switch_ == SWITCH_DO_BEHAVIOR ) + { + result = do_behavior_.behavior_method_name; + } + else if( active_switch_ == SWITCH_ENTER_BEHAVIOR ) + { + result = entry_behavior_.behavior_method_name; + } + else if( active_switch_ == SWITCH_EXIT_BEHAVIOR ) + { + result = exit_behavior_.behavior_method_name; + } + } + else if(_variable_name == VARIABLE_CLASS_INSTANCE_NAME ) + { + if( active_switch_ == SWITCH_TRANSITION_BEHAVIOR ) + { + result = do_behavior_.behavior_class_name; + } + else if( active_switch_ == SWITCH_TRANSITION_GUARD ) + { + result = transition_guard_.behavior_class_name; + } + else if( active_switch_ == SWITCH_DO_BEHAVIOR ) + { + result = do_behavior_.behavior_class_name; + } + else if( active_switch_ == SWITCH_ENTER_BEHAVIOR ) + { + result = entry_behavior_.behavior_class_name; + } + else if( active_switch_ == SWITCH_EXIT_BEHAVIOR ) + { + result = exit_behavior_.behavior_class_name; + } + } + else + { + throw sxe::exception( "No variable name: '%'!", _variable_name ); + } + return( result ); +} + + +void recipe_callback_impl::before_loop( const std::string& _loop_name ) +{ + if( _loop_name == LOOP_NAMESPACE_OPEN ) + { + namespace_index_ = 0; + } + else if( _loop_name == LOOP_BEHAVIOR_CLASSES ) + { + behavior_classes_index_ = 0; + } + else if( _loop_name == LOOP_TRANSITIONS ) + { + transition_index_ = 0; + } + else if( _loop_name == LOOP_REGIONS ) + { + if( composite_states_stack_.empty() ) + { + composite_states_stack_.push( &state_machine_model_.get_root_state() ); + } + regions_index_stack_.push( 0 ); + } + else if( _loop_name == LOOP_STATES ) + { + composite_states_index_stack_.push( 0 ); + } + else if( _loop_name == LOOP_PSEUDOSTATES ) + { + pseudostate_index_ = 0; + } + else if( _loop_name == LOOP_STATE_PSEUDOSTATES ) + { + state_pseudostate_index_ = 0; + } + else if( _loop_name == LOOP_EVENTS ) + { + event_index_ = 0; + } +} + + +void recipe_callback_impl::before_loop_iteration( const std::string& _loop_name ) +{ + if( _loop_name == LOOP_REGIONS ) + { + regions_stack_.push( composite_states_stack_.top()->get_regions()[regions_index_stack_.top()] ); + } + else if( _loop_name == LOOP_STATES ) + { + composite_states_stack_.push( regions_stack_.top()->get_states()[composite_states_index_stack_.top()] ); + fill_struct( _loop_name ); + } + else if( _loop_name == LOOP_STATE_PSEUDOSTATES ) + { + // Nothing to do... + } + else if( _loop_name == LOOP_PSEUDOSTATES ) + { + // Nothing to do... + } + else if( _loop_name == LOOP_TRANSITIONS ) + { + fill_struct( _loop_name ); + } +} + + +void recipe_callback_impl::after_loop_iteration( const std::string& _loop_name ) +{ + if( _loop_name == LOOP_NAMESPACE_OPEN ) + { + ++namespace_index_; + } + else if( _loop_name == VARIABLE_NAMESPACE_CLOSE ) + { + --namespace_index_; + } + else if( _loop_name == LOOP_BEHAVIOR_CLASSES ) + { + ++behavior_classes_index_; + } + else if( _loop_name == LOOP_TRANSITIONS ) + { + ++transition_index_; + } + else if( _loop_name == LOOP_REGIONS ) + { + ++regions_index_stack_.top(); + regions_stack_.pop(); + } + else if( _loop_name == LOOP_STATES ) + { + ++composite_states_index_stack_.top(); + composite_states_stack_.pop(); + } + else if( _loop_name == LOOP_PSEUDOSTATES ) + { + ++pseudostate_index_; + } + else if( _loop_name == LOOP_STATE_PSEUDOSTATES ) + { + ++state_pseudostate_index_; + } + else if( _loop_name == LOOP_EVENTS ) + { + ++event_index_; + } +} + + +void recipe_callback_impl::after_loop( const std::string& _loop_name ) +{ + if( _loop_name == LOOP_REGIONS ) + { + if( composite_states_stack_.size() == 1 ) + { + composite_states_stack_.pop(); + } + regions_index_stack_.pop(); + } + else if( _loop_name == LOOP_STATES ) + { + composite_states_index_stack_.pop(); + } + else if( _loop_name == LOOP_PSEUDOSTATES ) + { + // Nothing to do... + } + else if( _loop_name == LOOP_STATE_PSEUDOSTATES ) + { + // Nothing to do... + } + else if( _loop_name == LOOP_BEHAVIOR_CLASSES ) + { + // Nothing to do... + } +} + + +bool recipe_callback_impl::check_loop_condition( const std::string& _loop_name ) const +{ + bool result = false; + if( _loop_name == LOOP_NAMESPACE_OPEN ) + { + result = namespace_index_ < namespaces_.size(); + } + else if( _loop_name == VARIABLE_NAMESPACE_CLOSE ) + { + result = namespace_index_ > 0; + } + else if( _loop_name == LOOP_BEHAVIOR_CLASSES ) + { + result = behavior_classes_index_ < behavior_classes_.size(); + } + else if( _loop_name == LOOP_TRANSITIONS ) + { + result = transition_index_ < state_machine_model_.get_transitions().size(); + } + else if( _loop_name == LOOP_REGIONS ) + { + const sxy::model::state_model* state_to_check = composite_states_stack_.top(); + SX_ASSERT( state_to_check, "There is no state in the stack!" ); + result = regions_index_stack_.top() < state_to_check->get_regions().size(); + } + else if( _loop_name == LOOP_STATES ) + { + if( !composite_states_stack_.empty() ) + { + if( !composite_states_stack_.top()->get_regions().empty() ) + { + if( !regions_index_stack_.empty() ) + { + const sxy::model::region_model* region_to_check = composite_states_stack_.top()->get_regions()[regions_index_stack_.top()]; + result = composite_states_index_stack_.top() < region_to_check->get_states().size(); + } + } + } + } + else if( _loop_name == LOOP_PSEUDOSTATES ) + { + const sxy::model::region_model* region_to_check = regions_stack_.top(); + result = pseudostate_index_ < region_to_check->get_pseudostates().size(); + } + else if( _loop_name == LOOP_STATE_PSEUDOSTATES ) + { + if( !composite_states_stack_.empty() ) + { + const sxy::model::composite_state_model* state_to_check = + dynamic_cast< const sxy::model::composite_state_model* >( composite_states_stack_.top() ); + if( state_to_check ) + { + result = state_pseudostate_index_ < state_to_check->get_state_pseudostates().size(); + } + } + } + else if( _loop_name == LOOP_EVENTS ) + { + result = event_index_ < state_machine_model_.get_events().size(); + } + + return( result ); +} + + +bool recipe_callback_impl::check_condition( const std::string& _condition_name ) const +{ + bool result = true; + + if( _condition_name == VARIABLE_LAST_BEHAVIOR_CLASS ) + { + result = behavior_classes_index_ == behavior_classes_.size() - 1; + } + else if( _condition_name == CONDITION_IS_STATE ) + { + if( !composite_states_stack_.empty() ) + { + const sxy::model::state_model* state = composite_states_stack_.top(); + result = state != SX_NULLPTR; + } + else + { + throw sxe::exception( "There is no vertex to check if it is a composite state!" ); + } + } + else if( _condition_name == CONDITION_IS_COMPOSITE_STATE ) + { + if( !composite_states_stack_.empty() ) + { + const sxy::model::composite_state_model* state = + dynamic_cast< const sxy::model::composite_state_model* > ( composite_states_stack_.top() ); + result = state != SX_NULLPTR; + } + else + { + throw sxe::exception( "There is no state to check if it is a composite state!" ); + } + } + else if( _condition_name == CONDITION_LAST_PSEUDOSTATE ) + { + result = pseudostate_index_ == regions_stack_.top()->get_pseudostates().size() - 1; + } + + return( result ); +} + + +void recipe_callback_impl::condition_begin( const std::string& _condition_name ) +{ + if( _condition_name == CONDITION_IS_STATE ) + { + if( composite_states_stack_.empty() ) + { + composite_states_stack_.push( &state_machine_model_.get_root_state() ); + } + } + else if( _condition_name == CONDITION_IS_COMPOSITE_STATE ) + { + // Nothing to do... + } +} + + +void recipe_callback_impl::condition_end( const std::string& _condition_name ) +{ + if( _condition_name == CONDITION_IS_STATE ) + { + if( composite_states_stack_.size() == 1 ) + { + composite_states_stack_.pop(); + } + } + else if( _condition_name == CONDITION_IS_COMPOSITE_STATE ) + { + // Nothing to do... + } +} + + +int recipe_callback_impl::get_switch_case( const std::string& _switch_name ) +{ + behavior_classes_index_ = 0; + active_switch_ = _switch_name; + int index = SWITCH_DEFAULT_INDEX; + if( _switch_name == SWITCH_TRANSITION_BEHAVIOR ) + { + index = get_index( do_behavior_ ); + } + else if( _switch_name == SWITCH_TRANSITION_GUARD ) + { + index = get_index( transition_guard_ ); + } + else if( _switch_name == SWITCH_ENTER_BEHAVIOR ) + { + index = get_index( entry_behavior_ ); + } + else if( _switch_name == SWITCH_DO_BEHAVIOR ) + { + index = get_index( do_behavior_ ); + } + else if( _switch_name == SWITCH_EXIT_BEHAVIOR ) + { + index = get_index( exit_behavior_ ); + } + return( index ); +} + + +std::string recipe_callback_impl::get_state_property( const std::string& _property ) const +{ + std::string result( "" ); + const sxy::model::region_model* region_to_check = regions_stack_.top(); + const sxy::model::state_model* state = region_to_check->get_states()[composite_states_index_stack_.top()]; + if( composite_states_index_stack_.top() < region_to_check->get_states().size() ) + { + if( _property == VARIABLE_STATE_NAME ) + { + result = state->get_name(); + } + else if( _property == VARIABLE_STATE_TYPE ) + { + result = model_element_type_to_string( state->get_type() ); + } + else + { + throw sxe::exception( "Wrong command!" ); + } + } + else + { + throw sxe::exception( "No state to get name/type!" ); + } + + return( result ); +} + + +std::string recipe_callback_impl::get_pseudostate_property( const std::string& _property ) const +{ + std::string result( "" ); + const sxy::model::region_model* region_to_check = regions_stack_.top(); + const sxy::model::pseudostate_model* pseudostate = region_to_check->get_pseudostates()[pseudostate_index_]; + if( pseudostate_index_ < region_to_check->get_pseudostates().size() ) + { + if( _property == VARIABLE_PSEUDOSTATE_NAME ) + { + result = pseudostate->get_name(); + } + else if( _property == VARIABLE_PSEUDOSTATE_TYPE ) + { + result = model_element_type_to_string( pseudostate->get_type() ); + } + else + { + throw sxe::exception( "Wrong command!" ); + } + } + else + { + throw sxe::exception( "No pseudostate to get name/type!" ); + } + + return( result ); +} + + +std::string recipe_callback_impl::get_state_pseudostate_property( const std::string& _property ) const +{ + std::string result( "" ); + const sxy::model::composite_state_model* state = dynamic_cast< const sxy::model::composite_state_model* >( composite_states_stack_.top() ); + if( state ) + { + const sxy::model::pseudostate_model* state_pseudostate = state->get_state_pseudostates()[state_pseudostate_index_]; + if( _property == VARIABLE_STATE_PSEUDOSTATE_NAME ) + { + result = state_pseudostate->get_name(); + } + else if( _property == VARIABLE_STATE_PSEUDOSTATE_TYPE ) + { + result = model_element_type_to_string( state_pseudostate->get_type() ); + } + else + { + throw sxe::exception( "Wrong command!" ); + } + } + + return( result ); +} + + +std::string recipe_callback_impl::get_event_property( const std::string& _property ) const +{ + std::string result( "" ); + if( event_index_ < state_machine_model_.get_events().size() ) + { + sxy::model::event_model& event = state_machine_model_.get_events()[event_index_]; + if( _property == VARIABLE_EVENT_ID ) + { + result = sxe::to_string( event.id ); + } + else if( _property == VARIABLE_EVENT_NAME ) + { + result = event.name; + } + else if( _property == VARIABLE_EVENT_PRIORITY ) + { + result = sxe::to_string( event.priority ); + } + else + { + throw sxe::exception( "Wrong command!" ); + } + } + else + { + throw sxe::exception( "Event index out of range!" ); + } + + return( result ); +} + + +std::string recipe_callback_impl::get_date_time_string() const +{ + std::stringstream date_time_stream; + time_t rawtime; + time( &rawtime ); + tm timeinfo = *localtime( &rawtime ); + date_time_stream << std::setfill( FILL_VALUE ) << std::setw( WIDTH_YEAR ) << ( YEAR_1900 + timeinfo.tm_year ) << + SLASH_CHAR << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << ++timeinfo.tm_mon << SLASH_CHAR << std::setfill( + FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_mday << " " << std::setfill( FILL_VALUE ) << + std::setw( WIDTH_CLOCK ) << timeinfo.tm_hour << COLON_CHAR << std::setfill( FILL_VALUE ) << + std::setw( WIDTH_CLOCK ) << timeinfo.tm_min << COLON_CHAR << std::setfill( FILL_VALUE ) << + std::setw( WIDTH_CLOCK ) << timeinfo.tm_sec; + return( date_time_stream.str() ); +} + + +std::string recipe_callback_impl::get_transition_events() const +{ + std::string result( "" ); + if( state_machine_model_.get_transitions().size() > 0 ) + { + const sxy::model::transition_model* trans = state_machine_model_.get_transitions().at( transition_index_ ); + sxy::model::event_id id = 0; + if( !trans->get_event_ids().empty() ) + { + result = OPEN_BRACE_CHAR; + for( std::size_t i = 0; i < trans->get_event_ids().size(); ++i ) + { + id = trans->get_event_ids()[i]; + if( id == sxy::model::Y_MODEL_COMPLETION_EVENT_ID ) + { + result += VARIABLE_COMPLETION_EVENT_ID; + } + else + { + result += sxe::to_string( id ); + } + result += COMMA_CHAR; + result += " "; + } + result.erase( result.length() - 2, 2 ); + result += CLOSE_BRACE_CHAR; + } + else + { + result = VARIABLE_COMPLETION_EVENT_ID; + } + } + + return( result ); +} + + +void recipe_callback_impl::fill_struct( const std::string& _loop_name ) +{ + if( _loop_name == LOOP_TRANSITIONS ) + { + const sxy::model::transition_model* trans = state_machine_model_.get_transitions().at( transition_index_ ); + fill_one_behavior_struct( do_behavior_, trans->get_behavior() ); + fill_one_behavior_struct( transition_guard_, trans->get_guard() ); + } + else if( _loop_name == LOOP_STATES ) + { + const model::state_model* state = composite_states_stack_.top(); + fill_one_behavior_struct( entry_behavior_, state->get_enter_behavior() ); + fill_one_behavior_struct( do_behavior_, state->get_do_behavior() ); + fill_one_behavior_struct( exit_behavior_, state->get_exit_behavior() ); + } +} + + +void recipe_callback_impl::fill_one_behavior_struct( behavior_struct& _behavior, const std::string& _behavior_string ) +{ + if( _behavior_string.empty() ) + { + // Nothing to do... + _behavior.call_operator = access_operator::AO_NO_ACCESS_OPERATOR; + _behavior.behavior_class_name = ""; + _behavior.behavior_method_name = ""; + } + else if( _behavior_string.find( THIS_ACCESS ) != std::string::npos ) + { + // this->foo + _behavior.call_operator = access_operator::AO_THIS_ACCESS; + _behavior.behavior_class_name = behavior_classes_[0]; + _behavior.behavior_method_name = _behavior_string.substr( _behavior_string.find( THIS_ACCESS ) + THIS_ACCESS.length(), _behavior_string.length() - _behavior_string.find( THIS_ACCESS ) - THIS_ACCESS.length() ); + } + else if( _behavior_string.find( POINTER_ACCESS ) != std::string::npos ) + { + // bar->foo + _behavior.call_operator = access_operator::AO_POINTER_ACCESS; + _behavior.behavior_class_name = _behavior_string.substr( 0, _behavior_string.find( POINTER_ACCESS ) ); + _behavior.behavior_method_name = _behavior_string.substr( _behavior_string.find( POINTER_ACCESS ) + 2, _behavior_string.length() - _behavior_string.find( POINTER_ACCESS ) - 2 ); + } + else if( _behavior_string.find( REFERENCE_ACCESS ) != std::string::npos ) + { + // bar.foo + _behavior.call_operator = access_operator::AO_REFERENCE_ACCESS; + _behavior.behavior_class_name = _behavior_string.substr( 0, _behavior_string.find( DOT_CHAR ) ); + _behavior.behavior_method_name = _behavior_string.substr( _behavior_string.find( DOT_CHAR ) + 1, _behavior_string.length() - _behavior_string.find( DOT_CHAR ) - 1 ); + } + else + { + // bar::foo + _behavior.call_operator = access_operator::AO_FUNCTION_ACCESS; + _behavior.behavior_class_name = ""; + _behavior.behavior_method_name = _behavior_string; + } +} + + +int recipe_callback_impl::get_index( const behavior_struct& _behavior_struct ) +{ + int index = SWITCH_DEFAULT_INDEX; + + switch( _behavior_struct.call_operator ) + { + case access_operator::AO_THIS_ACCESS: + { + index = 0; + break; + } + case access_operator::AO_POINTER_ACCESS: + { + index = 1; + break; + } + case access_operator::AO_REFERENCE_ACCESS: + { + index = 2; + break; + } + case access_operator::AO_FUNCTION_ACCESS: + { + index = 3; + break; + } + default: + break; + } + + return( index ); +} + + +} diff --git a/libygen/source/state_machine_type.cpp b/libygen/source/state_machine_type.cpp new file mode 100644 index 0000000..fa6c47d --- /dev/null +++ b/libygen/source/state_machine_type.cpp @@ -0,0 +1,111 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "state_machine_type.hpp" + +#include + +#include "essentials/exception.hpp" +#include "essentials/conversion.hpp" + +#include "generator_grammar.hpp" + + +namespace sxy +{ + + +// cppcheck-suppress unusedFunction +state_machine_type sm_type_from_string( const std::string& _type ) +{ + state_machine_type type( state_machine_type::SMT_SYNC ); + const std::string string_type = sxe::to_lower( _type ); + + if( string_type == VARIABLE_SM_SYNC ) + { + type = state_machine_type::SMT_SYNC; + } + else if( string_type == VARIABLE_SM_ASYNC ) + { + type = state_machine_type::SMT_ASYNC; + } + else + { + throw sxe::exception( "State machine type is '%' and it should be '%' or '%'", string_type, VARIABLE_SM_SYNC, + VARIABLE_SM_ASYNC ); + } + + return( type ); +} + + +const std::string sm_type_to_string( const state_machine_type& _type ) +{ + std::string type( "" ); + if( _type == state_machine_type::SMT_SYNC ) + { + type = VARIABLE_SM_SYNC; + } + else if( _type == state_machine_type::SMT_ASYNC ) + { + type = VARIABLE_SM_ASYNC; + } + else + { + throw sxe::exception( "Unknown state machine type!" ); + } + + return ( type ); +} + + +const std::string get_state_machine_class_as_string( const state_machine_type& _type ) +{ + std::string type( "" ); + if( _type == state_machine_type::SMT_SYNC ) + { + type = VARIABLE_SYNC_SM_CLASS; + } + else if( _type == state_machine_type::SMT_ASYNC ) + { + type = VARIABLE_ASYNC_SM_CLASS; + } + else + { + throw sxe::exception( "Unknown state machine type!" ); + } + + return ( type ); +} + + +// cppcheck-suppress unusedFunction +std::istream& operator>>( std::istream& _in_stream, sxy::state_machine_type& _sm_type ) +{ + std::string token; + _in_stream >> token; + if( token == VARIABLE_SM_SYNC ) + { + _sm_type = sxy::state_machine_type::SMT_SYNC; + } + else if( token == VARIABLE_SM_ASYNC ) + { + _sm_type = sxy::state_machine_type::SMT_ASYNC; + } + else + { + _in_stream.setstate( std::ios_base::failbit ); + } + + return(_in_stream); +} + + +} diff --git a/license/Anhang_Appendix_20170406.pdf b/license/Anhang_Appendix_20170406.pdf index 680e667..431ac0d 100644 Binary files a/license/Anhang_Appendix_20170406.pdf and b/license/Anhang_Appendix_20170406.pdf differ diff --git a/license/boost/LICENSE_1_0.txt b/license/boost/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/license/boost/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/license/license.txt b/license/license.txt index 1a7ef01..ee48940 100644 --- a/license/license.txt +++ b/license/license.txt @@ -1,9 +1,9 @@ -Dieses Verzeichnis enthält die folgenden Lizenzdokumente: -This directory contains the following license documents: -- Kommerzielle Lizenz/commercial license - - Deutsch (German): Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf - - English: Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf -- Private und wissenschaftliche Lizenz/private and academic license - - Deutsch (German): Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf - - English: Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf +Dieses Verzeichnis enthält die folgenden Lizenzdokumente: +This directory contains the following license documents: +- Kommerzielle Lizenz/commercial license + - Deutsch (German): Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf + - English: Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf +- Private und wissenschaftliche Lizenz/private and academic license + - Deutsch (German): Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf + - English: Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf - Deutsch und English (German and English): Anhang_Appendix_20170406.pdf \ No newline at end of file diff --git a/license/rapidjson/license.txt b/license/rapidjson/license.txt new file mode 100644 index 0000000..7ccc161 --- /dev/null +++ b/license/rapidjson/license.txt @@ -0,0 +1,57 @@ +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License. +If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license. +A copy of the MIT License is included in this file. + +Other dependencies and licenses: + +Open Source Software Licensed Under the BSD License: +-------------------------------------------------------------------- + +The msinttypes r29 +Copyright (c) 2006-2013 Alexander Chemeris +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Open Source Software Licensed Under the JSON License: +-------------------------------------------------------------------- + +json.org +Copyright (c) 2002 JSON.org +All Rights Reserved. + +JSON_checker +Copyright (c) 2002 JSON.org +All Rights Reserved. + + +Terms of the JSON License: +--------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Terms of the MIT License: +-------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..1febba0 --- /dev/null +++ b/version.txt @@ -0,0 +1,12 @@ +Versions + +• yasmine 1.2.0 released 2017-04-25 + • libyasmine 1.1.2 + • essentials 1.2.0 + • hermes 1.0.1 + • genesis 0.2.0 + • yasmine_model 0.1.0 + • libygen 0.1.0 + • ygen 0.1.0 + + \ No newline at end of file diff --git a/yasmine.sln b/yasmine.sln index 380e2a0..8f641a5 100644 --- a/yasmine.sln +++ b/yasmine.sln @@ -1,272 +1,540 @@ - -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}") = "licenses", "licenses", "{FBC833F8-033B-4400-8CBA-C71A32CF62B4}" - ProjectSection(SolutionItems) = preProject - license\license.txt = license\license.txt - 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 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "event_collector_example", "examples\event_collector_example\event_collector_example.vcxproj", "{B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}" - ProjectSection(ProjectDependencies) = postProject - {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "essentials", "essentials", "{9DE9E971-362C-4A08-91D5-56ABA346AC1C}" - ProjectSection(SolutionItems) = preProject - externals\essentials\license\essentials_Anhang_Appendix_20170406.pdf = externals\essentials\license\essentials_Anhang_Appendix_20170406.pdf - externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf - externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf - externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf - externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hermes", "hermes", "{47973C26-88C1-4C07-8B31-6D448D7BD387}" - ProjectSection(SolutionItems) = preProject - externals\hermes\license\hermes_Anhang_Appendix_20170406.pdf = externals\hermes\license\hermes_Anhang_Appendix_20170406.pdf - externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf - externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf - externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf - externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "yasmine", "yasmine", "{790287FF-8ECB-440C-8D3D-343AF0951E7B}" - ProjectSection(SolutionItems) = preProject - license\Anhang_Appendix_20170406.pdf = license\Anhang_Appendix_20170406.pdf - license\license.txt = license\license.txt - license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf - license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf - license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf - license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf - 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 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|Win32.ActiveCfg = Debug|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|Win32.Build.0 = Debug|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|x64.ActiveCfg = Debug|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|x64.Build.0 = Debug|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|Win32.ActiveCfg = Debug|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|Win32.Build.0 = Debug|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|x64.ActiveCfg = Debug|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|x64.Build.0 = Debug|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|Win32.ActiveCfg = Debug|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|Win32.Build.0 = Debug|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|x64.ActiveCfg = Debug|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|x64.Build.0 = Debug|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|Win32.ActiveCfg = Release|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|Win32.Build.0 = Release|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|x64.ActiveCfg = Release|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|x64.Build.0 = Release|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|Win32.ActiveCfg = Release|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|Win32.Build.0 = Release|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|x64.ActiveCfg = Release|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|x64.Build.0 = Release|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|Win32.ActiveCfg = Release|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|Win32.Build.0 = Release|Win32 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|x64.ActiveCfg = Release|x64 - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.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} - {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} - {9DE9E971-362C-4A08-91D5-56ABA346AC1C} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} - {47973C26-88C1-4C07-8B31-6D448D7BD387} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} - {790287FF-8ECB-440C-8D3D-343AF0951E7B} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} - 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}") = "licenses", "licenses", "{FBC833F8-033B-4400-8CBA-C71A32CF62B4}" +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 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "event_collector_example", "examples\event_collector_example\event_collector_example.vcxproj", "{B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "essentials", "essentials", "{9DE9E971-362C-4A08-91D5-56ABA346AC1C}" + ProjectSection(SolutionItems) = preProject + externals\essentials\license\essentials_Anhang_Appendix_20170406.pdf = externals\essentials\license\essentials_Anhang_Appendix_20170406.pdf + externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf + externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf + externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf + externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = externals\essentials\license\essentials_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hermes", "hermes", "{47973C26-88C1-4C07-8B31-6D448D7BD387}" + ProjectSection(SolutionItems) = preProject + externals\hermes\license\hermes_Anhang_Appendix_20170406.pdf = externals\hermes\license\hermes_Anhang_Appendix_20170406.pdf + externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf + externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf + externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf + externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = externals\hermes\license\hermes_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "yasmine", "yasmine", "{790287FF-8ECB-440C-8D3D-343AF0951E7B}" + ProjectSection(SolutionItems) = preProject + license\Anhang_Appendix_20170406.pdf = license\Anhang_Appendix_20170406.pdf + license\license.txt = license\license.txt + license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf + license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = license\Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf + license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf + license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = license\Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "code generator", "code generator", "{AF9A9587-13D2-4D16-9C3A-AB3061E3FEF3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core library", "core library", "{ABDBC512-39DD-4625-A015-C23AA0690AD1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "model", "model", "{68F3A738-05B2-48AE-AF75-B8E9FE63660E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yasmine_model", "yasmine_model\yasmine_model.vcxproj", "{2069AE83-AE26-484A-A6E7-E872E0045020}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genesis", "genesis\genesis.vcxproj", "{466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libygen", "libygen\libygen.vcxproj", "{CED23388-105D-46FA-9EC3-AD923C209AED}" + ProjectSection(ProjectDependencies) = postProject + {2069AE83-AE26-484A-A6E7-E872E0045020} = {2069AE83-AE26-484A-A6E7-E872E0045020} + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357} = {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ygen", "ygen\ygen.vcxproj", "{E70CC0C5-256B-41E2-A852-B1904C2D84D3}" + ProjectSection(ProjectDependencies) = postProject + {CED23388-105D-46FA-9EC3-AD923C209AED} = {CED23388-105D-46FA-9EC3-AD923C209AED} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B883C29E-485C-4C8F-ACB1-A1602378BF5C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "generator_example", "examples\generator_example\generator_example.vcxproj", "{CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}" + ProjectSection(ProjectDependencies) = postProject + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {A728DDFB-BE51-49B5-8593-4E89E024A500} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "genesis", "genesis", "{A23DCF32-F7CB-450B-B4A0-59AD7BACFDD4}" + ProjectSection(SolutionItems) = preProject + genesis\license\genesis_Anhang_Appendix_20170406.pdf = genesis\license\genesis_Anhang_Appendix_20170406.pdf + genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf = genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406.pdf + genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf = genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_geschaeftliche_Nutzung_Fassung_20170406_en.pdf + genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf = genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406.pdf + genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf = genesis\license\genesis_Lizenz_und_Nutzungsbedingungen_private_und wissenschaftliche_Nutzung_Fassung_20170406_en.pdf + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "version", "version", "{520EB861-9C31-49DB-B60A-0F5618BBAB53}" + ProjectSection(SolutionItems) = preProject + version.txt = version.txt + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug - C++ 03|Win32 = Debug - C++ 03|Win32 + Debug - C++ 03|x64 = Debug - C++ 03|x64 + Debug - Clang|Win32 = Debug - Clang|Win32 + Debug - Clang|x64 = Debug - Clang|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 - Clang|Win32 = Release - Clang|Win32 + Release - Clang|x64 = Release - Clang|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 - Clang|Win32.ActiveCfg = Debug - Clang|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - Clang|Win32.Build.0 = Debug - Clang|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - Clang|x64.ActiveCfg = Debug - Clang|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Debug - Clang|x64.Build.0 = Debug - Clang|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 - Clang|Win32.ActiveCfg = Release - Clang|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - Clang|Win32.Build.0 = Release - Clang|Win32 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - Clang|x64.ActiveCfg = Release - Clang|x64 + {A728DDFB-BE51-49B5-8593-4E89E024A500}.Release - Clang|x64.Build.0 = Release - Clang|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 - Clang|Win32.ActiveCfg = Debug - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - Clang|Win32.Build.0 = Debug - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - Clang|x64.ActiveCfg = Debug - C++ 03|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Debug - Clang|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 - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {C231C585-F237-4F08-8BF5-8DC7106599D4}.Release - Clang|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 - Clang|Win32.ActiveCfg = Debug - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - Clang|Win32.Build.0 = Debug - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - Clang|x64.ActiveCfg = Debug - C++ 03|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Debug - Clang|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 - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {DDCFB59A-D19C-4382-ACFD-747105EB8D03}.Release - Clang|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 - Clang|Win32.ActiveCfg = Debug - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - Clang|Win32.Build.0 = Debug - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - Clang|x64.ActiveCfg = Debug - C++ 03|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Debug - Clang|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 - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {5FA6552A-6FFB-44DE-BEBA-49FD1F1701EA}.Release - Clang|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 - Clang|Win32.ActiveCfg = Debug - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug - Clang|Win32.Build.0 = Debug - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Debug - Clang|x64.ActiveCfg = Debug - C++ 03|x64 + {44767840-E79D-4049-B97B-867D32783090}.Debug - Clang|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 - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {44767840-E79D-4049-B97B-867D32783090}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {44767840-E79D-4049-B97B-867D32783090}.Release - Clang|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 - Clang|Win32.ActiveCfg = Debug - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - Clang|Win32.Build.0 = Debug - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - Clang|x64.ActiveCfg = Debug - C++ 03|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Debug - Clang|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 - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {E27E791D-29D2-4FAA-A683-D58228818F67}.Release - Clang|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 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - Clang|Win32.ActiveCfg = Debug - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - Clang|Win32.Build.0 = Debug - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - Clang|x64.ActiveCfg = Debug - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - Clang|x64.Build.0 = Debug - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|Win32.ActiveCfg = Debug|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|Win32.Build.0 = Debug|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|x64.ActiveCfg = Debug|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug - VS 2013|x64.Build.0 = Debug|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|Win32.ActiveCfg = Debug|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|Win32.Build.0 = Debug|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|x64.ActiveCfg = Debug|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Debug|x64.Build.0 = Debug|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - Clang|x64.Build.0 = Release - C++ 03|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|Win32.ActiveCfg = Release|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|Win32.Build.0 = Release|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|x64.ActiveCfg = Release|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release - VS 2013|x64.Build.0 = Release|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|Win32.ActiveCfg = Release|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|Win32.Build.0 = Release|Win32 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|x64.ActiveCfg = Release|x64 + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E}.Release|x64.Build.0 = Release|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - Clang|Win32.ActiveCfg = Debug - Clang|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - Clang|Win32.Build.0 = Debug - Clang|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - Clang|x64.ActiveCfg = Debug - Clang|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - Clang|x64.Build.0 = Debug - Clang|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - VS 2013|Win32.ActiveCfg = Debug - VS 2013|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - VS 2013|Win32.Build.0 = Debug - VS 2013|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - VS 2013|x64.ActiveCfg = Debug - VS 2013|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug - VS 2013|x64.Build.0 = Debug - VS 2013|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug|Win32.ActiveCfg = Debug|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug|Win32.Build.0 = Debug|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug|x64.ActiveCfg = Debug|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Debug|x64.Build.0 = Debug|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - Clang|Win32.ActiveCfg = Release - C++ 03|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - Clang|Win32.Build.0 = Release - C++ 03|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - Clang|x64.ActiveCfg = Release - C++ 03|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - Clang|x64.Build.0 = Release - C++ 03|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - VS 2013|Win32.ActiveCfg = Release - VS 2013|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - VS 2013|Win32.Build.0 = Release - VS 2013|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - VS 2013|x64.ActiveCfg = Release - VS 2013|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release - VS 2013|x64.Build.0 = Release - VS 2013|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release|Win32.ActiveCfg = Release|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release|Win32.Build.0 = Release|Win32 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release|x64.ActiveCfg = Release|x64 + {2069AE83-AE26-484A-A6E7-E872E0045020}.Release|x64.Build.0 = Release|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - Clang|Win32.ActiveCfg = Debug|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - Clang|Win32.Build.0 = Debug|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - Clang|x64.ActiveCfg = Debug|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - Clang|x64.Build.0 = Debug|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - VS 2013|Win32.ActiveCfg = Debug|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - VS 2013|Win32.Build.0 = Debug|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - VS 2013|x64.ActiveCfg = Debug|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug - VS 2013|x64.Build.0 = Debug|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug|Win32.ActiveCfg = Debug|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug|Win32.Build.0 = Debug|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug|x64.ActiveCfg = Debug|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Debug|x64.Build.0 = Debug|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - Clang|Win32.ActiveCfg = Release|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - Clang|Win32.Build.0 = Release|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - Clang|x64.ActiveCfg = Release|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - Clang|x64.Build.0 = Release|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - VS 2013|Win32.ActiveCfg = Release|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - VS 2013|Win32.Build.0 = Release|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - VS 2013|x64.ActiveCfg = Release|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release - VS 2013|x64.Build.0 = Release|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release|Win32.ActiveCfg = Release|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release|Win32.Build.0 = Release|Win32 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release|x64.ActiveCfg = Release|x64 + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357}.Release|x64.Build.0 = Release|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - Clang|Win32.ActiveCfg = Debug|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - Clang|Win32.Build.0 = Debug|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - Clang|x64.ActiveCfg = Debug|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - Clang|x64.Build.0 = Debug|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - VS 2013|Win32.ActiveCfg = Debug|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - VS 2013|Win32.Build.0 = Debug|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - VS 2013|x64.ActiveCfg = Debug|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug - VS 2013|x64.Build.0 = Debug|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug|Win32.ActiveCfg = Debug|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug|Win32.Build.0 = Debug|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug|x64.ActiveCfg = Debug|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Debug|x64.Build.0 = Debug|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - Clang|Win32.ActiveCfg = Release|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - Clang|Win32.Build.0 = Release|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - Clang|x64.ActiveCfg = Release|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - Clang|x64.Build.0 = Release|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - VS 2013|Win32.ActiveCfg = Release|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - VS 2013|Win32.Build.0 = Release|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - VS 2013|x64.ActiveCfg = Release|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release - VS 2013|x64.Build.0 = Release|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release|Win32.ActiveCfg = Release|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release|Win32.Build.0 = Release|Win32 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release|x64.ActiveCfg = Release|x64 + {CED23388-105D-46FA-9EC3-AD923C209AED}.Release|x64.Build.0 = Release|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - Clang|Win32.ActiveCfg = Debug|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - Clang|Win32.Build.0 = Debug|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - Clang|x64.ActiveCfg = Debug|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - Clang|x64.Build.0 = Debug|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - VS 2013|Win32.ActiveCfg = Debug|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - VS 2013|Win32.Build.0 = Debug|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - VS 2013|x64.ActiveCfg = Debug|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug - VS 2013|x64.Build.0 = Debug|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug|Win32.Build.0 = Debug|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug|x64.ActiveCfg = Debug|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Debug|x64.Build.0 = Debug|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - Clang|Win32.ActiveCfg = Release|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - Clang|Win32.Build.0 = Release|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - Clang|x64.ActiveCfg = Release|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - Clang|x64.Build.0 = Release|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - VS 2013|Win32.ActiveCfg = Release|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - VS 2013|Win32.Build.0 = Release|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - VS 2013|x64.ActiveCfg = Release|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release - VS 2013|x64.Build.0 = Release|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release|Win32.ActiveCfg = Release|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release|Win32.Build.0 = Release|Win32 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release|x64.ActiveCfg = Release|x64 + {E70CC0C5-256B-41E2-A852-B1904C2D84D3}.Release|x64.Build.0 = Release|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - C++ 03|Win32.ActiveCfg = Debug - C++ 03|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - C++ 03|Win32.Build.0 = Debug - C++ 03|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - C++ 03|x64.ActiveCfg = Debug - C++ 03|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - C++ 03|x64.Build.0 = Debug - C++ 03|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - Clang|Win32.ActiveCfg = Debug|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - Clang|Win32.Build.0 = Debug|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - Clang|x64.ActiveCfg = Debug|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - Clang|x64.Build.0 = Debug|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - VS 2013|Win32.ActiveCfg = Debug|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - VS 2013|Win32.Build.0 = Debug|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - VS 2013|x64.ActiveCfg = Debug|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug - VS 2013|x64.Build.0 = Debug|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug|Win32.ActiveCfg = Debug|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug|Win32.Build.0 = Debug|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug|x64.ActiveCfg = Debug|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Debug|x64.Build.0 = Debug|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - C++ 03|Win32.ActiveCfg = Release - C++ 03|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - C++ 03|Win32.Build.0 = Release - C++ 03|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - C++ 03|x64.ActiveCfg = Release - C++ 03|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - C++ 03|x64.Build.0 = Release - C++ 03|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - Clang|Win32.ActiveCfg = Release|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - Clang|Win32.Build.0 = Release|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - Clang|x64.ActiveCfg = Release|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - Clang|x64.Build.0 = Release|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - VS 2013|Win32.ActiveCfg = Release|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - VS 2013|Win32.Build.0 = Release|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - VS 2013|x64.ActiveCfg = Release|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release - VS 2013|x64.Build.0 = Release|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release|Win32.ActiveCfg = Release|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release|Win32.Build.0 = Release|Win32 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release|x64.ActiveCfg = Release|x64 + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A728DDFB-BE51-49B5-8593-4E89E024A500} = {ABDBC512-39DD-4625-A015-C23AA0690AD1} + {C231C585-F237-4F08-8BF5-8DC7106599D4} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {DDCFB59A-D19C-4382-ACFD-747105EB8D03} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {B7DF480E-DC38-410F-86E7-330696F7D5AB} = {ABDBC512-39DD-4625-A015-C23AA0690AD1} + {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} + {B9D2ABFB-6CD3-4C8F-ACC3-5BE2D798552E} = {B7DF480E-DC38-410F-86E7-330696F7D5AB} + {9DE9E971-362C-4A08-91D5-56ABA346AC1C} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} + {47973C26-88C1-4C07-8B31-6D448D7BD387} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} + {790287FF-8ECB-440C-8D3D-343AF0951E7B} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} + {2069AE83-AE26-484A-A6E7-E872E0045020} = {68F3A738-05B2-48AE-AF75-B8E9FE63660E} + {466B53F7-FF2E-4A0D-94C1-48E1ACC7D357} = {AF9A9587-13D2-4D16-9C3A-AB3061E3FEF3} + {CED23388-105D-46FA-9EC3-AD923C209AED} = {AF9A9587-13D2-4D16-9C3A-AB3061E3FEF3} + {E70CC0C5-256B-41E2-A852-B1904C2D84D3} = {AF9A9587-13D2-4D16-9C3A-AB3061E3FEF3} + {B883C29E-485C-4C8F-ACB1-A1602378BF5C} = {AF9A9587-13D2-4D16-9C3A-AB3061E3FEF3} + {CA16ABEE-C6DE-4BD4-9DE4-5C2F1D149A68} = {B883C29E-485C-4C8F-ACB1-A1602378BF5C} + {A23DCF32-F7CB-450B-B4A0-59AD7BACFDD4} = {FBC833F8-033B-4400-8CBA-C71A32CF62B4} + EndGlobalSection +EndGlobal diff --git a/yasmine_model/CMakeLists.txt b/yasmine_model/CMakeLists.txt new file mode 100644 index 0000000..cfb575a --- /dev/null +++ b/yasmine_model/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 3.5) + +project(yasmine_model) + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +file(GLOB yasmine_model_SRC "include/*.hpp" "source/*.cpp") + +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 \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") + else() + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") + endif() + +endif() + + +# for release +if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) + #Creates fast code. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") + + #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}") + +include_directories("/usr/include/rapidjson") +include_directories("./../yasmine_model/include") +include_directories("./../externals/essentials/include") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_library(yasmine_model SHARED ${yasmine_model_SRC}) +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_library(yasmine_model STATIC ${yasmine_model_SRC}) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if("${CPP_VERSION}" STREQUAL "03") + target_link_libraries (yasmine_model LINK_PUBLIC pthread boost_system boost_thread boost_chrono) + else() + target_link_libraries (yasmine_model LINK_PUBLIC pthread) + endif() +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_link_libraries (hello_yasmine LINK_PUBLIC) +endif() + +install(TARGETS yasmine_model DESTINATION lib) +install(FILES *.hpp DESTINATION include) +set_target_properties(yasmine_model PROPERTIES PREFIX "") \ No newline at end of file diff --git a/yasmine_model/changelog.txt b/yasmine_model/changelog.txt new file mode 100644 index 0000000..6541240 --- /dev/null +++ b/yasmine_model/changelog.txt @@ -0,0 +1,8 @@ +# Change log +All notable changes to this project are documented in this file. + + +##[1.0.0] - 2017-04-24 + +• The very first released version of yasmine_model + diff --git a/yasmine_model/include/build_number.hpp b/yasmine_model/include/build_number.hpp new file mode 100644 index 0000000..116e66d --- /dev/null +++ b/yasmine_model/include/build_number.hpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef BUILD_NUMBER_BEA27738_6D7E_43AE_A958_052FA6C308CF +#define BUILD_NUMBER_BEA27738_6D7E_43AE_A958_052FA6C308CF + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + + + const sxe::uint16_t BUILD_NUMBER( 656 ); + + +} + + +} + + +#endif diff --git a/yasmine_model/include/choice_model.hpp b/yasmine_model/include/choice_model.hpp new file mode 100644 index 0000000..c5f0a27 --- /dev/null +++ b/yasmine_model/include/choice_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CHOICE_MODEL_D643AB58_F738_4961_8DD3_A6A6D2CD55BB +#define CHOICE_MODEL_D643AB58_F738_4961_8DD3_A6A6D2CD55BB + + +#include "pseudostate_model.hpp" +#include "choice_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface chice_model +//!\brief Interface for a choice pseudostate in the model. +class choice_model: public virtual pseudostate_model +{ +public: + choice_model() + { + // Nothing to do... + } + + + virtual ~choice_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( choice_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/choice_model_fwd.hpp b/yasmine_model/include/choice_model_fwd.hpp new file mode 100644 index 0000000..afa4166 --- /dev/null +++ b/yasmine_model/include/choice_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CHOICE_MODEL_FWD_078ABD3E_3696_4115_8594_303027ADDD81 +#define CHOICE_MODEL_FWD_078ABD3E_3696_4115_8594_303027ADDD81 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class choice_model; + + +typedef sxe::SX_UNIQUE_PTR choice_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/choice_model_impl.hpp b/yasmine_model/include/choice_model_impl.hpp new file mode 100644 index 0000000..f6eb94c --- /dev/null +++ b/yasmine_model/include/choice_model_impl.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CHOICE_MODEL_IMPL_62F688E5_4520_44BA_A749_E428975B0111 +#define CHOICE_MODEL_IMPL_62F688E5_4520_44BA_A749_E428975B0111 + + +#include "choice_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class chice_model_impl +//!\brief A choice pseudostate in the model. +class choice_model_impl SX_FINAL: + public virtual choice_model, public pseudostate_model_impl +{ +public: + //!\brief Constructor. + //!\param _name Name of the choice. + explicit choice_model_impl( const std::string& _name ); + virtual ~choice_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( choice_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/composite_state_model.hpp b/yasmine_model/include/composite_state_model.hpp new file mode 100644 index 0000000..cc00c30 --- /dev/null +++ b/yasmine_model/include/composite_state_model.hpp @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef COMPOSITE_STATE_MODEL_3486C4FF_7607_4948_B81E_542780DEAAA6 +#define COMPOSITE_STATE_MODEL_3486C4FF_7607_4948_B81E_542780DEAAA6 + + +#include "state_model.hpp" +#include "composite_state_model_fwd.hpp" +#include "pseudostate_model_fwd.hpp" +#include "region_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface composite_state_model +//!\brief Interface for a composite state in the model. +class composite_state_model: + public virtual state_model +{ + + +public: + composite_state_model() + { + // Nothing to do... + } + + + virtual ~composite_state_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( composite_state_model ) + virtual const std::string& get_enter_behavior() const = 0; + virtual void set_enter_behavior( const std::string& _enter_behavior ) = 0; + virtual const std::string& get_exit_behavior() const = 0; + virtual void set_exit_behavior( const std::string& _exit_behavior ) = 0; + virtual void add_region( region_model_uptr _region ) = 0; + virtual raw_const_pseduostate_models get_state_pseudostates() const = 0; + virtual void add_state_pseudostate( pseudostate_model_uptr _pseudostate ) = 0; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/composite_state_model_fwd.hpp b/yasmine_model/include/composite_state_model_fwd.hpp new file mode 100644 index 0000000..97b3b43 --- /dev/null +++ b/yasmine_model/include/composite_state_model_fwd.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef COMPOSITE_STATE_MODEL_FWD_75E12710_3E61_444B_B3A6_D3986CFE466B +#define COMPOSITE_STATE_MODEL_FWD_75E12710_3E61_444B_B3A6_D3986CFE466B + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + +class composite_state_model_impl; + + +typedef sxe::SX_UNIQUE_PTR< composite_state_model_impl > composite_state_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/composite_state_model_impl.hpp b/yasmine_model/include/composite_state_model_impl.hpp new file mode 100644 index 0000000..eab43eb --- /dev/null +++ b/yasmine_model/include/composite_state_model_impl.hpp @@ -0,0 +1,79 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef COMPOSITE_STATE_MODEL_IMPL_EAF5C6B0_9341_4872_B701_0283A0FE433E +#define COMPOSITE_STATE_MODEL_IMPL_EAF5C6B0_9341_4872_B701_0283A0FE433E + + +#include "composite_state_model.hpp" +#include "state_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class composite_state_model_impl +//!\brief A composite state in the model. +class composite_state_model_impl SX_FINAL: + public virtual composite_state_model, public state_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the composite state. + //!\param _enter_behavior Entry behavior of the composite state. + //!\param _exit_bahvior Exit behavior of the composite state. + //!\param _deferred_events List of IDs of deferred event. + explicit composite_state_model_impl( const std::string& _name, const std::string& _enter_behavior = "", + const std::string& _exit_behavior = "", const event_ids& _deferred_events = event_ids() ); + virtual ~composite_state_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( composite_state_model_impl ) + virtual const std::string& get_do_behavior() const SX_OVERRIDE; + virtual void set_do_behavior( const std::string& _do_behavior ) SX_OVERRIDE; + //!\brief Get the entry behavior of the composite state. + virtual const std::string& get_enter_behavior() const SX_OVERRIDE; + //!\brief Set the entry behavior of the composite state. + void set_enter_behavior( const std::string& _enter_behavior ) SX_OVERRIDE; + //!\brief Get the exit behavior of the composite state. + virtual const std::string& get_exit_behavior() const SX_OVERRIDE; + //!\brief Set the exit behavior of the composite state. + void set_exit_behavior( const std::string& _exit_behavior ) SX_OVERRIDE; + //!\brief Get the regions of the composite state. + virtual const raw_const_region_models get_regions() const SX_OVERRIDE; + //!\brief Add a region to the list of regions of the composite state. + virtual void add_region( region_model_uptr _region ) SX_OVERRIDE; + //!\brief Get the state pseudostates of the composite state. + virtual raw_const_pseduostate_models get_state_pseudostates() const SX_OVERRIDE; + //!\brief Add a state pseudostate to the list of the state pseudostates of the composite state. + virtual void add_state_pseudostate( pseudostate_model_uptr _pseudostate ) SX_OVERRIDE; + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; + + +private: + std::string enter_behavior_; + const std::string do_behavior_; + std::string exit_behavior_; + region_models_uptr regions_; + pseudostate_models_uptr state_pseudostates_; +}; + + +} + +} + + +#endif diff --git a/yasmine_model/include/consts.hpp b/yasmine_model/include/consts.hpp new file mode 100644 index 0000000..1547e41 --- /dev/null +++ b/yasmine_model/include/consts.hpp @@ -0,0 +1,92 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef CONSTS_ACE2AE01_CFDD_4BD0_AB05_9B3190BFE90D +#define CONSTS_ACE2AE01_CFDD_4BD0_AB05_9B3190BFE90D + + +#include + + +namespace sxy +{ + + +namespace model +{ + + +extern const char* const JSON_STATE_MACHINE_NODE; +extern const char* const JSON_ROOT_NODE; +extern const char* const JSON_TRANSITIONS_NODE; +extern const char* const JSON_NAME_NODE; +extern const char* const JSON_TYPE_NODE; +extern const char* const JSON_ENTER_BEHAVIOR_NODE; +extern const char* const JSON_DO_BEHAVIOR_NODE; +extern const char* const JSON_EXIT_BEHAVIOR_NODE; +extern const char* const JSON_REGIONS_NODE; +extern const char* const JSON_VERTICES_NODE; +extern const char* const JSON_STATE_PSEUDOSTATES_NODE; +extern const char* const JSON_PSEUDOSTATES_NODE; +extern const char* const JSON_TRANSITION_KIND_NODE; +extern const char* const JSON_TRANSITION_SOURCE_NODE; +extern const char* const JSON_TRANSITION_TARGET_NODE; +extern const char* const JSON_TRANSITION_GUARD_NODE; +extern const char* const JSON_TRANSITION_BEHAVIOR_NODE; +extern const char* const JSON_TRANSITION_EVENTS_NODE; +extern const char* const JSON_DEFERRED_EVENTS; +extern const char* const JSON_ERROR_EVENT; +extern const char* const JSON_EVENT_ID; +extern const char* const JSON_EVENT_NAME; +extern const char* const JSON_EVENT_LIST_NODE; +extern const char* const JSON_EVENT_PRIORITY; +extern const char* const JSON_VERSION; +extern const char* const JSON_CURRENT_VERSION_VALUE; +extern const char* const JSON_VERSION_1; + + +extern const std::string TYPE_TRANSITION; +extern const std::string TYPE_SIMPLE_STATE; +extern const std::string TYPE_ASYNC_SIMPLE_STATE; +extern const std::string TYPE_COMPOSITE_STATE; +extern const std::string TYPE_FINAL_STATE; +extern const std::string TYPE_INITIAL_PSEUDOSTATE; +extern const std::string TYPE_TERMINATE_PSEUDOSTATE; +extern const std::string TYPE_ENTRY_POINT; +extern const std::string TYPE_EXIT_POINT; +extern const std::string TYPE_DEEP_HISTORY; +extern const std::string TYPE_SHALLOW_HISTORY; +extern const std::string TYPE_JOIN; +extern const std::string TYPE_JUNCTION; +extern const std::string TYPE_FORK; +extern const std::string TYPE_CHOICE; +extern const std::string TYPE_REGION; +extern const std::string TYPE_UNKNOWN; + + +extern const std::string CONFIG_FILE_IS_CORRUPTED; +extern const std::string CHOOSE_FILE_TEXT; +extern const std::string FILE_CANNOT_BE_OPENED; +extern const std::string PATH_CONFIG_JSON_FILE; +extern const std::string CHOOSE_FILE_TYPE; +extern const std::string CHOOSE_FILE_TEXT_SAVE; +extern const std::string CHOOSE_FILE_DEFAULT_SAVING_NAME; +extern const std::string CHOOSE_FILE_TYPE_SAVE; + +extern const char* const TRANSITION_MUST_BE_IN_JSON_ARRAY; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/deep_history_model.hpp b/yasmine_model/include/deep_history_model.hpp new file mode 100644 index 0000000..d5cbe92 --- /dev/null +++ b/yasmine_model/include/deep_history_model.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef DEEP_HISTORY_MODEL_8B24A7EC_863C_4FFE_9E08_00CF3CD6E083 +#define DEEP_HISTORY_MODEL_8B24A7EC_863C_4FFE_9E08_00CF3CD6E083 + + +#include "pseudostate_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface deep_history_model +//!\brief Interface for a deep history pseudostate in the model. +class deep_history_model: public virtual pseudostate_model +{ +public: + deep_history_model() + { + // Nothing to do... + } + + + virtual ~deep_history_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( deep_history_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/deep_history_model_fwd.hpp b/yasmine_model/include/deep_history_model_fwd.hpp new file mode 100644 index 0000000..580d5b9 --- /dev/null +++ b/yasmine_model/include/deep_history_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef DEEP_HISTORY_MODEL_FWD_1129EEB8_986F_4376_9024_0E01089223D3 +#define DEEP_HISTORY_MODEL_FWD_1129EEB8_986F_4376_9024_0E01089223D3 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class deep_history_model; + + +typedef sxe::SX_UNIQUE_PTR deep_history_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/deep_history_model_impl.hpp b/yasmine_model/include/deep_history_model_impl.hpp new file mode 100644 index 0000000..987fbe6 --- /dev/null +++ b/yasmine_model/include/deep_history_model_impl.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef DEEP_HISTORY_MODEL_IMPL_A4563ACA_2A35_4E93_AEF0_676FBE34AEB7 +#define DEEP_HISTORY_MODEL_IMPL_A4563ACA_2A35_4E93_AEF0_676FBE34AEB7 + + +#include "deep_history_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class deep_history_model_impl +//!\brief A deep history pseudostate in the model. +class deep_history_model_impl SX_FINAL: + public virtual deep_history_model, public pseudostate_model_impl +{ + + +public: + //!\Constructor. + //!\param _name Name of the deep history. + explicit deep_history_model_impl( const std::string& _name ); + virtual ~deep_history_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( deep_history_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/entry_point_model.hpp b/yasmine_model/include/entry_point_model.hpp new file mode 100644 index 0000000..4a80f35 --- /dev/null +++ b/yasmine_model/include/entry_point_model.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef ENTRY_POINT_MODEL_6D3516CB_20CF_476F_A80D_A4C97BFCD281 +#define ENTRY_POINT_MODEL_6D3516CB_20CF_476F_A80D_A4C97BFCD281 + + +#include "pseudostate_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface entry_point_model +//!\brief Interface for an entry point pseudostate in the model. +class entry_point_model: public virtual pseudostate_model +{ +public: + entry_point_model() + { + // Nothing to do... + } + + + virtual ~entry_point_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( entry_point_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/entry_point_model_fwd.hpp b/yasmine_model/include/entry_point_model_fwd.hpp new file mode 100644 index 0000000..d305b63 --- /dev/null +++ b/yasmine_model/include/entry_point_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef ENTRY_POINT_MODEL_FWD_69CED1F7_2B8F_49BD_8D17_239E35C00D3D +#define ENTRY_POINT_MODEL_FWD_69CED1F7_2B8F_49BD_8D17_239E35C00D3D + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class entry_point_model; + + +typedef sxe::SX_UNIQUE_PTR entry_point_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/entry_point_model_impl.hpp b/yasmine_model/include/entry_point_model_impl.hpp new file mode 100644 index 0000000..c61c70f --- /dev/null +++ b/yasmine_model/include/entry_point_model_impl.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef ENTRY_POINT_MODEL_IMPL_36B48DAE_8799_46A0_84DD_5E02A89B044F +#define ENTRY_POINT_MODEL_IMPL_36B48DAE_8799_46A0_84DD_5E02A89B044F + + +#include "entry_point_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class entry_point_model_impl +//!\brief An entry point pseudostate in the model. +class entry_point_model_impl SX_FINAL: + public virtual entry_point_model, public pseudostate_model_impl +{ +public: + //!\brief Constructor. + //!\param _name Name of the entry point. + explicit entry_point_model_impl( const std::string& _name ); + virtual ~entry_point_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( entry_point_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/event_model.hpp b/yasmine_model/include/event_model.hpp new file mode 100644 index 0000000..6b98ab6 --- /dev/null +++ b/yasmine_model/include/event_model.hpp @@ -0,0 +1,57 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EVENT_3677D50A_2158_4FCD_BB50_308B5C537D87 +#define EVENT_3677D50A_2158_4FCD_BB50_308B5C537D87 + + +#include "essentials/non_copyable.hpp" + +#include "event_model_id.hpp" +#include "event_model_priority.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\struct event_model +//!\brief An event in the model. +struct event_model +{ +public: + //!\brief Constructor. + event_model(); + + //!\brief Constructor. + //!\param _name Name of the event. + //!\param _id Id of the event. + //!\param _priority Priority of the event. + event_model( const std::string _name, const event_id _id, const event_priority _priority ); + ~event_model() SX_NOEXCEPT; + + + std::string name; + event_id id; + event_priority priority; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/event_model_id.hpp b/yasmine_model/include/event_model_id.hpp new file mode 100644 index 0000000..f9bba19 --- /dev/null +++ b/yasmine_model/include/event_model_id.hpp @@ -0,0 +1,57 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EVENT_MODEL_ID_0A9A572D_AEA6_43BF_94B7_23F87E581966 +#define EVENT_MODEL_ID_0A9A572D_AEA6_43BF_94B7_23F87E581966 + + +#include +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +struct event_model; + + +//!\brief The type alias for yasmine model's event IDs. +typedef sxe::uint32_t event_id; +//!\brief The type alias for yasmine model's event ID list. +typedef std::vector< event_id > event_ids; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + +extern const event_id Y_MODEL_COMPLETION_EVENT_ID; + +#else + +extern const event_id Y_MODEL_COMPLETION_EVENT_ID; + +#endif + + +typedef sxe::shared_ptr< event_model > event_sptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/event_model_priority.hpp b/yasmine_model/include/event_model_priority.hpp new file mode 100644 index 0000000..00d1bd5 --- /dev/null +++ b/yasmine_model/include/event_model_priority.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EVENT_MODEL_PRIORITY_E5077DAE_CCFB_416A_845C_593C6FE00A01 +#define EVENT_MODEL_PRIORITY_E5077DAE_CCFB_416A_845C_593C6FE00A01 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\brief The type alias for yasmine model's event priorities. +typedef sxe::int8_t event_priority; + +#if defined( SX_CPP03_BOOST ) || ( defined(_MSC_VER) && _MSC_VER <=1800 ) + +#ifdef max + #undef max +#endif + +#define DEFAULT_EVENT_PRIORITY 0u + +#else + +//!\brief yasmine model's predefined default event priority. +constexpr event_priority DEFAULT_EVENT_PRIORITY = 0; + +#endif + + +} + + +} + + +#endif diff --git a/yasmine_model/include/exit_point_model.hpp b/yasmine_model/include/exit_point_model.hpp new file mode 100644 index 0000000..51f4d35 --- /dev/null +++ b/yasmine_model/include/exit_point_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EXIT_POINT_MODEL_DE3EF1F0_F25E_4350_A872_1D9C37669EF0 +#define EXIT_POINT_MODEL_DE3EF1F0_F25E_4350_A872_1D9C37669EF0 + + +#include "pseudostate_model.hpp" +#include "exit_point_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface exit_point_model +//!\brief Interface for an exit point pseudostate in the model. +class exit_point_model: public virtual pseudostate_model +{ +public: + exit_point_model() + { + // Nothing to do... + } + + + virtual ~exit_point_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( exit_point_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/exit_point_model_fwd.hpp b/yasmine_model/include/exit_point_model_fwd.hpp new file mode 100644 index 0000000..e182db6 --- /dev/null +++ b/yasmine_model/include/exit_point_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EXIT_POINT_MODEL_FWD_473EEC5E_6555_469A_BC91_54F4B48EFA5F +#define EXIT_POINT_MODEL_FWD_473EEC5E_6555_469A_BC91_54F4B48EFA5F + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class exit_point_model; + + +typedef sxe::SX_UNIQUE_PTR exit_point_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/exit_point_model_impl.hpp b/yasmine_model/include/exit_point_model_impl.hpp new file mode 100644 index 0000000..12b7d57 --- /dev/null +++ b/yasmine_model/include/exit_point_model_impl.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef EXIT_POINT_MODEL_IMPL_737E881A_9FD7_4F2B_95BC_6A5CAB7BADF9 +#define EXIT_POINT_MODEL_IMPL_737E881A_9FD7_4F2B_95BC_6A5CAB7BADF9 + + +#include "exit_point_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class exit_point_model_impl +//!\brief An exit point pseudostate in the model. +class exit_point_model_impl SX_FINAL : + public virtual exit_point_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the exit point. + explicit exit_point_model_impl( const std::string& _name ); + virtual ~exit_point_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( exit_point_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/final_state_model.hpp b/yasmine_model/include/final_state_model.hpp new file mode 100644 index 0000000..12285f0 --- /dev/null +++ b/yasmine_model/include/final_state_model.hpp @@ -0,0 +1,58 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FINAL_STATE_MODEL_418502AE_CCF1_4713_90D0_2335AF26A3B7 +#define FINAL_STATE_MODEL_418502AE_CCF1_4713_90D0_2335AF26A3B7 + + +#include "state_model.hpp" +#include "final_state_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + + +//!\interface final_state_model +//!\brief Interface for a final state in the model. +class final_state_model: + public virtual state_model +{ + + +public: + final_state_model() + { + // Nothing to do... + } + + + virtual ~final_state_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( final_state_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/final_state_model_fwd.hpp b/yasmine_model/include/final_state_model_fwd.hpp new file mode 100644 index 0000000..6769933 --- /dev/null +++ b/yasmine_model/include/final_state_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FINAL_STATE_MODEL_FWD_04E34AF8_1979_4E4A_B7B8_5B1DED81777A +#define FINAL_STATE_MODEL_FWD_04E34AF8_1979_4E4A_B7B8_5B1DED81777A + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class final_state_model; + + +typedef sxe::SX_UNIQUE_PTR< final_state_model > final_state_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/final_state_model_impl.hpp b/yasmine_model/include/final_state_model_impl.hpp new file mode 100644 index 0000000..b7c926f --- /dev/null +++ b/yasmine_model/include/final_state_model_impl.hpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FINAL_STATE_MODEL_IMPL_D3F6C9F5_29BD_4897_B744_9F1A70DA0B8D +#define FINAL_STATE_MODEL_IMPL_D3F6C9F5_29BD_4897_B744_9F1A70DA0B8D + + +#include "final_state_model.hpp" +#include "state_model_impl.hpp" +#include "region_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class final_state_model_impl +//!\brief A final state in the model. +class final_state_model_impl SX_FINAL: + public virtual final_state_model, public state_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the final state. + explicit final_state_model_impl( const std::string& _name ); + virtual ~final_state_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( final_state_model_impl ) + virtual const raw_const_region_models get_regions() const SX_OVERRIDE; + virtual const std::string& get_enter_behavior() const SX_OVERRIDE; + virtual void set_enter_behavior( const std::string& _enter_behavior ) SX_OVERRIDE; + virtual const std::string& get_do_behavior() const SX_OVERRIDE; + virtual void set_do_behavior( const std::string& _do_behavior ) SX_OVERRIDE; + virtual const std::string& get_exit_behavior() const SX_OVERRIDE; + virtual void set_exit_behavior( const std::string& _exit_behavior ) SX_OVERRIDE; + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; + + +private: + const std::string no_behavior_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/fork_model.hpp b/yasmine_model/include/fork_model.hpp new file mode 100644 index 0000000..e6418ce --- /dev/null +++ b/yasmine_model/include/fork_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FORK_MODEL_A7E3D550_1A3B_4DA6_B381_9988647E9915 +#define FORK_MODEL_A7E3D550_1A3B_4DA6_B381_9988647E9915 + + +#include "pseudostate_model.hpp" +#include "fork_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface fork_model +//!\brief Interface for a fork pseudostate in the model. +class fork_model: public virtual pseudostate_model +{ +public: + fork_model() + { + // Nothing to do... + } + + + virtual ~fork_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( fork_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/fork_model_fwd.hpp b/yasmine_model/include/fork_model_fwd.hpp new file mode 100644 index 0000000..ee44e85 --- /dev/null +++ b/yasmine_model/include/fork_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FORK_MODEL_FWD_8B0AC9A1_6CA3_4748_8968_6F92F11A5202 +#define FORK_MODEL_FWD_8B0AC9A1_6CA3_4748_8968_6F92F11A5202 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class fork_model; + + +typedef sxe::SX_UNIQUE_PTR fork_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/fork_model_impl.hpp b/yasmine_model/include/fork_model_impl.hpp new file mode 100644 index 0000000..55b76ae --- /dev/null +++ b/yasmine_model/include/fork_model_impl.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef FORK_MODEL_IMPL_46FE8620_288B_48A2_B020_D9E0E8962E2F +#define FORK_MODEL_IMPL_46FE8620_288B_48A2_B020_D9E0E8962E2F + + +#include "fork_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class fork_model_impl +//!\brief A fork pseudostate in the model. +class fork_model_impl SX_FINAL: + public virtual fork_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the fork. + explicit fork_model_impl( const std::string& _name ); + virtual ~fork_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( fork_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/initial_pseudostate_model.hpp b/yasmine_model/include/initial_pseudostate_model.hpp new file mode 100644 index 0000000..7f03978 --- /dev/null +++ b/yasmine_model/include/initial_pseudostate_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef INITIAL_PSEUDOSTATE_MODEL_32EC2305_FEBD_4F09_A6DB_4E9C79B7172B +#define INITIAL_PSEUDOSTATE_MODEL_32EC2305_FEBD_4F09_A6DB_4E9C79B7172B + + +#include "pseudostate_model.hpp" +#include "initial_pseudostate_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface initial_pseudostate_model +//!\brief Interface for an initial pseudostate int the model. +class initial_pseudostate_model: public virtual pseudostate_model +{ +public: + initial_pseudostate_model() + { + // Nothing to do... + } + + + virtual ~initial_pseudostate_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( initial_pseudostate_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/initial_pseudostate_model_fwd.hpp b/yasmine_model/include/initial_pseudostate_model_fwd.hpp new file mode 100644 index 0000000..a41c00a --- /dev/null +++ b/yasmine_model/include/initial_pseudostate_model_fwd.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef INITIAL_PSEUDOSTATE_MODEL_FWD_52FE4FA1_C7A1_423B_BEBC_719018572126 +#define INITIAL_PSEUDOSTATE_MODEL_FWD_52FE4FA1_C7A1_423B_BEBC_719018572126 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + +class initial_pseudostate_model; + + +typedef sxe::SX_UNIQUE_PTR< initial_pseudostate_model > initial_pseudostate_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/initial_pseudostate_model_impl.hpp b/yasmine_model/include/initial_pseudostate_model_impl.hpp new file mode 100644 index 0000000..8755f2c --- /dev/null +++ b/yasmine_model/include/initial_pseudostate_model_impl.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef INITIAL_PSEUDOSTATE_MODEL_IMPL_BF7EC689_C277_476C_AE7B_DD17EA0CCAC9 +#define INITIAL_PSEUDOSTATE_MODEL_IMPL_BF7EC689_C277_476C_AE7B_DD17EA0CCAC9 + + +#include "initial_pseudostate_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class model_vertex_visitor; + + +//!\class initial_pseudostate_model_impl +//!\brief An initial pseudostate in the model. +class initial_pseudostate_model_impl SX_FINAL: + public virtual initial_pseudostate_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the initial pseudostate. + explicit initial_pseudostate_model_impl( const std::string& _name ); + virtual ~initial_pseudostate_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( initial_pseudostate_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/join_model.hpp b/yasmine_model/include/join_model.hpp new file mode 100644 index 0000000..95174f5 --- /dev/null +++ b/yasmine_model/include/join_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JOIN_MODEL_925E12E6_260B_4B8C_99D1_454D32458D0C +#define JOIN_MODEL_925E12E6_260B_4B8C_99D1_454D32458D0C + + +#include "pseudostate_model.hpp" +#include "join_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface join_model +//!\brief Interface for a join pseudostate in the model. +class join_model: public virtual pseudostate_model +{ +public: + join_model() + { + // Nothing to do... + } + + + virtual ~join_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( join_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/join_model_fwd.hpp b/yasmine_model/include/join_model_fwd.hpp new file mode 100644 index 0000000..6cfe25a --- /dev/null +++ b/yasmine_model/include/join_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JOIN_MODEL_FWD_BCB21DB9_9880_4F39_8C28_7E6B841B6326 +#define JOIN_MODEL_FWD_BCB21DB9_9880_4F39_8C28_7E6B841B6326 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class join_model; + + +typedef sxe::SX_UNIQUE_PTR join_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/join_model_impl.hpp b/yasmine_model/include/join_model_impl.hpp new file mode 100644 index 0000000..8a30bee --- /dev/null +++ b/yasmine_model/include/join_model_impl.hpp @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JOIN_MODEL_IMPL_B7AE319E_F291_4AE5_81C3_D18CE80F0D09 +#define JOIN_MODEL_IMPL_B7AE319E_F291_4AE5_81C3_D18CE80F0D09 + + +#include "pseudostate_model_impl.hpp" +#include "join_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + + //!\class join_model_impl + //!\brief A join pseudostate in the model. +class join_model_impl SX_FINAL: + public virtual join_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the join. + explicit join_model_impl( const std::string& _name ); + virtual ~join_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( join_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + + + +} + + +} + + +#endif diff --git a/yasmine_model/include/json_parser_helper.hpp b/yasmine_model/include/json_parser_helper.hpp new file mode 100644 index 0000000..dee09ed --- /dev/null +++ b/yasmine_model/include/json_parser_helper.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JSON_PARSER_HELPER_A98B95E7_1604_4778_92B0_A3C11BF6EF82 +#define JSON_PARSER_HELPER_A98B95E7_1604_4778_92B0_A3C11BF6EF82 + + +#include + +#include "document.h" + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +std::string get_object_member_string( const rapidjson::Value& _obj, const char* const _name_of_member ); +sxe::int64_t get_object_member_int( const rapidjson::Value& _obj, const char* const _name_of_member ); +const rapidjson::Value& get_object_member_array( const rapidjson::Value& _obj, const char* const _name_of_member ); +std::vector< const rapidjson::Value* > extract_members_from_array( const rapidjson::Value& _array ); +void string_to_json( const char* const _json_as_string, rapidjson::Document& _document ); +const rapidjson::Value& find_member( const rapidjson::Value& _member, const char* const _name ); +const rapidjson::Value& find_object_member( const rapidjson::Value& _document, const char* const _name ); + + +} + + +#endif diff --git a/yasmine_model/include/json_reader.hpp b/yasmine_model/include/json_reader.hpp new file mode 100644 index 0000000..8de7954 --- /dev/null +++ b/yasmine_model/include/json_reader.hpp @@ -0,0 +1,109 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JSON_READER_B84EDCFB_85B6_4060_971F_96D6FB6D87B7 +#define JSON_READER_B84EDCFB_85B6_4060_971F_96D6FB6D87B7 + + +#include + +#include "essentials/non_copyable.hpp" +#include "essentials/uri.hpp" + +#include "transition_model_kind.hpp" +#include "region_model_fwd.hpp" +#include "pseudostate_model_fwd.hpp" +#include "state_machine_model_fwd.hpp" +#include "state_model_fwd.hpp" +#include "composite_state_model_fwd.hpp" +#include "simple_state_model_fwd.hpp" +#include "final_state_model_fwd.hpp" +#include "entry_point_model_fwd.hpp" +#include "exit_point_model_fwd.hpp" +#include "deep_history_model_fwd.hpp" +#include "shallow_history_model_fwd.hpp" +#include "initial_pseudostate_model_fwd.hpp" +#include "join_model_fwd.hpp" +#include "junction_model_fwd.hpp" +#include "fork_model_fwd.hpp" +#include "terminate_pseudostate_model_fwd.hpp" +#include "choice_model_fwd.hpp" +#include "transition_model_fwd.hpp" +#include "consts.hpp" +#include "model_element_type.hpp" +#include "json_parser_helper.hpp" +#include "event_model.hpp" + + +namespace sxy +{ + +//!\class json_reader +//!\brief Provides the ability to read an yasmine model from a JSON file (.ym). +class json_reader SX_FINAL +{ +public: + //!\brief Constructor. An essentials exception (sxe::exception) is thrown if reading of the json fails. + //!\param _file JSON file containing the model description. + explicit json_reader( const std::string& _file ); + ~json_reader() SX_NOEXCEPT; + SX_NO_COPY(json_reader) + //!\brief Retrieve the read model. + //!\return Pointer to the model. + model::state_machine_model_ptr get_model_ptr(); + + +private: + void read_json_file( const std::string& _file ); + model::state_machine_model_ptr read_into_model(); + sxy::model::event_ids read_deferred_events( const rapidjson::Value& _state ) const; + model::composite_state_model_uptr read_composite_state( const rapidjson::Value& _root ); + model::simple_state_model_uptr read_simple_state( const rapidjson::Value& _state, bool _is_async = false ); + model::final_state_model_uptr read_final_state( const rapidjson::Value& _state ); + model::region_model_impl_uptr read_region( const rapidjson::Value& _region ); + model::state_model_uptr read_state( const rapidjson::Value& _state ); + model::pseudostate_model_uptr read_state_pseudostate( const rapidjson::Value& _state_pseudostate ); + model::pseudostate_model_uptr read_pseudostate( const rapidjson::Value& _pseudostate ); + model::initial_pseudostate_model_uptr read_initial_pseudostate( const rapidjson::Value& _pseudostate ); + model::join_model_uptr read_join( const rapidjson::Value& _pseudostate ); + model::fork_model_uptr read_fork( const rapidjson::Value& _pseudostate ); + model::choice_model_uptr read_choice( const rapidjson::Value& _pseudostate ); + model::junction_model_uptr read_junction( const rapidjson::Value& _pseudostate ); + model::terminate_pseudostate_model_uptr read_terminate_pseudostate( const rapidjson::Value& _pseudostate ); + model::deep_history_model_uptr read_deep_history( const rapidjson::Value& _pseudostate ); + model::shallow_history_model_uptr read_shallow_history( const rapidjson::Value& _pseudostate ); + model::entry_point_model_uptr read_entry_point( const rapidjson::Value& _pseudostate ); + model::exit_point_model_uptr read_exit_point( const rapidjson::Value& _pseudostate ); + model::transition_model_uptr read_transition( const rapidjson::Value& _transition ); + static sxy::model::transition_model_kind get_transition_kind( unsigned int _kind ); + sxe::int64_t get_event_id_by_name( const std::string& _name ) const; + sxe::int64_t get_event_priority_by_name( const std::string& _name ) const; + void get_event_list( model::state_machine_model_ptr& _model ); + void check_document() const; + + template< typename pseudostate_impl > + sxe::SX_UNIQUE_PTR< pseudostate_impl > function_read_pseudostate( const rapidjson::Value& _pseudostate ) + { + const std::string pseudostate_name = get_object_member_string( sxe::ref( _pseudostate ), model::JSON_NAME_NODE ); + sxe::SX_UNIQUE_PTR< pseudostate_impl > new_pseudostate = + SX_MAKE_UNIQUE< pseudostate_impl >( pseudostate_name ); + return( sxe::move( new_pseudostate ) ); + } + + + rapidjson::Document document_; + model::state_machine_model_ptr model_; +}; + + +} + + +#endif diff --git a/yasmine_model/include/json_writer.hpp b/yasmine_model/include/json_writer.hpp new file mode 100644 index 0000000..3a9ef3b --- /dev/null +++ b/yasmine_model/include/json_writer.hpp @@ -0,0 +1,104 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JSON_WRITER_F29233A0_535E_4285_AE04_E0E163819CB2 +#define JSON_WRITER_F29233A0_535E_4285_AE04_E0E163819CB2 + + +#include + +#define RAPIDJSON_NO_SIZETYPEDEFINE + + +namespace rapidjson +{ + + +typedef std::size_t SizeType; + + +} + +#include + +#include "state_machine_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class state_machine_element_model; +class transition_model_impl; +class simple_state_model; +class pseudostate_model_impl; +class pseudostate_model; +class region_model; +class composite_state_model; +class final_state_model; + + +} + + +//!\class json_writer +//!\brief Provides the ability to write a model to a file. +class json_writer SX_FINAL +{ +public: + //!\brief Constructor. Writes the model into a .ym file (JSON). An essentials exception (sxe::exception) is thrown if the write fails. + //!\param _json_file_name Name of the output file. + //!\param _state_machine_model The state machine model that shall be written. + json_writer( const std::string & _json_file_name, const model::state_machine_model &_state_machine_model ); + ~json_writer() SX_NOEXCEPT; + SX_NO_COPY( json_writer ) + + +private: + void write_json_to_file( const std::string& _json_file, const model::state_machine_model& _state_machine_model ); + // cppcheck-suppress unusedPrivateFunction + static void write_text_to_file( const char* _json_char, const std::string& _json_file ); + static void add_version( rapidjson::Value& _document, rapidjson::MemoryPoolAllocator< >& _allocator ); + static void add_events_from_model( const model::state_machine_model& _state_machine_model, + rapidjson::Value& _events, rapidjson::MemoryPoolAllocator< >& _allocator ); + // cppcheck-suppress unusedPrivateFunction + static void add_transitions_from_model( const model::state_machine_model& _state_machine_model, + rapidjson::Value& _transitions, rapidjson::MemoryPoolAllocator< >& _allocator ); + static void add_regions_from_model( const model::composite_state_model& _composite_state_model, + rapidjson::Value& _regions, rapidjson::MemoryPoolAllocator< >& _allocator ); + static void fill_region_object( const model::region_model& _region_model, rapidjson::Value& _region, + rapidjson::MemoryPoolAllocator< >& _allocator ); + static void fill_pseudostate_object( const model::pseudostate_model& _pseudostate_model, rapidjson::Value& _pseudostate, + rapidjson::MemoryPoolAllocator< >& _allocator ); + static void fill_simple_state_object( const model::simple_state_model& _simple_state_model, rapidjson::Value& _simple_state, + rapidjson::MemoryPoolAllocator< >& _allocator ); + static void fill_composite_state_object( const model::composite_state_model& _composite_state_model, + rapidjson::Value& _composite_state, rapidjson::MemoryPoolAllocator< >& _allocator ); + static void fill_final_state_object( const model::final_state_model& _final_state_model, + rapidjson::Value& _final_state, rapidjson::MemoryPoolAllocator< >& _allocator ); + static void add_state_pseudostates_from_model( const model::composite_state_model& _composite_state_model, + rapidjson::Value& _state_pseudostates, rapidjson::MemoryPoolAllocator< >& _allocator ); + static rapidjson::Value& create_rapidjson_string_value( const std::string& _string, + rapidjson::Value& _json_string_value ); + static void fill_base_info( rapidjson::Value& _json_val, const model::state_machine_element_model& _element, + rapidjson::MemoryPoolAllocator< >& _allocator ); + static const std::string get_event_name_by_id( const sxy::model::event_id& _event_id, + const model::state_machine_model& _state_machine_model ); +}; + + +} + + +#endif diff --git a/yasmine_model/include/junction_model.hpp b/yasmine_model/include/junction_model.hpp new file mode 100644 index 0000000..1e28053 --- /dev/null +++ b/yasmine_model/include/junction_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JUNCTION_MODEL_F486D1A4_FE05_4FBF_9E00_F69FBFCC70B2 +#define JUNCTION_MODEL_F486D1A4_FE05_4FBF_9E00_F69FBFCC70B2 + + +#include "pseudostate_model.hpp" +#include "junction_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface junction_model +//!\brief Interface for a junction pseudostate in the model. +class junction_model: public virtual pseudostate_model +{ +public: + junction_model() + { + // Nothing to do... + } + + + virtual ~junction_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( junction_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/junction_model_fwd.hpp b/yasmine_model/include/junction_model_fwd.hpp new file mode 100644 index 0000000..1fc1163 --- /dev/null +++ b/yasmine_model/include/junction_model_fwd.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JUNCTION_MODEL_FWD_3F13D352_5072_4D42_B1E6_1A8426302DE7 +#define JUNCTION_MODEL_FWD_3F13D352_5072_4D42_B1E6_1A8426302DE7 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + +class junction_model; + + +typedef sxe::SX_UNIQUE_PTR junction_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/junction_model_impl.hpp b/yasmine_model/include/junction_model_impl.hpp new file mode 100644 index 0000000..a4e835f --- /dev/null +++ b/yasmine_model/include/junction_model_impl.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef JUNCTION_MODEL_IMPL_7E649570_1C3D_45B3_B282_BB8633E7177E +#define JUNCTION_MODEL_IMPL_7E649570_1C3D_45B3_B282_BB8633E7177E + + +#include "junction_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class junction_model_impl +//!\brief A junction pseudostate in the model. +class junction_model_impl SX_FINAL: + public virtual junction_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the junction. + explicit junction_model_impl( const std::string& _name ); + virtual ~junction_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( junction_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/model.hpp b/yasmine_model/include/model.hpp new file mode 100644 index 0000000..78cd019 --- /dev/null +++ b/yasmine_model/include/model.hpp @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef MODEL_70A5CEB1_6704_4CA7_B205_65579AFDC215 +#define MODEL_70A5CEB1_6704_4CA7_B205_65579AFDC215 + + +#include "json_reader.hpp" +#include "json_writer.hpp" + +#include "transition_model.hpp" +#include "state_machine_model.hpp" + +#include "simple_state_model_impl.hpp" +#include "composite_state_model_impl.hpp" +#include "final_state_model_impl.hpp" +#include "pseudostate_model_impl.hpp" + +#include "model_exception.hpp" + + +#endif diff --git a/yasmine_model/include/model_element_type.hpp b/yasmine_model/include/model_element_type.hpp new file mode 100644 index 0000000..e253b17 --- /dev/null +++ b/yasmine_model/include/model_element_type.hpp @@ -0,0 +1,124 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef MODEL_ELEMENT_TYPE_88FF44C0_7912_4212_8E10_42FF3FD556EA +#define MODEL_ELEMENT_TYPE_88FF44C0_7912_4212_8E10_42FF3FD556EA + + +#include + + +namespace sxy +{ + + +namespace model +{ + + +#ifndef SX_CPP03_BOOST + + +enum model_element_type +{ + TYE_UNKNOWN = -1, + TYE_TRANSITION = 0, + TYE_SIMPLE_STATE = 1, + TYE_COMPOSITE_STATE = 2, + TYE_FINAL_STATE = 3, + TYE_INITIAL_PSEUDOSTATE = 4, + TYE_TERMINATE_PSEUDOSTATE = 5, + TYE_ENTRY_POINT = 6, + TYE_EXIT_POINT = 7, + TYE_DEEP_HISTORY = 8, + TYE_SHALLOW_HISTORY = 9, + TYE_JOIN = 10, + TYE_JUNCTION = 11, + TYE_FORK = 12, + TYE_CHOICE = 13, + TYE_REGION = 14, + TYE_ASYNC_SIMPLE_STATE = 15 +}; + + +#else + + + struct model_element_type + { + + + enum inner + { + TYE_UNKNOWN = -1, + TYE_TRANSITION = 0, + TYE_SIMPLE_STATE = 1, + TYE_COMPOSITE_STATE = 2, + TYE_FINAL_STATE = 3, + TYE_INITIAL_PSEUDOSTATE = 4, + TYE_TERMINATE_PSEUDOSTATE = 5, + TYE_ENTRY_POINT = 6, + TYE_EXIT_POINT = 7, + TYE_DEEP_HISTORY = 8, + TYE_SHALLOW_HISTORY = 9, + TYE_JOIN = 10, + TYE_JUNCTION = 11, + TYE_FORK = 12, + TYE_CHOICE = 13, + TYE_REGION = 14, + TYE_ASYNC_SIMPLE_STATE = 15 + }; + + + // cppcheck-suppress noExplicitConstructor + model_element_type() : value_( TYE_UNKNOWN ) + { + // Nothing to do... + } + + + // cppcheck-suppress noExplicitConstructor + model_element_type( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + // cppcheck-suppress functionConst + operator inner() + { + return ( value_ ); + } + + + inner value_; + + }; + + + bool operator==( const sxy::model::model_element_type& _lhs, const sxy::model::model_element_type::inner _rhs ); + bool operator==( const sxy::model::model_element_type::inner _lhs, const sxy::model::model_element_type& _rhs ); + bool operator<( const sxy::model::model_element_type _lhs, const sxy::model::model_element_type _rhs ); + + +#endif + + +model_element_type model_element_type_from_string( const std::string& _type_as_string ); +const std::string model_element_type_to_string( const model_element_type& _type ); + + +} + + +} + + +#endif diff --git a/yasmine_model/include/model_exception.hpp b/yasmine_model/include/model_exception.hpp new file mode 100644 index 0000000..a4281fa --- /dev/null +++ b/yasmine_model/include/model_exception.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef MODEL_EXCEPTION_B00095A5_7B53_4E9D_956C_2DC6188F2E2D +#define MODEL_EXCEPTION_B00095A5_7B53_4E9D_956C_2DC6188F2E2D + + +#include "essentials/exception_template.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +SX_EXCEPTION( exception ) + + +} + + +} + + +#endif diff --git a/yasmine_model/include/model_version.hpp b/yasmine_model/include/model_version.hpp new file mode 100644 index 0000000..89bdffe --- /dev/null +++ b/yasmine_model/include/model_version.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E +#define VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace version +{ + + +void log_version(); + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +} + + +#endif diff --git a/yasmine_model/include/model_vertex_visitor.hpp b/yasmine_model/include/model_vertex_visitor.hpp new file mode 100644 index 0000000..bcc4d89 --- /dev/null +++ b/yasmine_model/include/model_vertex_visitor.hpp @@ -0,0 +1,80 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef MODEL_VERTEX_VISITOR_2F339562_6B94_4450_95C9_F0FA105E4D6B +#define MODEL_VERTEX_VISITOR_2F339562_6B94_4450_95C9_F0FA105E4D6B + + +#include "essentials/non_copyable.hpp" +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class simple_state_model; +class composite_state_model; +class final_state_model; +class initial_pseudostate_model; +class terminate_pseudostate_model; +class entry_point_model; +class exit_point_model; +class deep_history_model; +class shallow_history_model; +class join_model; +class junction_model; +class choice_model; +class fork_model; + + +class model_vertex_visitor +{ +public: + model_vertex_visitor() + { + // Nothing to do... + } + + + virtual ~model_vertex_visitor() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( model_vertex_visitor ) + virtual void visit( const simple_state_model& _simple_state_model ) = 0; + virtual void visit( const composite_state_model& _composite_state_model ) = 0; + virtual void visit( const final_state_model& _final_state_model ) const = 0; + virtual void visit( const initial_pseudostate_model& _initial_pseudostate_model ) const = 0; + virtual void visit( const terminate_pseudostate_model& _terminate_pseudostate_model ) const = 0; + virtual void visit( const entry_point_model& _entry_point_model ) const = 0; + virtual void visit( const exit_point_model& _exit_point_model ) const = 0; + virtual void visit( const deep_history_model& _deep_history_model ) const = 0; + virtual void visit( const shallow_history_model& _shallow_history_model ) const = 0; + virtual void visit( const join_model& _join_model ) const = 0; + virtual void visit( const fork_model& _fork_model ) const = 0; + virtual void visit( const junction_model& _junction_model ) const = 0; + virtual void visit( const choice_model& _choice_model ) const = 0; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/pseudostate_model.hpp b/yasmine_model/include/pseudostate_model.hpp new file mode 100644 index 0000000..ed51d17 --- /dev/null +++ b/yasmine_model/include/pseudostate_model.hpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef PSEUDOSTATE_MODEL_D08608A5_1FE4_41BC_9E9F_AE335AE13969 +#define PSEUDOSTATE_MODEL_D08608A5_1FE4_41BC_9E9F_AE335AE13969 + + +#include "state_machine_element_model.hpp" +#include "pseudostate_model_fwd.hpp" +#include "transition_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class model_vertex_visitor; + + +//!\interface pseudostate_model +//!\brief Interface for a pseudostate in the model. +class pseudostate_model: public virtual state_machine_element_model +{ +public: + pseudostate_model() + { + // Nothing to do... + } + + + virtual ~pseudostate_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + virtual raw_const_transition_models get_incoming_transitions() const = 0; + virtual void add_incoming_transition( transition_models _incoming_transition ) = 0; + virtual raw_const_transition_models get_outgoing_transitions() const = 0; + virtual void add_outgoing_transition( transition_models _outgoing_transition ) = 0; + virtual void accept( model_vertex_visitor& _constructor_visitor ) const = 0; +}; + + +} +} + + +#endif diff --git a/yasmine_model/include/pseudostate_model_fwd.hpp b/yasmine_model/include/pseudostate_model_fwd.hpp new file mode 100644 index 0000000..e80ccaf --- /dev/null +++ b/yasmine_model/include/pseudostate_model_fwd.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef PSEUDOSTATE_MODEL_FWD_B51FBD5C_C127_419E_8E47_4FACE291D1AE +#define PSEUDOSTATE_MODEL_FWD_B51FBD5C_C127_419E_8E47_4FACE291D1AE + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class pseudostate_model; + + +typedef sxe::SX_UNIQUE_PTR pseudostate_model_uptr; +typedef std::vector pseudostate_models_uptr; +typedef std::vector< const pseudostate_model*> raw_const_pseduostate_models; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/pseudostate_model_impl.hpp b/yasmine_model/include/pseudostate_model_impl.hpp new file mode 100644 index 0000000..57d2dce --- /dev/null +++ b/yasmine_model/include/pseudostate_model_impl.hpp @@ -0,0 +1,65 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef PSEUDOSTATE_MODEL_IMPL_5B405971_4677_4872_9BD7_1AC88418E022 +#define PSEUDOSTATE_MODEL_IMPL_5B405971_4677_4872_9BD7_1AC88418E022 + + +#include "pseudostate_model.hpp" +#include "state_machine_element_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class pseudostate_model_impl +//!\brief A pseudostate in the model. +class pseudostate_model_impl: + public virtual pseudostate_model, public state_machine_element_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the pseudostate. + //!\param _type Type of the pseudostate. + pseudostate_model_impl( const std::string& _name, const model_element_type& _type ); + virtual ~pseudostate_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( pseudostate_model_impl ) + //!\brief Get the list of the incoming transitions of the pseudostate. + virtual raw_const_transition_models get_incoming_transitions() const SX_OVERRIDE; + //!\brief Add an incoming transition to the list of the incoming transitions of the pseudostate. + virtual void add_incoming_transition( transition_models _incoming_transition ) SX_OVERRIDE; + //!\brief Get the list of the outgoing transitions of the pseudostate. + virtual raw_const_transition_models get_outgoing_transitions() const SX_OVERRIDE; + //!\brief Add a outgoing transition to the list of the outgoing transitions of the pseudostate. + virtual void add_outgoing_transition( transition_models _outgoing_transition ) SX_OVERRIDE; + + +private: + transition_models incoming_transitions_; + transition_models outgoing_transitions_; + + +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/region_model.hpp b/yasmine_model/include/region_model.hpp new file mode 100644 index 0000000..3700eb1 --- /dev/null +++ b/yasmine_model/include/region_model.hpp @@ -0,0 +1,61 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef REGION_MODEL_54D9A6B5_527D_4ECE_959C_2DD711919B25 +#define REGION_MODEL_54D9A6B5_527D_4ECE_959C_2DD711919B25 + + +#include "state_machine_element_model.hpp" +#include "region_model_fwd.hpp" +#include "state_model_fwd.hpp" +#include "pseudostate_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface region_model +//!\brief Interface for a region in the model. +class region_model: + public virtual state_machine_element_model +{ +public: + region_model() + { + // Nothing to do... + } + + + virtual ~region_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( region_model ) + virtual row_const_state_models get_states() const = 0; + virtual void add_state( state_model_uptr _state ) = 0; + virtual raw_const_pseduostate_models get_pseudostates() const = 0; + virtual void add_pseudostate( pseudostate_model_uptr _region_pseudostate ) = 0; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/region_model_fwd.hpp b/yasmine_model/include/region_model_fwd.hpp new file mode 100644 index 0000000..7a1dd39 --- /dev/null +++ b/yasmine_model/include/region_model_fwd.hpp @@ -0,0 +1,44 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef REGION_MODEL_FWD_77B8548B_6558_41A0_8514_0EDE8724D8BE +#define REGION_MODEL_FWD_77B8548B_6558_41A0_8514_0EDE8724D8BE + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class region_model; +class region_model_impl; + + +typedef sxe::SX_UNIQUE_PTR region_model_uptr; +typedef sxe::SX_UNIQUE_PTR region_model_impl_uptr; +typedef std::vector region_models_uptr; +typedef std::vector raw_const_region_models; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/region_model_impl.hpp b/yasmine_model/include/region_model_impl.hpp new file mode 100644 index 0000000..1aca840 --- /dev/null +++ b/yasmine_model/include/region_model_impl.hpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef REGION_MODEL_IMPL_2907B5BB_8F99_4B72_94E1_AFA0D1F8106E +#define REGION_MODEL_IMPL_2907B5BB_8F99_4B72_94E1_AFA0D1F8106E + + +#include "region_model.hpp" +#include "state_machine_element_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class region_model_impl +//!\brief A region in the model. +class region_model_impl SX_FINAL: + public virtual region_model, public state_machine_element_model_impl +{ +public: + //!\brief Constructor. + //!\param _name Name of the region. + explicit region_model_impl( const std::string& _name ); + virtual ~region_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( region_model_impl ) + //!\brief Get the list of the states of the region. + row_const_state_models get_states() const SX_OVERRIDE; + //!\brief Add a state to the region. + void add_state( state_model_uptr _state ) SX_OVERRIDE; + //!\brief Get the list of pseudostates of the region. + raw_const_pseduostate_models get_pseudostates() const SX_OVERRIDE; + //!\brief Add a pseudostate to the region. + void add_pseudostate( pseudostate_model_uptr _region_pseudostate ) SX_OVERRIDE; + + +private: + state_models_uptr states_; + pseudostate_models_uptr pseudostates_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/shallow_history_model.hpp b/yasmine_model/include/shallow_history_model.hpp new file mode 100644 index 0000000..272f18c --- /dev/null +++ b/yasmine_model/include/shallow_history_model.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SHALLOW_HISTORY_MODEL_A6D474FF_C5C7_4608_8645_099C8B3521EE +#define SHALLOW_HISTORY_MODEL_A6D474FF_C5C7_4608_8645_099C8B3521EE + + +#include "pseudostate_model.hpp" +#include "shallow_history_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface shallow_history_model +//!\brief Interface for a shallow history pseudostate in the model. +class shallow_history_model: public virtual pseudostate_model +{ +public: + shallow_history_model() + { + // Nothing to do... + } + + + virtual ~shallow_history_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( shallow_history_model ) +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/shallow_history_model_fwd.hpp b/yasmine_model/include/shallow_history_model_fwd.hpp new file mode 100644 index 0000000..a2db7eb --- /dev/null +++ b/yasmine_model/include/shallow_history_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SHALLOW_HISTORY_MODEL_FWD_60DB298B_5BEB_4D05_9884_FDD59AF899F2 +#define SHALLOW_HISTORY_MODEL_FWD_60DB298B_5BEB_4D05_9884_FDD59AF899F2 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class shallow_history_model; + + +typedef sxe::SX_UNIQUE_PTR shallow_history_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/shallow_history_model_impl.hpp b/yasmine_model/include/shallow_history_model_impl.hpp new file mode 100644 index 0000000..a303ce2 --- /dev/null +++ b/yasmine_model/include/shallow_history_model_impl.hpp @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SHALLOW_HISTORY_MODEL_IMPL_CDCC97A1_5256_4665_81DB_94D4A3006DE5 +#define SHALLOW_HISTORY_MODEL_IMPL_CDCC97A1_5256_4665_81DB_94D4A3006DE5 + + +#include "shallow_history_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class shallow_history_model_impl +//!\brief A shallow history pseudostate in the model. +class shallow_history_model_impl SX_FINAL: + public virtual shallow_history_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the shallow history. + explicit shallow_history_model_impl( const std::string& _name ); + virtual ~shallow_history_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( shallow_history_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/simple_state_model.hpp b/yasmine_model/include/simple_state_model.hpp new file mode 100644 index 0000000..25918a0 --- /dev/null +++ b/yasmine_model/include/simple_state_model.hpp @@ -0,0 +1,58 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SIMPLE_STATE_MODEL_0B93DA0E_CD9B_486A_A5FC_4DDC8375C4C4 +#define SIMPLE_STATE_MODEL_0B93DA0E_CD9B_486A_A5FC_4DDC8375C4C4 + + +#include "state_model.hpp" +#include "simple_state_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface simple_state_model +//!\brief Interface for a simple state in the model. +class simple_state_model : public virtual state_model +{ +public: + simple_state_model() + { + // Nothing to do... + } + + + virtual ~simple_state_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( simple_state_model ) + virtual event_sptr get_error_event() const = 0; + virtual void set_error_event( event_sptr _error_event ) = 0; + virtual bool is_async() const = 0; + virtual void set_is_async( bool _is_async ) = 0; + + +}; + + +} +} + + +#endif diff --git a/yasmine_model/include/simple_state_model_fwd.hpp b/yasmine_model/include/simple_state_model_fwd.hpp new file mode 100644 index 0000000..a4c16ed --- /dev/null +++ b/yasmine_model/include/simple_state_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SIMPLE_STATE_MODEL_FWD_61DCA492_D0C8_4611_B51B_951C675B4881 +#define SIMPLE_STATE_MODEL_FWD_61DCA492_D0C8_4611_B51B_951C675B4881 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class simple_state_model; + + +typedef sxe::SX_UNIQUE_PTR< simple_state_model > simple_state_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/simple_state_model_impl.hpp b/yasmine_model/include/simple_state_model_impl.hpp new file mode 100644 index 0000000..922b26e --- /dev/null +++ b/yasmine_model/include/simple_state_model_impl.hpp @@ -0,0 +1,88 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef SIMPLE_STATE_MODEL_IMPL_D70699AF_2D8D_4556_8F0B_A16E3FF78852 +#define SIMPLE_STATE_MODEL_IMPL_D70699AF_2D8D_4556_8F0B_A16E3FF78852 + + +#include "simple_state_model.hpp" +#include "state_model_impl.hpp" +#include "region_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class simple_state_model_impl +//!\brief A simple state in the model. +class simple_state_model_impl SX_FINAL: + public virtual simple_state_model, public state_model_impl +{ +public: + //!\brief Constructor. + //!\param _name Name of the simple state. + //!\param _enter_behavior Entry behavior of the simple state. + //!\param _do_behavior Do behavior of the simple state. + //!\param _exit_bahvior Exit behavior of the simple state. + //!\param _deferred_events List of IDs of deferred events. + //!\param _error_event Event that is fired in case an exception occurs. + //!\param _is_async Specify if the simple state is sync or async. + explicit simple_state_model_impl( const std::string& _name, const std::string& _enter_behavior = "", + const std::string& _do_behavior = "", const std::string& _exit_behavior = "", + const event_ids& _deferred_events = event_ids(), event_sptr _error_event = event_sptr(), bool _is_async = false ); + virtual ~simple_state_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( simple_state_model_impl ) + //!\brief Get the enter behavior of the simple state. + virtual const std::string& get_enter_behavior() const SX_OVERRIDE; + //!\brief Set the enter behavior of the simple state. + virtual void set_enter_behavior( const std::string& _enter_behavior ) SX_OVERRIDE; + //!\brief Get the do behavior of the simple state. + virtual const std::string& get_do_behavior() const SX_OVERRIDE; + //!\brief Set the do behavior of the simple state. + virtual void set_do_behavior( const std::string& _do_behavior ) SX_OVERRIDE; + //!\brief Get the exit behavior of the simple state. + virtual const std::string& get_exit_behavior() const SX_OVERRIDE; + //!\brief Set the exit behavior of the simple state. + virtual void set_exit_behavior( const std::string& _exit_behavior ) SX_OVERRIDE; + virtual const raw_const_region_models get_regions() const SX_OVERRIDE; + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; + //!\brief Get the error event stored by the simple state. + //!\return Pointer to the event stored by the simple state. + virtual event_sptr get_error_event() const SX_OVERRIDE; + //!\brief Set the error event stored by the simple state. + virtual void set_error_event( event_sptr _error_event ) SX_OVERRIDE; + //!\brief Check if the simple state is asynchronous. + //!\return True for async, false otherwise. + virtual bool is_async() const SX_OVERRIDE; + //!\brief Set the simple state to be asynchronous or synchronous. + virtual void set_is_async( bool _is_async ) SX_OVERRIDE; + + +private: + std::string enter_behavior_; + std::string do_behavior_; + std::string exit_behavior_; + event_sptr error_event_; + bool is_async_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_element_model.hpp b/yasmine_model/include/state_machine_element_model.hpp new file mode 100644 index 0000000..725c794 --- /dev/null +++ b/yasmine_model/include/state_machine_element_model.hpp @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MACHINE_ELEMENT_MODEL_34418F5F_B45F_4C66_BC45_41DF4FE3A0D0 +#define STATE_MACHINE_ELEMENT_MODEL_34418F5F_B45F_4C66_BC45_41DF4FE3A0D0 + + +#include "essentials/non_copyable.hpp" + +#include "model_element_type.hpp" + + +namespace sxe +{ + class uri; +} + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface state_machine_element_model +//!\brief Interface for an element in the state machine model. +class state_machine_element_model +{ +public: + state_machine_element_model() + { + // Nothing to do... + } + + + virtual ~state_machine_element_model() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( state_machine_element_model ) + virtual const std::string & get_name() const = 0; + virtual const sxe::uri get_uri() const = 0; + virtual model::model_element_type get_type() const = 0; + virtual const state_machine_element_model* get_parent() const = 0; + virtual void set_parent( const state_machine_element_model* _parent ) = 0; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_element_model_impl.hpp b/yasmine_model/include/state_machine_element_model_impl.hpp new file mode 100644 index 0000000..892b998 --- /dev/null +++ b/yasmine_model/include/state_machine_element_model_impl.hpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MACHINE_ELEMENT_MODEL_IMPL_07873CFE_DADC_4CDC_A2CE_28C029CD5696 +#define STATE_MACHINE_ELEMENT_MODEL_IMPL_07873CFE_DADC_4CDC_A2CE_28C029CD5696 + + +#include "essentials/uri.hpp" + +#include "state_machine_element_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class state_machine_element_model_impl +//!\brief An element of the state machine in the model. +class state_machine_element_model_impl: + public virtual state_machine_element_model +{ +public: + //!\brief Constructor. + //!\param _name Name of the element. + //!\param _type Type of the element. + state_machine_element_model_impl( const std::string& _name, const model_element_type& _type ); + virtual ~state_machine_element_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( state_machine_element_model_impl ) + //!\brief Get the name of the element. + //!\return Name of the element. + virtual const std::string & get_name() const SX_OVERRIDE; + //!\brief Set the name of the element. + //!\param _name Name of the element. + void set_name( const std::string& _name ); + //!\brief Get the parent of the element. + //!\return Pointer to the parent element. + virtual const state_machine_element_model* get_parent() const SX_OVERRIDE; + //!\brief Set the parent of the element. + //!\param _parent Parent of the element. + virtual void set_parent( const state_machine_element_model* _parent ) SX_OVERRIDE; + //!\brief Get the uri of the element. + //!\return Uri of the element. + virtual const sxe::uri get_uri() const SX_OVERRIDE; + //!\brief Get the type of the element. + //!\return Element's type. + virtual model_element_type get_type() const SX_OVERRIDE; + + +private: + void add_ancestor_uri( sxe::uri& _uri ) const; + + std::string name_; + const state_machine_element_model* parent_; + const model_element_type type_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_model.hpp b/yasmine_model/include/state_machine_model.hpp new file mode 100644 index 0000000..b946f72 --- /dev/null +++ b/yasmine_model/include/state_machine_model.hpp @@ -0,0 +1,78 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MACHINE_MODEL_3F3E9321_9E31_4FE6_AC87_B084AF84F17A +#define STATE_MACHINE_MODEL_3F3E9321_9E31_4FE6_AC87_B084AF84F17A + +#include + +#include "essentials/non_copyable.hpp" + +#include "transition_model_fwd.hpp" +#include "composite_state_model_fwd.hpp" +#include "event_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class state_machine_model +//!\brief Class representing a model of a complete state machine. +class state_machine_model +{ +public: + typedef std::vector< event_model > events; + + state_machine_model(); + ~state_machine_model() SX_NOEXCEPT; + SX_NO_COPY( state_machine_model ) + + //!\brief Add a transition to the state machine. + void add_transition( transition_model_uptr _transition ); + + //!\brief Get a list of transitions. + //!\return List of transitions. + raw_const_transition_models get_transitions() const; + + //!\brief Get a reference to the root state of the state machine. + //!\reference Reference to the root state of the state machine. + composite_state_model_impl& get_root_state() const; + + //!\brief Add the root state to the state machine. + void add_root_state( composite_state_model_uptr _root_state ); + + //!\brief Get a list of events that was read from JSON file. This events are the events used in this state machine's scenario. + events get_events() const; + + //!\brief Add an event to the list of the events. + //!\param _event_name Name of the event. + //!\param _event_id Id of the event. + void add_event( const std::string& _event_name, const event_id& _event_id, const event_priority& _event_priority ); + + +private: + transition_models transitions_; + composite_state_model_uptr root_state_; + events event_list_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_machine_model_fwd.hpp b/yasmine_model/include/state_machine_model_fwd.hpp new file mode 100644 index 0000000..38a18a2 --- /dev/null +++ b/yasmine_model/include/state_machine_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MACHINE_MODEL_FWD_B054EB55_9683_4009_BB28_7F3721F6F787 +#define STATE_MACHINE_MODEL_FWD_B054EB55_9683_4009_BB28_7F3721F6F787 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class state_machine_model; + + +typedef sxe::SX_UNIQUE_PTR< state_machine_model > state_machine_model_ptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_model.hpp b/yasmine_model/include/state_model.hpp new file mode 100644 index 0000000..7c555b8 --- /dev/null +++ b/yasmine_model/include/state_model.hpp @@ -0,0 +1,69 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MODEL_AE9CA281_0B08_469D_BA4A_9608DD495579 +#define STATE_MODEL_AE9CA281_0B08_469D_BA4A_9608DD495579 + + +#include "state_machine_element_model.hpp" +#include "state_model_fwd.hpp" +#include "transition_model.hpp" +#include "region_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class model_vertex_visitor; + + +//!\interface state_model +//!\brief Interface for a state in the model. +class state_model : public virtual state_machine_element_model +{ +public: + state_model() + { + // Nothing to do... + } + + + virtual ~state_model() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( state_model ) + virtual raw_const_transition_models get_transitions() const = 0; + virtual const event_ids& get_deferred_events() const = 0; + virtual const raw_const_region_models get_regions() const = 0; + virtual const std::string& get_enter_behavior() const = 0; + virtual void set_enter_behavior( const std::string& _enter_behavior ) = 0; + virtual const std::string& get_do_behavior() const = 0; + virtual void set_do_behavior( const std::string& _do_behavior ) = 0; + virtual const std::string& get_exit_behavior() const = 0; + virtual void set_exit_behavior( const std::string& _exit_behavior ) = 0; + virtual void accept( model_vertex_visitor& _constructor_visitor ) const = 0; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_model_fwd.hpp b/yasmine_model/include/state_model_fwd.hpp new file mode 100644 index 0000000..323859b --- /dev/null +++ b/yasmine_model/include/state_model_fwd.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MODEL_FWD_00C93D56_497F_4C12_B9EC_F4846284C2BC +#define STATE_MODEL_FWD_00C93D56_497F_4C12_B9EC_F4846284C2BC + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class state_model; + + +typedef sxe::SX_UNIQUE_PTR state_model_uptr; +typedef std::vector state_models_uptr; +typedef std::vector row_const_state_models; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/state_model_impl.hpp b/yasmine_model/include/state_model_impl.hpp new file mode 100644 index 0000000..ba28f2e --- /dev/null +++ b/yasmine_model/include/state_model_impl.hpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef STATE_MODEL_IMPL_469ADCF1_AE5F_478C_A906_218099D99C09 +#define STATE_MODEL_IMPL_469ADCF1_AE5F_478C_A906_218099D99C09 + + +#include "state_model.hpp" +#include "state_machine_element_model_impl.hpp" +#include "transition_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class state_model_impl +//!\brief A state in the model. +class state_model_impl: + public virtual state_model, public state_machine_element_model_impl +{ +public: + //!\brief Constructor. + //!\param _name Name of the state. + //!\param _type Type of the state model. + //!\param _deferred_events List of IDs of deferred events. + state_model_impl( const std::string& _name, const model_element_type& _type, + const event_ids& _deferred_events = event_ids() ); + virtual ~state_model_impl() SX_NOEXCEPT; + SX_NO_COPY( state_model_impl ) + //!\brief Get the list of transitions of the state. + virtual raw_const_transition_models get_transitions() const SX_OVERRIDE; + //!\brief Get the list of IDs of deferred events. + virtual const event_ids& get_deferred_events() const SX_OVERRIDE; + + +private: + transition_models transitions_; + event_ids deferred_events_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/terminate_pseudostate_model.hpp b/yasmine_model/include/terminate_pseudostate_model.hpp new file mode 100644 index 0000000..3a0f642 --- /dev/null +++ b/yasmine_model/include/terminate_pseudostate_model.hpp @@ -0,0 +1,57 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TERMINATE_PSEUDOSTATE_MODEL_97493430_4F5E_4EA7_B152_E1E38C11C470 +#define TERMINATE_PSEUDOSTATE_MODEL_97493430_4F5E_4EA7_B152_E1E38C11C470 + + +#include "pseudostate_model.hpp" +#include "terminate_pseudostate_model_fwd.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface terminate_pseudostate_model +//!\brief Interface for a terminate pseudostate in the model. +class terminate_pseudostate_model: public virtual pseudostate_model +{ +public: + terminate_pseudostate_model() + { + // Nothing to do... + } + + + virtual ~terminate_pseudostate_model() SX_NOEXCEPT SX_OVERRIDE + { + // Nothing to do... + } + + + SX_NO_COPY( terminate_pseudostate_model ) + + +private: +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/terminate_pseudostate_model_fwd.hpp b/yasmine_model/include/terminate_pseudostate_model_fwd.hpp new file mode 100644 index 0000000..8717a37 --- /dev/null +++ b/yasmine_model/include/terminate_pseudostate_model_fwd.hpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TERMINATE_PSEUDOSTATE_MODEL_FWD_FB36F386_39E6_42C2_A689_E6BAD7D78738 +#define TERMINATE_PSEUDOSTATE_MODEL_FWD_FB36F386_39E6_42C2_A689_E6BAD7D78738 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class terminate_pseudostate_model; + + +typedef sxe::SX_UNIQUE_PTR terminate_pseudostate_model_uptr; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/terminate_pseudostate_model_impl.hpp b/yasmine_model/include/terminate_pseudostate_model_impl.hpp new file mode 100644 index 0000000..160f3f1 --- /dev/null +++ b/yasmine_model/include/terminate_pseudostate_model_impl.hpp @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TERMINATE_PSEUDOSTATE_MODEL_IMPL_F473E031_5035_4D29_ACBD_2F292A9BC6F8 +#define TERMINATE_PSEUDOSTATE_MODEL_IMPL_F473E031_5035_4D29_ACBD_2F292A9BC6F8 + + +#include "terminate_pseudostate_model.hpp" +#include "pseudostate_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class model_vertex_visitor; + + +//!\class terminate_pseudostate_model_impl +//!\brief A terminate pseudostate in the model. +class terminate_pseudostate_model_impl SX_FINAL: + public virtual terminate_pseudostate_model, public pseudostate_model_impl +{ + + +public: + //!\brief Constructor. + //!\param _name Name of the terminate pseudostate. + explicit terminate_pseudostate_model_impl( const std::string& _name ); + virtual ~terminate_pseudostate_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( terminate_pseudostate_model_impl ) + virtual void accept( model_vertex_visitor& _constructor_visitor ) const SX_OVERRIDE; +}; + + + +} + + +} + + +#endif diff --git a/yasmine_model/include/transition_model.hpp b/yasmine_model/include/transition_model.hpp new file mode 100644 index 0000000..4c1bc39 --- /dev/null +++ b/yasmine_model/include/transition_model.hpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TRANSITION_MODEL_6ACABA37_E084_4091_8DAE_51878E9A3D54 +#define TRANSITION_MODEL_6ACABA37_E084_4091_8DAE_51878E9A3D54 + + +#include "state_machine_element_model.hpp" +#include "transition_model_fwd.hpp" +#include "transition_model_kind.hpp" +#include "event_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\interface transition_model +//!\brief Interface for a transition in the model. +class transition_model: public virtual state_machine_element_model +{ +public: + transition_model() + { + // Nothing to do... + } + + + virtual ~transition_model() SX_NOEXCEPT + { + // Nothing to do... + } + + + SX_NO_COPY( transition_model ) + virtual transition_model_kind get_kind() const = 0; + virtual const std::string& get_behavior() const = 0; + virtual const std::string& get_guard() const = 0; + virtual const sxe::uri& get_source() const = 0; + virtual const sxe::uri& get_target() const = 0; + virtual const event_ids& get_event_ids() const = 0; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/transition_model_fwd.hpp b/yasmine_model/include/transition_model_fwd.hpp new file mode 100644 index 0000000..52a79c4 --- /dev/null +++ b/yasmine_model/include/transition_model_fwd.hpp @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TRANSITION_MODEL_FWD_4026F90C_A4BE_4D2E_86C9_61B0A3CB98D3 +#define TRANSITION_MODEL_FWD_4026F90C_A4BE_4D2E_86C9_61B0A3CB98D3 + + +#include + +#include "essentials/compatibility/compatibility.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +class transition_model; + + +typedef sxe::SX_UNIQUE_PTR transition_model_uptr; +typedef std::vector transition_models; +typedef std::vector raw_const_transition_models; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/transition_model_impl.hpp b/yasmine_model/include/transition_model_impl.hpp new file mode 100644 index 0000000..68769b1 --- /dev/null +++ b/yasmine_model/include/transition_model_impl.hpp @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef TRANSITION_MODEL_IMPL_6EA9FC2E_FBED_4750_9D48_532B7A0FFAC2 +#define TRANSITION_MODEL_IMPL_6EA9FC2E_FBED_4750_9D48_532B7A0FFAC2 + + +#include "transition_model.hpp" + +#include "essentials/uri.hpp" + +#include "state_machine_element_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +//!\class transition_model +//!\brief A transition in the model. +class transition_model_impl: + public virtual transition_model, public state_machine_element_model_impl +{ +public: + //!\brief Constructor. + //!\param _name Name of the transition. + //!\param _source_uri Uri of the source vertex. + //!\param _target_uri Uri of the target vertex. + //!\param _king Transition kind. + //!\param _behavior Behavior of the transition.. + //!\param _guard Guard of the transition. + //!\param _events List of IDs of events. + transition_model_impl( const std::string& _name, const sxe::uri& _source_uri, const sxe::uri& _target_uri, + const transition_model_kind _kind, const std::string& _behavior, const std::string& _guard, + const event_ids& _events ); + virtual ~transition_model_impl() SX_NOEXCEPT SX_OVERRIDE; + SX_NO_COPY( transition_model_impl ) + virtual transition_model_kind get_kind() const SX_OVERRIDE; + + //!\brief Get the behavior of the transition. + //!\return String behavior of the transition. + virtual const std::string& get_behavior() const SX_OVERRIDE; + //!\brief Get the guard of the transition. + //!\return String guard of the transition. + virtual const std::string& get_guard() const SX_OVERRIDE; + //!\brief Get the URI of the transition's source vertex. + virtual const sxe::uri& get_source() const SX_OVERRIDE; + //!\brief Set the URI of the transition's source vertex. + virtual const sxe::uri& get_target() const SX_OVERRIDE; + //!\brief Get the List of IDs of transition's events. + const event_ids& get_event_ids() const SX_OVERRIDE; + + +private: + const sxe::uri source_; + const sxe::uri target_; + const transition_model_kind kind_; + const std::string behavior_; + const std::string guard_; + const event_ids events_; +}; + + +} + + +} + + +#endif diff --git a/yasmine_model/include/transition_model_kind.hpp b/yasmine_model/include/transition_model_kind.hpp new file mode 100644 index 0000000..99b419a --- /dev/null +++ b/yasmine_model/include/transition_model_kind.hpp @@ -0,0 +1,96 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef TRANSITION_MODEL_KIND_BD2A7DB6_BB45_4A4C_A6AA_5F3A3ECA8532 +#define TRANSITION_MODEL_KIND_BD2A7DB6_BB45_4A4C_A6AA_5F3A3ECA8532 + + +#include + + +namespace sxy +{ + + +namespace model +{ + + +#ifndef SX_CPP03_BOOST + + + enum class transition_model_kind + { + EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 + }; + + +#else + + + struct transition_model_kind + { + + enum inner + { + EXTERNAL = 0, INTERNAL = 1, LOCAL = 2 + }; + + + // cppcheck-suppress noExplicitConstructor + transition_model_kind() : value_( EXTERNAL ) + { + // Nothing to do... + } + + + // cppcheck-suppress noExplicitConstructor + transition_model_kind( const inner _value ) : value_( _value ) + { + // Nothing to do... + } + + + // cppcheck-suppress functionConst + operator inner() + { + return ( value_ ); + } + + + inner value_; + + }; + +#endif + + +std::string to_string( const transition_model_kind _kind ); + + +#ifdef SX_CPP03_BOOST + + +bool operator==( const transition_model_kind& _lhs, const transition_model_kind::inner _rhs ); +bool operator==( const transition_model_kind::inner _lhs, const transition_model_kind& _rhs ); +bool operator<( const transition_model_kind _lhs, const transition_model_kind _rhs ); + + + +#endif + +} + + +} + + +#endif diff --git a/yasmine_model/source/choice_model_impl.cpp b/yasmine_model/source/choice_model_impl.cpp new file mode 100644 index 0000000..f7db37c --- /dev/null +++ b/yasmine_model/source/choice_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "choice_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +choice_model_impl::choice_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_CHOICE ) +{ + // Nothing to do... +} + + +choice_model_impl::~choice_model_impl()SX_NOEXCEPT +{ + // Nothing to do... +} + + +void choice_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/composite_state_model_impl.cpp b/yasmine_model/source/composite_state_model_impl.cpp new file mode 100644 index 0000000..6a1042e --- /dev/null +++ b/yasmine_model/source/composite_state_model_impl.cpp @@ -0,0 +1,132 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "composite_state_model_impl.hpp" + +#include "pseudostate_model.hpp" +#include "model_vertex_visitor.hpp" +#include "model_element_type.hpp" +#include "region_model.hpp" +#include "essentials/base.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +composite_state_model_impl::composite_state_model_impl( const std::string& _name, const std::string& _enter_behavior, + const std::string& _exit_behavior, const event_ids& _deferred_events ) + : state_model_impl( _name, model_element_type::TYE_COMPOSITE_STATE, _deferred_events ), + enter_behavior_( _enter_behavior ), + do_behavior_( "" ), + exit_behavior_( _exit_behavior ), + regions_(), + state_pseudostates_() +{ + // Nothing to do... +} + + +composite_state_model_impl::~composite_state_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const std::string& composite_state_model_impl::get_do_behavior() const +{ + return( do_behavior_ ); +} + + +void composite_state_model_impl::set_do_behavior( const std::string& _do_behavior ) +{ + SX_UNUSED_PARAMETER( _do_behavior ); +} + + +const std::string& composite_state_model_impl::get_enter_behavior() const +{ + return( enter_behavior_ ); +} + + +void composite_state_model_impl::set_enter_behavior( const std::string& _enter_behavior ) +{ + enter_behavior_ = _enter_behavior; +} + + +const std::string& composite_state_model_impl::get_exit_behavior() const +{ + return( exit_behavior_ ); +} + + +void composite_state_model_impl::set_exit_behavior( const std::string& _exit_behavior ) +{ + exit_behavior_ = _exit_behavior; +} + + +const raw_const_region_models composite_state_model_impl::get_regions() const +{ + raw_const_region_models regions; + if( !regions_.empty() ) + { + SX_FOR( const region_model_uptr ®ion, regions_ ) + { + regions.push_back( region.get() ); + } + } + + return( regions ); +} + + +void composite_state_model_impl::add_region( region_model_uptr _region ) +{ + _region->set_parent( this ); + regions_.push_back( sxe::move( _region ) ); +} + + +raw_const_pseduostate_models composite_state_model_impl::get_state_pseudostates() const +{ + raw_const_pseduostate_models pseudostates; + SX_FOR( const pseudostate_model_uptr &pseudostate, state_pseudostates_ ) + { + pseudostates.push_back( pseudostate.get() ); + } + return( pseudostates ); +} + + +void composite_state_model_impl::add_state_pseudostate( pseudostate_model_uptr _pseudostate ) +{ + _pseudostate->set_parent( this ); + state_pseudostates_.push_back( sxe::move( _pseudostate ) ); +} + + +void composite_state_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/consts.cpp b/yasmine_model/source/consts.cpp new file mode 100644 index 0000000..9409d3a --- /dev/null +++ b/yasmine_model/source/consts.cpp @@ -0,0 +1,85 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "consts.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +const char* const JSON_STATE_MACHINE_NODE = "state_machine"; +const char* const JSON_ROOT_NODE = "root"; +const char* const JSON_TRANSITIONS_NODE = "transitions"; +const char* const JSON_NAME_NODE = "name"; +const char* const JSON_TYPE_NODE = "type"; +const char* const JSON_ENTER_BEHAVIOR_NODE = "enter_behavior"; +const char* const JSON_DO_BEHAVIOR_NODE = "do_behavior"; +const char* const JSON_EXIT_BEHAVIOR_NODE = "exit_behavior"; +const char* const JSON_REGIONS_NODE = "regions"; +const char* const JSON_VERTICES_NODE = "vertices"; +const char* const JSON_STATE_PSEUDOSTATES_NODE = "pseudostates"; +const char* const JSON_PSEUDOSTATES_NODE = "pseudostates"; +const char* const JSON_TRANSITION_KIND_NODE = "kind"; +const char* const JSON_TRANSITION_SOURCE_NODE = "source"; +const char* const JSON_TRANSITION_TARGET_NODE = "target"; +const char* const JSON_TRANSITION_GUARD_NODE = "guard"; +const char* const JSON_TRANSITION_BEHAVIOR_NODE = "behavior"; +const char* const JSON_TRANSITION_EVENTS_NODE = "event_name"; +const char* const JSON_DEFERRED_EVENTS = "deferred_event_name"; +const char* const JSON_ERROR_EVENT = "error_event"; +const char* const JSON_EVENT_ID = "ID"; +const char* const JSON_EVENT_NAME = "name"; +const char* const JSON_EVENT_LIST_NODE = "event_list"; +const char* const JSON_EVENT_PRIORITY = "priority"; +const char* const JSON_VERSION = "version"; +const char* const JSON_CURRENT_VERSION_VALUE = "2.0"; +const char* const JSON_VERSION_1 = "1.0"; + + +const std::string TYPE_TRANSITION = "transition"; +const std::string TYPE_SIMPLE_STATE = "simple_state"; +const std::string TYPE_ASYNC_SIMPLE_STATE = "async_simple_state"; +const std::string TYPE_COMPOSITE_STATE = "composite_state"; +const std::string TYPE_FINAL_STATE = "final_state"; +const std::string TYPE_INITIAL_PSEUDOSTATE = "initial_pseudostate"; +const std::string TYPE_TERMINATE_PSEUDOSTATE = "terminate_pseudostate"; +const std::string TYPE_ENTRY_POINT = "entry_point"; +const std::string TYPE_EXIT_POINT = "exit_point"; +const std::string TYPE_DEEP_HISTORY = "deep_history"; +const std::string TYPE_SHALLOW_HISTORY = "shallow_history"; +const std::string TYPE_JOIN = "join"; +const std::string TYPE_JUNCTION = "junction"; +const std::string TYPE_FORK = "fork"; +const std::string TYPE_CHOICE = "choice"; +const std::string TYPE_REGION = "region"; +const std::string TYPE_UNKNOWN = "unknown"; + + +const std::string CONFIG_FILE_IS_CORRUPTED = "Config file is corrupted!"; +const std::string CHOOSE_FILE_TEXT = "Select log file"; +const std::string FILE_CANNOT_BE_OPENED = "File cannot be opened!"; +const std::string PATH_CONFIG_JSON_FILE = "path_config.json"; +const std::string CHOOSE_FILE_TYPE = "file (*.*);;"; +const std::string CHOOSE_FILE_TEXT_SAVE = "Select file to save data"; +const std::string CHOOSE_FILE_DEFAULT_SAVING_NAME = "state_machine.json"; +const std::string CHOOSE_FILE_TYPE_SAVE = "all files (*.*);;"; + + +const char* const TRANSITION_MUST_BE_IN_JSON_ARRAY = "Transitions from the json file are not in an array!"; + +} + + +} diff --git a/yasmine_model/source/deep_history_model_impl.cpp b/yasmine_model/source/deep_history_model_impl.cpp new file mode 100644 index 0000000..5a38334 --- /dev/null +++ b/yasmine_model/source/deep_history_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "deep_history_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +deep_history_model_impl::deep_history_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_DEEP_HISTORY ) +{ + // Nothing to do... +} + + +deep_history_model_impl::~deep_history_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void deep_history_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/entry_point_model_impl.cpp b/yasmine_model/source/entry_point_model_impl.cpp new file mode 100644 index 0000000..1d41a22 --- /dev/null +++ b/yasmine_model/source/entry_point_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "entry_point_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +entry_point_model_impl::entry_point_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_ENTRY_POINT ) +{ + // Nothing to do... +} + + +entry_point_model_impl::~entry_point_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void entry_point_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/event_model.cpp b/yasmine_model/source/event_model.cpp new file mode 100644 index 0000000..4aa5a26 --- /dev/null +++ b/yasmine_model/source/event_model.cpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "event_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + + event_model::event_model() + : name(), + id(), + priority() + { + // Nothing to do... + } + + + event_model::event_model( const std::string _name, const event_id _id, const event_priority _priority ) + : name( _name ), + id( _id ), + priority( _priority ) + { + // Nothing to do... + } + + + event_model::~event_model() SX_NOEXCEPT + { + // Nothing to do... + } + + +} + + +} diff --git a/yasmine_model/source/event_model_id.cpp b/yasmine_model/source/event_model_id.cpp new file mode 100644 index 0000000..c5d9bd9 --- /dev/null +++ b/yasmine_model/source/event_model_id.cpp @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifdef SX_CPP03_BOOST + + +#include "event_model_id.hpp" + +namespace sxy +{ + + +namespace model +{ + + const event_id Y_MODEL_COMPLETION_EVENT_ID = std::numeric_limits::max(); + +} + + +} + +#else + + +#include "event_model_id.hpp" + +namespace sxy +{ + + + namespace model + { + + const event_id Y_MODEL_COMPLETION_EVENT_ID = std::numeric_limits::max(); + + } + + +} + + +#endif diff --git a/yasmine_model/source/exit_point_model_impl.cpp b/yasmine_model/source/exit_point_model_impl.cpp new file mode 100644 index 0000000..a377ffb --- /dev/null +++ b/yasmine_model/source/exit_point_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "exit_point_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +exit_point_model_impl::exit_point_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_EXIT_POINT ) +{ + // Nothing to do... +} + + +exit_point_model_impl::~exit_point_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void exit_point_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/final_state_model_impl.cpp b/yasmine_model/source/final_state_model_impl.cpp new file mode 100644 index 0000000..b3d87f6 --- /dev/null +++ b/yasmine_model/source/final_state_model_impl.cpp @@ -0,0 +1,92 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "final_state_model_impl.hpp" + +#include "essentials/base.hpp" + +#include "model_vertex_visitor.hpp" +#include "model_element_type.hpp" + + +namespace sxy +{ + + +namespace model +{ + +final_state_model_impl::final_state_model_impl( const std::string& _name ) + : state_model_impl( _name, model_element_type::TYE_FINAL_STATE ), + no_behavior_("") +{ + // Nothing to do... +} + + +final_state_model_impl::~final_state_model_impl()SX_NOEXCEPT +{ + // Nothing to do... +} + + +const raw_const_region_models final_state_model_impl::get_regions() const +{ + raw_const_region_models regions; + return( regions ); +} + + +const std::string& final_state_model_impl::get_enter_behavior() const +{ + return( no_behavior_ ); +} + + +void final_state_model_impl::set_enter_behavior( const std::string& _enter_behavior ) +{ + SX_UNUSED_PARAMETER( _enter_behavior ); +} + + +const std::string& final_state_model_impl::get_do_behavior() const +{ + return( no_behavior_ ); +} + + +void final_state_model_impl::set_do_behavior( const std::string& _do_behavior ) +{ + SX_UNUSED_PARAMETER( _do_behavior ); +} + + +const std::string& final_state_model_impl::get_exit_behavior() const +{ + return( no_behavior_ ); +} + + +void final_state_model_impl::set_exit_behavior( const std::string& _exit_behavior ) +{ + SX_UNUSED_PARAMETER( _exit_behavior ); +} + + +void final_state_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/fork_model_impl.cpp b/yasmine_model/source/fork_model_impl.cpp new file mode 100644 index 0000000..89bcea5 --- /dev/null +++ b/yasmine_model/source/fork_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "fork_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +fork_model_impl::fork_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_FORK ) +{ + // Nothing to do... +} + + +fork_model_impl::~fork_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void fork_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/initial_pseudostate_model_impl.cpp b/yasmine_model/source/initial_pseudostate_model_impl.cpp new file mode 100644 index 0000000..9a08602 --- /dev/null +++ b/yasmine_model/source/initial_pseudostate_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "initial_pseudostate_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +initial_pseudostate_model_impl::initial_pseudostate_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_INITIAL_PSEUDOSTATE ) +{ + // Nothing to do... +} + + +initial_pseudostate_model_impl::~initial_pseudostate_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void initial_pseudostate_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/join_model_impl.cpp b/yasmine_model/source/join_model_impl.cpp new file mode 100644 index 0000000..1341114 --- /dev/null +++ b/yasmine_model/source/join_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "join_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +join_model_impl::join_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_JOIN ) +{ + // Nothing to do... +} + + +join_model_impl::~join_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void join_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/json_parser_helper.cpp b/yasmine_model/source/json_parser_helper.cpp new file mode 100644 index 0000000..4f14474 --- /dev/null +++ b/yasmine_model/source/json_parser_helper.cpp @@ -0,0 +1,139 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "json_parser_helper.hpp" + +#include "model_exception.hpp" + + +namespace sxy +{ + + +std::string get_object_member_string( const rapidjson::Value& _obj, const char* const _name_of_member ) +{ + std::string found_value = ""; + if( _obj.IsObject() ) + { + const rapidjson::Value& found_member = find_member( _obj, _name_of_member ); + if( found_member.IsString() ) + { + found_value = found_member.GetString(); + } + else + { + throw model::exception( "Member % is not a string type!", _name_of_member ); + } + } + + return( found_value ); +} + + +sxe::int64_t get_object_member_int( const rapidjson::Value& _obj, const char* const _name_of_member ) +{ + int found_value = 0; + if( _obj.IsObject() ) + { + const rapidjson::Value& found_member = find_member( _obj, _name_of_member ); + if( found_member.IsInt64() ) + { + found_value = found_member.GetInt64(); + } + else + { + throw model::exception( "Member % is not a Int64 type!", _name_of_member ); + } + } + + return( found_value ); +} + + +const rapidjson::Value& get_object_member_array( const rapidjson::Value& _obj, const char* const _name_of_member ) +{ + const rapidjson::Value& array_object = _obj.MemberBegin()->value; + if( _obj.IsObject() ) + { + const rapidjson::GenericMemberIterator< true, rapidjson::UTF8< >, rapidjson::MemoryPoolAllocator< > > member + = _obj.FindMember( _name_of_member ); + if( member != _obj.MemberEnd() ) + { + if( member->value.IsArray() ) + { + return( _obj.FindMember( _name_of_member )->value ); + } + else + { + throw model::exception( "Member % is not an array!", _name_of_member ); + } + } + else + { + throw model::exception( "Member % was not found!", _name_of_member ); + } + } + + return( array_object ); +} + + +std::vector< const rapidjson::Value* > extract_members_from_array( const rapidjson::Value& _array ) +{ + std::vector< const rapidjson::Value* > array_of_values; + if( _array.IsArray() ) + { + for( rapidjson::Value::ConstValueIterator itr = _array.Begin(); itr != _array.End(); ++itr ) + { + array_of_values.push_back( &*itr ); + } + } + + return( array_of_values ); +} + + +void string_to_json( const char* const _json_as_string, rapidjson::Document& _document ) +{ + _document.Parse< 0 >( _json_as_string ); +} + + +const rapidjson::Value& find_member( const rapidjson::Value& _member, const char* const _name ) +{ + if( _member.HasMember( _name ) ) + { + if( _member.FindMember( _name ) == _member.MemberEnd() ) + { + throw sxy::model::exception( "Member % not found!", _name ); + } + } + else + { + throw sxy::model::exception( "Member % not found!", _name ); + } + + return( _member.FindMember( _name )->value ); +} + + +const rapidjson::Value& find_object_member( const rapidjson::Value& _document, const char* const _name ) +{ + const rapidjson::Value& found_member = find_member( _document, _name ); + if( !found_member.IsObject() ) + { + throw sxy::model::exception( "Member % is not an object!", _name ); + } + + return( found_member ); +} + + +} diff --git a/yasmine_model/source/json_reader.cpp b/yasmine_model/source/json_reader.cpp new file mode 100644 index 0000000..eedad03 --- /dev/null +++ b/yasmine_model/source/json_reader.cpp @@ -0,0 +1,594 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "json_reader.hpp" + +#include +#include + +#include "essentials/base.hpp" +#include "essentials/exception.hpp" +#include "essentials/uri.hpp" + +#include "consts.hpp" +#include "model_element_type.hpp" +#include "json_parser_helper.hpp" +#include "composite_state_model_impl.hpp" +#include "simple_state_model_impl.hpp" +#include "final_state_model_impl.hpp" +#include "state_machine_model.hpp" +#include "region_model_impl.hpp" +#include "pseudostate_model_impl.hpp" +#include "entry_point_model_impl.hpp" +#include "exit_point_model_impl.hpp" +#include "deep_history_model_impl.hpp" +#include "shallow_history_model_impl.hpp" +#include "initial_pseudostate_model_impl.hpp" +#include "join_model_impl.hpp" +#include "junction_model_impl.hpp" +#include "fork_model_impl.hpp" +#include "terminate_pseudostate_model_impl.hpp" +#include "choice_model_impl.hpp" +#include "transition_model_impl.hpp" +#include "model_exception.hpp" + + +namespace sxy +{ + + +json_reader::json_reader( const std::string& _file ) + : document_(), + model_() +{ + read_json_file( _file ); + check_document(); + model_ = read_into_model(); +} + + +json_reader::~json_reader() SX_NOEXCEPT +{ + // Nothing to do... +} + + +model::state_machine_model_ptr json_reader::get_model_ptr() +{ + return( sxe::move( model_ ) ); +} + + +void json_reader::read_json_file( const std::string& _file ) +{ + +#ifndef SX_CPP03_BOOST + std::ifstream infile( _file, std::ios::in ); +#else + std::ifstream infile( _file.c_str(), std::ios::in ); +#endif + + if( infile.is_open() ) + { + std::stringstream strStream; + strStream << infile.rdbuf(); + infile.close(); + string_to_json( strStream.str().c_str(), document_ ); + } + else + { + throw sxe::exception( "File % can't be opened!", _file ); + } +} + + +model::state_machine_model_ptr json_reader::read_into_model() +{ + model::state_machine_model_ptr sm_model = SX_MAKE_UNIQUE< model::state_machine_model >(); + const rapidjson::Value& object_member = find_object_member( document_, model::JSON_STATE_MACHINE_NODE ); + const rapidjson::Value& root = find_object_member( object_member, model::JSON_ROOT_NODE ); + sm_model->add_root_state( read_composite_state( root ) ); + std::vector transitions_list = + extract_members_from_array( get_object_member_array( object_member, model::JSON_TRANSITIONS_NODE ) ); + + SX_FOR( const rapidjson::Value* json_transition , transitions_list ) + { + model::transition_model_uptr transition = read_transition( *json_transition ); + sm_model->add_transition( sxe::move( transition ) ); + } + + get_event_list( sm_model ); + + return( sxe::move( sm_model ) ); +} + + +sxy::model::event_ids json_reader::read_deferred_events( const rapidjson::Value& _state ) const +{ + std::vector deferred_event_list = + extract_members_from_array( get_object_member_array( _state, model::JSON_DEFERRED_EVENTS ) ); + + sxy::model::event_ids deferred_events; + SX_FOR( const rapidjson::Value* const an_event, deferred_event_list ) + { + const std::string event_name = get_object_member_string( sxe::ref( *an_event ), model::JSON_EVENT_NAME ); + sxy::model::event_id event_id = get_event_id_by_name( event_name ); + deferred_events.push_back( event_id ); + } + return( deferred_events ); +} + + +model::composite_state_model_uptr json_reader::read_composite_state( const rapidjson::Value& _root ) +{ + std::string name = get_object_member_string( sxe::ref(_root), model::JSON_NAME_NODE ); + std::string enter_behavior_string = get_object_member_string( sxe::ref( _root), model::JSON_ENTER_BEHAVIOR_NODE ); + std::string exit_behavior_string = get_object_member_string( sxe::ref( _root), model::JSON_EXIT_BEHAVIOR_NODE ); + sxe::SX_UNIQUE_PTR< model::composite_state_model_impl > one_composite_state = + SX_MAKE_UNIQUE< model::composite_state_model_impl >( name, enter_behavior_string, + exit_behavior_string, read_deferred_events( _root ) ); + std::vector json_regions = + extract_members_from_array( get_object_member_array( _root, model::JSON_REGIONS_NODE ) ); + + SX_FOR( const rapidjson::Value* one_region , json_regions ) + { + model::region_model_impl_uptr region = read_region( *one_region ); + one_composite_state->add_region( sxe::move( region ) ); + } + + std::vector json_state_pseudostates = + extract_members_from_array( get_object_member_array( _root, model::JSON_STATE_PSEUDOSTATES_NODE ) ); + + SX_FOR( const rapidjson::Value* one_state_pseudostate, json_state_pseudostates ) + { + model::pseudostate_model_uptr state_pseudostate = read_state_pseudostate( *one_state_pseudostate ); + one_composite_state->add_state_pseudostate( sxe::move( state_pseudostate ) ); + } + + return( sxe::move( one_composite_state ) ); +} + + +model::simple_state_model_uptr json_reader::read_simple_state( const rapidjson::Value& _state, bool _is_async ) +{ + std::string name = get_object_member_string( sxe::ref( _state), model::JSON_NAME_NODE ); + std::string enter_behavior = get_object_member_string( sxe::ref( _state), model::JSON_ENTER_BEHAVIOR_NODE ); + std::string do_behavior = get_object_member_string( sxe::ref( _state), model::JSON_DO_BEHAVIOR_NODE ); + std::string exit_behavior = get_object_member_string( sxe::ref( _state), model::JSON_EXIT_BEHAVIOR_NODE ); + sxy::model::event_sptr error_event = sxy::model::event_sptr(); + try + { + const std::string behavior_exception_event = get_object_member_string( _state, model::JSON_ERROR_EVENT ); + if( !behavior_exception_event.empty() ) + { + const sxy::model::event_id behavior_exception_event_id = get_event_id_by_name( behavior_exception_event ); + const sxy::model::event_priority behavior_exception_event_priority = + get_event_priority_by_name( behavior_exception_event ); + error_event = SX_MAKE_SHARED( behavior_exception_event, behavior_exception_event_id, + behavior_exception_event_priority ); + } + } + catch ( ... ) + { + // Nothing to do... + } + sxe::SX_UNIQUE_PTR< model::simple_state_model_impl > simple_state = + SX_MAKE_UNIQUE< model::simple_state_model_impl >( name, enter_behavior, + do_behavior, exit_behavior, read_deferred_events( _state ), error_event, _is_async ); + return( sxe::move( simple_state ) ); +} + + +model::final_state_model_uptr json_reader::read_final_state( const rapidjson::Value& _state ) +{ + std::string name = get_object_member_string( sxe::ref( _state), model::JSON_NAME_NODE ); + sxe::SX_UNIQUE_PTR< model::final_state_model_impl > final_state = + SX_MAKE_UNIQUE< model::final_state_model_impl >( name ); + return( sxe::move( final_state ) ); +} + + +model::region_model_impl_uptr json_reader::read_region( const rapidjson::Value& _region ) +{ + const std::string name = get_object_member_string( sxe::ref( _region), model::JSON_NAME_NODE ); + sxe::SX_UNIQUE_PTR< model::region_model_impl > region = + SX_MAKE_UNIQUE< model::region_model_impl >( name ); + std::vector vertices = + extract_members_from_array( get_object_member_array( _region, model::JSON_VERTICES_NODE ) ); + + SX_FOR( const rapidjson::Value* vertice, vertices ) + { + sxy::model::model_element_type vertice_type = model::model_element_type_from_string( get_object_member_string( sxe::ref( *vertice ), + model::JSON_TYPE_NODE ) ); + + if( vertice_type == sxy::model::model_element_type::TYE_SIMPLE_STATE || + vertice_type == sxy::model::model_element_type::TYE_ASYNC_SIMPLE_STATE || + vertice_type == sxy::model::model_element_type::TYE_COMPOSITE_STATE || + vertice_type == sxy::model::model_element_type::TYE_FINAL_STATE ) + { + sxy::model::state_model_uptr state = read_state( *vertice ); + region->add_state( sxe::move( state ) ); + } + else + { + sxy::model::pseudostate_model_uptr pseudostate = read_pseudostate( *vertice ); + region->add_pseudostate( sxe::move( pseudostate ) ); + } + } + + return( sxe::move( region ) ); +} + + +model::state_model_uptr json_reader::read_state( const rapidjson::Value& _state ) +{ + model::state_model_uptr state; + + const model::model_element_type state_type = model::model_element_type_from_string( get_object_member_string( sxe::ref( _state ), + model::JSON_TYPE_NODE ) ); +#ifndef SX_CPP03_BOOST + switch( state_type ) +#else + switch( state_type.value_ ) +#endif + { + case model::model_element_type::TYE_SIMPLE_STATE: + { + state = read_simple_state( _state ); + break; + } + + case model::model_element_type::TYE_ASYNC_SIMPLE_STATE: + { + state = read_simple_state( _state, true ); + break; + } + + case model::model_element_type::TYE_COMPOSITE_STATE: + { + state = read_composite_state( _state ); + break; + } + + case model::model_element_type::TYE_FINAL_STATE: + { + state = read_final_state( _state ); + break; + } + + default: + { + throw sxe::exception( "The element % in the array of states, is not a state!", + get_object_member_string( sxe::ref(_state), model::JSON_NAME_NODE ) ); + } + } + + return( state ); +} + + +model::pseudostate_model_uptr json_reader::read_state_pseudostate( const rapidjson::Value& _state_pseudostate ) +{ + model::pseudostate_model_uptr pseudostate; + + switch( model::model_element_type_from_string( get_object_member_string( sxe::ref( _state_pseudostate), model::JSON_TYPE_NODE ) ) ) + { + case model::model_element_type::TYE_ENTRY_POINT: + { + pseudostate = read_entry_point( _state_pseudostate ); + break; + } + + case model::model_element_type::TYE_EXIT_POINT: + { + pseudostate = read_exit_point( _state_pseudostate ); + break; + } + + case model::model_element_type::TYE_DEEP_HISTORY: + { + pseudostate = read_deep_history( _state_pseudostate ); + break; + } + + case model::model_element_type::TYE_SHALLOW_HISTORY: + { + pseudostate = read_shallow_history( _state_pseudostate ); + break; + } + + default: + { + throw sxe::exception( "The element % in the array of state-pseudostates, is not a state pseudostate!", + get_object_member_string( sxe::ref( _state_pseudostate), model::JSON_NAME_NODE ) ); + } + } + + return( pseudostate ); +} + + +model::pseudostate_model_uptr json_reader::read_pseudostate( const rapidjson::Value& _pseudostate ) +{ + model::pseudostate_model_uptr pseudostate; + + switch( model::model_element_type_from_string( get_object_member_string( sxe::ref( _pseudostate), model::JSON_TYPE_NODE ) ) ) + { + case model::model_element_type::TYE_JOIN: + { + pseudostate = read_join( _pseudostate ); + break; + } + + case model::model_element_type::TYE_JUNCTION: + { + pseudostate = read_junction( _pseudostate ); + break; + } + + case model::model_element_type::TYE_INITIAL_PSEUDOSTATE: + { + pseudostate = read_initial_pseudostate( _pseudostate ); + break; + } + + case model::model_element_type::TYE_TERMINATE_PSEUDOSTATE: + { + pseudostate = read_terminate_pseudostate( _pseudostate ); + break; + } + + case model::model_element_type::TYE_CHOICE: + { + pseudostate = read_choice( _pseudostate ); + break; + } + + case model::model_element_type::TYE_FORK: + { + pseudostate = read_fork( _pseudostate ); + break; + } + + default: + { + throw sxe::exception( "The element % in the array of states, is not a state!", + get_object_member_string( sxe::ref( _pseudostate), model::JSON_NAME_NODE ) ); + } + } + + return( sxe::move( pseudostate ) ); +} + + +model::initial_pseudostate_model_uptr json_reader::read_initial_pseudostate( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::initial_pseudostate_model_impl >( _pseudostate ) ); +} + + +model::join_model_uptr json_reader::read_join( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::join_model_impl >( _pseudostate ) ); +} + + +model::fork_model_uptr json_reader::read_fork( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::fork_model_impl >( _pseudostate ) ); +} + + +model::choice_model_uptr json_reader::read_choice( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::choice_model_impl >( _pseudostate ) ); +} + + +model::junction_model_uptr json_reader::read_junction( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::junction_model_impl >( _pseudostate ) ); +} + + +model::terminate_pseudostate_model_uptr json_reader::read_terminate_pseudostate( + const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::terminate_pseudostate_model_impl >( _pseudostate ) ); +} + + +model::deep_history_model_uptr json_reader::read_deep_history( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::deep_history_model_impl >( _pseudostate ) ); +} + + +model::shallow_history_model_uptr json_reader::read_shallow_history( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::shallow_history_model_impl >( _pseudostate ) ); +} + + +model::entry_point_model_uptr json_reader::read_entry_point( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::entry_point_model_impl >( _pseudostate ) ); +} + + +model::exit_point_model_uptr json_reader::read_exit_point( const rapidjson::Value& _pseudostate ) +{ + return( function_read_pseudostate< model::exit_point_model_impl >( _pseudostate ) ); +} + + +model::transition_model_uptr json_reader::read_transition( const rapidjson::Value& _transition ) +{ + const std::string name = get_object_member_string( sxe::ref( _transition), model::JSON_NAME_NODE ); + sxe::int64_t json_transition_kind = get_object_member_int( sxe::ref( _transition ), model::JSON_TRANSITION_KIND_NODE ); + const std::string source_vertex = + get_object_member_string( sxe::ref( _transition ), model::JSON_TRANSITION_SOURCE_NODE ); + const std::string target_vertex = + get_object_member_string( sxe::ref( _transition ), model::JSON_TRANSITION_TARGET_NODE ); + const std::string transition_guard = + get_object_member_string( sxe::ref( _transition ), model::JSON_TRANSITION_GUARD_NODE ); + const std::string transition_behavior = + get_object_member_string( sxe::ref( _transition ), model::JSON_TRANSITION_BEHAVIOR_NODE ); + std::vector events_list = + extract_members_from_array( get_object_member_array( _transition, model::JSON_TRANSITION_EVENTS_NODE ) ); + sxy::model::event_ids events; + + SX_FOR( const rapidjson::Value* one_event, events_list ) + { + if( one_event->IsObject() ) + { + const std::string event_name = get_object_member_string( sxe::ref( *one_event ), model::JSON_EVENT_NAME ); + sxe::int64_t event_id = get_event_id_by_name( event_name ); + events.push_back( event_id ); + } + else + { + throw sxe::exception( "Event is not an JSON object! Structure is broken." ); + } + + } + + sxy::model::transition_model_kind kind = get_transition_kind( json_transition_kind ); + sxe::SX_UNIQUE_PTR< model::transition_model_impl > transition = + SX_MAKE_UNIQUE< model::transition_model_impl >( name, sxe::uri( source_vertex ), sxe::uri( target_vertex ), + kind, transition_behavior, transition_guard, events ); + return( sxe::move( transition ) ); +} + + +sxy::model::transition_model_kind json_reader::get_transition_kind( unsigned int _kind ) +{ + sxy::model::transition_model_kind kind( sxy::model::transition_model_kind::EXTERNAL ); + switch( _kind ) + { + case 0: + kind = sxy::model::transition_model_kind::EXTERNAL; + break; + + case 1: + kind = sxy::model::transition_model_kind::INTERNAL; + break; + + case 2: + kind = sxy::model::transition_model_kind::LOCAL; + break; + + default: + throw sxe::exception( "Transition has no legal kind (LOCAL, EXTERNAL, INTERNAL)." ); + break; + } + + return( kind ); +} + + +sxe::int64_t json_reader::get_event_id_by_name( const std::string& _name ) const +{ + sxe::int64_t event_id = sxy::model::Y_MODEL_COMPLETION_EVENT_ID; + std::vector event_list = + extract_members_from_array( get_object_member_array( document_, model::JSON_EVENT_LIST_NODE ) ); + + SX_FOR( const rapidjson::Value* const an_event, event_list ) + { + const std::string event_name = get_object_member_string( sxe::ref( *an_event ), model::JSON_EVENT_NAME ); + if( event_name == _name ) + { + event_id = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_ID ); + break; + } + } + + return( event_id ); +} + + +sxe::int64_t json_reader::get_event_priority_by_name( const std::string& _name ) const +{ +#ifdef SX_CPP03_BOOST + sxe::int64_t priority ( DEFAULT_EVENT_PRIORITY); +#else + sxe::int64_t priority( sxy::model::DEFAULT_EVENT_PRIORITY ); +#endif + std::vector event_list = + extract_members_from_array( get_object_member_array( document_, model::JSON_EVENT_LIST_NODE ) ); + + SX_FOR( const rapidjson::Value* const an_event, event_list ) + { + const std::string event_name = get_object_member_string( sxe::ref( *an_event ), model::JSON_EVENT_NAME ); + if( event_name == _name ) + { + try + { + priority = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_PRIORITY ); + } + catch( ... ) + { +#ifdef SX_CPP03_BOOST + priority = DEFAULT_EVENT_PRIORITY; +#else + priority = sxy::model::DEFAULT_EVENT_PRIORITY; +#endif + } + break; + } + } + + return( priority ); +} + + + +void json_reader::get_event_list( model::state_machine_model_ptr& _model ) +{ + std::vector event_list = + extract_members_from_array( get_object_member_array( document_, model::JSON_EVENT_LIST_NODE ) ); + + SX_FOR( const rapidjson::Value* const an_event, event_list ) + { + const std::string event_name = get_object_member_string( sxe::ref( *an_event ), model::JSON_EVENT_NAME ); + sxy::model::event_id event_id = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_ID ); +#ifdef SX_CPP03_BOOST + sxy::model::event_priority priority = DEFAULT_EVENT_PRIORITY; +#else + sxy::model::event_priority priority = sxy::model::DEFAULT_EVENT_PRIORITY; +#endif + if( document_.HasMember( model::JSON_VERSION ) ) + { + const std::string json_version = get_object_member_string( document_, model::JSON_VERSION ); + if( json_version != model::JSON_VERSION_1 ) + { + priority = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_PRIORITY ); + } + } + _model->add_event( event_name, event_id, priority ); + } +} + + +void json_reader::check_document() const +{ + if( !document_.IsObject() ) + { + throw model::exception( "Model file is corrupted!" ); + } + + if( document_.ObjectEmpty() ) + { + throw model::exception( "Model file is corrupted!" ); + } +} + + +} diff --git a/yasmine_model/source/json_writer.cpp b/yasmine_model/source/json_writer.cpp new file mode 100644 index 0000000..8b7d05f --- /dev/null +++ b/yasmine_model/source/json_writer.cpp @@ -0,0 +1,375 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "json_writer.hpp" + +#include + +#include "rapidjson/prettywriter.h" + +#include "essentials/exception.hpp" +#include "essentials/base.hpp" + +#include "consts.hpp" +#include "transition_model.hpp" +#include "state_machine_model.hpp" +#include "model_element_type.hpp" +#include "composite_state_model_impl.hpp" +#include "region_model_impl.hpp" +#include "simple_state_model_impl.hpp" +#include "final_state_model_impl.hpp" +#include "pseudostate_model_impl.hpp" +#include "event_model.hpp" + + +namespace sxy +{ + + +json_writer::json_writer( const std::string& _json_file_name, const model::state_machine_model& _state_machine_model ) +{ + write_json_to_file( _json_file_name, _state_machine_model ); +} + + +json_writer::~json_writer()SX_NOEXCEPT +{ + // Nothing to do... +} + + +void json_writer::write_json_to_file( const std::string& _json_file, const model::state_machine_model& _state_machine_model ) +{ + rapidjson::Document doc; + doc.SetObject(); + add_version( doc, doc.GetAllocator() ); + rapidjson::Value json_state_machine( rapidjson::kObjectType ); + + rapidjson::Value json_events( rapidjson::kArrayType ); + add_events_from_model( _state_machine_model, json_events, doc.GetAllocator() ); + doc.AddMember( rapidjson::StringRef( model::JSON_EVENT_LIST_NODE ), json_events, doc.GetAllocator() ); + + rapidjson::Value json_transitions( rapidjson::kArrayType ); + add_transitions_from_model( _state_machine_model, json_transitions, doc.GetAllocator() ); + json_state_machine.AddMember( rapidjson::StringRef( model::JSON_TRANSITIONS_NODE ), json_transitions, doc.GetAllocator() ); + + rapidjson::Value root( rapidjson::kObjectType ); + sxy::model::composite_state_model_impl& root_state = _state_machine_model.get_root_state(); + fill_composite_state_object( root_state, root, doc.GetAllocator() ); + json_state_machine.AddMember( rapidjson::StringRef( model::JSON_ROOT_NODE ), root, doc.GetAllocator() ); + + doc.AddMember( rapidjson::StringRef( model::JSON_STATE_MACHINE_NODE ), json_state_machine, doc.GetAllocator() ); + rapidjson::StringBuffer string_buffer; + rapidjson::PrettyWriter< rapidjson::StringBuffer > writer( string_buffer ); + doc.Accept( writer ); + const char* const json_char = string_buffer.GetString(); + write_text_to_file( json_char, _json_file ); +} + + +void json_writer::write_text_to_file( const char* _json_char, const std::string& _json_file ) +{ +#ifndef SX_CPP03_BOOST + std::ofstream json_file( _json_file, std::ios_base::out ); +#else + std::ofstream json_file( _json_file.c_str(), std::ios_base::out ); +#endif + + if( json_file.is_open() ) + { + json_file << _json_char << std::endl; + json_file.close(); + } + else + { + throw sxe::exception( "File % cannot be opened for writing!", _json_file ); + } +} + + +void json_writer::add_version( rapidjson::Value& _document, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + _document.AddMember( rapidjson::StringRef( model::JSON_VERSION ), + rapidjson::StringRef( model::JSON_CURRENT_VERSION_VALUE ), _allocator ); +} + + +void json_writer::add_events_from_model( const model::state_machine_model& _state_machine_model, + rapidjson::Value& _events, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + SX_FOR( const sxy::model::event_model& an_event, _state_machine_model.get_events() ) + { + const std::string name = an_event.name; + sxy::model::event_id id = an_event.id; + sxy::model::event_priority priority = an_event.priority; + + rapidjson::Value json_event( rapidjson::kObjectType ); + rapidjson::Value name_val; + name_val.SetString( name.c_str(), name.length(), _allocator ); + json_event.AddMember( rapidjson::StringRef( model::JSON_NAME_NODE ), name_val, _allocator ); + json_event.AddMember( rapidjson::StringRef( model::JSON_EVENT_ID ), id, _allocator ); + json_event.AddMember( rapidjson::StringRef( model::JSON_EVENT_PRIORITY ), priority, _allocator ); + + _events.PushBack( json_event.Move(), _allocator ); + } +} + + +void json_writer::add_transitions_from_model( const model::state_machine_model& _state_machine_model, + rapidjson::Value& _transitions, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + SX_FOR( const model::transition_model* transition, _state_machine_model.get_transitions() ) + { + rapidjson::Value json_transition( rapidjson::kObjectType ); + rapidjson::Value name_node; + + json_transition.AddMember( rapidjson::StringRef( model::JSON_NAME_NODE ), + create_rapidjson_string_value( transition->get_name(), name_node ).Move(), _allocator ); + int kind = transition->get_kind() == sxy::model::transition_model_kind::EXTERNAL ? + 0 : ( transition->get_kind() == sxy::model::transition_model_kind::INTERNAL ? 1 : 2 ); + json_transition.AddMember( rapidjson::StringRef( model::JSON_TRANSITION_KIND_NODE ), kind, _allocator ); + const std::string source = transition->get_source().to_string(); + rapidjson::Value source_val; + source_val.SetString( source.c_str(), source.length(), _allocator ); + json_transition.AddMember( rapidjson::StringRef( model::JSON_TRANSITION_SOURCE_NODE ), source_val, _allocator ); + const std::string target = transition->get_target().to_string(); + rapidjson::Value target_val; + target_val.SetString( target.c_str(), target.length(), _allocator ); + json_transition.AddMember( rapidjson::StringRef( model::JSON_TRANSITION_TARGET_NODE ), target_val, _allocator ); + rapidjson::Value json_events( rapidjson::kArrayType ); + + SX_FOR( sxy::model::event_id transition_event_id, transition->get_event_ids() ) + { + rapidjson::Value json_event( rapidjson::kObjectType ); + rapidjson::Value name_val; + const std::string name = get_event_name_by_id( transition_event_id, _state_machine_model ); + name_val.SetString( name.c_str(), name.length(), _allocator ); + json_event.AddMember( rapidjson::StringRef( model::JSON_NAME_NODE ), name_val, _allocator ); + json_events.PushBack( json_event.Move(), _allocator ); + } + + json_transition.AddMember( rapidjson::StringRef( model::JSON_TRANSITION_EVENTS_NODE ), json_events, _allocator ); + rapidjson::Value transition_guard; + json_transition.AddMember( rapidjson::StringRef( model::JSON_TRANSITION_GUARD_NODE ), + create_rapidjson_string_value( transition->get_guard(), transition_guard ).Move(), _allocator ); + rapidjson::Value transition_behavior; + json_transition.AddMember( rapidjson::StringRef( model::JSON_TRANSITION_BEHAVIOR_NODE ), + create_rapidjson_string_value( transition->get_behavior(), transition_behavior ).Move(), _allocator ); + _transitions.PushBack( json_transition.Move(), _allocator ); + } +} + + +void json_writer::add_regions_from_model( const model::composite_state_model& _composite_state_model, + rapidjson::Value& _regions, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + SX_FOR( const sxy::model::region_model* const region, _composite_state_model.get_regions() ) + { + rapidjson::Value json_region( rapidjson::kObjectType ); + fill_region_object( *region, json_region, _allocator ); + if( json_region.IsObject() ) + { + _regions.PushBack( json_region.Move(), _allocator ); + } + } +} + + +void json_writer::fill_region_object( const model::region_model& _region_model, rapidjson::Value& _region, + rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + rapidjson::Value name_node; + _region.AddMember( rapidjson::StringRef( model::JSON_NAME_NODE ), + create_rapidjson_string_value( _region_model.get_name(), name_node ).Move(), _allocator ); + rapidjson::Value json_states( rapidjson::kArrayType ); + + SX_FOR( const sxy::model::state_model* const one_state_model, _region_model.get_states() ) + { + const model::model_element_type type_of_state = one_state_model->get_type(); + +#ifndef SX_CPP03_BOOST + switch( type_of_state ) +#else + switch( type_of_state.value_ ) +#endif + { + case model::model_element_type::TYE_SIMPLE_STATE: + { + const model::simple_state_model_impl* simple_state_model = + dynamic_cast< const model::simple_state_model_impl* >( one_state_model ); + SX_ASSERT( simple_state_model, "Simple state cannot be written to json file!" ); + rapidjson::Value json_state( rapidjson::kObjectType ); + fill_simple_state_object( *simple_state_model, json_state, _allocator ); + json_states.PushBack( json_state, _allocator ); + break; + } + + case model::model_element_type::TYE_COMPOSITE_STATE: + { + const model::composite_state_model_impl* composite_state_state_model = + dynamic_cast< const model::composite_state_model_impl* >( one_state_model ); + SX_ASSERT( composite_state_state_model, "Composite state cannot be written to json file!" ); + rapidjson::Value json_state( rapidjson::kObjectType ); + fill_composite_state_object( *composite_state_state_model, json_state, _allocator ); + json_states.PushBack( json_state, _allocator ); + break; + } + + case model::model_element_type::TYE_FINAL_STATE: + { + const model::final_state_model_impl* final_state_model = + dynamic_cast< const model::final_state_model_impl* >( one_state_model ); + SX_ASSERT( final_state_model, "Final state cannot be written to json file!" ); + rapidjson::Value json_state( rapidjson::kObjectType ); + fill_final_state_object( *final_state_model, json_state, _allocator ); + json_states.PushBack( json_state, _allocator ); + break; + } + + default: + SX_ASSERT( false, "Type is not correct!" ); + } + } + + _region.AddMember( rapidjson::StringRef( model::JSON_VERTICES_NODE ), json_states, _allocator ); + rapidjson::Value json_pseudostates( rapidjson::kArrayType ); + + SX_FOR( const sxy::model::pseudostate_model* const pseudostate, _region_model.get_pseudostates() ) + { + rapidjson::Value json_pseudostate( rapidjson::kObjectType ); + fill_pseudostate_object( *pseudostate, json_pseudostate, _allocator ); + json_pseudostates.PushBack( json_pseudostate, _allocator ); + } + + _region.AddMember( rapidjson::StringRef( model::JSON_PSEUDOSTATES_NODE ), json_pseudostates, _allocator ); +} + + +void json_writer::fill_pseudostate_object( const model::pseudostate_model& _pseudostate_model, + rapidjson::Value& _pseudostate, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + fill_base_info( _pseudostate, _pseudostate_model, _allocator ); +} + + +void json_writer::fill_simple_state_object( const model::simple_state_model& _simple_state_model, + rapidjson::Value& _simple_state, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + if( _simple_state_model.is_async() ) + { + rapidjson::Value name_node; + _simple_state.AddMember( rapidjson::StringRef( model::JSON_NAME_NODE ), + create_rapidjson_string_value( _simple_state_model.get_name(), name_node ).Move(), _allocator ); + rapidjson::Value type_node; + _simple_state.AddMember( rapidjson::StringRef( model::JSON_TYPE_NODE ), + create_rapidjson_string_value( model::TYPE_ASYNC_SIMPLE_STATE, type_node ).Move(), _allocator ); + } + else + { + fill_base_info( _simple_state, _simple_state_model, _allocator ); + } + + rapidjson::Value transition_enter_behavior; + _simple_state.AddMember( rapidjson::StringRef( model::JSON_ENTER_BEHAVIOR_NODE ), + create_rapidjson_string_value( _simple_state_model.get_enter_behavior(), transition_enter_behavior ).Move(), _allocator ); + rapidjson::Value transition_do_behavior; + _simple_state.AddMember( rapidjson::StringRef( model::JSON_DO_BEHAVIOR_NODE ), + create_rapidjson_string_value( _simple_state_model.get_do_behavior(), transition_do_behavior ).Move(), _allocator ); + rapidjson::Value transition_exit_behavior; + _simple_state.AddMember( rapidjson::StringRef( model::JSON_EXIT_BEHAVIOR_NODE ), + create_rapidjson_string_value( _simple_state_model.get_exit_behavior(), transition_exit_behavior ).Move(), _allocator ); + rapidjson::Value deferred_events( rapidjson::kArrayType ); + _simple_state.AddMember( rapidjson::StringRef( model::JSON_DEFERRED_EVENTS ), deferred_events, _allocator ); +} + + +void json_writer::fill_composite_state_object( const model::composite_state_model& _composite_state_model, + rapidjson::Value& _composite_state, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + fill_base_info( _composite_state, _composite_state_model, _allocator ); + + // regions + rapidjson::Value json_regions( rapidjson::kArrayType ); + add_regions_from_model( _composite_state_model, json_regions, _allocator ); + _composite_state.AddMember( rapidjson::StringRef( model::JSON_REGIONS_NODE ), json_regions, _allocator ); + + // state_pseudostates + rapidjson::Value json_state_pseudostates( rapidjson::kArrayType ); + add_state_pseudostates_from_model( _composite_state_model, json_state_pseudostates, _allocator ); + _composite_state.AddMember( rapidjson::StringRef( model::JSON_STATE_PSEUDOSTATES_NODE ), json_state_pseudostates, _allocator ); + + // behaviors + rapidjson::Value transition_enter_behavior; + _composite_state.AddMember( rapidjson::StringRef( model::JSON_ENTER_BEHAVIOR_NODE ), + create_rapidjson_string_value( _composite_state_model.get_enter_behavior(), transition_enter_behavior ).Move(), _allocator ); + rapidjson::Value transition_exit_behavior; + _composite_state.AddMember( rapidjson::StringRef( model::JSON_EXIT_BEHAVIOR_NODE ), + create_rapidjson_string_value( _composite_state_model.get_exit_behavior(), transition_exit_behavior ).Move(), _allocator ); +} + + +void json_writer::fill_final_state_object( const model::final_state_model& _final_state_model, rapidjson::Value& _final_state, + rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + fill_base_info( _final_state, _final_state_model, _allocator ); +} + + +void json_writer::add_state_pseudostates_from_model( const model::composite_state_model& _composite_state_model, + rapidjson::Value& _state_pseudostates, rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + SX_FOR( const sxy::model::pseudostate_model* const state_pseudostate, _composite_state_model.get_state_pseudostates() ) + { + rapidjson::Value json_state_pseudostate( rapidjson::kObjectType ); + fill_pseudostate_object( *state_pseudostate, json_state_pseudostate, _allocator ); + _state_pseudostates.PushBack( json_state_pseudostate.Move(), _allocator ); + } +} + + +rapidjson::Value& json_writer::create_rapidjson_string_value( const std::string& _string, + rapidjson::Value& _json_string_value ) +{ + _json_string_value.SetString( _string.c_str(), _string.length() ); + return( _json_string_value ); +} + + +void json_writer::fill_base_info( rapidjson::Value& _json_val, const model::state_machine_element_model& _element, + rapidjson::MemoryPoolAllocator< >& _allocator ) +{ + rapidjson::Value name_node; + _json_val.AddMember( rapidjson::StringRef( model::JSON_NAME_NODE ), + create_rapidjson_string_value( _element.get_name(), name_node ).Move(), _allocator ); + rapidjson::Value type_node; + const std::string node_type = model_element_type_to_string( _element.get_type() ); + type_node.SetString( node_type.c_str(), node_type.length(), _allocator ); + _json_val.AddMember( rapidjson::StringRef( model::JSON_TYPE_NODE ), type_node.Move(), _allocator ); +} + + +const std::string json_writer::get_event_name_by_id( const sxy::model::event_id& _event_id, + const model::state_machine_model& _state_machine_model ) +{ + std::string event_name = ""; + SX_FOR( const sxy::model::event_model& an_event , _state_machine_model.get_events() ) + { + if( _event_id == an_event.id ) + { + event_name = an_event.name; + break; + } + } + + return( event_name ); +} + + +} diff --git a/yasmine_model/source/junction_model_impl.cpp b/yasmine_model/source/junction_model_impl.cpp new file mode 100644 index 0000000..5038a28 --- /dev/null +++ b/yasmine_model/source/junction_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "junction_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +junction_model_impl::junction_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_JUNCTION ) +{ + // Nothing to do... +} + + +junction_model_impl::~junction_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void junction_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/model_element_type.cpp b/yasmine_model/source/model_element_type.cpp new file mode 100644 index 0000000..81748ca --- /dev/null +++ b/yasmine_model/source/model_element_type.cpp @@ -0,0 +1,211 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "model_element_type.hpp" + +#include "essentials/base.hpp" +#include "consts.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +#ifdef SX_CPP03_BOOST + + bool operator==( const sxy::model::model_element_type& _lhs, const sxy::model::model_element_type::inner _rhs ) + { + return( _lhs.value_ == _rhs ); + } + + + bool operator==( const sxy::model::model_element_type::inner _lhs, const sxy::model::model_element_type& _rhs ) + { + return( _lhs == _rhs.value_ ); + } + + + bool operator<( const sxy::model::model_element_type _lhs, const sxy::model::model_element_type _rhs ) + { + return ( _lhs.value_ < _rhs.value_ ); + } + +#endif + + +model_element_type model_element_type_from_string( const std::string& _type_as_string ) +{ + model_element_type element_type; + + if( _type_as_string == TYPE_TRANSITION ) + { + element_type = model_element_type::TYE_TRANSITION; + } + else if( _type_as_string == TYPE_SIMPLE_STATE ) + { + element_type = model_element_type::TYE_SIMPLE_STATE; + } + else if( _type_as_string == TYPE_ASYNC_SIMPLE_STATE ) + { + element_type = model_element_type::TYE_ASYNC_SIMPLE_STATE; + } + else if( _type_as_string == TYPE_COMPOSITE_STATE ) + { + element_type = model_element_type::TYE_COMPOSITE_STATE; + } + else if( _type_as_string == TYPE_FINAL_STATE ) + { + element_type = model_element_type::TYE_FINAL_STATE; + } + else if( _type_as_string == TYPE_INITIAL_PSEUDOSTATE ) + { + element_type = model_element_type::TYE_INITIAL_PSEUDOSTATE; + } + else if( _type_as_string == TYPE_TERMINATE_PSEUDOSTATE ) + { + element_type = model_element_type::TYE_TERMINATE_PSEUDOSTATE; + } + else if( _type_as_string == TYPE_ENTRY_POINT ) + { + element_type = model_element_type::TYE_ENTRY_POINT; + } + else if( _type_as_string == TYPE_EXIT_POINT ) + { + element_type = model_element_type::TYE_EXIT_POINT; + } + else if( _type_as_string == TYPE_DEEP_HISTORY ) + { + element_type = model_element_type::TYE_DEEP_HISTORY; + } + else if( _type_as_string == TYPE_SHALLOW_HISTORY ) + { + element_type = model_element_type::TYE_SHALLOW_HISTORY; + } + else if( _type_as_string == TYPE_JOIN ) + { + element_type = model_element_type::TYE_JOIN; + } + else if( _type_as_string == TYPE_JUNCTION ) + { + element_type = model_element_type::TYE_JUNCTION; + } + else if( _type_as_string == TYPE_FORK ) + { + element_type = model_element_type::TYE_FORK; + } + else if( _type_as_string == TYPE_CHOICE ) + { + element_type = model_element_type::TYE_CHOICE; + } + else if( _type_as_string == TYPE_REGION ) + { + element_type = model_element_type::TYE_REGION; + } + else + { + element_type = model_element_type::TYE_UNKNOWN; + } + + + return( element_type ); +} + + +const std::string model_element_type_to_string( const model_element_type& _type ) +{ + std::string type; + +#ifndef SX_CPP03_BOOST + switch( _type ) +#else + switch( _type.value_ ) +#endif + { + case model_element_type::TYE_TRANSITION: + type = TYPE_TRANSITION; + break; + + case model_element_type::TYE_SIMPLE_STATE: + type = TYPE_SIMPLE_STATE; + break; + + case model_element_type::TYE_ASYNC_SIMPLE_STATE: + type = TYPE_ASYNC_SIMPLE_STATE; + break; + + case model_element_type::TYE_COMPOSITE_STATE: + type = TYPE_COMPOSITE_STATE; + break; + + case model_element_type::TYE_FINAL_STATE: + type = TYPE_FINAL_STATE; + break; + + case model_element_type::TYE_INITIAL_PSEUDOSTATE: + type = TYPE_INITIAL_PSEUDOSTATE; + break; + + case model_element_type::TYE_TERMINATE_PSEUDOSTATE: + type = TYPE_TERMINATE_PSEUDOSTATE; + break; + + case model_element_type::TYE_ENTRY_POINT: + type = TYPE_ENTRY_POINT; + break; + + case model_element_type::TYE_EXIT_POINT: + type = TYPE_EXIT_POINT; + break; + + case model_element_type::TYE_DEEP_HISTORY: + type = TYPE_DEEP_HISTORY; + break; + + case model_element_type::TYE_SHALLOW_HISTORY: + type = TYPE_SHALLOW_HISTORY; + break; + + case model_element_type::TYE_JOIN: + type = TYPE_JOIN; + break; + + case model_element_type::TYE_JUNCTION: + type = TYPE_JUNCTION; + break; + + case model_element_type::TYE_FORK: + type = TYPE_FORK; + break; + + case model_element_type::TYE_CHOICE: + type = TYPE_CHOICE; + break; + + case model_element_type::TYE_REGION: + type = TYPE_REGION; + break; + + default: + SX_ASSERT( false, "No corresponding type!" ); + break; + } + + + return ( type ); +} + + +} + +} diff --git a/yasmine_model/source/model_version.cpp b/yasmine_model/source/model_version.cpp new file mode 100644 index 0000000..866efc4 --- /dev/null +++ b/yasmine_model/source/model_version.cpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "model_version.hpp" + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/sxprintf.hpp" + +#include "build_number.hpp" + + +namespace sxy +{ + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 0 ); +const sxe::uint16_t VERSION_MINOR( 1 ); +const sxe::uint16_t VERSION_PATCH( 0 ); + + +} + + +void log_version() +{ + std::cout << sxe::sxprintf( "yasmine_model library version %.%.%.%.", get_major_version(), + get_minor_version(), get_patch_version(), get_build_number() ) << std::endl; +} + + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( BUILD_NUMBER ); +} + + +} + + +} diff --git a/yasmine_model/source/pseudostate_model_impl.cpp b/yasmine_model/source/pseudostate_model_impl.cpp new file mode 100644 index 0000000..7f6845f --- /dev/null +++ b/yasmine_model/source/pseudostate_model_impl.cpp @@ -0,0 +1,74 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "pseudostate_model_impl.hpp" + +#include "transition_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +pseudostate_model_impl::pseudostate_model_impl( const std::string& _name, const model_element_type& _type ) + : state_machine_element_model_impl( _name, _type ) +{ + // Nothing to do... +} + + +pseudostate_model_impl::~pseudostate_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +raw_const_transition_models pseudostate_model_impl::get_incoming_transitions() const +{ + raw_const_transition_models transitions; + SX_FOR( const transition_model_uptr &transition, incoming_transitions_ ) + { + transitions.push_back( transition.get() ); + } + return( transitions ); +} + + +void pseudostate_model_impl::add_incoming_transition( transition_models _incoming_transition ) +{ + incoming_transitions_ = sxe::move( _incoming_transition ); +} + + +raw_const_transition_models pseudostate_model_impl::get_outgoing_transitions() const +{ + raw_const_transition_models transitions; + SX_FOR( const transition_model_uptr &transition, outgoing_transitions_ ) + { + transitions.push_back( transition.get() ); + } + return( transitions ); +} + + +void pseudostate_model_impl::add_outgoing_transition( transition_models _outgoing_transition ) +{ + outgoing_transitions_ = sxe::move( _outgoing_transition ); +} + + +} + + +} diff --git a/yasmine_model/source/region_model_impl.cpp b/yasmine_model/source/region_model_impl.cpp new file mode 100644 index 0000000..e44565a --- /dev/null +++ b/yasmine_model/source/region_model_impl.cpp @@ -0,0 +1,77 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "region_model_impl.hpp" + +#include "pseudostate_model.hpp" +#include "state_model.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +region_model_impl::region_model_impl( const std::string& _name ) + : state_machine_element_model_impl( _name, model_element_type::TYE_REGION ) +{ + // Nothing to do... +} + + +region_model_impl::~region_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +row_const_state_models region_model_impl::get_states() const +{ + row_const_state_models states; + SX_FOR( const state_model_uptr &state, states_ ) + { + states.push_back( state.get() ); + } + return( states ); +} + + +void region_model_impl::add_state( state_model_uptr _state ) +{ + _state->set_parent( this ); + states_.push_back( sxe::move( _state ) ); +} + + +raw_const_pseduostate_models region_model_impl::get_pseudostates() const +{ + raw_const_pseduostate_models pseudostates; + SX_FOR( const pseudostate_model_uptr &pseudostate, pseudostates_ ) + { + pseudostates.push_back( pseudostate.get() ); + } + return( pseudostates ); +} + + +void region_model_impl::add_pseudostate( pseudostate_model_uptr _pseudostate ) +{ + _pseudostate->set_parent( this ); + pseudostates_.push_back( sxe::move( _pseudostate ) ); +} + + +} + + +} diff --git a/yasmine_model/source/shallow_history_model_impl.cpp b/yasmine_model/source/shallow_history_model_impl.cpp new file mode 100644 index 0000000..e5d66b9 --- /dev/null +++ b/yasmine_model/source/shallow_history_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "shallow_history_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +shallow_history_model_impl::shallow_history_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_SHALLOW_HISTORY ) +{ + // Nothing to do... +} + + +shallow_history_model_impl::~shallow_history_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void shallow_history_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/simple_state_model_impl.cpp b/yasmine_model/source/simple_state_model_impl.cpp new file mode 100644 index 0000000..3cfed56 --- /dev/null +++ b/yasmine_model/source/simple_state_model_impl.cpp @@ -0,0 +1,121 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "simple_state_model_impl.hpp" + +#include "model_vertex_visitor.hpp" +#include "model_element_type.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +simple_state_model_impl::simple_state_model_impl( const std::string& _name, const std::string& _enter_behavior, + const std::string& _do_behavior, const std::string& _exit_behavior, const event_ids& _deferred_events, + event_sptr _error_event, bool _is_async) + : state_model_impl( _name, model_element_type::TYE_SIMPLE_STATE, _deferred_events ), + enter_behavior_( _enter_behavior ), + do_behavior_( _do_behavior ), + exit_behavior_( _exit_behavior ), + error_event_( _error_event ), + is_async_( _is_async ) +{ + // Nothing to do... +} + + +simple_state_model_impl::~simple_state_model_impl()SX_NOEXCEPT +{ + // Nothing to do... +} + + +const std::string& simple_state_model_impl::get_enter_behavior() const +{ + return( enter_behavior_ ); +} + + +void simple_state_model_impl::set_enter_behavior( const std::string& _enter_behavior ) +{ + enter_behavior_ = _enter_behavior; +} + + +const std::string& simple_state_model_impl::get_do_behavior() const +{ + return( do_behavior_ ); +} + + +void simple_state_model_impl::set_do_behavior( const std::string& _do_behavior ) +{ + do_behavior_ = _do_behavior; +} + + +const std::string& simple_state_model_impl::get_exit_behavior() const +{ + return( exit_behavior_ ); +} + + +void simple_state_model_impl::set_exit_behavior( const std::string& _exit_behavior ) +{ + exit_behavior_ = _exit_behavior; +} + + +const raw_const_region_models simple_state_model_impl::get_regions() const +{ + raw_const_region_models regions; + return( regions ); +} + + +void simple_state_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +event_sptr simple_state_model_impl::get_error_event() const +{ + return( error_event_ ); +} + + +void simple_state_model_impl::set_error_event( event_sptr _error_event ) +{ + error_event_ = _error_event; +} + + +bool simple_state_model_impl::is_async() const +{ + return( is_async_ ); +} + + +void simple_state_model_impl::set_is_async( bool _is_async ) +{ + is_async_ = _is_async; +} + + +} + + +} diff --git a/yasmine_model/source/state_machine_element_model_impl.cpp b/yasmine_model/source/state_machine_element_model_impl.cpp new file mode 100644 index 0000000..2015b52 --- /dev/null +++ b/yasmine_model/source/state_machine_element_model_impl.cpp @@ -0,0 +1,93 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "state_machine_element_model_impl.hpp" + +#include "model_element_type.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +state_machine_element_model_impl::state_machine_element_model_impl( + const std::string& _name, + const model_element_type& _type ) + : name_( _name ), + parent_(), + type_( _type ) +{ + // Nothing to do... +} + + +state_machine_element_model_impl::~state_machine_element_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +const std::string& state_machine_element_model_impl::get_name() const +{ + return( name_ ); +} + + +void state_machine_element_model_impl::set_name( const std::string& _name ) +{ + name_ = _name; +} + + +const state_machine_element_model* state_machine_element_model_impl::get_parent() const +{ + return( parent_ ); +} + + +void state_machine_element_model_impl::set_parent( const state_machine_element_model* _parent ) +{ + parent_ = _parent; +} + + +const sxe::uri state_machine_element_model_impl::get_uri() const +{ + sxe::uri element_uri( get_name() ); + add_ancestor_uri( element_uri ); + return( element_uri ); +} + + +model_element_type state_machine_element_model_impl::get_type() const +{ + return( type_ ); +} + + +void state_machine_element_model_impl::add_ancestor_uri( sxe::uri& _uri ) const +{ + const state_machine_element_model* parent = get_parent(); + while( parent ) + { + _uri.push_front( parent->get_name() ); + parent = parent->get_parent(); + } +} + + +} + + +} diff --git a/yasmine_model/source/state_machine_model.cpp b/yasmine_model/source/state_machine_model.cpp new file mode 100644 index 0000000..5ba54cd --- /dev/null +++ b/yasmine_model/source/state_machine_model.cpp @@ -0,0 +1,88 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "state_machine_model.hpp" + +#include "composite_state_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +state_machine_model::state_machine_model() + : transitions_(), + root_state_(), + event_list_() +{ + // Nothing to do... +} + + +state_machine_model::~state_machine_model() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void state_machine_model::add_transition( transition_model_uptr _transition ) +{ + transitions_.push_back( sxe::move( _transition ) ); +} + + +raw_const_transition_models state_machine_model::get_transitions() const +{ + raw_const_transition_models transitions; + if( !transitions_.empty() ) + { + SX_FOR( const transition_model_uptr &transition, transitions_ ) + { + transitions.push_back( transition.get() ); + } + } + + return( transitions ); +} + + +composite_state_model_impl& state_machine_model::get_root_state() const +{ + return( *root_state_ ); +} + + +void state_machine_model::add_root_state( composite_state_model_uptr _root_state ) +{ + root_state_ = sxe::move( _root_state ); +} + + +sxy::model::state_machine_model::events state_machine_model::get_events() const +{ + return( event_list_ ); +} + + +void state_machine_model::add_event( const std::string& _event_name, const event_id& _event_id, + const event_priority& _event_priority ) +{ + event_list_.push_back( event_model( _event_name, _event_id, _event_priority ) ); +} + + +} + + +} diff --git a/yasmine_model/source/state_model_impl.cpp b/yasmine_model/source/state_model_impl.cpp new file mode 100644 index 0000000..ffd922b --- /dev/null +++ b/yasmine_model/source/state_model_impl.cpp @@ -0,0 +1,58 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "state_model_impl.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +state_model_impl::state_model_impl( const std::string& _name, const model_element_type& _type, + const event_ids& _deferred_events ) + : state_machine_element_model_impl( _name, _type ), + transitions_(), + deferred_events_( _deferred_events ) +{ + // Nothing to do... +} + + +state_model_impl::~state_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +raw_const_transition_models state_model_impl::get_transitions() const +{ + std::vector< const transition_model* > transitions; + SX_FOR( const transition_model_uptr &transition, transitions_ ) + { + transitions.push_back( transition.get() ); + } + return( transitions ); +} + + +const event_ids& state_model_impl::get_deferred_events() const +{ + return( deferred_events_ ); +} + + +} + + +} diff --git a/yasmine_model/source/terminate_pseudostate_model_impl.cpp b/yasmine_model/source/terminate_pseudostate_model_impl.cpp new file mode 100644 index 0000000..b5f322a --- /dev/null +++ b/yasmine_model/source/terminate_pseudostate_model_impl.cpp @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "terminate_pseudostate_model_impl.hpp" + +#include "model_vertex_visitor.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +terminate_pseudostate_model_impl::terminate_pseudostate_model_impl( const std::string& _name ) + : pseudostate_model_impl( _name, model_element_type::TYE_TERMINATE_PSEUDOSTATE ) +{ + // Nothing to do... +} + + +terminate_pseudostate_model_impl::~terminate_pseudostate_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +void terminate_pseudostate_model_impl::accept( model_vertex_visitor& _constructor_visitor ) const +{ + _constructor_visitor.visit( *this ); +} + + +} + + +} diff --git a/yasmine_model/source/transition_model_impl.cpp b/yasmine_model/source/transition_model_impl.cpp new file mode 100644 index 0000000..2c9e36a --- /dev/null +++ b/yasmine_model/source/transition_model_impl.cpp @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "transition_model_impl.hpp" + +namespace sxy +{ + + +namespace model +{ + + +transition_model_impl::transition_model_impl( const std::string& _name, const sxe::uri& _source_uri, + const sxe::uri& _target_uri, const transition_model_kind _kind, const std::string& _behavior, + const std::string& _guard, const event_ids& _events ) + : state_machine_element_model_impl( _name, model_element_type::TYE_TRANSITION ), + source_( _source_uri.to_string() ), + target_( _target_uri ), + kind_( _kind ), + behavior_( _behavior ), + guard_( _guard ), + events_( _events ) +{ + // Nothing to do... +} + + +transition_model_impl::~transition_model_impl() SX_NOEXCEPT +{ + // Nothing to do... +} + + +transition_model_kind transition_model_impl::get_kind() const +{ + return( kind_ ); +} + + +const std::string& transition_model_impl::get_behavior() const +{ + return( behavior_ ); +} + + +const std::string& transition_model_impl::get_guard() const +{ + return( guard_ ); +} + + +const sxe::uri& transition_model_impl::get_source() const +{ + return( source_ ); +} + + +const sxe::uri& transition_model_impl::get_target() const +{ + return( target_ ); +} + + +const event_ids& transition_model_impl::get_event_ids() const +{ + return( events_ ); +} + + +} + + +} diff --git a/yasmine_model/source/transition_model_kind.cpp b/yasmine_model/source/transition_model_kind.cpp new file mode 100644 index 0000000..9d284df --- /dev/null +++ b/yasmine_model/source/transition_model_kind.cpp @@ -0,0 +1,80 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "transition_model_kind.hpp" + + +namespace sxy +{ + + +namespace model +{ + + +std::string to_string( const transition_model_kind _kind ) +{ + std::string kind = ""; + +#ifndef SX_CPP03_BOOST + switch( _kind ) +#else + switch (_kind.value_) +#endif + { + case transition_model_kind::EXTERNAL: + kind = "EXTERNAL"; + break; + + case transition_model_kind::INTERNAL: + kind = "INTERNAL"; + break; + + case transition_model_kind::LOCAL: + kind = "LOCAL"; + break; + + default: + break; + } + + return( kind ); +} + + + +#ifdef SX_CPP03_BOOST + + +bool operator==(const transition_model_kind& _lhs, const transition_model_kind::inner _rhs) +{ + return( _lhs.value_ == _rhs ); +} + + +bool operator==(const transition_model_kind::inner _lhs, const transition_model_kind& _rhs) +{ + return( _lhs == _rhs.value_ ); +} + + +bool operator<(const transition_model_kind _lhs, const transition_model_kind _rhs) +{ + return ( _lhs.value_ < _rhs.value_ ); +} + + +#endif + + +} + +} diff --git a/yasmine_model/yasmine_model.vcxproj b/yasmine_model/yasmine_model.vcxproj new file mode 100644 index 0000000..ff35c12 --- /dev/null +++ b/yasmine_model/yasmine_model.vcxproj @@ -0,0 +1,589 @@ + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug - Clang + Win32 + + + Debug - Clang + x64 + + + Debug - VS 2013 + Win32 + + + Debug - VS 2013 + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release - VS 2013 + Win32 + + + Release - VS 2013 + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {2069AE83-AE26-484A-A6E7-E872E0045020} + Win32Proj + ymodel_v1 + 8.1 + + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v140_clang_c2 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + true + v140_clang_c2 + Unicode + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + MachineX86 + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + E:\data\seadex\trunk\proj\yasmine\source\yasmine\yasmine_test_utils;%(AdditionalIncludeDirectories) + + + Console + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + E:\data\seadex\trunk\proj\yasmine\source\yasmine\yasmine_test_utils;%(AdditionalIncludeDirectories) + + + Console + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + E:\data\seadex\trunk\proj\yasmine\source\yasmine\yasmine_test_utils;%(AdditionalIncludeDirectories) + + + Console + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/yasmine_model/yasmine_model.vcxproj.filters b/yasmine_model/yasmine_model.vcxproj.filters new file mode 100644 index 0000000..d01f8e4 --- /dev/null +++ b/yasmine_model/yasmine_model.vcxproj.filters @@ -0,0 +1,426 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {c3bbb7bf-6be7-4b08-9649-68f33d2b1c85} + + + {0f24761a-34a9-47c1-9a75-f7da343ac7e5} + + + {227af17c-9201-4134-a623-f5328b7a77e2} + + + {b8ca1ed4-350c-4658-9a25-f149801bd666} + + + {430aef14-bee7-415a-ada6-b7c565ab3ee5} + + + {3ab6d0d7-0575-40a0-a8a3-f003057ee42b} + + + {afab9df9-960e-4aa1-8b7d-1180eb86b6f1} + + + {0ea77ccc-7630-482b-b806-a768eb1aef10} + + + {705cfaa2-4dcb-4f51-adb7-d933f3e04b6c} + + + {2e1a6e0c-5702-405d-8463-ed0b33ae2590} + + + {0d3bb0a8-094f-4df0-a304-9da09fca10f8} + + + {2671d936-3fbd-4e64-aa50-15d64d43b457} + + + {f23a6b72-fd79-4e80-94f0-df764a94a2fa} + + + {31e6d6f0-beef-4573-a2ee-45bb97e3972d} + + + {f3585f15-06be-4a13-8b57-021f06f33586} + + + {c435bfdf-a901-42bf-8149-b5b498bd573f} + + + {ca791aac-15dc-4770-82a2-4af4749309bc} + + + {558aca08-79e1-4822-82f2-d4294f22c133} + + + + + Quelldateien + + + Quelldateien\json + + + Quelldateien\json + + + Quelldateien\json + + + Quelldateien\state machine\element + + + Quelldateien\state machine + + + Quelldateien\state machine + + + Quelldateien\state machine + + + Quelldateien\state machine\vertex\state + + + Quelldateien\state machine\vertex\state + + + Quelldateien\state machine\vertex\state + + + Quelldateien\state machine\vertex\state + + + Quelldateien\state machine\vertex\state + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien\state machine\vertex\pseudostate + + + Quelldateien + + + Quelldateien\state machine\element + + + Quelldateien\extenals\essentials + + + Quelldateien\extenals\essentials + + + Quelldateien\extenals\essentials + + + Quelldateien\extenals\essentials + + + Quelldateien\extenals\essentials + + + Quelldateien\state machine\element + + + Quelldateien\state machine\element + + + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien\json + + + Headerdateien\json + + + Headerdateien\json + + + Headerdateien\state machine + + + Headerdateien\state machine + + + Headerdateien\state machine + + + Headerdateien\state machine + + + Headerdateien\state machine\element + + + Headerdateien\state machine\element + + + Headerdateien\state machine\element + + + Headerdateien\state machine\visitors + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\state + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien\state machine\vertex\pseudostate + + + Headerdateien + + + Headerdateien + + + Headerdateien\state machine\element + + + Headerdateien\externals\essentials\compatibility + + + Headerdateien\externals\essentials\compatibility + + + Headerdateien\externals\essentials\compatibility + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\externals\essentials + + + Headerdateien\state machine\element + + + Headerdateien\state machine\element + + + Headerdateien\state machine\element + + + + + + \ No newline at end of file diff --git a/ygen/CMakeLists.txt b/ygen/CMakeLists.txt new file mode 100644 index 0000000..1a2e244 --- /dev/null +++ b/ygen/CMakeLists.txt @@ -0,0 +1,125 @@ +cmake_minimum_required(VERSION 3.5) + +project(ygen) + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +file(GLOB ygen_SRC "source/*.cpp" "include/*.hpp") + +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 \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") + else() + set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") + 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") + +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(ygen ${ygen_SRC}) +include_directories("./include") +include_directories("./../externals/essentials/include") +include_directories("./../genesis/include") +include_directories("./../libygen/include") + +#using boost +if("${CPP_VERSION}" STREQUAL "03") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + link_directories("${SX_BOOST_LIB_PATH}") + endif() +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET(Boost_USE_STATIC_LIBS ON) + SET(BOOST_ROOT "${SX_BOOST_LIB_INCLUDE}") + SET(Boost_INCLUDE_DIRS "${SX_BOOST_LIB_INCLUDE}") + include_directories(${Boost_INCLUDE_DIRS}) + target_link_libraries(ygen LINK_PUBLIC ${Boost_LIBRARIES}) + target_link_libraries(ygen LINK_PUBLIC "boost_program_options.a") + target_link_libraries(ygen LINK_PUBLIC "boost_filesystem.a") + target_link_libraries (ygen LINK_PUBLIC libygen) +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_link_libraries (ygen LINK_PUBLIC libygen) +endif() + + +install(TARGETS ygen DESTINATION bin) diff --git a/ygen/changelog.txt b/ygen/changelog.txt new file mode 100644 index 0000000..1555932 --- /dev/null +++ b/ygen/changelog.txt @@ -0,0 +1,6 @@ +# Change log +All notable changes to this project are documented in this file. + +##[0.1.0] - 2017-04-25 + +• The very first released version of ygen \ No newline at end of file diff --git a/ygen/include/ygen_build_number.hpp b/ygen/include/ygen_build_number.hpp new file mode 100644 index 0000000..8ddd08a --- /dev/null +++ b/ygen/include/ygen_build_number.hpp @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef YGEN_BUILD_NUMBER_6A03477D_693F_4384_A67F_DA4DE8B81CA2 +#define YGEN_BUILD_NUMBER_6A03477D_693F_4384_A67F_DA4DE8B81CA2 + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace version +{ + + + const sxe::uint16_t BUILD_NUMBER( 656 ); + + +} + + +#endif diff --git a/ygen/include/ygen_magic_consts.hpp b/ygen/include/ygen_magic_consts.hpp new file mode 100644 index 0000000..cd83e3f --- /dev/null +++ b/ygen/include/ygen_magic_consts.hpp @@ -0,0 +1,40 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef YGEN_MAGIC_CONSTS_E10A7CB5_C48C_44D0_93C2_6FE9F6350ADC +#define YGEN_MAGIC_CONSTS_E10A7CB5_C48C_44D0_93C2_6FE9F6350ADC + +#include + + +extern const char* const DESCRIPTION_TITLE; +extern const char* const HELP_OPTION_TEXT; +extern const char* const DISPLAY_CFG_TEXT; +extern const char* const NAMESPACES_TEXT; +extern const char* const BEHAVIOR_CLASSES_TEXT; +extern const char* const TEMPLATE_DIR_TEXT; +extern const char* const TEMPLATE_DIR_DEFAULT; +extern const char* const SOURCE_TEMPLATE_FILE_TEXT; +extern const char* const SOURCE_TEMPLATE_FILE_DEFAULT; +extern const char* const HEADER_TEMPLATE_FILE_TEXT; +extern const char* const HEADER_TEMPLATE_FILE_DEFAULT; +extern const char* const SOURCE_OUT_FILE_TEXT; +extern const char* const OUT_FILE_NAME_DEFAULT; +extern const char* const HEADER_OUT_FILE_TEXT; +extern const char* const HEADER_OUT_FILE_DEFAULT; +extern const char* const MODEL_FILE_TEXT; +extern const char* const STATE_MACHINE_NAME_TEXT; +extern const char* const STATE_MACHINE_TYPE_TEXT; +extern const char* const STATE_MACHINE_TYPE_SYNC; +extern const char* const STATE_MACHINE_TYPE_ASYNC; +extern const int DESCRIPTION_COLUMN_WIDTH; + + +#endif diff --git a/ygen/include/ygen_version.hpp b/ygen/include/ygen_version.hpp new file mode 100644 index 0000000..4b6e344 --- /dev/null +++ b/ygen/include/ygen_version.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef YGEN_VERSION_222818B9_7102_4223_9009_208C9C53544A +#define YGEN_VERSION_222818B9_7102_4223_9009_208C9C53544A + + +#include "essentials/compatibility/compatibility.hpp" + + +namespace version +{ + + +void log_version(); + + +sxe::uint16_t get_major_version(); +sxe::uint16_t get_minor_version(); +sxe::uint16_t get_patch_version(); +sxe::uint16_t get_build_number(); + + +} + + +#endif diff --git a/ygen/source/main.cpp b/ygen/source/main.cpp new file mode 100644 index 0000000..11a6b5f --- /dev/null +++ b/ygen/source/main.cpp @@ -0,0 +1,128 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +#include "boost/program_options.hpp" + +#include "ygen_magic_consts.hpp" +#include "generator.hpp" +#include "genesis_exception.hpp" + + +bool parse_program_options( int argc, char** argv, boost::program_options::variables_map& _variables, sxy::config& _config ) +{ + bool printHelp = false; + using namespace boost::program_options; + options_description description( DESCRIPTION_TITLE, DESCRIPTION_COLUMN_WIDTH ); + + description.add_options() + ( "help,h" , HELP_OPTION_TEXT ) + ( "template_dir,t", value( &_config.template_path )->default_value( TEMPLATE_DIR_DEFAULT ), TEMPLATE_DIR_TEXT ) + ( "source_template,s", value( &_config.source_template_file )->default_value( SOURCE_TEMPLATE_FILE_DEFAULT ), SOURCE_TEMPLATE_FILE_TEXT ) + ( "header_template,e", value( &_config.header_template_file )->default_value( HEADER_TEMPLATE_FILE_DEFAULT ), HEADER_TEMPLATE_FILE_TEXT ) + ( "out_file,o", value( &_config.source_output_file ), SOURCE_OUT_FILE_TEXT ) + ( "namespace,n", value< std::vector >( &_config.namespaces ), NAMESPACES_TEXT ) + ( "behavior_classe,b", value< std::vector >( &_config.behavior_classes ), BEHAVIOR_CLASSES_TEXT ) + ( "model,m", value( &_config.model_file ), MODEL_FILE_TEXT ) + ( "state_machine_name,i", value( &_config.state_machine_name ), STATE_MACHINE_NAME_TEXT ) + ( "state_machine_type,y", value( &_config.sm_type )->default_value(sxy::state_machine_type::SMT_SYNC, STATE_MACHINE_TYPE_SYNC ), STATE_MACHINE_TYPE_TEXT) + ( "display_cfg,d", DISPLAY_CFG_TEXT ); + + + try + { + store( parse_command_line( argc, argv, description ), _variables ); + notify( _variables ); + + if( _variables.count( "state_machine_name" ) ) + { + std::string out_file = boost::any_cast< std::string >( _variables["state_machine_name"].value() ); + if( _variables.count( "out_file" ) ) + { + out_file = boost::any_cast< std::string >( _variables["out_file"].value() ); + } + _config.source_output_file = out_file + ".cpp"; + _config.header_output_file = out_file + ".hpp"; + } + + if( _variables.count( "help" ) ) + { + printHelp = true; + } + + if( _variables.count( "display_cfg" ) ) + { + _config.print(); + } + } + catch( const std::exception& ex ) + { + std::cout << "Error parsing command line: " << ex.what() << std::endl; + printHelp = true; + } + catch( ... ) + { + std::cout << "Unknown exception!" << std::endl; + printHelp = true; + } + + if( printHelp ) + { + std::stringstream helpStream; + helpStream << description; + std::cout << helpStream.str() << std::endl; + } + + return( !printHelp ); +} + + +int main( int argc, char** argv ) +{ + int error = 0; + + try + { + boost::program_options::variables_map variables; + sxy::config generator_config; + + if( parse_program_options( argc, argv, variables, generator_config ) ) + { + sxy::generate( generator_config ); + } + } + catch( const sx::genesis::genesis_exception& ex ) + { + error = 1; + std::cout << ex.what() << std::endl; + } + catch( const std::exception& std_ex ) + { + error = 2; + std::cout << std_ex.what() << std::endl; + } + catch( ... ) + { + error = 3; + std::cout << "Unknown error!" << std::endl; + } + + if( error == 0 ) + { + std::cout << std::endl << "Files successfully generated!" << std::endl; + } + else + { + std::cout << std::endl << "Files were not generated! See error(s) above." << std::endl; + } + + return( error ); +} diff --git a/ygen/source/ygen_magic_consts.cpp b/ygen/source/ygen_magic_consts.cpp new file mode 100644 index 0000000..251109a --- /dev/null +++ b/ygen/source/ygen_magic_consts.cpp @@ -0,0 +1,32 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "ygen_magic_consts.hpp" + +const char* const DESCRIPTION_TITLE = "Supported options"; +const char* const HELP_OPTION_TEXT = "Show this help."; +const char* const DISPLAY_CFG_TEXT = "Display current configuration."; +const char* const NAMESPACES_TEXT = "Set namespace list."; +const char* const BEHAVIOR_CLASSES_TEXT = "Set classes that contain methods and functions associated to state's and transition's behaviors and transition's guards."; +const char* const TEMPLATE_DIR_TEXT = "Set template directory."; +const char* const TEMPLATE_DIR_DEFAULT = "./templates"; +const char* const SOURCE_TEMPLATE_FILE_TEXT = "Set source template file (for .cpp)."; +const char* const SOURCE_TEMPLATE_FILE_DEFAULT = "source.gtpl"; +const char* const HEADER_TEMPLATE_FILE_TEXT = "Set header template file (for .hpp)."; +const char* const HEADER_TEMPLATE_FILE_DEFAULT = "header.gtpl"; +const char* const SOURCE_OUT_FILE_TEXT = "Set name of the generated cpp and hpp files. Overwrites the source and header file names given by the state machine name."; +const char* const MODEL_FILE_TEXT = "Set the state machine's model file path."; +const char* const STATE_MACHINE_NAME_TEXT = "Set the state machine name. This will also be used as the name of the generated files."; +const char* const STATE_MACHINE_TYPE_TEXT = "Set the type of the state machine. Type can be 'sync' for a sync state machine or 'async' for a async state machine."; +const char* const STATE_MACHINE_TYPE_SYNC = "sync"; +const char* const STATE_MACHINE_TYPE_ASYNC = "async"; + +const int DESCRIPTION_COLUMN_WIDTH = 120; + diff --git a/ygen/source/ygen_version.cpp b/ygen/source/ygen_version.cpp new file mode 100644 index 0000000..4951952 --- /dev/null +++ b/ygen/source/ygen_version.cpp @@ -0,0 +1,68 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "ygen_version.hpp" + +#include + +#include "essentials/compatibility/compatibility.hpp" +#include "essentials/sxprintf.hpp" + +#include "ygen_build_number.hpp" + + +namespace version +{ + + +namespace +{ + + +const sxe::uint16_t VERSION_MAJOR( 0 ); +const sxe::uint16_t VERSION_MINOR( 1 ); +const sxe::uint16_t VERSION_PATCH( 0 ); + + +} + + +void log_version() +{ + std::cout << sxe::sxprintf( "ygen application version %.%.%.%.", get_major_version(), + get_minor_version(), get_patch_version(), get_build_number() ) << std::endl; +} + + +sxe::uint16_t get_major_version() +{ + return( VERSION_MAJOR ); +} + + +sxe::uint16_t get_minor_version() +{ + return( VERSION_MINOR ); +} + + +sxe::uint16_t get_patch_version() +{ + return( VERSION_PATCH ); +} + + +sxe::uint16_t get_build_number() +{ + return( BUILD_NUMBER ); +} + + +} diff --git a/ygen/templates/composite_state.gtpl b/ygen/templates/composite_state.gtpl new file mode 100644 index 0000000..d2d5ec7 --- /dev/null +++ b/ygen/templates/composite_state.gtpl @@ -0,0 +1,2 @@ +$loop(regions) sxy::region& $var(region_name) = $var(current_state_name).add_region("$var(region_name)"); +$template(region.gtpl)$pool$if(is_state)$if(is_composite_state)$loop(state_pseudostates) sxy::$var(state_pseudostate_type)& $var(state_pseudostate_name) = $var(current_state_name).add_$var(state_pseudostate_type)("$var(state_pseudostate_name)");$pool$fi$fi \ No newline at end of file diff --git a/ygen/templates/do_behavior.gtpl b/ygen/templates/do_behavior.gtpl new file mode 100644 index 0000000..8e5bf40 --- /dev/null +++ b/ygen/templates/do_behavior.gtpl @@ -0,0 +1,7 @@ +$switch(do_behavior) +$case(0)Y_BEHAVIOR_METHOD2( this, &$var(behavior_class_name)::$var(behavior_method_name) )$esac +$case(1)Y_BEHAVIOR_METHOD2( $var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(2)Y_BEHAVIOR_METHOD2( &_$var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(3)Y_BEHAVIOR_FUNCTION2( $var(behavior_method_name) )$esac +$default()Y_EMPTY_BEHAVIOR$tluafed +$hctiws \ No newline at end of file diff --git a/ygen/templates/enter_behavior.gtpl b/ygen/templates/enter_behavior.gtpl new file mode 100644 index 0000000..0e463c0 --- /dev/null +++ b/ygen/templates/enter_behavior.gtpl @@ -0,0 +1,7 @@ +$switch(enter_behavior) +$case(0)Y_BEHAVIOR_METHOD2( this, &$var(behavior_class_name)::$var(behavior_method_name) )$esac +$case(1)Y_BEHAVIOR_METHOD2( $var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(2)Y_BEHAVIOR_METHOD2( &_$var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(3)Y_BEHAVIOR_FUNCTION2( $var(behavior_method_name) )$esac +$default()Y_EMPTY_BEHAVIOR$tluafed +$hctiws \ No newline at end of file diff --git a/ygen/templates/exit_behavior.gtpl b/ygen/templates/exit_behavior.gtpl new file mode 100644 index 0000000..f654b9d --- /dev/null +++ b/ygen/templates/exit_behavior.gtpl @@ -0,0 +1,7 @@ +$switch(exit_behavior) +$case(0)Y_BEHAVIOR_METHOD2( this, &$var(behavior_class_name)::$var(behavior_method_name) )$esac +$case(1)Y_BEHAVIOR_METHOD2( $var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(2)Y_BEHAVIOR_METHOD2( &_$var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(3)Y_BEHAVIOR_FUNCTION2( $var(behavior_method_name) )$esac +$default()Y_EMPTY_BEHAVIOR$tluafed +$hctiws \ No newline at end of file diff --git a/ygen/templates/header.gtpl b/ygen/templates/header.gtpl new file mode 100644 index 0000000..efe864a --- /dev/null +++ b/ygen/templates/header.gtpl @@ -0,0 +1,22 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file was generated by yasmine's ygen @ $var(datetime). // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef $var(state_machine_name_caps)_HPP_ +#define $var(state_machine_name_caps)_HPP_ + +#include "yasmine.hpp" +$loop(behavior_classes)#include "$var(behavior_class_name).hpp"$pool$@ +$loop(namespace_open)namespace $var(namespace_name) +{$@$@$pool +$loop(events)$@Y_EVENT_CREATE($var(event_name), $var(event_id))$pool +$@ +using state_machine_uptr = std::unique_ptr<$var(state_machine_type)>; + +state_machine_uptr create_state_machine(const std::string& _name$loop(behavior_classes), $loop(namespace_open)$var(namespace_name)::$pool$var(behavior_class_name)& _$var(behavior_class_name) $pool); + +$loop(namespace_close)}$@$@$pool + +#endif diff --git a/ygen/templates/region.gtpl b/ygen/templates/region.gtpl new file mode 100644 index 0000000..c67bf77 --- /dev/null +++ b/ygen/templates/region.gtpl @@ -0,0 +1,4 @@ +$loop(states) sxy::$var(state_type)& $var(state_name) = $var(region_name).add_$var(state_type)("$var(state_name)", $if(is_composite_state, not)$template(do_behavior.gtpl), $fi$template(enter_behavior.gtpl), $template(exit_behavior.gtpl)); +$if(is_composite_state)$template(composite_state.gtpl)$fi$pool +$loop(pseudostates) sxy::$var(pseudostate_type)& $var(pseudostate_name) = $var(region_name).add_$var(pseudostate_type)("$var(pseudostate_name)"); +$pool \ No newline at end of file diff --git a/ygen/templates/source.gtpl b/ygen/templates/source.gtpl new file mode 100644 index 0000000..8d109e3 --- /dev/null +++ b/ygen/templates/source.gtpl @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file was generated by yasmine's ygen @ $var(datetime). // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "$var(state_machine_name).hpp" +#include + +$loop(namespace_open)namespace $var(namespace_name) +{$@$@$pool + +state_machine_uptr create_state_machine(const std::string& _name$loop(behavior_classes), $loop(namespace_open)$var(namespace_name)::$pool$var(behavior_class_name)& _$var(behavior_class_name) $pool) +{ + state_machine_uptr the_state_machine = std::make_unique< $var(state_machine_type) >( _name ); + + // vertices { + sxy::composite_state& $var(root_name) = the_state_machine->get_root_state(); +$template(composite_state.gtpl) // } vertices + + + // transitions { + $loop(transitions)the_state_machine->add_transition($var(transition_event_id), $var(source_vertex), $var(target_vertex), $var(transition_kind), $template(transition_guard.gtpl), $template(transition_behavior.gtpl)); + $pool// } transitions + + return(std::move(the_state_machine)); +} + +$loop(namespace_close)}$@$@$pool \ No newline at end of file diff --git a/ygen/templates/transition_behavior.gtpl b/ygen/templates/transition_behavior.gtpl new file mode 100644 index 0000000..9408739 --- /dev/null +++ b/ygen/templates/transition_behavior.gtpl @@ -0,0 +1,7 @@ +$switch(transition_behavior) +$case(0)Y_BEHAVIOR_METHOD2( this, &$var(behavior_class_name)::$var(behavior_method_name) )$esac +$case(1)Y_BEHAVIOR_METHOD2( $var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(2)Y_BEHAVIOR_METHOD2( &_$var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(3)Y_BEHAVIOR_FUNCTION2( $var(behavior_method_name) )$esac +$default()Y_EMPTY_BEHAVIOR$tluafed +$hctiws \ No newline at end of file diff --git a/ygen/templates/transition_guard.gtpl b/ygen/templates/transition_guard.gtpl new file mode 100644 index 0000000..e0bbbd0 --- /dev/null +++ b/ygen/templates/transition_guard.gtpl @@ -0,0 +1,7 @@ +$switch(transition_guard) +$case(0)Y_GUARD_METHOD2( this, &$var(behavior_class_name)::$var(behavior_method_name) )$esac +$case(1)Y_GUARD_METHOD2( $var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(2)Y_GUARD_METHOD2( &_$var(class_instance_name), &$var(class_instance_name)::$var(behavior_method_name) )$esac +$case(3)Y_GUARD_FUNCTION2( $var(behavior_method_name) )$esac +$default()Y_EMPTY_GUARD$tluafed +$hctiws \ No newline at end of file diff --git a/ygen/ygen.vcxproj b/ygen/ygen.vcxproj new file mode 100644 index 0000000..8e130a3 --- /dev/null +++ b/ygen/ygen.vcxproj @@ -0,0 +1,305 @@ + + + + + Debug - C++ 03 + Win32 + + + Debug - C++ 03 + x64 + + + Debug + Win32 + + + Release - C++ 03 + Win32 + + + Release - C++ 03 + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {E70CC0C5-256B-41E2-A852-B1904C2D84D3} + generator + 8.1 + ygen + + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + true + v120 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ygen/ygen.vcxproj.filters b/ygen/ygen.vcxproj.filters new file mode 100644 index 0000000..f2d0534 --- /dev/null +++ b/ygen/ygen.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file