diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/boost/libs/statechart | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/statechart')
102 files changed, 15547 insertions, 0 deletions
diff --git a/src/boost/libs/statechart/CMakeLists.txt b/src/boost/libs/statechart/CMakeLists.txt new file mode 100644 index 000000000..4073be332 --- /dev/null +++ b/src/boost/libs/statechart/CMakeLists.txt @@ -0,0 +1,36 @@ +# Generated by `boostdep --cmake statechart` +# Copyright 2020 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_statechart VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) + +add_library(boost_statechart INTERFACE) +add_library(Boost::statechart ALIAS boost_statechart) + +target_include_directories(boost_statechart INTERFACE include) + +target_link_libraries(boost_statechart + INTERFACE + Boost::assert + Boost::bind + Boost::config + Boost::conversion + Boost::core + Boost::detail + Boost::function + Boost::mpl + Boost::smart_ptr + Boost::static_assert + Boost::thread + Boost::type_traits +) + +if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + + add_subdirectory(test) + +endif() + diff --git a/src/boost/libs/statechart/Jamfile.v2 b/src/boost/libs/statechart/Jamfile.v2 new file mode 100644 index 000000000..517e1c457 --- /dev/null +++ b/src/boost/libs/statechart/Jamfile.v2 @@ -0,0 +1,10 @@ +############################################################################## +# Copyright 2005-2006 Andreas Huber Doenni +# Distributed under the Boost Software License, Version 1.0. (See accompany- +# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +############################################################################## + +project libs/statechart ; + +build-project example ; +build-project test ; diff --git a/src/boost/libs/statechart/Statechart.sln b/src/boost/libs/statechart/Statechart.sln new file mode 100644 index 000000000..5984996bc --- /dev/null +++ b/src/boost/libs/statechart/Statechart.sln @@ -0,0 +1,336 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BitMachine", "example\BitMachine\BitMachine.vcproj", "{CF66596F-7DEA-4BB6-A728-F7FEF2889855}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Camera", "example\Camera\Camera.vcproj", "{7FD5B025-1675-4D68-BA85-588AFC99C5B8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Handcrafted", "example\Handcrafted\Handcrafted.vcproj", "{155DB9E1-28AC-4671-8248-5FD03E8FCDAD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Keyboard", "example\Keyboard\Keyboard.vcproj", "{4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PingPong", "example\PingPong\PingPong.vcproj", "{11CCA9FC-6012-4B64-8C61-808D0F8D1B51}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StopWatch", "example\StopWatch\StopWatch.vcproj", "{DFA55264-E7F5-43FE-841F-D56AC48FF2A8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TransitionTest", "test\TransitionTest.vcproj", "{D9103E3E-640D-4AB7-910C-ACA96709ED0A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeferralTest", "test\DeferralTest.vcproj", "{E599D469-A2BD-42FB-A217-73A420213D06}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidTransitionTest1", "test\InvalidTransitionTest1.vcproj", "{345A4DD5-8B5C-40E4-95D2-4CF5A2621040}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidTransitionTest2", "test\InvalidTransitionTest2.vcproj", "{FCB42B5B-DDE0-4E12-8474-F55DC85606FE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HistoryTest", "test\HistoryTest.vcproj", "{206654FA-7AA0-4E06-BCFA-DC94D4281755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidChartTest1", "test\InvalidChartTest1.vcproj", "{AA1A7669-702E-4D56-A390-849612EB9CDF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidChartTest3", "test\InvalidChartTest3.vcproj", "{7083917A-4A8D-4BEF-A435-61AAF3BA554C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidChartTest2", "test\InvalidChartTest2.vcproj", "{CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest1", "test\InconsistentHistoryTest1.vcproj", "{B2739180-6048-4CA7-A96B-ECE182100321}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest2", "test\InconsistentHistoryTest2.vcproj", "{7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest3", "test\InconsistentHistoryTest3.vcproj", "{801027D8-DC4E-48DC-9F98-75BA0B7F2997}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest4", "test\InconsistentHistoryTest4.vcproj", "{A211FFC9-D4B4-4C3A-900E-044A7519F8E4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest5", "test\InconsistentHistoryTest5.vcproj", "{BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest6", "test\InconsistentHistoryTest6.vcproj", "{7D2AB32E-930A-4758-8FAF-F5E0A19A411C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest7", "test\InconsistentHistoryTest7.vcproj", "{41A33CE9-785E-4EC2-9022-A3B229D4935B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InconsistentHistoryTest8", "test\InconsistentHistoryTest8.vcproj", "{FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnsuppDeepHistoryTest", "test\UnsuppDeepHistoryTest.vcproj", "{7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StateCastTest", "test\StateCastTest.vcproj", "{1826122F-4DB3-4C69-8BB2-E0B18D809FA9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TypeInfoTest", "test\TypeInfoTest.vcproj", "{6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StateIterationTest", "test\StateIterationTest.vcproj", "{D52BF95D-392C-4535-B332-CB3CC29C8227}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomReactionTest", "test\CustomReactionTest.vcproj", "{2D85E7DE-2347-43EA-843F-691101E6F98F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TerminationTest", "test\TerminationTest.vcproj", "{A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FifoSchedulerTest", "test\FifoSchedulerTest.vcproj", "{3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidResultAssignTest", "test\InvalidResultAssignTest.vcproj", "{962F23F9-D433-4825-9945-D5A5C5337B7F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidResultDefCtorTest", "test\InvalidResultDefCtorTest.vcproj", "{8381EC0A-7D7B-4127-93E8-DFE12F023611}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvalidResultCopyTest", "test\InvalidResultCopyTest.vcproj", "{856A30E8-85E8-4BE4-B208-B5FC395408AF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnconsumedResultTest", "test\UnconsumedResultTest.vcproj", "{93FEA76A-3C04-4A70-B53B-485490CF38A1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InStateReactionTest", "test\InStateReactionTest.vcproj", "{DAD64722-72C8-4424-9024-185A0D0D897A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TuTest", "test\TuTest.vcproj", "{892D213C-F575-4003-BB0F-5787DA2C407D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Performance", "example\Performance\Performance.vcproj", "{045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3D7ED412-11AE-4AE7-8258-0FF6CF8BD11C}" + ProjectSection(SolutionItems) = preProject + example\Jamfile.v2 = example\Jamfile.v2 + test\Jamfile.v2 = test\Jamfile.v2 + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{FF998410-FD7E-4B0E-8754-20003E19F51D}" + ProjectSection(SolutionItems) = preProject + doc\acknowledgments.html = doc\acknowledgments.html + doc\configuration.html = doc\configuration.html + doc\contact.html = doc\contact.html + doc\definitions.html = doc\definitions.html + doc\faq.html = doc\faq.html + doc\future_and_history.html = doc\future_and_history.html + doc\index.html = doc\index.html + doc\performance.html = doc\performance.html + doc\rationale.html = doc\rationale.html + doc\reference.html = doc\reference.html + doc\tutorial.html = doc\tutorial.html + doc\uml_mapping.html = doc\uml_mapping.html + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TriggeringEventTest", "test\TriggeringEventTest.vcproj", "{DFE5C3C2-0CF9-4709-8393-96201E9A8181}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + DebugFail|Win32 = DebugFail|Win32 + Release|Win32 = Release|Win32 + ReleaseFail|Win32 = ReleaseFail|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF66596F-7DEA-4BB6-A728-F7FEF2889855}.Debug|Win32.ActiveCfg = Debug|Win32 + {CF66596F-7DEA-4BB6-A728-F7FEF2889855}.Debug|Win32.Build.0 = Debug|Win32 + {CF66596F-7DEA-4BB6-A728-F7FEF2889855}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {CF66596F-7DEA-4BB6-A728-F7FEF2889855}.Release|Win32.ActiveCfg = Release|Win32 + {CF66596F-7DEA-4BB6-A728-F7FEF2889855}.Release|Win32.Build.0 = Release|Win32 + {CF66596F-7DEA-4BB6-A728-F7FEF2889855}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {7FD5B025-1675-4D68-BA85-588AFC99C5B8}.Debug|Win32.ActiveCfg = Debug|Win32 + {7FD5B025-1675-4D68-BA85-588AFC99C5B8}.Debug|Win32.Build.0 = Debug|Win32 + {7FD5B025-1675-4D68-BA85-588AFC99C5B8}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {7FD5B025-1675-4D68-BA85-588AFC99C5B8}.Release|Win32.ActiveCfg = Release|Win32 + {7FD5B025-1675-4D68-BA85-588AFC99C5B8}.Release|Win32.Build.0 = Release|Win32 + {7FD5B025-1675-4D68-BA85-588AFC99C5B8}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {155DB9E1-28AC-4671-8248-5FD03E8FCDAD}.Debug|Win32.ActiveCfg = Debug|Win32 + {155DB9E1-28AC-4671-8248-5FD03E8FCDAD}.Debug|Win32.Build.0 = Debug|Win32 + {155DB9E1-28AC-4671-8248-5FD03E8FCDAD}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {155DB9E1-28AC-4671-8248-5FD03E8FCDAD}.Release|Win32.ActiveCfg = Release|Win32 + {155DB9E1-28AC-4671-8248-5FD03E8FCDAD}.Release|Win32.Build.0 = Release|Win32 + {155DB9E1-28AC-4671-8248-5FD03E8FCDAD}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}.Debug|Win32.ActiveCfg = Debug|Win32 + {4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}.Debug|Win32.Build.0 = Debug|Win32 + {4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}.Release|Win32.ActiveCfg = Release|Win32 + {4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}.Release|Win32.Build.0 = Release|Win32 + {4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {11CCA9FC-6012-4B64-8C61-808D0F8D1B51}.Debug|Win32.ActiveCfg = Debug|Win32 + {11CCA9FC-6012-4B64-8C61-808D0F8D1B51}.Debug|Win32.Build.0 = Debug|Win32 + {11CCA9FC-6012-4B64-8C61-808D0F8D1B51}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {11CCA9FC-6012-4B64-8C61-808D0F8D1B51}.Release|Win32.ActiveCfg = Release|Win32 + {11CCA9FC-6012-4B64-8C61-808D0F8D1B51}.Release|Win32.Build.0 = Release|Win32 + {11CCA9FC-6012-4B64-8C61-808D0F8D1B51}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {DFA55264-E7F5-43FE-841F-D56AC48FF2A8}.Debug|Win32.ActiveCfg = Debug|Win32 + {DFA55264-E7F5-43FE-841F-D56AC48FF2A8}.Debug|Win32.Build.0 = Debug|Win32 + {DFA55264-E7F5-43FE-841F-D56AC48FF2A8}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {DFA55264-E7F5-43FE-841F-D56AC48FF2A8}.Release|Win32.ActiveCfg = Release|Win32 + {DFA55264-E7F5-43FE-841F-D56AC48FF2A8}.Release|Win32.Build.0 = Release|Win32 + {DFA55264-E7F5-43FE-841F-D56AC48FF2A8}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {D9103E3E-640D-4AB7-910C-ACA96709ED0A}.Debug|Win32.ActiveCfg = Debug|Win32 + {D9103E3E-640D-4AB7-910C-ACA96709ED0A}.Debug|Win32.Build.0 = Debug|Win32 + {D9103E3E-640D-4AB7-910C-ACA96709ED0A}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {D9103E3E-640D-4AB7-910C-ACA96709ED0A}.Release|Win32.ActiveCfg = Release|Win32 + {D9103E3E-640D-4AB7-910C-ACA96709ED0A}.Release|Win32.Build.0 = Release|Win32 + {D9103E3E-640D-4AB7-910C-ACA96709ED0A}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {E599D469-A2BD-42FB-A217-73A420213D06}.Debug|Win32.ActiveCfg = Debug|Win32 + {E599D469-A2BD-42FB-A217-73A420213D06}.Debug|Win32.Build.0 = Debug|Win32 + {E599D469-A2BD-42FB-A217-73A420213D06}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {E599D469-A2BD-42FB-A217-73A420213D06}.Release|Win32.ActiveCfg = Release|Win32 + {E599D469-A2BD-42FB-A217-73A420213D06}.Release|Win32.Build.0 = Release|Win32 + {E599D469-A2BD-42FB-A217-73A420213D06}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {345A4DD5-8B5C-40E4-95D2-4CF5A2621040}.Debug|Win32.ActiveCfg = Debug|Win32 + {345A4DD5-8B5C-40E4-95D2-4CF5A2621040}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {345A4DD5-8B5C-40E4-95D2-4CF5A2621040}.DebugFail|Win32.Build.0 = Debug|Win32 + {345A4DD5-8B5C-40E4-95D2-4CF5A2621040}.Release|Win32.ActiveCfg = Release|Win32 + {345A4DD5-8B5C-40E4-95D2-4CF5A2621040}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {345A4DD5-8B5C-40E4-95D2-4CF5A2621040}.ReleaseFail|Win32.Build.0 = Release|Win32 + {FCB42B5B-DDE0-4E12-8474-F55DC85606FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {FCB42B5B-DDE0-4E12-8474-F55DC85606FE}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {FCB42B5B-DDE0-4E12-8474-F55DC85606FE}.DebugFail|Win32.Build.0 = Debug|Win32 + {FCB42B5B-DDE0-4E12-8474-F55DC85606FE}.Release|Win32.ActiveCfg = Release|Win32 + {FCB42B5B-DDE0-4E12-8474-F55DC85606FE}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {FCB42B5B-DDE0-4E12-8474-F55DC85606FE}.ReleaseFail|Win32.Build.0 = Release|Win32 + {206654FA-7AA0-4E06-BCFA-DC94D4281755}.Debug|Win32.ActiveCfg = Debug|Win32 + {206654FA-7AA0-4E06-BCFA-DC94D4281755}.Debug|Win32.Build.0 = Debug|Win32 + {206654FA-7AA0-4E06-BCFA-DC94D4281755}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {206654FA-7AA0-4E06-BCFA-DC94D4281755}.Release|Win32.ActiveCfg = Release|Win32 + {206654FA-7AA0-4E06-BCFA-DC94D4281755}.Release|Win32.Build.0 = Release|Win32 + {206654FA-7AA0-4E06-BCFA-DC94D4281755}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {AA1A7669-702E-4D56-A390-849612EB9CDF}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA1A7669-702E-4D56-A390-849612EB9CDF}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {AA1A7669-702E-4D56-A390-849612EB9CDF}.DebugFail|Win32.Build.0 = Debug|Win32 + {AA1A7669-702E-4D56-A390-849612EB9CDF}.Release|Win32.ActiveCfg = Release|Win32 + {AA1A7669-702E-4D56-A390-849612EB9CDF}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {AA1A7669-702E-4D56-A390-849612EB9CDF}.ReleaseFail|Win32.Build.0 = Release|Win32 + {7083917A-4A8D-4BEF-A435-61AAF3BA554C}.Debug|Win32.ActiveCfg = Debug|Win32 + {7083917A-4A8D-4BEF-A435-61AAF3BA554C}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {7083917A-4A8D-4BEF-A435-61AAF3BA554C}.DebugFail|Win32.Build.0 = Debug|Win32 + {7083917A-4A8D-4BEF-A435-61AAF3BA554C}.Release|Win32.ActiveCfg = Release|Win32 + {7083917A-4A8D-4BEF-A435-61AAF3BA554C}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {7083917A-4A8D-4BEF-A435-61AAF3BA554C}.ReleaseFail|Win32.Build.0 = Release|Win32 + {CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}.Debug|Win32.ActiveCfg = Debug|Win32 + {CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}.DebugFail|Win32.Build.0 = Debug|Win32 + {CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}.Release|Win32.ActiveCfg = Release|Win32 + {CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}.ReleaseFail|Win32.Build.0 = Release|Win32 + {B2739180-6048-4CA7-A96B-ECE182100321}.Debug|Win32.ActiveCfg = Debug|Win32 + {B2739180-6048-4CA7-A96B-ECE182100321}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {B2739180-6048-4CA7-A96B-ECE182100321}.DebugFail|Win32.Build.0 = Debug|Win32 + {B2739180-6048-4CA7-A96B-ECE182100321}.Release|Win32.ActiveCfg = Release|Win32 + {B2739180-6048-4CA7-A96B-ECE182100321}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {B2739180-6048-4CA7-A96B-ECE182100321}.ReleaseFail|Win32.Build.0 = Release|Win32 + {7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}.Debug|Win32.ActiveCfg = Debug|Win32 + {7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}.DebugFail|Win32.Build.0 = Debug|Win32 + {7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}.Release|Win32.ActiveCfg = Release|Win32 + {7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}.ReleaseFail|Win32.Build.0 = Release|Win32 + {801027D8-DC4E-48DC-9F98-75BA0B7F2997}.Debug|Win32.ActiveCfg = Debug|Win32 + {801027D8-DC4E-48DC-9F98-75BA0B7F2997}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {801027D8-DC4E-48DC-9F98-75BA0B7F2997}.DebugFail|Win32.Build.0 = Debug|Win32 + {801027D8-DC4E-48DC-9F98-75BA0B7F2997}.Release|Win32.ActiveCfg = Release|Win32 + {801027D8-DC4E-48DC-9F98-75BA0B7F2997}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {801027D8-DC4E-48DC-9F98-75BA0B7F2997}.ReleaseFail|Win32.Build.0 = Release|Win32 + {A211FFC9-D4B4-4C3A-900E-044A7519F8E4}.Debug|Win32.ActiveCfg = Debug|Win32 + {A211FFC9-D4B4-4C3A-900E-044A7519F8E4}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {A211FFC9-D4B4-4C3A-900E-044A7519F8E4}.DebugFail|Win32.Build.0 = Debug|Win32 + {A211FFC9-D4B4-4C3A-900E-044A7519F8E4}.Release|Win32.ActiveCfg = Release|Win32 + {A211FFC9-D4B4-4C3A-900E-044A7519F8E4}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {A211FFC9-D4B4-4C3A-900E-044A7519F8E4}.ReleaseFail|Win32.Build.0 = Release|Win32 + {BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}.Debug|Win32.ActiveCfg = Debug|Win32 + {BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}.DebugFail|Win32.Build.0 = Debug|Win32 + {BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}.Release|Win32.ActiveCfg = Release|Win32 + {BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}.ReleaseFail|Win32.Build.0 = Release|Win32 + {7D2AB32E-930A-4758-8FAF-F5E0A19A411C}.Debug|Win32.ActiveCfg = Debug|Win32 + {7D2AB32E-930A-4758-8FAF-F5E0A19A411C}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {7D2AB32E-930A-4758-8FAF-F5E0A19A411C}.DebugFail|Win32.Build.0 = Debug|Win32 + {7D2AB32E-930A-4758-8FAF-F5E0A19A411C}.Release|Win32.ActiveCfg = Release|Win32 + {7D2AB32E-930A-4758-8FAF-F5E0A19A411C}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {7D2AB32E-930A-4758-8FAF-F5E0A19A411C}.ReleaseFail|Win32.Build.0 = Release|Win32 + {41A33CE9-785E-4EC2-9022-A3B229D4935B}.Debug|Win32.ActiveCfg = Debug|Win32 + {41A33CE9-785E-4EC2-9022-A3B229D4935B}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {41A33CE9-785E-4EC2-9022-A3B229D4935B}.DebugFail|Win32.Build.0 = Debug|Win32 + {41A33CE9-785E-4EC2-9022-A3B229D4935B}.Release|Win32.ActiveCfg = Release|Win32 + {41A33CE9-785E-4EC2-9022-A3B229D4935B}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {41A33CE9-785E-4EC2-9022-A3B229D4935B}.ReleaseFail|Win32.Build.0 = Release|Win32 + {FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}.Debug|Win32.ActiveCfg = Debug|Win32 + {FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}.DebugFail|Win32.Build.0 = Debug|Win32 + {FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}.Release|Win32.ActiveCfg = Release|Win32 + {FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}.ReleaseFail|Win32.Build.0 = Release|Win32 + {7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}.Debug|Win32.ActiveCfg = Debug|Win32 + {7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}.DebugFail|Win32.Build.0 = Debug|Win32 + {7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}.Release|Win32.ActiveCfg = Release|Win32 + {7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}.ReleaseFail|Win32.Build.0 = Release|Win32 + {1826122F-4DB3-4C69-8BB2-E0B18D809FA9}.Debug|Win32.ActiveCfg = Debug|Win32 + {1826122F-4DB3-4C69-8BB2-E0B18D809FA9}.Debug|Win32.Build.0 = Debug|Win32 + {1826122F-4DB3-4C69-8BB2-E0B18D809FA9}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {1826122F-4DB3-4C69-8BB2-E0B18D809FA9}.Release|Win32.ActiveCfg = Release|Win32 + {1826122F-4DB3-4C69-8BB2-E0B18D809FA9}.Release|Win32.Build.0 = Release|Win32 + {1826122F-4DB3-4C69-8BB2-E0B18D809FA9}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}.Debug|Win32.ActiveCfg = Debug|Win32 + {6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}.Debug|Win32.Build.0 = Debug|Win32 + {6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}.Release|Win32.ActiveCfg = Release|Win32 + {6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}.Release|Win32.Build.0 = Release|Win32 + {6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {D52BF95D-392C-4535-B332-CB3CC29C8227}.Debug|Win32.ActiveCfg = Debug|Win32 + {D52BF95D-392C-4535-B332-CB3CC29C8227}.Debug|Win32.Build.0 = Debug|Win32 + {D52BF95D-392C-4535-B332-CB3CC29C8227}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {D52BF95D-392C-4535-B332-CB3CC29C8227}.Release|Win32.ActiveCfg = Release|Win32 + {D52BF95D-392C-4535-B332-CB3CC29C8227}.Release|Win32.Build.0 = Release|Win32 + {D52BF95D-392C-4535-B332-CB3CC29C8227}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {2D85E7DE-2347-43EA-843F-691101E6F98F}.Debug|Win32.ActiveCfg = Debug|Win32 + {2D85E7DE-2347-43EA-843F-691101E6F98F}.Debug|Win32.Build.0 = Debug|Win32 + {2D85E7DE-2347-43EA-843F-691101E6F98F}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {2D85E7DE-2347-43EA-843F-691101E6F98F}.Release|Win32.ActiveCfg = Release|Win32 + {2D85E7DE-2347-43EA-843F-691101E6F98F}.Release|Win32.Build.0 = Release|Win32 + {2D85E7DE-2347-43EA-843F-691101E6F98F}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}.Debug|Win32.ActiveCfg = Debug|Win32 + {A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}.Debug|Win32.Build.0 = Debug|Win32 + {A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}.Release|Win32.ActiveCfg = Release|Win32 + {A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}.Release|Win32.Build.0 = Release|Win32 + {A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}.Debug|Win32.ActiveCfg = Debug|Win32 + {3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}.Debug|Win32.Build.0 = Debug|Win32 + {3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}.Release|Win32.ActiveCfg = Release|Win32 + {3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}.Release|Win32.Build.0 = Release|Win32 + {3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {962F23F9-D433-4825-9945-D5A5C5337B7F}.Debug|Win32.ActiveCfg = Debug|Win32 + {962F23F9-D433-4825-9945-D5A5C5337B7F}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {962F23F9-D433-4825-9945-D5A5C5337B7F}.DebugFail|Win32.Build.0 = Debug|Win32 + {962F23F9-D433-4825-9945-D5A5C5337B7F}.Release|Win32.ActiveCfg = Release|Win32 + {962F23F9-D433-4825-9945-D5A5C5337B7F}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {962F23F9-D433-4825-9945-D5A5C5337B7F}.ReleaseFail|Win32.Build.0 = Release|Win32 + {8381EC0A-7D7B-4127-93E8-DFE12F023611}.Debug|Win32.ActiveCfg = Debug|Win32 + {8381EC0A-7D7B-4127-93E8-DFE12F023611}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {8381EC0A-7D7B-4127-93E8-DFE12F023611}.DebugFail|Win32.Build.0 = Debug|Win32 + {8381EC0A-7D7B-4127-93E8-DFE12F023611}.Release|Win32.ActiveCfg = Release|Win32 + {8381EC0A-7D7B-4127-93E8-DFE12F023611}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {8381EC0A-7D7B-4127-93E8-DFE12F023611}.ReleaseFail|Win32.Build.0 = Release|Win32 + {856A30E8-85E8-4BE4-B208-B5FC395408AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {856A30E8-85E8-4BE4-B208-B5FC395408AF}.Debug|Win32.Build.0 = Debug|Win32 + {856A30E8-85E8-4BE4-B208-B5FC395408AF}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {856A30E8-85E8-4BE4-B208-B5FC395408AF}.Release|Win32.ActiveCfg = Release|Win32 + {856A30E8-85E8-4BE4-B208-B5FC395408AF}.Release|Win32.Build.0 = Release|Win32 + {856A30E8-85E8-4BE4-B208-B5FC395408AF}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {93FEA76A-3C04-4A70-B53B-485490CF38A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {93FEA76A-3C04-4A70-B53B-485490CF38A1}.Debug|Win32.Build.0 = Debug|Win32 + {93FEA76A-3C04-4A70-B53B-485490CF38A1}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {93FEA76A-3C04-4A70-B53B-485490CF38A1}.Release|Win32.ActiveCfg = Release|Win32 + {93FEA76A-3C04-4A70-B53B-485490CF38A1}.Release|Win32.Build.0 = Release|Win32 + {93FEA76A-3C04-4A70-B53B-485490CF38A1}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {DAD64722-72C8-4424-9024-185A0D0D897A}.Debug|Win32.ActiveCfg = Debug|Win32 + {DAD64722-72C8-4424-9024-185A0D0D897A}.Debug|Win32.Build.0 = Debug|Win32 + {DAD64722-72C8-4424-9024-185A0D0D897A}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {DAD64722-72C8-4424-9024-185A0D0D897A}.Release|Win32.ActiveCfg = Release|Win32 + {DAD64722-72C8-4424-9024-185A0D0D897A}.Release|Win32.Build.0 = Release|Win32 + {DAD64722-72C8-4424-9024-185A0D0D897A}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {892D213C-F575-4003-BB0F-5787DA2C407D}.Debug|Win32.ActiveCfg = Debug|Win32 + {892D213C-F575-4003-BB0F-5787DA2C407D}.Debug|Win32.Build.0 = Debug|Win32 + {892D213C-F575-4003-BB0F-5787DA2C407D}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {892D213C-F575-4003-BB0F-5787DA2C407D}.Release|Win32.ActiveCfg = Release|Win32 + {892D213C-F575-4003-BB0F-5787DA2C407D}.Release|Win32.Build.0 = Release|Win32 + {892D213C-F575-4003-BB0F-5787DA2C407D}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.Debug|Win32.ActiveCfg = Debug|Win32 + {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.Debug|Win32.Build.0 = Debug|Win32 + {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.Release|Win32.ActiveCfg = Release|Win32 + {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.Release|Win32.Build.0 = Release|Win32 + {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Debug|Win32.ActiveCfg = Debug|Win32 + {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Debug|Win32.Build.0 = Debug|Win32 + {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.DebugFail|Win32.ActiveCfg = Debug|Win32 + {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Release|Win32.ActiveCfg = Release|Win32 + {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Release|Win32.Build.0 = Release|Win32 + {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.ReleaseFail|Win32.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {FF998410-FD7E-4B0E-8754-20003E19F51D} = {3D7ED412-11AE-4AE7-8258-0FF6CF8BD11C} + EndGlobalSection +EndGlobal diff --git a/src/boost/libs/statechart/example/BitMachine/BitMachine.cpp b/src/boost/libs/statechart/example/BitMachine/BitMachine.cpp new file mode 100644 index 000000000..89478a5a4 --- /dev/null +++ b/src/boost/libs/statechart/example/BitMachine/BitMachine.cpp @@ -0,0 +1,264 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +#define NO_OF_BITS 3 +////////////////////////////////////////////////////////////////////////////// +// This program demonstrates the fact that measures must be taken to hide some +// of the complexity (e.g. in separate .cpp file) of a Boost.Statechart state +// machine once a certain size is reached. +// For this purpose, a state machine with exactly 2^NO_OF_BITS states (i.e. +// BitState< 0 > .. BitState< 2^NO_OF_BITS - 1 >) is generated. For the events +// EvFlipBit< 0 > .. EvFlipBit< NO_OF_BITS - 1 > there is a transition from +// each state to the state with the corresponding bit toggled. That is, there +// is a total of 2^NO_OF_BITS * NO_OF_BITS transitions. +// E.g. if the state machine is currently in state BitState< 5 > and receives +// EvFlipBit< 2 >, it transitions to state BitState< 1 >. If it is in +// BitState< 15 > and receives EvFlipBit< 4 > it transitions to BitState< 31 > +// etc. +// The maximum size of such a state machine depends on your compiler. The +// following table gives upper limits for NO_OF_BITS. From this, rough +// estimates for the maximum size of any "naively" implemented Boost.Statechart +// machine (i.e. no attempt is made to hide inner state implementation in a +// .cpp file) can be deduced. +// +// NOTE: Due to the fact that the amount of generated code more than +// *doubles* each time NO_OF_BITS is *incremented*, build times on most +// compilers soar when NO_OF_BITS > 6. +// +// Compiler | max. NO_OF_BITS b | max. states s | +// --------------|-------------------|----------------| +// MSVC 7.1 | b < 6 | 32 < s < 64 | +// GCC 3.4.2 (1) | b < 8 | 128 < s < 256 | +// +// (1) This is a practical rather than a hard limit, caused by a compiler +// memory footprint that was significantly larger than the 1GB physical +// memory installed in the test machine. The resulting frequent swapping +// led to compilation times of hours rather than minutes. +////////////////////////////////////////////////////////////////////////////// + + + +#include "UniqueObject.hpp" + +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/front_inserter.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/copy.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/integral_c.hpp> +#include <boost/mpl/shift_left.hpp> +#include <boost/mpl/bitxor.hpp> +#include <boost/mpl/for_each.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/aux_/lambda_support.hpp> + +#include <boost/config.hpp> +#include <boost/intrusive_ptr.hpp> + +#include <iostream> +#include <iomanip> +#include <cstddef> // size_t + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +# pragma warning( disable: 444 ) // destructor for base is not virtual +# pragma warning( disable: 981 ) // operands are evaluated in unspecified order +#endif + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +////////////////////////////////////////////////////////////////////////////// +struct IDisplay +{ + virtual void Display() const = 0; +}; + +////////////////////////////////////////////////////////////////////////////// +template< class BitNo > +struct EvFlipBit : sc::event< EvFlipBit< BitNo > > {}; + +template< class StateNo > +struct BitState; + +struct BitMachine : sc::state_machine< + BitMachine, BitState< mpl::integral_c< unsigned int, 0 > > > {}; + +template< class BitNo, class StateNo > +struct FlipTransition +{ + private: + typedef typename mpl::bitxor_< + StateNo, + mpl::shift_left< mpl::integral_c< unsigned int, 1 >, BitNo > + >::type NextStateNo; + + public: + typedef typename sc::transition< + EvFlipBit< BitNo >, BitState< NextStateNo > > type; + + BOOST_MPL_AUX_LAMBDA_SUPPORT( 2, FlipTransition, (BitNo, StateNo) ); +}; + +////////////////////////////////////////////////////////////////////////////// +void DisplayBits( unsigned int number ) +{ + char buffer[ NO_OF_BITS + 1 ]; + buffer[ NO_OF_BITS ] = 0; + + for ( unsigned int bit = 0; bit < NO_OF_BITS; ++bit ) + { + buffer[ bit ] = number & ( 1 << ( NO_OF_BITS - bit - 1 ) ) ? '1' : '0'; + } + + std::cout << "Current state: " << std::setw( 4 ) << + number << " (" << buffer << ")" << std::endl; +} + +template< class StateNo > +struct BitState : sc::simple_state< BitState< StateNo >, BitMachine >, + UniqueObject< BitState< StateNo > >, IDisplay +{ + void * operator new( std::size_t size ) + { + return UniqueObject< BitState< StateNo > >::operator new( size ); + } + + void operator delete( void * p, std::size_t size ) + { + UniqueObject< BitState< StateNo > >::operator delete( p, size ); + } + + typedef typename mpl::copy< + typename mpl::transform_view< + mpl::range_c< unsigned int, 0, NO_OF_BITS >, + FlipTransition< mpl::placeholders::_, StateNo > >::type, + mpl::front_inserter< mpl::list<> > + >::type reactions; + + virtual void Display() const + { + DisplayBits( StateNo::value ); + } +}; + + +void DisplayMachineState( const BitMachine & bitMachine ) +{ + bitMachine.state_cast< const IDisplay & >().Display(); +} + +////////////////////////////////////////////////////////////////////////////// +boost::intrusive_ptr< const sc::event_base > pFlipBitEvents[ NO_OF_BITS ]; + +struct EventInserter +{ + template< class BitNo > + void operator()( const BitNo & ) + { + pFlipBitEvents[ BitNo::value ] = new EvFlipBit< BitNo >(); + } +}; + +void FillEventArray() +{ + mpl::for_each< mpl::range_c< unsigned int, 0, NO_OF_BITS > >( + EventInserter() ); +} + +////////////////////////////////////////////////////////////////////////////// +void VisitAllStates( BitMachine & bitMachine, unsigned int msb ) +{ + if ( msb > 0 ) + { + VisitAllStates( bitMachine, msb - 1 ); + } + + bitMachine.process_event( *pFlipBitEvents[ msb ] ); + DisplayMachineState( bitMachine ); + + if ( msb > 0 ) + { + VisitAllStates( bitMachine, msb - 1 ); + } +} + +////////////////////////////////////////////////////////////////////////////// +char GetKey() +{ + char key; + std::cin >> key; + return key; +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + FillEventArray(); + + const unsigned int noOfStates = 1 << NO_OF_BITS; + std::cout << "Boost.Statechart BitMachine example\n"; + std::cout << "Machine configuration: " << noOfStates << + " states interconnected with " << noOfStates * NO_OF_BITS << + " transitions.\n\n"; + + for ( unsigned int bit = 0; bit < NO_OF_BITS; ++bit ) + { + std::cout << bit - 0 << "<CR>: Flips bit " << bit - 0 << "\n"; + } + + std::cout << "a<CR>: Goes through all states automatically\n"; + std::cout << "e<CR>: Exits the program\n\n"; + std::cout << "You may chain commands, e.g. 31<CR> flips bits 3 and 1\n\n"; + + + BitMachine bitMachine; + bitMachine.initiate(); + + char key = GetKey(); + + while ( key != 'e' ) + { + if ( ( key >= '0' ) && ( key < static_cast< char >( '0' + NO_OF_BITS ) ) ) + { + bitMachine.process_event( *pFlipBitEvents[ key - '0' ] ); + DisplayMachineState( bitMachine ); + } + else + { + switch( key ) + { + case 'a': + { + VisitAllStates( bitMachine, NO_OF_BITS - 1 ); + } + break; + + default: + { + std::cout << "Invalid key!\n"; + } + } + } + + key = GetKey(); + } + + return 0; +} diff --git a/src/boost/libs/statechart/example/BitMachine/BitMachine.vcproj b/src/boost/libs/statechart/example/BitMachine/BitMachine.vcproj new file mode 100644 index 000000000..af02845a9 --- /dev/null +++ b/src/boost/libs/statechart/example/BitMachine/BitMachine.vcproj @@ -0,0 +1,301 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="BitMachine" + ProjectGUID="{CF66596F-7DEA-4BB6-A728-F7FEF2889855}" + RootNamespace="BitMachine" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/Zm300 /bigobj" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + EnablePREfast="false" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/BitMachine.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/BitMachine.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + EmbedManifest="true" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/Zm300 /bigobj" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="true" + ExceptionHandling="1" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + EnablePREfast="false" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/BitMachine.exe" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + EmbedManifest="true" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" + > + <File + RelativePath="BitMachine.cpp" + > + </File> + </Filter> + <Filter + Name="Statechart Header Files" + Filter="h;hpp;hxx;hm;inl;inc" + > + <File + RelativePath="..\..\..\..\boost\statechart\asynchronous_state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\custom_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deep_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deferral.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_base.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_processor.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\fifo_scheduler.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\in_state_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\null_exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\result.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\shallow_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\simple_state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\termination.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\transition.hpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + > + <File + RelativePath=".\UniqueObject.hpp" + > + </File> + <File + RelativePath=".\UniqueObjectAllocator.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/BitMachine/UniqueObject.hpp b/src/boost/libs/statechart/example/BitMachine/UniqueObject.hpp new file mode 100644 index 000000000..d4e0cb288 --- /dev/null +++ b/src/boost/libs/statechart/example/BitMachine/UniqueObject.hpp @@ -0,0 +1,41 @@ +#ifndef BOOST_STATECHART_EXAMPLE_UNIQUE_OBJECT_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_UNIQUE_OBJECT_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "UniqueObjectAllocator.hpp" + +#include <cstddef> // size_t + + + +////////////////////////////////////////////////////////////////////////////// +template< class Derived > +class UniqueObject +{ + public: + ////////////////////////////////////////////////////////////////////////// + void * operator new( std::size_t size ) + { + return UniqueObjectAllocator< Derived >::allocate( size ); + } + + void operator delete( void * p, std::size_t size ) + { + UniqueObjectAllocator< Derived >::deallocate( p, size ); + } + + protected: + ////////////////////////////////////////////////////////////////////////// + UniqueObject() {} + ~UniqueObject() {} +}; + + + +#endif diff --git a/src/boost/libs/statechart/example/BitMachine/UniqueObjectAllocator.hpp b/src/boost/libs/statechart/example/BitMachine/UniqueObjectAllocator.hpp new file mode 100644 index 000000000..09c8836f3 --- /dev/null +++ b/src/boost/libs/statechart/example/BitMachine/UniqueObjectAllocator.hpp @@ -0,0 +1,78 @@ +#ifndef BOOST_STATECHART_EXAMPLE_UNIQUE_OBJECT_ALLOCATOR_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_UNIQUE_OBJECT_ALLOCATOR_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/detail/avoid_unused_warning.hpp> + +#include <boost/config.hpp> + +#ifdef BOOST_MSVC +# pragma warning( push ) +# pragma warning( disable: 4511 ) // copy constructor could not be generated +# pragma warning( disable: 4512 ) // assignment operator could not be generated +#endif + +#include <boost/type_traits/alignment_of.hpp> + +#ifdef BOOST_MSVC +# pragma warning( pop ) +#endif + +#include <boost/type_traits/type_with_alignment.hpp> +#include <boost/assert.hpp> + +#include <cstddef> // size_t + + + +////////////////////////////////////////////////////////////////////////////// +template< class T > +class UniqueObjectAllocator +{ + public: + ////////////////////////////////////////////////////////////////////////// + static void * allocate( std::size_t size ) + { + boost::statechart::detail::avoid_unused_warning( size ); + BOOST_ASSERT( !constructed_ && ( size == sizeof( T ) ) ); + constructed_ = true; + return &storage_.data_[ 0 ]; + } + + static void deallocate( void * p, std::size_t size ) + { + boost::statechart::detail::avoid_unused_warning( p ); + boost::statechart::detail::avoid_unused_warning( size ); + BOOST_ASSERT( constructed_ && + ( p == &storage_.data_[ 0 ] ) && ( size == sizeof( T ) ) ); + constructed_ = false; + } + + private: + ////////////////////////////////////////////////////////////////////////// + union storage + { + char data_[ sizeof( T ) ]; + typename boost::type_with_alignment< + boost::alignment_of< T >::value >::type aligner_; + }; + + static bool constructed_; + static storage storage_; +}; + +template< class T > +bool UniqueObjectAllocator< T >::constructed_ = false; +template< class T > +typename UniqueObjectAllocator< T >::storage + UniqueObjectAllocator< T >::storage_; + + + +#endif diff --git a/src/boost/libs/statechart/example/Camera/Camera.cpp b/src/boost/libs/statechart/example/Camera/Camera.cpp new file mode 100644 index 000000000..8e4a984c4 --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Camera.cpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Precompiled.hpp" +#include "Camera.hpp" +#include "Configuring.hpp" +#include "Shooting.hpp" + + + +////////////////////////////////////////////////////////////////////////////// +NotShooting::NotShooting() +{ + std::cout << "Entering NotShooting\n"; +} + +NotShooting::~NotShooting() +{ + std::cout << "Exiting NotShooting\n"; +} + +sc::result NotShooting::react( const EvShutterHalf & ) +{ + if ( context< Camera >().IsBatteryLow() ) + { + return forward_event(); + } + else + { + return transit< Shooting >(); + } +} + +////////////////////////////////////////////////////////////////////////////// +Idle::Idle() +{ + std::cout << "Entering Idle\n"; +} + +Idle::~Idle() +{ + std::cout << "Exiting Idle\n"; +} + +sc::result Idle::react( const EvConfig & ) +{ + return transit< Configuring >(); +} diff --git a/src/boost/libs/statechart/example/Camera/Camera.hpp b/src/boost/libs/statechart/example/Camera/Camera.hpp new file mode 100644 index 000000000..11bdf639f --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Camera.hpp @@ -0,0 +1,64 @@ +#ifndef BOOST_STATECHART_EXAMPLE_CAMERA_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_CAMERA_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/config.hpp> + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +#endif + + + +namespace sc = boost::statechart; + + + +////////////////////////////////////////////////////////////////////////////// +struct EvShutterHalf : sc::event< EvShutterHalf > {}; +struct EvShutterFull : sc::event< EvShutterFull > {}; +struct EvShutterRelease : sc::event< EvShutterRelease > {}; +struct EvConfig : sc::event< EvConfig > {}; + +struct NotShooting; +struct Camera : sc::state_machine< Camera, NotShooting > +{ + bool IsMemoryAvailable() const { return true; } + bool IsBatteryLow() const { return false; } +}; + +struct Idle; +struct NotShooting : sc::simple_state< NotShooting, Camera, Idle > +{ + typedef sc::custom_reaction< EvShutterHalf > reactions; + + NotShooting(); + ~NotShooting(); + + sc::result react( const EvShutterHalf & ); +}; + + struct Idle : sc::simple_state< Idle, NotShooting > + { + typedef sc::custom_reaction< EvConfig > reactions; + + Idle(); + ~Idle(); + + sc::result react( const EvConfig & ); + }; + + + +#endif diff --git a/src/boost/libs/statechart/example/Camera/Camera.vcproj b/src/boost/libs/statechart/example/Camera/Camera.vcproj new file mode 100644 index 000000000..b6e4edcb8 --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Camera.vcproj @@ -0,0 +1,335 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="Camera" + ProjectGUID="{7FD5B025-1675-4D68-BA85-588AFC99C5B8}" + RootNamespace="Camera" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="2" + PrecompiledHeaderThrough="Precompiled.hpp" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Camera.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/Camera.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="true" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + UsePrecompiledHeader="2" + PrecompiledHeaderThrough="Precompiled.hpp" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Camera.exe" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" + > + <File + RelativePath="Camera.cpp" + > + </File> + <File + RelativePath=".\Configuring.cpp" + > + </File> + <File + RelativePath="Main.cpp" + > + </File> + <File + RelativePath="Precompiled.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\Shooting.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc" + > + <File + RelativePath="Camera.hpp" + > + </File> + <File + RelativePath="Configuring.hpp" + > + </File> + <File + RelativePath="Precompiled.hpp" + > + </File> + <File + RelativePath="Shooting.hpp" + > + </File> + </Filter> + <Filter + Name="Statechart Header Files" + > + <File + RelativePath="..\..\..\..\boost\statechart\asynchronous_state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\custom_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deep_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deferral.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_base.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_processor.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\fifo_scheduler.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\in_state_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\null_exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\result.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\shallow_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\simple_state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\termination.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\transition.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/Camera/Configuring.cpp b/src/boost/libs/statechart/example/Camera/Configuring.cpp new file mode 100644 index 000000000..f524a88af --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Configuring.cpp @@ -0,0 +1,24 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Precompiled.hpp" +#include "Configuring.hpp" +#include <iostream> +#include <stdexcept> + + + +Configuring::Configuring() +{ + std::cout << "Entering Configuring\n"; +} + +Configuring::~Configuring() +{ + std::cout << "Exiting Configuring\n"; +} diff --git a/src/boost/libs/statechart/example/Camera/Configuring.hpp b/src/boost/libs/statechart/example/Camera/Configuring.hpp new file mode 100644 index 000000000..39819e5fb --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Configuring.hpp @@ -0,0 +1,39 @@ +#ifndef BOOST_STATECHART_EXAMPLE_CONFIGURING_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_CONFIGURING_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Camera.hpp" + +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/config.hpp> + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +#endif + + + +namespace sc = boost::statechart; + + + +////////////////////////////////////////////////////////////////////////////// +struct Configuring : sc::simple_state< Configuring, NotShooting > +{ + typedef sc::transition< EvConfig, Idle > reactions; + + Configuring(); + ~Configuring(); +}; + + + +#endif diff --git a/src/boost/libs/statechart/example/Camera/Main.cpp b/src/boost/libs/statechart/example/Camera/Main.cpp new file mode 100644 index 000000000..d99bfe9e4 --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Main.cpp @@ -0,0 +1,110 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// This program shows how a state machine can be spread over several +// translation units if necessary. The inner workings of a digital camera are +// modeled, the corresponding state chart looks as follows: +// +// --------------------------- +// | | +// | NotShooting | +// | | +// | ------------- |<---O +// | O--->| Idle | | -------------- +// | ------------- | EvShutterHalf | | +// | | ^ |------------------>| Shooting | +// | EvConfig | | EvConfig | | | +// | v | | EvShutterRelease | | +// | ------------- |<------------------| | +// | | Configuring | | | | +// | ------------- | -------------- +// --------------------------- +// +// The states Configuring and Shooting will contain a large amount of logic, +// so they are implemented in their own translation units. This way one team +// could implement the Configuring mode while the other would work on the +// Shooting mode. Once the above state chart is implemented, the teams could +// work completely independently of each other. + + + +#include "Precompiled.hpp" +#include "Camera.hpp" +#include <iostream> + + + +////////////////////////////////////////////////////////////////////////////// +char GetKey() +{ + char key; + std::cin >> key; + return key; +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + std::cout << "Boost.Statechart Camera example\n\n"; + + std::cout << "h<CR>: Press shutter half-way\n"; + std::cout << "f<CR>: Press shutter fully\n"; + std::cout << "r<CR>: Release shutter\n"; + std::cout << "c<CR>: Enter/exit configuration\n"; + std::cout << "e<CR>: Exits the program\n\n"; + std::cout << "You may chain commands, e.g. hfr<CR> first presses the shutter half-way,\n"; + std::cout << "fully and then releases it.\n\n"; + + + Camera myCamera; + myCamera.initiate(); + + char key = GetKey(); + + while ( key != 'e' ) + { + switch( key ) + { + case 'h': + { + myCamera.process_event( EvShutterHalf() ); + } + break; + + case 'f': + { + myCamera.process_event( EvShutterFull() ); + } + break; + + case 'r': + { + myCamera.process_event( EvShutterRelease() ); + } + break; + + case 'c': + { + myCamera.process_event( EvConfig() ); + } + break; + + default: + { + std::cout << "Invalid key!\n"; + } + break; + } + + key = GetKey(); + } + + return 0; +} diff --git a/src/boost/libs/statechart/example/Camera/Precompiled.cpp b/src/boost/libs/statechart/example/Camera/Precompiled.cpp new file mode 100644 index 000000000..c85c33d38 --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Precompiled.cpp @@ -0,0 +1,9 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Precompiled.hpp" diff --git a/src/boost/libs/statechart/example/Camera/Precompiled.hpp b/src/boost/libs/statechart/example/Camera/Precompiled.hpp new file mode 100644 index 000000000..ad71c5e63 --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Precompiled.hpp @@ -0,0 +1,20 @@ +#ifndef BOOST_STATECHART_EXAMPLE_PRECOMPILED_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_PRECOMPILED_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/custom_reaction.hpp> +#include <boost/mpl/list.hpp> +#include <iostream> + + + +#endif diff --git a/src/boost/libs/statechart/example/Camera/Shooting.cpp b/src/boost/libs/statechart/example/Camera/Shooting.cpp new file mode 100644 index 000000000..ae9a1abce --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Shooting.cpp @@ -0,0 +1,71 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Precompiled.hpp" +#include "Shooting.hpp" +#include <iostream> + +#include <boost/config.hpp> + +#ifdef BOOST_INTEL +# pragma warning( disable: 383 ) // reference to temporary used +#endif + + + +////////////////////////////////////////////////////////////////////////////// +Shooting::Shooting() +{ + std::cout << "Entering Shooting\n"; +} + +Shooting::~Shooting() +{ + std::cout << "Exiting Shooting\n"; +} + +////////////////////////////////////////////////////////////////////////////// +struct Storing : sc::simple_state< Storing, Shooting > +{ + Storing() + { + std::cout << "Picture taken!\n"; + } +}; + +////////////////////////////////////////////////////////////////////////////// +struct Focused : sc::simple_state< Focused, Shooting > +{ + typedef sc::custom_reaction< EvShutterFull > reactions; + + sc::result react( const EvShutterFull & ); +}; + +sc::result Focused::react( const EvShutterFull & ) +{ + if ( context< Camera >().IsMemoryAvailable() ) + { + return transit< Storing >(); + } + else + { + std::cout << "Cache memory full. Please wait...\n"; + return discard_event(); + } +} + +////////////////////////////////////////////////////////////////////////////// +Focusing::Focusing( my_context ctx ) : my_base( ctx ) +{ + post_event( boost::intrusive_ptr< EvInFocus >( new EvInFocus() ) ); +} + +sc::result Focusing::react( const EvInFocus & evt ) +{ + return transit< Focused >( &Shooting::DisplayFocused, evt ); +} diff --git a/src/boost/libs/statechart/example/Camera/Shooting.hpp b/src/boost/libs/statechart/example/Camera/Shooting.hpp new file mode 100644 index 000000000..1ae85d924 --- /dev/null +++ b/src/boost/libs/statechart/example/Camera/Shooting.hpp @@ -0,0 +1,64 @@ +#ifndef BOOST_STATECHART_EXAMPLE_SHOOTING_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_SHOOTING_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Camera.hpp" + +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> +#include <boost/statechart/deferral.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/config.hpp> + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +#endif + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +////////////////////////////////////////////////////////////////////////////// +struct EvInFocus : sc::event< EvInFocus > {}; + +struct Focusing; +struct Shooting : sc::simple_state< Shooting, Camera, Focusing > +{ + typedef sc::transition< EvShutterRelease, NotShooting > reactions; + + Shooting(); + ~Shooting(); + + void DisplayFocused( const EvInFocus & ) + { + std::cout << "Focused!\n"; + } +}; + + struct Focusing : sc::state< Focusing, Shooting > + { + typedef mpl::list< + sc::custom_reaction< EvInFocus >, + sc::deferral< EvShutterFull > + > reactions; + + Focusing( my_context ctx ); + sc::result react( const EvInFocus & ); + }; + + + +#endif diff --git a/src/boost/libs/statechart/example/Handcrafted/Handcrafted.cpp b/src/boost/libs/statechart/example/Handcrafted/Handcrafted.cpp new file mode 100644 index 000000000..7b77c26f4 --- /dev/null +++ b/src/boost/libs/statechart/example/Handcrafted/Handcrafted.cpp @@ -0,0 +1,205 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// This is a quick-and-dirty handcrafted state machine with two states and two +// transitions employing GOF-visitation (two virtual calls per event). +// It is used to make speed comparisons with Boost.Statechart machines. +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/config.hpp> + +#include <iostream> +#include <iomanip> +#include <ctime> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std +{ + using ::clock_t; + using ::clock; +} +#endif + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +#endif + + + +////////////////////////////////////////////////////////////////////////////// +class EvFlipBit; +class state_base +{ + public: + virtual ~state_base() {}; + + virtual const state_base & react( const EvFlipBit & toEvent ) const = 0; + + protected: + state_base() {} +}; + +template< class Derived > +class state : public state_base +{ + public: + state() : state_base() { } + + static const Derived & instance() + { + return instance_; + } + + private: + static const Derived instance_; +}; + +template< class Derived > +const Derived state< Derived >::instance_; + + +////////////////////////////////////////////////////////////////////////////// +class event_base +{ + public: + virtual ~event_base() {} + + protected: + event_base() {} + + public: + virtual const state_base & send( const state_base & toState ) const = 0; +}; + +template< class Derived > +class event : public event_base +{ + protected: + event() {} + + private: + virtual const state_base & send( const state_base & toState ) const + { + return toState.react( *static_cast< const Derived * >( this ) ); + } +}; + + +////////////////////////////////////////////////////////////////////////////// +class EvFlipBit : public event< EvFlipBit > { +public: + EvFlipBit() : event < EvFlipBit >() { } +}; +const EvFlipBit flip; + +class BitMachine +{ + public: + ////////////////////////////////////////////////////////////////////////// + BitMachine() : pCurrentState_( &Off::instance() ) {} + + void process_event( const event_base & evt ) + { + pCurrentState_ = &evt.send( *pCurrentState_ ); + } + + private: + ////////////////////////////////////////////////////////////////////////// + struct On : state< On > + { + On() : state<On>() { } + + virtual const state_base & react( const EvFlipBit & ) const + { + return Off::instance(); + } + }; + + struct Off : state< Off > + { + Off() : state<Off>() { } + + virtual const state_base & react( const EvFlipBit & ) const + { + return On::instance(); + } + }; + + const state_base * pCurrentState_; +}; + + +////////////////////////////////////////////////////////////////////////////// +char GetKey() +{ + char key; + std::cin >> key; + return key; +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + // common prime factors of 2^n-1 for n in [1,8] + const unsigned int noOfEvents = 3 * 3 * 5 * 7 * 17 * 31 * 127; + unsigned long eventsSentTotal = 0; + + std::cout << "Boost.Statechart Handcrafted example\n"; + std::cout << "Machine configuration: " << 2 << + " states interconnected with " << 2 << " transitions.\n\n"; + + std::cout << "p<CR>: Performance test\n"; + std::cout << "e<CR>: Exits the program\n\n"; + std::cout << + "You may chain commands, e.g. pe<CR> performs a test and then exits the program\n\n"; + + BitMachine bitMachine; + + char key = GetKey(); + + while ( key != 'e' ) + { + switch ( key ) + { + case 'p': + { + std::cout << "\nSending " << noOfEvents << + " events. Please wait...\n"; + + const unsigned long startEvents2 = eventsSentTotal; + const std::clock_t startTime2 = std::clock(); + + for ( unsigned int eventNo = 0; eventNo < noOfEvents; ++eventNo ) + { + bitMachine.process_event( flip ); + ++eventsSentTotal; + } + + const std::clock_t elapsedTime2 = std::clock() - startTime2; + const unsigned int eventsSent2 = eventsSentTotal - startEvents2; + std::cout << "Time to dispatch one event and\n" << + "perform the resulting transition: "; + std::cout << elapsedTime2 * 1000.0 / eventsSent2 << " microseconds\n\n"; + } + break; + + default: + { + std::cout << "Invalid key!\n"; + } + } + + key = GetKey(); + } + + return 0; +} diff --git a/src/boost/libs/statechart/example/Handcrafted/Handcrafted.vcproj b/src/boost/libs/statechart/example/Handcrafted/Handcrafted.vcproj new file mode 100644 index 000000000..6cda53079 --- /dev/null +++ b/src/boost/libs/statechart/example/Handcrafted/Handcrafted.vcproj @@ -0,0 +1,205 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="Handcrafted" + ProjectGUID="{155DB9E1-28AC-4671-8248-5FD03E8FCDAD}" + RootNamespace="Handcrafted" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/Zm300" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Handcrafted.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/Handcrafted.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/Zm300" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="true" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Handcrafted.exe" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" + > + <File + RelativePath="Handcrafted.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/Jamfile.v2 b/src/boost/libs/statechart/example/Jamfile.v2 new file mode 100644 index 000000000..2a4851ca1 --- /dev/null +++ b/src/boost/libs/statechart/example/Jamfile.v2 @@ -0,0 +1,75 @@ +############################################################################## +# Copyright 2005-2006 Andreas Huber Doenni +# Distributed under the Boost Software License, Version 1.0. (See accompany- +# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +############################################################################## + +project libs/statechart/example ; + +local custom = <define>CUSTOMIZE_MEMORY_MANAGEMENT ; +local native = <define>BOOST_STATECHART_USE_NATIVE_RTTI ; + +rule independent-obj-build ( + name : directory : cpp-sources + : requirements * ) +{ + local objs ; + + for local cpp-source in $(cpp-sources) + { + obj $(name)$(cpp-source) + : $(directory)/$(cpp-source).cpp : $(requirements) ; + objs += $(name)$(cpp-source) ; + } + + return $(objs) ; +} + +rule statechart-st-example-build ( + name : directory : cpp-sources + : requirements * ) +{ + exe $(name) : [ independent-obj-build $(name) + : $(directory) : $(cpp-sources) + # Some platforms have either problems with the automatic + # detection of the threading mode (e.g. vc-7_1 & + # gcc >= 3.4.0) or don't support single-threaded mode + # (e.g. vc-8_0). We therefore manually turn MT + # off here + : <threading>single <define>BOOST_DISABLE_THREADS $(requirements) ] ; + + return $(name) ; +} + +rule statechart-mt-example-build ( + name : directory : cpp-sources + : requirements * ) +{ + exe $(name) : [ independent-obj-build $(name) + : $(directory) : $(cpp-sources) + : <threading>multi $(requirements) ] + ../../thread/build//boost_thread ; + + return $(name) ; +} + +stage run + : [ statechart-st-example-build BitMachine : BitMachine : BitMachine ] + [ statechart-st-example-build Camera + : Camera : Camera Configuring Main Shooting ] + [ statechart-st-example-build Handcrafted : Handcrafted : Handcrafted ] + [ statechart-st-example-build KeyboardNormal : Keyboard : Keyboard ] + [ statechart-st-example-build KeyboardNative + : Keyboard : Keyboard : $(native) ] + [ statechart-st-example-build PingPongSingle + : PingPong : PingPong Player : $(custom) ] + [ statechart-mt-example-build PingPongMulti1 + : PingPong : PingPong Player : $(custom) ] + [ statechart-mt-example-build PingPongMulti2 + : PingPong : PingPong Player : $(custom) <define>USE_TWO_THREADS ] + [ statechart-st-example-build StopWatch : StopWatch : StopWatch ] + [ statechart-st-example-build StopWatch2 : StopWatch : StopWatch2 ] + [ statechart-st-example-build PerformanceNormal + : Performance : Performance ] + [ statechart-st-example-build PerformanceCustom + : Performance : Performance : $(custom) ] + [ statechart-st-example-build PerformanceNative + : Performance : Performance : $(native) ] + : <install-dependencies>on <install-type>EXE <install-type>SHARED_LIB ; diff --git a/src/boost/libs/statechart/example/Keyboard/Keyboard.cpp b/src/boost/libs/statechart/example/Keyboard/Keyboard.cpp new file mode 100644 index 000000000..e9f086720 --- /dev/null +++ b/src/boost/libs/statechart/example/Keyboard/Keyboard.cpp @@ -0,0 +1,182 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// The following example program demonstrates the use of orthogonal states and +// state_downcast to query the state of orthogonal regions. +// Moreover, the use of the state type information interface is also shown. +////////////////////////////////////////////////////////////////////////////// +// #define BOOST_STATECHART_USE_NATIVE_RTTI + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/config.hpp> + +#include <iostream> +#include <iomanip> + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +# pragma warning( disable: 981 ) // operands are evaluated in unspecified order +#endif + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +////////////////////////////////////////////////////////////////////////////// +struct EvNumLockPressed : sc::event< EvNumLockPressed > {}; +struct EvCapsLockPressed : sc::event< EvCapsLockPressed > {}; +struct EvScrollLockPressed : sc::event< EvScrollLockPressed > {}; +struct EvRequestShutdown : sc::event< EvRequestShutdown > {}; + +struct Active; +struct Keyboard : sc::state_machine< Keyboard, Active > {}; + +struct NumLockOff; +struct CapsLockOff; +struct ScrollLockOff; +struct Active: sc::simple_state< + Active, Keyboard, mpl::list< NumLockOff, CapsLockOff, ScrollLockOff > > +{ + typedef sc::custom_reaction< EvRequestShutdown > reactions; + + sc::result react( const EvRequestShutdown & ); +}; + + struct NumLockOn : sc::simple_state< NumLockOn, Active::orthogonal< 0 > > + { + typedef sc::transition< EvNumLockPressed, NumLockOff > reactions; + }; + + struct NumLockOff : sc::simple_state< NumLockOff, Active::orthogonal< 0 > > + { + typedef sc::transition< EvNumLockPressed, NumLockOn > reactions; + }; + + struct CapsLockOn : sc::simple_state< CapsLockOn, Active::orthogonal< 1 > > + { + typedef sc::transition< EvCapsLockPressed, CapsLockOff > reactions; + }; + + struct CapsLockOff : sc::simple_state< CapsLockOff, Active::orthogonal< 1 > > + { + typedef sc::transition< EvCapsLockPressed, CapsLockOn > reactions; + }; + + struct ScrollLockOn : sc::simple_state< ScrollLockOn, Active::orthogonal< 2 > > + { + typedef sc::transition< EvScrollLockPressed, ScrollLockOff > reactions; + }; + + struct ScrollLockOff : sc::simple_state< ScrollLockOff, Active::orthogonal< 2 > > + { + typedef sc::transition< EvScrollLockPressed, ScrollLockOn > reactions; + }; + +sc::result Active::react( const EvRequestShutdown & ) +{ + if ( ( state_downcast< const NumLockOff * >() != 0 ) && + ( state_downcast< const CapsLockOff * >() != 0 ) && + ( state_downcast< const ScrollLockOff * >() != 0 ) ) + { + std::cout << "Shutdown request accepted\n"; + return terminate(); + } + else + { + std::cout << "Ignoring shutdown request\n\n"; + return discard_event(); + } +} + + +////////////////////////////////////////////////////////////////////////////// +void DisplayStateConfiguration( const Keyboard & keyboard ) +{ + char orthogonalRegion = 'a'; + + for ( Keyboard::state_iterator pLeafState = keyboard.state_begin(); + pLeafState != keyboard.state_end(); ++pLeafState ) + { + std::cout << "Orthogonal region " << orthogonalRegion << ": "; + + const Keyboard::state_base_type * pState = &*pLeafState; + + while ( pState != 0 ) + { + if ( pState != &*pLeafState ) + { + std::cout << " -> "; + } + + #ifdef BOOST_STATECHART_USE_NATIVE_RTTI + std::cout << std::setw( 15 ) << typeid( *pState ).name(); + #else + std::cout << std::setw( 15 ) << + pState->custom_dynamic_type_ptr< char >(); + #endif + pState = pState->outer_state_ptr(); + } + + std::cout << "\n"; + ++orthogonalRegion; + } + + std::cout << "\n"; +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + #ifndef BOOST_STATECHART_USE_NATIVE_RTTI + Active::custom_static_type_ptr( "Active" ); + NumLockOn::custom_static_type_ptr( "NumLockOn" ); + NumLockOff::custom_static_type_ptr( "NumLockOff" ); + CapsLockOn::custom_static_type_ptr( "CapsLockOn" ); + CapsLockOff::custom_static_type_ptr( "CapsLockOff" ); + ScrollLockOn::custom_static_type_ptr( "ScrollLockOn" ); + ScrollLockOff::custom_static_type_ptr( "ScrollLockOff" ); + #endif + + std::cout << "Boost.Statechart Keyboard example\n\n"; + Keyboard keyboard; + keyboard.initiate(); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvNumLockPressed() ); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvRequestShutdown() ); + keyboard.process_event( EvCapsLockPressed() ); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvRequestShutdown() ); + keyboard.process_event( EvScrollLockPressed() ); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvRequestShutdown() ); + + keyboard.process_event( EvNumLockPressed() ); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvRequestShutdown() ); + keyboard.process_event( EvCapsLockPressed() ); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvRequestShutdown() ); + keyboard.process_event( EvScrollLockPressed() ); + DisplayStateConfiguration( keyboard ); + keyboard.process_event( EvRequestShutdown() ); + + return 0; +} diff --git a/src/boost/libs/statechart/example/Keyboard/Keyboard.vcproj b/src/boost/libs/statechart/example/Keyboard/Keyboard.vcproj new file mode 100644 index 000000000..9ce6ac0ac --- /dev/null +++ b/src/boost/libs/statechart/example/Keyboard/Keyboard.vcproj @@ -0,0 +1,284 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="Keyboard" + ProjectGUID="{4CBF564B-EEC6-49E1-B69B-CABF5DDFC684}" + RootNamespace="Keyboard" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Keyboard.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/Keyboard.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="true" + ExceptionHandling="1" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Keyboard.exe" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\Keyboard.cpp" + > + </File> + </Filter> + <Filter + Name="Statechart Header Files" + > + <File + RelativePath="..\..\..\..\boost\statechart\asynchronous_state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\custom_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deep_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deferral.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_base.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_processor.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\fifo_scheduler.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\in_state_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\null_exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\result.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\shallow_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\simple_state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\termination.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\transition.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/Performance/Performance.cpp b/src/boost/libs/statechart/example/Performance/Performance.cpp new file mode 100644 index 000000000..7b127ce26 --- /dev/null +++ b/src/boost/libs/statechart/example/Performance/Performance.cpp @@ -0,0 +1,522 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// #define CUSTOMIZE_MEMORY_MANAGEMENT +// #define BOOST_STATECHART_USE_NATIVE_RTTI +////////////////////////////////////////////////////////////////////////////// +// This program measures event processing performance of the BitMachine +// (see BitMachine example for more information) with a varying number of +// states. Also, a varying number of transitions are replaced with in-state +// reactions. This allows us to calculate how much time is spent for state- +// entry and state-exit during a transition. All measurements are written to +// comma-separated-values files, one file for each individual BitMachine. +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/in_state_reaction.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/front_inserter.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/copy.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/integral_c.hpp> +#include <boost/mpl/shift_left.hpp> +#include <boost/mpl/bitxor.hpp> +#include <boost/mpl/for_each.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/aux_/lambda_support.hpp> + +#include <boost/intrusive_ptr.hpp> +#include <boost/config.hpp> +#include <boost/assert.hpp> + +#ifdef CUSTOMIZE_MEMORY_MANAGEMENT +# ifdef BOOST_MSVC +# pragma warning( push ) +# pragma warning( disable: 4127 ) // conditional expression is constant +# pragma warning( disable: 4800 ) // forcing value to bool 'true' or 'false' +# endif +# define BOOST_NO_MT +# include <boost/pool/pool_alloc.hpp> +# ifdef BOOST_MSVC +# pragma warning( pop ) +# endif +#endif + +#include <vector> +#include <ctime> +#include <iostream> +#include <fstream> +#include <iomanip> +#include <ios> +#include <string> +#include <algorithm> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std +{ + using ::clock_t; + using ::clock; +} +#endif + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +# pragma warning( disable: 444 ) // destructor for base is not virtual +# pragma warning( disable: 981 ) // operands are evaluated in unspecified order +#endif + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +////////////////////////////////////////////////////////////////////////////// +typedef mpl::integral_c< unsigned int, 0 > uint0; +typedef mpl::integral_c< unsigned int, 1 > uint1; +typedef mpl::integral_c< unsigned int, 2 > uint2; +typedef mpl::integral_c< unsigned int, 3 > uint3; +typedef mpl::integral_c< unsigned int, 4 > uint4; +typedef mpl::integral_c< unsigned int, 5 > uint5; +typedef mpl::integral_c< unsigned int, 6 > uint6; +typedef mpl::integral_c< unsigned int, 7 > uint7; +typedef mpl::integral_c< unsigned int, 8 > uint8; +typedef mpl::integral_c< unsigned int, 9 > uint9; + +////////////////////////////////////////////////////////////////////////////// +template< class BitNo > +struct EvFlipBit : sc::event< EvFlipBit< BitNo > > {}; + +boost::intrusive_ptr< const sc::event_base > pFlipBitEvents[] = +{ + new EvFlipBit< uint0 >, + new EvFlipBit< uint1 >, + new EvFlipBit< uint2 >, + new EvFlipBit< uint3 >, + new EvFlipBit< uint4 >, + new EvFlipBit< uint5 >, + new EvFlipBit< uint6 >, + new EvFlipBit< uint7 >, + new EvFlipBit< uint8 >, + new EvFlipBit< uint9 > +}; + + +////////////////////////////////////////////////////////////////////////////// +template< + class StateNo, + class NoOfBits, + class FirstTransitionBit > +struct BitState; + +template< class NoOfBits, class FirstTransitionBit > +struct BitMachine : sc::state_machine< + BitMachine< NoOfBits, FirstTransitionBit >, + BitState< uint0, NoOfBits, FirstTransitionBit > + #ifdef CUSTOMIZE_MEMORY_MANAGEMENT + , boost::fast_pool_allocator< int > + #endif +> +{ + public: + BitMachine() : inStateReactions_( 0 ), transitions_( 0 ) {} + + // GCC 3.4.2 doesn't seem to instantiate a function template despite the + // fact that an address of the instantiation is passed as a non-type + // template argument. This leads to linker errors when a function template + // is defined instead of the overloads below. + void InStateReaction( const EvFlipBit< uint0 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint1 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint2 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint3 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint4 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint5 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint6 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint7 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint8 > & ) + { + ++inStateReactions_; + } + + void InStateReaction( const EvFlipBit< uint9 > & ) + { + ++inStateReactions_; + } + + void Transition( const EvFlipBit< uint0 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint1 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint2 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint3 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint4 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint5 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint6 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint7 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint8 > & ) + { + ++transitions_; + } + + void Transition( const EvFlipBit< uint9 > & ) + { + ++transitions_; + } + + unsigned int GetNoOfInStateReactions() const + { + return inStateReactions_; + } + + unsigned int GetNoOfTransitions() const + { + return transitions_; + } + + private: + unsigned int inStateReactions_; + unsigned int transitions_; +}; + +////////////////////////////////////////////////////////////////////////////// +template< + class BitNo, class StateNo, class NoOfBits, class FirstTransitionBit > +struct FlipTransition +{ + private: + typedef typename mpl::bitxor_< + StateNo, + mpl::shift_left< uint1, BitNo > + >::type NextStateNo; + + public: + typedef typename mpl::if_< + mpl::less< BitNo, FirstTransitionBit >, + sc::in_state_reaction< + EvFlipBit< BitNo >, + BitMachine< NoOfBits, FirstTransitionBit >, + &BitMachine< NoOfBits, FirstTransitionBit >::InStateReaction >, + sc::transition< + EvFlipBit< BitNo >, + BitState< NextStateNo, NoOfBits, FirstTransitionBit >, + BitMachine< NoOfBits, FirstTransitionBit >, + &BitMachine< NoOfBits, FirstTransitionBit >::Transition > + >::type type; + + BOOST_MPL_AUX_LAMBDA_SUPPORT( + 3, FlipTransition, (BitNo, StateNo, FirstTransitionBit) ); +}; + +////////////////////////////////////////////////////////////////////////////// +template< + class StateNo, + class NoOfBits, + class FirstTransitionBit > +struct BitState : sc::simple_state< + BitState< StateNo, NoOfBits, FirstTransitionBit >, + BitMachine< NoOfBits, FirstTransitionBit > > +{ + typedef typename mpl::copy< + typename mpl::transform_view< + mpl::range_c< unsigned int, 0, NoOfBits::value >, + FlipTransition< + mpl::placeholders::_, StateNo, NoOfBits, FirstTransitionBit > + >::type, + mpl::front_inserter< mpl::list<> > + >::type reactions; +}; + +// GCC 3.4.2 doesn't seem to instantiate a class template member function +// despite the fact that an address of the function is passed as a non-type +// template argument. This leads to linker errors when the class template +// defining the functions is not explicitly instantiated. +template struct BitMachine< uint1, uint0 >; +template struct BitMachine< uint1, uint1 >; + +template struct BitMachine< uint2, uint0 >; +template struct BitMachine< uint2, uint1 >; +template struct BitMachine< uint2, uint2 >; + +template struct BitMachine< uint3, uint0 >; +template struct BitMachine< uint3, uint1 >; +template struct BitMachine< uint3, uint2 >; +template struct BitMachine< uint3, uint3 >; + +template struct BitMachine< uint4, uint0 >; +template struct BitMachine< uint4, uint1 >; +template struct BitMachine< uint4, uint2 >; +template struct BitMachine< uint4, uint3 >; +template struct BitMachine< uint4, uint4 >; + +template struct BitMachine< uint5, uint0 >; +template struct BitMachine< uint5, uint1 >; +template struct BitMachine< uint5, uint2 >; +template struct BitMachine< uint5, uint3 >; +template struct BitMachine< uint5, uint4 >; +template struct BitMachine< uint5, uint5 >; + +template struct BitMachine< uint6, uint0 >; +template struct BitMachine< uint6, uint1 >; +template struct BitMachine< uint6, uint2 >; +template struct BitMachine< uint6, uint3 >; +template struct BitMachine< uint6, uint4 >; +template struct BitMachine< uint6, uint5 >; +template struct BitMachine< uint6, uint6 >; + +template struct BitMachine< uint7, uint0 >; +template struct BitMachine< uint7, uint1 >; +template struct BitMachine< uint7, uint2 >; +template struct BitMachine< uint7, uint3 >; +template struct BitMachine< uint7, uint4 >; +template struct BitMachine< uint7, uint5 >; +template struct BitMachine< uint7, uint6 >; +template struct BitMachine< uint7, uint7 >; + + +//////////////////////////////////////////////////////////////////////////// +struct PerfResult +{ + PerfResult( double inStateRatio, double nanoSecondsPerReaction ) : + inStateRatio_( inStateRatio ), + nanoSecondsPerReaction_( nanoSecondsPerReaction ) + { + } + + double inStateRatio_; + double nanoSecondsPerReaction_; +}; + +template< class NoOfBits, class FirstTransitionBit > +class PerformanceTester +{ + public: + //////////////////////////////////////////////////////////////////////// + static PerfResult Test() + { + eventsSent_ = 0; + BitMachine< NoOfBits, FirstTransitionBit > machine; + machine.initiate(); + const std::clock_t startTime = std::clock(); + + const unsigned int laps = eventsToSend_ / ( GetNoOfStates() - 1 ); + + for ( unsigned int lap = 0; lap < laps; ++lap ) + { + VisitAllStatesImpl( machine, NoOfBits::value - 1 ); + } + + const std::clock_t elapsedTime = std::clock() - startTime; + + BOOST_ASSERT( eventsSent_ == eventsToSend_ ); + BOOST_ASSERT( + machine.GetNoOfInStateReactions() + + machine.GetNoOfTransitions() == eventsSent_ ); + + return PerfResult( + static_cast< double >( machine.GetNoOfInStateReactions() ) / + eventsSent_, + static_cast< double >( elapsedTime ) / + CLOCKS_PER_SEC * 1000.0 * 1000.0 * 1000.0 / eventsSent_ ); + } + + static unsigned int GetNoOfStates() + { + return 1 << NoOfBits::value; + } + + static unsigned int GetNoOfReactions() + { + return GetNoOfStates() * NoOfBits::value; + } + + private: + //////////////////////////////////////////////////////////////////////// + static void VisitAllStatesImpl( + BitMachine< NoOfBits, FirstTransitionBit > & machine, + unsigned int bit ) + { + if ( bit > 0 ) + { + PerformanceTester< NoOfBits, FirstTransitionBit >:: + VisitAllStatesImpl( machine, bit - 1 ); + } + + machine.process_event( *pFlipBitEvents[ bit ] ); + ++PerformanceTester< NoOfBits, FirstTransitionBit >::eventsSent_; + + if ( bit > 0 ) + { + PerformanceTester< NoOfBits, FirstTransitionBit >:: + VisitAllStatesImpl( machine, bit - 1 ); + } + } + + // common prime factors of 2^n-1 for n in [1,8] + static const unsigned int eventsToSend_ = 3 * 3 * 5 * 7 * 17 * 31 * 127; + static unsigned int eventsSent_; +}; + +template< class NoOfBits, class FirstTransitionBit > +unsigned int PerformanceTester< NoOfBits, FirstTransitionBit >::eventsSent_; + + +////////////////////////////////////////////////////////////////////////////// +typedef std::vector< PerfResult > PerfResultList; + +template< class NoOfBits > +struct PerfResultBackInserter +{ + public: + PerfResultBackInserter( PerfResultList & perfResultList ) : + perfResultList_( perfResultList ) + { + } + + template< class FirstTransitionBit > + void operator()( const FirstTransitionBit & ) + { + perfResultList_.push_back( + PerformanceTester< NoOfBits, FirstTransitionBit >::Test() ); + } + + private: + // avoids C4512 (assignment operator could not be generated) + PerfResultBackInserter & operator=( const PerfResultBackInserter & ); + + PerfResultList & perfResultList_; +}; + +template< class NoOfBits > +std::vector< PerfResult > TestMachine() +{ + PerfResultList result; + + mpl::for_each< mpl::range_c< unsigned int, 0, NoOfBits::value + 1 > >( + PerfResultBackInserter< NoOfBits >( result ) ); + + return result; +} + +template< class NoOfBits > +void TestAndWriteResults() +{ + PerfResultList results = TestMachine< NoOfBits >(); + + std::fstream output; + output.exceptions( + std::ios_base::badbit | std::ios_base::eofbit | std::ios_base::failbit ); + + std::string prefix = std::string( BOOST_COMPILER ) + "__"; + std::replace( prefix.begin(), prefix.end(), ' ', '_' ); + + output.open( + ( prefix + std::string( 1, '0' + static_cast< char >( NoOfBits::value ) ) + + ".txt" ).c_str(), + std::ios_base::out ); + + for ( PerfResultList::const_iterator pResult = results.begin(); + pResult != results.end(); ++pResult ) + { + output << std::fixed << std::setprecision( 0 ) << + std::setw( 8 ) << pResult->inStateRatio_ * 100 << ',' << + std::setw( 8 ) << pResult->nanoSecondsPerReaction_ << "\n"; + } +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + std::cout << + "Boost.Statechart in-state reaction vs. transition performance test\n\n"; + std::cout << "Press <CR> to start the test: "; + + { + std::string input; + std::getline( std::cin, input ); + } + + TestAndWriteResults< uint1 >(); + TestAndWriteResults< uint2 >(); + TestAndWriteResults< uint3 >(); + + return 0; +} diff --git a/src/boost/libs/statechart/example/Performance/Performance.vcproj b/src/boost/libs/statechart/example/Performance/Performance.vcproj new file mode 100644 index 000000000..3f59de013 --- /dev/null +++ b/src/boost/libs/statechart/example/Performance/Performance.vcproj @@ -0,0 +1,285 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="Performance" + ProjectGUID="{045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}" + RootNamespace="Performance" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/Zm800" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Performance.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/Performance.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/Zm800" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="true" + ExceptionHandling="1" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Performance.exe" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" + > + <File + RelativePath="Performance.cpp" + > + </File> + </Filter> + <Filter + Name="Statechart Header Files" + Filter="h;hpp;hxx;hm;inl;inc" + > + <File + RelativePath="..\..\..\..\boost\statechart\asynchronous_state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\custom_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deep_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deferral.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_base.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_processor.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\fifo_scheduler.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\in_state_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\null_exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\result.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\shallow_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\simple_state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\termination.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\transition.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/Performance/Performance.xls b/src/boost/libs/statechart/example/Performance/Performance.xls Binary files differnew file mode 100644 index 000000000..1eb95ad29 --- /dev/null +++ b/src/boost/libs/statechart/example/Performance/Performance.xls diff --git a/src/boost/libs/statechart/example/PingPong/PingPong.cpp b/src/boost/libs/statechart/example/PingPong/PingPong.cpp new file mode 100644 index 000000000..715ebf98b --- /dev/null +++ b/src/boost/libs/statechart/example/PingPong/PingPong.cpp @@ -0,0 +1,181 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// #define USE_TWO_THREADS // ignored for single-threaded builds +// #define CUSTOMIZE_MEMORY_MANAGEMENT +////////////////////////////////////////////////////////////////////////////// +// The following example program demonstrates the use of asynchronous state +// machines. First, it creates two objects of the same simple state machine +// mimicking a table tennis player. It then sends an event (the ball) to the +// first state machine. Upon reception, the first machine sends a similar +// event to the second state machine, which then sends the event back to the +// first machine. The two machines continue to bounce the event back and forth +// until one machine "has enough" and aborts the game. The two players don't +// "know" each other, they can only pass the ball back and forth because the +// event representing the ball also carries two boost::function objects. +// Both reference the fifo_scheduler<>::queue_event() function, binding the +// scheduler and the handle of the opponent. One can be used to return the +// ball to the opponent and the other can be used to abort the game. +// Depending on whether the program is compiled single-threaded or +// multi-threaded and the USE_TWO_THREADS define above, the two +// machines either run in the same thread without/with mutex locking or in two +// different threads with mutex locking. +////////////////////////////////////////////////////////////////////////////// + + +#include "Player.hpp" + +#include <boost/statechart/asynchronous_state_machine.hpp> +#include <boost/statechart/fifo_worker.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/config.hpp> +#include <boost/intrusive_ptr.hpp> +#include <boost/function.hpp> +#include <boost/bind.hpp> + +#ifdef BOOST_HAS_THREADS +# include <boost/thread/thread.hpp> +#endif + +#include <iostream> +#include <ctime> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std +{ + using ::clock_t; + using ::clock; +} +#endif + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +# pragma warning( disable: 383 ) // reference to temporary used +# pragma warning( disable: 981 ) // operands are evaluated in unspecified order +#endif + + + +namespace sc = boost::statechart; + + + +////////////////////////////////////////////////////////////////////////////// +const unsigned int noOfEvents = 1000000; + + +////////////////////////////////////////////////////////////////////////////// +char GetKey() +{ + char key; + std::cin >> key; + return key; +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + std::cout << "Boost.Statechart PingPong example\n\n"; + std::cout << "Threading configuration:\n"; + #ifdef BOOST_HAS_THREADS + std::cout << "Multi-threaded build with "; + #ifdef USE_TWO_THREADS + std::cout << 2; + #else + std::cout << 1; + #endif + std::cout << " thread(s).\n"; + #else + std::cout << "Single-threaded build\n"; + #endif + + std::cout << "\np<CR>: Performance test\n"; + std::cout << "e<CR>: Exits the program\n\n"; + + char key = GetKey(); + + while ( key != 'e' ) + { + switch( key ) + { + case 'p': + { + #ifdef BOOST_HAS_THREADS + MyScheduler scheduler1( true ); + #else + MyScheduler scheduler1; + #endif + + #ifdef USE_TWO_THREADS + #ifdef BOOST_HAS_THREADS + MyScheduler scheduler2( true ); + #else + MyScheduler & scheduler2 = scheduler1; + #endif + #else + MyScheduler & scheduler2 = scheduler1; + #endif + + MyScheduler::processor_handle player1 = + scheduler1.create_processor< Player >( noOfEvents / 2 ); + scheduler1.initiate_processor( player1 ); + MyScheduler::processor_handle player2 = + scheduler2.create_processor< Player >( noOfEvents / 2 ); + scheduler2.initiate_processor( player2 ); + + boost::intrusive_ptr< BallReturned > pInitialBall = new BallReturned(); + pInitialBall->returnToOpponent = boost::bind( + &MyScheduler::queue_event, &scheduler1, player1, _1 ); + pInitialBall->abortGame = boost::bind( + &MyScheduler::queue_event, + &scheduler1, player1, MakeIntrusive( new GameAborted() ) ); + + scheduler2.queue_event( player2, pInitialBall ); + + std::cout << "\nHaving players return the ball " << + noOfEvents << " times. Please wait...\n"; + + const unsigned int prevCount = Player::TotalNoOfProcessedEvents(); + const std::clock_t startTime = std::clock(); + + #ifdef USE_TWO_THREADS + #ifdef BOOST_HAS_THREADS + boost::thread otherThread( + boost::bind( &MyScheduler::operator(), &scheduler2, 0 ) ); + scheduler1(); + otherThread.join(); + #else + scheduler1(); + #endif + #else + scheduler1(); + #endif + + const std::clock_t elapsedTime = std::clock() - startTime; + std::cout << "Time to send and dispatch one event and\n" << + "perform the resulting transition: "; + std::cout << elapsedTime / static_cast< double >( CLOCKS_PER_SEC ) * + 1000000.0 / ( Player::TotalNoOfProcessedEvents() - prevCount ) + << " microseconds\n\n"; + } + break; + + default: + { + std::cout << "Invalid key!\n"; + } + } + + key = GetKey(); + } + + return 0; +} diff --git a/src/boost/libs/statechart/example/PingPong/PingPong.vcproj b/src/boost/libs/statechart/example/PingPong/PingPong.vcproj new file mode 100644 index 000000000..febebbc60 --- /dev/null +++ b/src/boost/libs/statechart/example/PingPong/PingPong.vcproj @@ -0,0 +1,301 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="PingPong" + ProjectGUID="{11CCA9FC-6012-4B64-8C61-808D0F8D1B51}" + RootNamespace="PingPong" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_ALL_DYN_LINK" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="false" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/PingPong.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\..\bin.v2\libs\thread\build\msvc-9.0\$(ConfigurationName)\threading-multi";"$(ProjectDir)..\..\..\..\bin.v2\libs\date_time\build\msvc-9.0\$(ConfigurationName)\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/PingPong.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + CommandLine="copy $(ProjectDir)..\..\..\..\bin.v2\libs\thread\build\msvc-9.0\$(ConfigurationName)\threading-multi\*.dll $(TargetDir)
copy $(ProjectDir)..\..\..\..\bin.v2\libs\date_time\build\msvc-9.0\$(ConfigurationName)\threading-multi\*.dll $(TargetDir)
" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_ALL_DYN_LINK" + StringPooling="true" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="false" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/PingPong.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\..\bin.v2\libs\thread\build\msvc-9.0\$(ConfigurationName)\threading-multi";"$(ProjectDir)..\..\..\..\bin.v2\libs\date_time\build\msvc-9.0\$(ConfigurationName)\threading-multi"" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + CommandLine="copy $(ProjectDir)..\..\..\..\bin.v2\libs\thread\build\msvc-9.0\$(ConfigurationName)\threading-multi\*.dll $(TargetDir)
copy $(ProjectDir)..\..\..\..\bin.v2\libs\date_time\build\msvc-9.0\$(ConfigurationName)\threading-multi\*.dll $(TargetDir)
" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\PingPong.cpp" + > + </File> + <File + RelativePath=".\Player.cpp" + > + </File> + </Filter> + <Filter + Name="Statechart Header Files" + > + <File + RelativePath="..\..\..\..\boost\statechart\asynchronous_state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\custom_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deep_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deferral.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_base.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_processor.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\fifo_scheduler.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\in_state_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\null_exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\result.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\shallow_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\simple_state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\termination.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\transition.hpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + > + <File + RelativePath=".\Player.hpp" + > + </File> + <File + RelativePath=".\Waiting.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/PingPong/Player.cpp b/src/boost/libs/statechart/example/PingPong/Player.cpp new file mode 100644 index 000000000..a67dbd8d6 --- /dev/null +++ b/src/boost/libs/statechart/example/PingPong/Player.cpp @@ -0,0 +1,24 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "Player.hpp" +#include "Waiting.hpp" // Waiting.hpp is only included here + + + +////////////////////////////////////////////////////////////////////////////// +void Player::initiate_impl() +{ + // Since we can only initiate at a point where the definitions of all the + // states in the initial state configuration are known, we duplicate + // the implementation of asynchronous_state_machine<>::initiate_impl() here + sc::state_machine< Player, Waiting, MyAllocator >::initiate(); +} + + +unsigned int Player::totalNoOfProcessedEvents_ = 0; diff --git a/src/boost/libs/statechart/example/PingPong/Player.hpp b/src/boost/libs/statechart/example/PingPong/Player.hpp new file mode 100644 index 000000000..9b333d7c4 --- /dev/null +++ b/src/boost/libs/statechart/example/PingPong/Player.hpp @@ -0,0 +1,126 @@ +#ifndef BOOST_STATECHART_EXAMPLE_PLAYER_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_PLAYER_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/fifo_scheduler.hpp> +#include <boost/statechart/asynchronous_state_machine.hpp> + +#include <boost/config.hpp> +#include <boost/intrusive_ptr.hpp> +#include <boost/mpl/list.hpp> +#include <boost/function.hpp> + +#ifdef CUSTOMIZE_MEMORY_MANAGEMENT +# ifdef BOOST_HAS_THREADS + // for some reason the following is not automatically defined +# if defined( BOOST_MSVC ) | defined( BOOST_INTEL ) +# define __WIN32__ +# endif +# else +# define BOOST_NO_MT +# endif + +# ifdef BOOST_MSVC +# pragma warning( push ) +# pragma warning( disable: 4127 ) // conditional expression is constant +# endif + +# include <boost/pool/pool_alloc.hpp> + +# ifdef BOOST_MSVC +# pragma warning( pop ) +# endif +#endif + +#include <memory> // std::allocator + + + +namespace sc = boost::statechart; + + + +////////////////////////////////////////////////////////////////////////////// +template< class T > +boost::intrusive_ptr< T > MakeIntrusive( T * pObject ) +{ + return boost::intrusive_ptr< T >( pObject ); +} + + +////////////////////////////////////////////////////////////////////////////// +struct BallReturned : sc::event< BallReturned > +{ + boost::function1< void, const boost::intrusive_ptr< const BallReturned > & > + returnToOpponent; + boost::function0< void > abortGame; +}; + +struct GameAborted : sc::event< GameAborted > {}; + +#ifdef CUSTOMIZE_MEMORY_MANAGEMENT +typedef boost::fast_pool_allocator< int > MyAllocator; +typedef sc::fifo_scheduler< + sc::fifo_worker< MyAllocator >, MyAllocator > MyScheduler; +#else +typedef std::allocator< sc::none > MyAllocator; +typedef sc::fifo_scheduler<> MyScheduler; +#endif + + +////////////////////////////////////////////////////////////////////////////// +struct Player; +struct Waiting; + +namespace boost +{ +namespace statechart +{ + // The following class member specialization ensures that + // state_machine<>::initiate is not instantiated at a point where Waiting + // is not defined yet. + template<> + inline void asynchronous_state_machine< + Player, Waiting, MyScheduler, MyAllocator >::initiate_impl() {} +} +} + + +struct Player : sc::asynchronous_state_machine< + Player, Waiting, MyScheduler, MyAllocator > +{ + public: + Player( my_context ctx, unsigned int maxNoOfReturns ) : + my_base( ctx ), + maxNoOfReturns_( maxNoOfReturns ) + { + } + + static unsigned int & TotalNoOfProcessedEvents() + { + return totalNoOfProcessedEvents_; + } + + unsigned int GetMaxNoOfReturns() const + { + return maxNoOfReturns_; + } + + private: + // This function is defined in the Player.cpp + virtual void initiate_impl(); + + static unsigned int totalNoOfProcessedEvents_; + const unsigned int maxNoOfReturns_; +}; + + + +#endif diff --git a/src/boost/libs/statechart/example/PingPong/Waiting.hpp b/src/boost/libs/statechart/example/PingPong/Waiting.hpp new file mode 100644 index 000000000..b4e5e6008 --- /dev/null +++ b/src/boost/libs/statechart/example/PingPong/Waiting.hpp @@ -0,0 +1,96 @@ +#ifndef BOOST_STATECHART_EXAMPLE_WAITING_HPP_INCLUDED +#define BOOST_STATECHART_EXAMPLE_WAITING_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + +#include "Player.hpp" + +#include <boost/statechart/state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/intrusive_ptr.hpp> +#include <boost/mpl/list.hpp> +#include <boost/function.hpp> +#include <boost/bind.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +////////////////////////////////////////////////////////////////////////////// +struct Waiting : sc::state< Waiting, Player > +{ + public: + ////////////////////////////////////////////////////////////////////////// + typedef mpl::list< + sc::custom_reaction< BallReturned >, + sc::custom_reaction< GameAborted > + > reactions; + + Waiting( my_context ctx ) : + my_base( ctx ), + noOfReturns_( 0 ), + pBallReturned_( new BallReturned() ) + { + outermost_context_type & machine = outermost_context(); + // as we will always return the same event to the opponent, we construct + // and fill it here so that we can reuse it over and over + pBallReturned_->returnToOpponent = boost::bind( + &MyScheduler::queue_event, + &machine.my_scheduler(), machine.my_handle(), _1 ); + pBallReturned_->abortGame = boost::bind( + &MyScheduler::queue_event, + &machine.my_scheduler(), machine.my_handle(), + MakeIntrusive( new GameAborted() ) ); + } + + sc::result react( const GameAborted & ) + { + return DestroyMyself(); + } + + sc::result react( const BallReturned & ballReturned ) + { + outermost_context_type & machine = outermost_context(); + ++machine.TotalNoOfProcessedEvents(); + + if ( noOfReturns_++ < machine.GetMaxNoOfReturns() ) + { + ballReturned.returnToOpponent( pBallReturned_ ); + return discard_event(); + } + else + { + ballReturned.abortGame(); + return DestroyMyself(); + } + } + + private: + ////////////////////////////////////////////////////////////////////////// + sc::result DestroyMyself() + { + outermost_context_type & machine = outermost_context(); + machine.my_scheduler().destroy_processor( machine.my_handle() ); + machine.my_scheduler().terminate(); + return terminate(); + } + + // avoids C4512 (assignment operator could not be generated) + Waiting & operator=( const Waiting & ); + + unsigned int noOfReturns_; + const boost::intrusive_ptr< BallReturned > pBallReturned_; +}; + + + +#endif diff --git a/src/boost/libs/statechart/example/StopWatch/StopWatch.cpp b/src/boost/libs/statechart/example/StopWatch/StopWatch.cpp new file mode 100644 index 000000000..93c50ecf6 --- /dev/null +++ b/src/boost/libs/statechart/example/StopWatch/StopWatch.cpp @@ -0,0 +1,189 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// The following code implements the state-machine (this is the version +// discussed in the tutorial): +// +// -------------------------------- +// | | +// | O Active | +// | | |<---- +// | v | | EvReset +// | ---------------------------- | | +// | | | |----- +// | | Stopped | | +// | ---------------------------- | +// | | ^ | +// | | EvStartStop | EvStartStop |<-----O +// | v | | +// | ---------------------------- | +// | | | | +// | | Running | | +// | ---------------------------- | +// -------------------------------- + + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/config.hpp> + +#include <ctime> +#include <iostream> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std +{ + using ::time; + using ::difftime; + using ::time_t; +} +#endif + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +# pragma warning( disable: 444 ) // destructor for base is not virtual +# pragma warning( disable: 981 ) // operands are evaluated in unspecified order +#endif + + + +namespace sc = boost::statechart; + + + +////////////////////////////////////////////////////////////////////////////// +struct EvStartStop : sc::event< EvStartStop > {}; +struct EvReset : sc::event< EvReset > {}; + +struct IElapsedTime +{ + virtual double ElapsedTime() const = 0; +}; + +struct Active; +struct StopWatch : sc::state_machine< StopWatch, Active > {}; + +struct Stopped; +struct Active : sc::simple_state< Active, StopWatch, Stopped > +{ + public: + typedef sc::transition< EvReset, Active > reactions; + + Active() : elapsedTime_( 0.0 ) {} + + double & ElapsedTime() + { + return elapsedTime_; + } + + double ElapsedTime() const + { + return elapsedTime_; + } + + private: + double elapsedTime_; +}; + + struct Running : IElapsedTime, sc::simple_state< Running, Active > + { + public: + typedef sc::transition< EvStartStop, Stopped > reactions; + + Running() : startTime_( std::time( 0 ) ) {} + + ~Running() + { + context< Active >().ElapsedTime() = ElapsedTime(); + } + + virtual double ElapsedTime() const + { + return context< Active >().ElapsedTime() + + std::difftime( std::time( 0 ), startTime_ ); + } + + private: + std::time_t startTime_; + }; + + struct Stopped : IElapsedTime, sc::simple_state< Stopped, Active > + { + typedef sc::transition< EvStartStop, Running > reactions; + + virtual double ElapsedTime() const + { + return context< Active >().ElapsedTime(); + } + }; + + +////////////////////////////////////////////////////////////////////////////// +char GetKey() +{ + char key; + std::cin >> key; + return key; +} + + +////////////////////////////////////////////////////////////////////////////// +int main() +{ + std::cout << "Boost.Statechart StopWatch example\n\n"; + std::cout << "s<CR>: Starts/Stops stop watch\n"; + std::cout << "r<CR>: Resets stop watch\n"; + std::cout << "d<CR>: Displays the elapsed time in seconds\n"; + std::cout << "e<CR>: Exits the program\n\n"; + std::cout << "You may chain commands, e.g. rs<CR> resets and starts stop watch\n\n"; + + StopWatch stopWatch; + stopWatch.initiate(); + + char key = GetKey(); + + while ( key != 'e' ) + { + switch( key ) + { + case 'r': + { + stopWatch.process_event( EvReset() ); + } + break; + + case 's': + { + stopWatch.process_event( EvStartStop() ); + } + break; + + case 'd': + { + std::cout << "Elapsed time: " << + stopWatch.state_cast< const IElapsedTime & >().ElapsedTime() << "\n"; + } + break; + + default: + { + std::cout << "Invalid key!\n"; + } + break; + } + + key = GetKey(); + } + + return 0; +} diff --git a/src/boost/libs/statechart/example/StopWatch/StopWatch.vcproj b/src/boost/libs/statechart/example/StopWatch/StopWatch.vcproj new file mode 100644 index 000000000..f04b6c760 --- /dev/null +++ b/src/boost/libs/statechart/example/StopWatch/StopWatch.vcproj @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="StopWatch" + ProjectGUID="{DFA55264-E7F5-43FE-841F-D56AC48FF2A8}" + RootNamespace="StopWatch" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/StopWatch.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/StopWatch.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + StringPooling="true" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/StopWatch.exe" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" + > + <File + RelativePath="StopWatch.cpp" + > + </File> + </Filter> + <Filter + Name="Statechart Header Files" + Filter="h;hpp;hxx;hm;inl;inc" + > + <File + RelativePath="..\..\..\..\boost\statechart\asynchronous_state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\custom_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deep_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\deferral.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_base.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\event_processor.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\fifo_scheduler.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\in_state_reaction.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\null_exception_translator.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\result.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\shallow_history.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\simple_state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\state_machine.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\termination.hpp" + > + </File> + <File + RelativePath="..\..\..\..\boost\statechart\transition.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/example/StopWatch/StopWatch2.cpp b/src/boost/libs/statechart/example/StopWatch/StopWatch2.cpp new file mode 100644 index 000000000..3a11b2475 --- /dev/null +++ b/src/boost/libs/statechart/example/StopWatch/StopWatch2.cpp @@ -0,0 +1,216 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2002-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +// The following code implements the state-machine (this version details an +// alternative way of retrieving the elapsed time from the main program): +// +// -------------------------------- +// | | +// | O Active | +// | | |<---- +// | v | | EvReset +// | ---------------------------- | | +// | | | |----- +// | | Stopped | | +// | ---------------------------- | +// | | ^ | +// | | EvStartStop | EvStartStop |<-----O +// | v | | +// | ---------------------------- | +// | | | | +// | | Running | | +// | ---------------------------- | +// -------------------------------- + + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/config.hpp> + +#include <ctime> +#include <iostream> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std +{ + using ::time; + using ::difftime; + using ::time_t; +} +#endif + +#ifdef BOOST_INTEL +# pragma warning( disable: 304 ) // access control not specified +# pragma warning( disable: 444 ) // destructor for base is not virtual +# pragma warning( disable: 981 ) // operands are evaluated in unspecified order +#endif + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvStartStop : sc::event< EvStartStop > {}; +struct EvReset : sc::event< EvReset > {}; +struct EvGetElapsedTime : sc::event< EvGetElapsedTime > +{ + public: + EvGetElapsedTime( double & time ) : time_( time ) {} + + void Assign( double time ) const + { + time_ = time; + } + + private: + double & time_; +}; + + +struct Active; +struct StopWatch : sc::state_machine< StopWatch, Active > {}; + + +struct Stopped; +struct Active : sc::simple_state< Active, StopWatch, Stopped > +{ + public: + typedef sc::transition< EvReset, Active > reactions; + + Active() : elapsedTime_( 0.0 ) {} + + double & ElapsedTime() + { + return elapsedTime_; + } + + double ElapsedTime() const + { + return elapsedTime_; + } + + private: + double elapsedTime_; +}; + +struct Running : sc::simple_state< Running, Active > +{ + public: + typedef mpl::list< + sc::custom_reaction< EvGetElapsedTime >, + sc::transition< EvStartStop, Stopped > + > reactions; + + Running() : startTime_( std::time( 0 ) ) {} + + ~Running() + { + context< Active >().ElapsedTime() = ElapsedTime(); + } + + sc::result react( const EvGetElapsedTime & evt ) + { + evt.Assign( ElapsedTime() ); + return discard_event(); + } + + private: + double ElapsedTime() const + { + return context< Active >().ElapsedTime() + + std::difftime( std::time( 0 ), startTime_ ); + } + + std::time_t startTime_; +}; + +struct Stopped : sc::simple_state< Stopped, Active > +{ + typedef mpl::list< + sc::custom_reaction< EvGetElapsedTime >, + sc::transition< EvStartStop, Running > + > reactions; + + sc::result react( const EvGetElapsedTime & evt ) + { + evt.Assign( context< Active >().ElapsedTime() ); + return discard_event(); + } +}; + + +namespace +{ + char GetKey() + { + char key; + std::cin >> key; + return key; + } +} + +int main() +{ + std::cout << "Boost.Statechart StopWatch example\n\n"; + std::cout << "s<CR>: Starts/Stops stop watch\n"; + std::cout << "r<CR>: Resets stop watch\n"; + std::cout << "d<CR>: Displays the elapsed time in seconds\n"; + std::cout << "e<CR>: Exits the program\n\n"; + std::cout << "You may chain commands, e.g. rs<CR> resets and starts stop watch\n\n"; + + StopWatch stopWatch; + stopWatch.initiate(); + + char key = GetKey(); + + while ( key != 'e' ) + { + switch( key ) + { + case 'r': + { + stopWatch.process_event( EvReset() ); + } + break; + + case 's': + { + stopWatch.process_event( EvStartStop() ); + } + break; + + case 'd': + { + double elapsedTime = 0.0; + stopWatch.process_event( EvGetElapsedTime( elapsedTime ) ); + std::cout << "Elapsed time: " << elapsedTime << "\n"; + } + break; + + default: + { + std::cout << "Invalid key!\n"; + } + break; + } + + key = GetKey(); + } + + return 0; +} diff --git a/src/boost/libs/statechart/index.html b/src/boost/libs/statechart/index.html new file mode 100644 index 000000000..ed899d1d2 --- /dev/null +++ b/src/boost/libs/statechart/index.html @@ -0,0 +1,32 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> + +<html> +<head> + <meta http-equiv="Content-Language" content="en-us"> + <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <meta http-equiv="refresh" content="0; URL=doc/index.html"> + + <title></title> +</head> + +<body> + <p>Automatic redirection failed, please go to <a href= + "doc/index.html">doc/index.html</a>.</p> + <hr> + + <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" + src="../../doc/images/valid-html401.png" + alt="Valid HTML 4.01 Transitional" height="31" width="88"></a></p> + + <p>Revised + <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->18 July, 2006<!--webbot bot="Timestamp" endspan i-checksum="21157" --></p> + + <p><i>Copyright © 2003-<!--webbot bot="Timestamp" s-type="EDITED" s-format="%Y" startspan -->2006<!--webbot bot="Timestamp" endspan i-checksum="770" --> <a href="doc/contact.html">Andreas Huber Dönni</a> + </i></p> + + <p><i>Distributed under the Boost Software License, Version 1.0. (See + accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or + copy at <a href= + "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> +</body> +</html> diff --git a/src/boost/libs/statechart/meta/libraries.json b/src/boost/libs/statechart/meta/libraries.json new file mode 100644 index 000000000..148e8cb78 --- /dev/null +++ b/src/boost/libs/statechart/meta/libraries.json @@ -0,0 +1,14 @@ +{ + "key": "statechart", + "name": "Statechart", + "authors": [ + "Andreas Huber Dönni" + ], + "description": "Boost.Statechart - Arbitrarily complex finite state machines can be implemented in easily readable and maintainable C++ code.", + "category": [ + "State" + ], + "maintainers": [ + "Andreas Huber <ahd6974-boostorg -at- yahoo.com>" + ] +} diff --git a/src/boost/libs/statechart/test/CustomReactionTest.cpp b/src/boost/libs/statechart/test/CustomReactionTest.cpp new file mode 100644 index 000000000..3dbabbf50 --- /dev/null +++ b/src/boost/libs/statechart/test/CustomReactionTest.cpp @@ -0,0 +1,381 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + +#include <set> +#include <map> +#include <string> + +#include <cstddef> // size_t + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvToC : sc::event< EvToC > {}; +struct EvToD : sc::event< EvToD > {}; + +struct EvDiscardNever : sc::event< EvDiscardNever > {}; +struct EvDiscardInB : sc::event< EvDiscardInB > {}; +struct EvDiscardInD : sc::event< EvDiscardInD > {}; + +struct EvTransit : sc::event< EvTransit > {}; +struct EvTransitWithAction : sc::event< EvTransitWithAction > {}; +struct EvDefer : sc::event< EvDefer > {}; +struct EvTerminate : sc::event< EvTerminate > {}; + + +struct A; +struct CustomReactionTest : sc::state_machine< CustomReactionTest, A > +{ + public: + ////////////////////////////////////////////////////////////////////////// + CustomReactionTest(); + + void Visited( const state_base_type & stt ) + { + const StateNamesMap::const_iterator found = + stateNamesMap_.find( stt.dynamic_type() ); + BOOST_REQUIRE( found != stateNamesMap_.end() ); + visitedStates_.insert( found->second ); + } + + void ClearVisited() + { + visitedStates_.clear(); + } + + void AssertVisitedAll( const std::string & stateNames ) const + { + for ( std::string::const_iterator expectedName = stateNames.begin(); + expectedName != stateNames.end(); ++expectedName ) + { + BOOST_REQUIRE( visitedStates_.find( + std::string( 1, *expectedName ) ) != visitedStates_.end() ); + } + } + + void AssertVisitedOne( const std::string & stateNames ) const + { + std::size_t found = 0; + + for ( std::string::const_iterator actualName = stateNames.begin(); + actualName != stateNames.end(); ++actualName ) + { + found = found + ( visitedStates_.find( + std::string( 1, *actualName ) ) != visitedStates_.end() ) ? 1 : 0; + } + + BOOST_REQUIRE( found == 1 ); + } + + void TransitionAction( const EvTransitWithAction & ) {} + + private: + ////////////////////////////////////////////////////////////////////////// + typedef std::map< state_base_type::id_type, std::string > StateNamesMap; + typedef std::set< std::string > VisitedStates; + + StateNamesMap stateNamesMap_; + VisitedStates visitedStates_; +}; + +struct B; +struct A : sc::simple_state< A, CustomReactionTest, B > +{ + typedef mpl::list< + sc::custom_reaction< EvDiscardNever >, + sc::custom_reaction< EvDiscardInB >, + sc::custom_reaction< EvDiscardInD >, + sc::custom_reaction< EvDefer >, + sc::custom_reaction< EvTerminate >, + sc::custom_reaction< EvTransitWithAction >, + sc::custom_reaction< EvTransit > + > reactions; + + sc::result react( const EvDiscardNever & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInB & ) + { + BOOST_FAIL( "An event discarded in B must never reach A" ); + return discard_event(); + } + + sc::result react( const EvDiscardInD & ) + { + BOOST_FAIL( "An event discarded in D must never reach B" ); + return discard_event(); + } + + // The following code is here just to make sure that calls to the transit<>, + // defer_event and terminate functions actually compile. + // Their functionality is tested extensively in TransitionTest, + // DeferralTest and TerminationTest with appropriate reactions. Internally, + // these reactions call exactly the same functions as the following custom + // reactions call. + sc::result react( const EvDefer & ) + { + return defer_event(); + } + + sc::result react( const EvTerminate & ) + { + return terminate(); + } + + sc::result react( const EvTransit & ) + { + return transit< A >(); + } + + sc::result react( const EvTransitWithAction & evt ) + { + return transit< A >( &CustomReactionTest::TransitionAction, evt ); + } +}; + + struct C; + struct B : sc::simple_state< B, A, C > + { + typedef mpl::list< + sc::custom_reaction< EvDiscardNever >, + sc::custom_reaction< EvDiscardInB >, + sc::custom_reaction< EvDiscardInD > + > reactions; + + sc::result react( const EvDiscardNever & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInB & ) + { + outermost_context().Visited( *this ); + return discard_event(); + } + + sc::result react( const EvDiscardInD & ) + { + BOOST_FAIL( "An event discarded in D must never reach B" ); + return discard_event(); + } + }; + + struct E; + struct F; + struct D : sc::simple_state< D, B, mpl::list< E, F > > + { + typedef mpl::list< + sc::transition< EvToC, C >, + sc::custom_reaction< EvDiscardNever >, + sc::custom_reaction< EvDiscardInB >, + sc::custom_reaction< EvDiscardInD > + > reactions; + + sc::result react( const EvDiscardNever & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInB & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInD & ) + { + outermost_context().Visited( *this ); + return discard_event(); + } + }; + + struct E : sc::simple_state< E, D::orthogonal< 0 > > + { + typedef mpl::list< + sc::custom_reaction< EvDiscardNever >, + sc::custom_reaction< EvDiscardInB >, + sc::custom_reaction< EvDiscardInD > + > reactions; + + sc::result react( const EvDiscardNever & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInB & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInD & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + }; + + struct F : sc::simple_state< F, D::orthogonal< 1 > > + { + typedef mpl::list< + sc::custom_reaction< EvDiscardNever >, + sc::custom_reaction< EvDiscardInB >, + sc::custom_reaction< EvDiscardInD > + > reactions; + + sc::result react( const EvDiscardNever & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInB & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInD & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + }; + + struct C : sc::simple_state< C, B > + { + typedef mpl::list< + sc::transition< EvToD, D >, + sc::custom_reaction< EvDiscardNever >, + sc::custom_reaction< EvDiscardInB >, + sc::custom_reaction< EvDiscardInD > + > reactions; + + sc::result react( const EvDiscardNever & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInB & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + + sc::result react( const EvDiscardInD & ) + { + outermost_context().Visited( *this ); + return forward_event(); + } + }; + +CustomReactionTest::CustomReactionTest() +{ + // We're not using custom type information to make this test work even when + // BOOST_STATECHART_USE_NATIVE_RTTI is defined + stateNamesMap_[ A::static_type() ] = "A"; + stateNamesMap_[ B::static_type() ] = "B"; + stateNamesMap_[ C::static_type() ] = "C"; + stateNamesMap_[ D::static_type() ] = "D"; + stateNamesMap_[ E::static_type() ] = "E"; + stateNamesMap_[ F::static_type() ] = "F"; +} + + +struct X1; +struct CustomReactionEventBaseTest : sc::state_machine< CustomReactionEventBaseTest, X1 > +{ + public: + CustomReactionEventBaseTest() : reactionCount_( 0 ) {} + + void IncrementReactionCount() + { + ++reactionCount_; + } + + unsigned int GetReactionCount() const + { + return reactionCount_; + } + + private: + unsigned int reactionCount_; +}; + +struct X1 : sc::simple_state< X1, CustomReactionEventBaseTest > +{ + typedef sc::custom_reaction< sc::event_base > reactions; + + sc::result react( const sc::event_base & ) + { + outermost_context().IncrementReactionCount(); + return discard_event(); + } +}; + + +int test_main( int, char* [] ) +{ + CustomReactionTest machine; + machine.initiate(); + + machine.process_event( EvDiscardNever() ); + machine.AssertVisitedAll( "ABC" ); + machine.ClearVisited(); + + machine.process_event( EvDiscardInB() ); + machine.AssertVisitedAll( "BC" ); + machine.process_event( EvToD() ); + machine.ClearVisited(); + + machine.process_event( EvDiscardNever() ); + machine.AssertVisitedAll( "ABDEF" ); + machine.ClearVisited(); + + machine.process_event( EvDiscardInD() ); + machine.AssertVisitedAll( "D" ); + machine.AssertVisitedOne( "EF" ); + machine.ClearVisited(); + + machine.process_event( EvDiscardInB() ); + machine.AssertVisitedAll( "BD" ); + machine.AssertVisitedOne( "EF" ); + machine.ClearVisited(); + + + CustomReactionEventBaseTest eventBaseMachine; + eventBaseMachine.initiate(); + BOOST_REQUIRE( eventBaseMachine.GetReactionCount() == 0 ); + eventBaseMachine.process_event( EvToC() ); + BOOST_REQUIRE( eventBaseMachine.GetReactionCount() == 1 ); + eventBaseMachine.process_event( EvToD() ); + BOOST_REQUIRE( eventBaseMachine.GetReactionCount() == 2 ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/CustomReactionTest.vcproj b/src/boost/libs/statechart/test/CustomReactionTest.vcproj new file mode 100644 index 000000000..a25064162 --- /dev/null +++ b/src/boost/libs/statechart/test/CustomReactionTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="CustomReactionTest" + ProjectGUID="{2D85E7DE-2347-43EA-843F-691101E6F98F}" + RootNamespace="CustomReactionTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/CustomReactionTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/CustomReactionTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/CustomReactionTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\CustomReactionTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/DeferralBug.cpp b/src/boost/libs/statechart/test/DeferralBug.cpp new file mode 100644 index 000000000..c3ab8ef07 --- /dev/null +++ b/src/boost/libs/statechart/test/DeferralBug.cpp @@ -0,0 +1,84 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2010 Igor R (http://thread.gmane.org/gmane.comp.lib.boost.user/62985) +// Copyright 2010 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + +#include <boost/statechart/event.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/deferral.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct ev1to2 : sc::event< ev1to2 > {}; +struct ev2to3 : sc::event< ev2to3 > {}; +struct ev3to4_1 : sc::event< ev3to4_1 > {}; +struct ev3to4_2 : sc::event< ev3to4_2 > {}; + +struct s1; +struct fsm : sc::state_machine< fsm, s1 > {}; + +struct s2; +struct s1 : sc::simple_state< s1, fsm > +{ + typedef mpl::list< + sc::transition< ev1to2, s2 >, + sc::deferral< ev2to3 >, + sc::deferral< ev3to4_1 >, + sc::deferral< ev3to4_2 > + > reactions; +}; + +struct s3; +struct s2 : sc::simple_state< s2, fsm > +{ + typedef mpl::list< + sc::transition< ev2to3, s3 >, + sc::deferral< ev3to4_1 >, + sc::deferral< ev3to4_2 > + > reactions; +}; + +struct s4_1; +struct s4_2; +struct s3 : sc::simple_state< s3, fsm > +{ + typedef mpl::list< + sc::transition< ev3to4_1, s4_1 >, + sc::transition< ev3to4_2, s4_2 > + > reactions; +}; + +struct s4_1 : sc::simple_state< s4_1, fsm > {}; +struct s4_2 : sc::simple_state< s4_2, fsm > {}; + +int test_main( int, char* [] ) +{ + fsm machine; + machine.initiate(); + machine.process_event( ev3to4_1() ); + machine.process_event( ev2to3() ); + machine.process_event( ev3to4_2() ); + machine.process_event( ev1to2() ); + BOOST_REQUIRE( machine.state_cast< const s4_1 * >() != 0 ); + machine.initiate(); + machine.process_event( ev3to4_1() ); + machine.process_event( ev3to4_2() ); + machine.process_event( ev1to2() ); + machine.process_event( ev2to3() ); + BOOST_REQUIRE( machine.state_cast< const s4_1 * >() != 0 ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/DeferralTest.cpp b/src/boost/libs/statechart/test/DeferralTest.cpp new file mode 100644 index 000000000..c54206c9d --- /dev/null +++ b/src/boost/libs/statechart/test/DeferralTest.cpp @@ -0,0 +1,172 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2004-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/deferral.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/intrusive_ptr.hpp> + +#include <boost/test/test_tools.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +template< class T > +boost::intrusive_ptr< T > MakeIntrusive( T * pT ) +{ + return boost::intrusive_ptr< T >( pT ); +} + +struct EvLeafDeferred : sc::event< EvLeafDeferred > {}; +struct EvNodeDeferred : sc::event< EvNodeDeferred > {}; +struct EvSwitch : sc::event< EvSwitch > {}; +struct EvDestroy : sc::event< EvDestroy > {}; + +struct Active; +struct DeferralTest : sc::state_machine< DeferralTest, Active > +{ + ////////////////////////////////////////////////////////////////////////// + DeferralTest() : processedCount_( 0 ) {} + + void IncrementProcessedCount() + { + ++processedCount_; + } + + unsigned int ProcessedCount() const + { + return processedCount_; + } + + private: + ////////////////////////////////////////////////////////////////////////// + unsigned int processedCount_; +}; + +struct Dead : sc::simple_state< Dead, DeferralTest > +{ + typedef sc::custom_reaction< EvNodeDeferred > reactions; + + sc::result react( const EvNodeDeferred & ) + { + outermost_context().IncrementProcessedCount(); + return discard_event(); + } +}; + +struct Idle; +struct Active : sc::simple_state< Active, DeferralTest, Idle > +{ + typedef mpl::list< + sc::custom_reaction< EvLeafDeferred >, + sc::deferral< EvNodeDeferred >, + sc::transition< EvDestroy, Dead > + > reactions; + + sc::result react( const EvLeafDeferred & ) + { + outermost_context().IncrementProcessedCount(); + return discard_event(); + } +}; + + struct Running : sc::simple_state< Running, Active > + { + typedef sc::transition< EvSwitch, Idle > reactions; + }; + + struct Idle : sc::simple_state< Idle, Active > + { + typedef mpl::list< + sc::transition< EvSwitch, Running >, + sc::deferral< EvLeafDeferred > + > reactions; + }; + + +struct EvToX2 : sc::event< EvToX2 > {}; +struct EvToX3 : sc::event< EvToX3 > {}; + +struct X1; +struct DeferralEventBaseTest : sc::state_machine< DeferralEventBaseTest, X1 > +{ +}; + +struct X3 : sc::simple_state< X3, DeferralEventBaseTest > {}; + +struct X2 : sc::simple_state< X2, DeferralEventBaseTest > +{ + typedef sc::transition< EvToX3, X3 > reactions; +}; + +struct X1 : sc::simple_state< X1, DeferralEventBaseTest > +{ + typedef mpl::list< + sc::transition< EvToX2, X2 >, + sc::deferral< sc::event_base > + > reactions; +}; + + +int test_main( int, char* [] ) +{ + DeferralTest machine; + machine.initiate(); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 0 ); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 0 ); + machine.process_event( *MakeIntrusive( new EvLeafDeferred() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 0 ); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 1 ); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 1 ); + machine.process_event( *MakeIntrusive( new EvLeafDeferred() ) ); + machine.process_event( *MakeIntrusive( new EvLeafDeferred() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 1 ); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 3 ); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 3 ); + machine.process_event( *MakeIntrusive( new EvNodeDeferred() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 3 ); + machine.process_event( *MakeIntrusive( new EvSwitch() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 3 ); + machine.process_event( EvNodeDeferred() ); + BOOST_REQUIRE( machine.ProcessedCount() == 3 ); + machine.process_event( *MakeIntrusive( new EvDestroy() ) ); + BOOST_REQUIRE( machine.ProcessedCount() == 5 ); + + + DeferralEventBaseTest eventBaseMachine; + // state_cast sanity check + BOOST_REQUIRE_THROW( eventBaseMachine.state_cast< const X1 & >(), std::bad_cast ); + eventBaseMachine.initiate(); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X1 & >() ); + // Deferral must work with heap-allocated and stack-allocated events + eventBaseMachine.process_event( EvToX3() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X1 & >() ); + eventBaseMachine.process_event( EvToX2() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X3 & >() ); + eventBaseMachine.initiate(); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X1 & >() ); + eventBaseMachine.process_event( EvToX2() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X2 & >() ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/DeferralTest.vcproj b/src/boost/libs/statechart/test/DeferralTest.vcproj new file mode 100644 index 000000000..9d762d1db --- /dev/null +++ b/src/boost/libs/statechart/test/DeferralTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="DeferralTest" + ProjectGUID="{E599D469-A2BD-42FB-A217-73A420213D06}" + RootNamespace="DeferralTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/DeferralTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/DeferralTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/DeferralTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\DeferralTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/FifoSchedulerTest.cpp b/src/boost/libs/statechart/test/FifoSchedulerTest.cpp new file mode 100644 index 000000000..507463d7a --- /dev/null +++ b/src/boost/libs/statechart/test/FifoSchedulerTest.cpp @@ -0,0 +1,326 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/test/test_tools.hpp> + +#include <boost/statechart/asynchronous_state_machine.hpp> +#include <boost/statechart/fifo_scheduler.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/termination.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/bind.hpp> +#include <boost/ref.hpp> + +#include <stdexcept> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvCheckCtorArgs : sc::event< EvCheckCtorArgs > +{ + public: + EvCheckCtorArgs( int expectedArgs ) : expectedArgs_( expectedArgs ) {} + const int expectedArgs_; + + private: + // avoids C4512 (assignment operator could not be generated) + EvCheckCtorArgs & operator=( const EvCheckCtorArgs & ); +}; + +struct EvTerminate : sc::event< EvTerminate > {}; +struct EvFail : sc::event< EvFail > {}; + + +struct Initial; +struct FifoSchedulerTest : + sc::asynchronous_state_machine< FifoSchedulerTest, Initial > +{ + public: + ////////////////////////////////////////////////////////////////////////// + FifoSchedulerTest( my_context ctx ) : + my_base( ctx ), + ctorArgs_( 0 ) + { + } + + FifoSchedulerTest( my_context ctx, int arg1 ) : + my_base( ctx ), + ctorArgs_( arg1 ) + { + } + + FifoSchedulerTest( my_context ctx, int arg1, int arg2 ) : + my_base( ctx ), + ctorArgs_( arg1 * 10 + arg2 ) + { + } + + FifoSchedulerTest( my_context ctx, int arg1, int arg2, int arg3 ) : + my_base( ctx ), + ctorArgs_( ( arg1 * 10 + arg2 ) * 10 + arg3 ) + { + } + + FifoSchedulerTest( + my_context ctx, + int arg1, int arg2, int arg3, int arg4 + ) : + my_base( ctx ), + ctorArgs_( ( ( arg1 * 10 + arg2 ) * 10 + arg3 ) * 10 + arg4 ) + { + } + + FifoSchedulerTest( + my_context ctx, + int arg1, int arg2, int arg3, int arg4, int arg5 + ) : + my_base( ctx ), + ctorArgs_( ( ( ( arg1 * 10 + arg2 ) * 10 + + arg3 ) * 10 + arg4 ) * 10 + arg5 ) + { + } + + FifoSchedulerTest( + my_context ctx, + int arg1, int arg2, int arg3, int arg4, int arg5, int arg6 + ) : + my_base( ctx ), + ctorArgs_( ( ( ( ( arg1 * 10 + arg2 ) * 10 + + arg3 ) * 10 + arg4 ) * 10 + arg5 ) * 10 + arg6 ) + { + } + + int CtorArgs() + { + return ctorArgs_; + } + + private: + ////////////////////////////////////////////////////////////////////////// + const int ctorArgs_; +}; + +boost::intrusive_ptr< const sc::event_base > MakeEvent( + const sc::event_base * pEvent ) +{ + return boost::intrusive_ptr< const sc::event_base >( pEvent ); +} + +struct Initial : sc::simple_state< Initial, FifoSchedulerTest > +{ + typedef mpl::list< + sc::custom_reaction< EvCheckCtorArgs >, + sc::termination< EvTerminate >, + sc::custom_reaction< EvFail > + > reactions; + + sc::result react( const EvCheckCtorArgs & ev ) + { + BOOST_REQUIRE( ev.expectedArgs_ == outermost_context().CtorArgs() ); + outermost_context_type & machine = outermost_context(); + machine.my_scheduler().queue_event( + machine.my_handle(), MakeEvent( new EvTerminate() ) ); + return discard_event(); + } + + sc::result react( const EvFail & ) + { + BOOST_FAIL( "State machine is unexpectedly still running." ); + return discard_event(); + } +}; + + +struct UnexpectedEventCount : public std::runtime_error +{ + UnexpectedEventCount() : std::runtime_error( "" ) {} +}; + +void RunScheduler( + sc::fifo_scheduler<> & scheduler, unsigned long expectedEventCount ) +{ + // Workaround: For some reason MSVC has a problem with BOOST_REQUIRE here + // (C1055: compiler limit: out of keys) + if ( scheduler() != expectedEventCount ) + { + throw UnexpectedEventCount(); + } +} + +static int refArg1; +static int refArg2; +static int refArg3; +static int refArg4; +static int refArg5; +static int refArg6; + +void Check( + sc::fifo_scheduler<> & scheduler, + const sc::fifo_scheduler<>::processor_handle & processor, + int ctorArgs ) +{ + refArg1 = 6; + refArg2 = 5; + refArg3 = 4; + refArg4 = 3; + refArg5 = 2; + refArg6 = 1; + + // Make sure the processor has been created + RunScheduler( scheduler, 1UL ); + + refArg1 = refArg2 = refArg3 = refArg4 = refArg5 = refArg6 = 0; + + scheduler.initiate_processor( processor ); + // This event triggers the queueing of another event, which itself + // terminates the machine ... + scheduler.queue_event( + processor, MakeEvent( new EvCheckCtorArgs( ctorArgs ) ) ); + // ... that's why 3 instead of two events must have been processed + RunScheduler( scheduler, 3UL ); + + // Since the machine has been terminated, this event will be ignored + scheduler.queue_event( processor, MakeEvent( new EvFail() ) ); + RunScheduler( scheduler, 1UL ); + + // Check that we can reinitiate the machine + scheduler.initiate_processor( processor ); + scheduler.queue_event( + processor, MakeEvent( new EvCheckCtorArgs( ctorArgs ) ) ); + RunScheduler( scheduler, 3UL ); + + // Check that we are terminated again + scheduler.queue_event( processor, MakeEvent( new EvFail() ) ); + RunScheduler( scheduler, 1UL ); + + scheduler.destroy_processor( processor ); + // The following will simply be ignored because the processor has already + // be destroyed + scheduler.initiate_processor( processor ); + scheduler.queue_event( + processor, MakeEvent( new EvCheckCtorArgs( ctorArgs ) ) ); + RunScheduler( scheduler, 3UL ); +} + +void SetToTrue( bool & value ) +{ + value = true; +} + +int test_main( int, char* [] ) +{ + try + { + sc::fifo_scheduler<> scheduler; + Check( scheduler, scheduler.create_processor< FifoSchedulerTest >(), 0 ); + + Check( + scheduler, scheduler.create_processor< FifoSchedulerTest >( 1 ), 1 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( + boost::cref( refArg1 ) ), + 6 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( 1, 2 ), + 12 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( + boost::cref( refArg1 ), boost::cref( refArg2 ) ), + 65 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3 ), + 123 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( + boost::cref( refArg1 ), boost::cref( refArg2 ), + boost::cref( refArg3 ) ), + 654 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4 ), + 1234 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( + boost::cref( refArg1 ), boost::cref( refArg2 ), + boost::cref( refArg3 ), boost::cref( refArg4 ) ), + 6543 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4, 5 ), + 12345 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( + boost::cref( refArg1 ), boost::cref( refArg2 ), + boost::cref( refArg3 ), boost::cref( refArg4 ), + boost::cref( refArg5 ) ), + 65432 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4, 5, 6 ), + 123456 ); + + Check( + scheduler, + scheduler.create_processor< FifoSchedulerTest >( + boost::cref( refArg1 ), boost::cref( refArg2 ), + boost::cref( refArg3 ), boost::cref( refArg4 ), + boost::cref( refArg5 ), boost::cref( refArg6 ) ), + 654321 ); + + RunScheduler( scheduler, 0UL ); + bool workItem1Processed = false; + scheduler.queue_work_item( + boost::bind( &SetToTrue, boost::ref( workItem1Processed ) ) ); + RunScheduler( scheduler, 1UL ); + BOOST_REQUIRE( workItem1Processed ); + + scheduler.terminate(); + RunScheduler( scheduler, 1UL ); + BOOST_REQUIRE( scheduler.terminated() ); + + RunScheduler( scheduler, 0UL ); + bool workItem2Processed = false; + scheduler.queue_work_item( + boost::bind( &SetToTrue, boost::ref( workItem2Processed ) ) ); + // After being terminated, a call to operator() must not process any more + // events + RunScheduler( scheduler, 0UL ); + BOOST_REQUIRE( !workItem2Processed ); + } + catch ( const UnexpectedEventCount & ) + { + BOOST_FAIL( "Unexpected event count." ); + } + + return 0; +} diff --git a/src/boost/libs/statechart/test/FifoSchedulerTest.vcproj b/src/boost/libs/statechart/test/FifoSchedulerTest.vcproj new file mode 100644 index 000000000..5ae9e5de2 --- /dev/null +++ b/src/boost/libs/statechart/test/FifoSchedulerTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="FifoSchedulerTest" + ProjectGUID="{3A9E80AF-DD29-4CE7-AB7D-1A13C766AC96}" + RootNamespace="FifoSchedulerTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/FifoSchedulerTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/FifoSchedulerTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/FifoSchedulerTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\FifoSchedulerTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/HistoryTest.cpp b/src/boost/libs/statechart/test/HistoryTest.cpp new file mode 100644 index 000000000..b33089e2e --- /dev/null +++ b/src/boost/libs/statechart/test/HistoryTest.cpp @@ -0,0 +1,334 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/shallow_history.hpp> +#include <boost/statechart/deep_history.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/shared_ptr.hpp> + +#include <boost/test/test_tools.hpp> + +#include <stdexcept> + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvToB : sc::event< EvToB > {}; + +struct EvToD : sc::event< EvToD > {}; +struct EvToDShallow : sc::event< EvToDShallow > {}; +struct EvToDDeep : sc::event< EvToDDeep > {}; +struct EvToDShallowLocal : sc::event< EvToDShallowLocal > {}; +struct EvToDDeepLocal : sc::event< EvToDDeepLocal > {}; + +struct EvToF : sc::event< EvToF > {}; +struct EvToFShallow : sc::event< EvToFShallow > {}; +struct EvToFDeep : sc::event< EvToFDeep > {}; + +struct EvToH : sc::event< EvToH > {}; +struct EvToI : sc::event< EvToI > {}; + +struct EvToM : sc::event< EvToM > {}; +struct EvToQ : sc::event< EvToQ > {}; + +struct EvWhatever : sc::event< EvWhatever > {}; + +struct A; +struct HistoryTest : sc::state_machine< HistoryTest, A > +{ + void unconsumed_event( const sc::event_base & ) + { + throw std::runtime_error( "Event was not consumed!" ); + } +}; + +struct B; +struct D; +struct F; +struct H; +struct I; +struct M; +struct Q; +struct A : sc::simple_state< A, HistoryTest, B > +{ + typedef mpl::list< + sc::transition< EvToB, B >, + sc::transition< EvToD, D >, + sc::transition< EvToDShallow, sc::shallow_history< D > >, + sc::transition< EvToDDeep, sc::deep_history< D > >, + sc::transition< EvToF, F >, + sc::transition< EvToFShallow, sc::shallow_history< F > >, + sc::transition< EvToFDeep, sc::deep_history< F > >, + sc::transition< EvToH, H >, + sc::transition< EvToI, I >, + sc::transition< EvToM, M >, + sc::transition< EvToQ, Q > + > reactions; +}; + + struct J; + struct N; + struct B : sc::simple_state< + B, A, mpl::list< sc::shallow_history< J >, sc::deep_history< N > >, + sc::has_full_history > {}; + + struct J : sc::simple_state< J, B::orthogonal< 0 > > {}; + struct L; + struct K : sc::simple_state< K, B::orthogonal< 0 >, L > {}; + + struct L : sc::simple_state< L, K > {}; + struct M : sc::simple_state< M, K > {}; + + struct N : sc::simple_state< N, B::orthogonal< 1 > > {}; + struct P; + struct O : sc::simple_state< O, B::orthogonal< 1 >, P > {}; + + struct P : sc::simple_state< P, O > {}; + struct Q : sc::simple_state< Q, O > {}; + + struct C : sc::simple_state< C, A, D, sc::has_full_history > {}; + + struct D : sc::simple_state< D, C > {}; + struct E : sc::simple_state< E, C, F, sc::has_full_history > {}; + + struct F : sc::simple_state< F, E > {}; + struct G : sc::simple_state< G, E, H > + { + typedef mpl::list< + sc::transition< EvToDShallowLocal, sc::shallow_history< D > >, + sc::transition< EvToDDeepLocal, sc::deep_history< D > > + > reactions; + }; + + struct H : sc::simple_state< H, G > {}; + struct I : sc::simple_state< I, G > {}; + + +int test_main( int, char* [] ) +{ + boost::shared_ptr< HistoryTest > pM = + boost::shared_ptr< HistoryTest >( new HistoryTest() ); + + // state_downcast sanity check + BOOST_REQUIRE_THROW( pM->state_downcast< const B & >(), std::bad_cast ); + pM->initiate(); + BOOST_REQUIRE_THROW( pM->state_downcast< const D & >(), std::bad_cast ); + + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + + // No history has been saved yet -> default state + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + // Direct inner is E when history is saved -> F + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->process_event( EvToH() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + // Direct inner is E when history is saved -> F + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->process_event( EvToF() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + // Direct inner was E when history was saved -> F + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->initiate(); + // History was cleared in termination -> default state + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->clear_shallow_history< C, 0 >(); + // History was cleared -> default state + pM->process_event( EvToDShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + + pM = boost::shared_ptr< HistoryTest >( new HistoryTest() ); + pM->initiate(); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + + // No history has been saved yet -> default state + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + + pM->process_event( EvToH() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + + pM->process_event( EvToF() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->initiate(); + // History was cleared in termination -> default state + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->clear_deep_history< C, 0 >(); + // History was cleared -> default state + pM->process_event( EvToDDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const D & >() ); + + + pM = boost::shared_ptr< HistoryTest >( new HistoryTest() ); + pM->initiate(); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + + // No history has been saved yet -> default state + pM->process_event( EvToFShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + pM->process_event( EvToFShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + // Direct inner is G when history is saved -> H + pM->process_event( EvToFShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + + pM->process_event( EvToH() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + // Direct inner was G when history was saved -> H + pM->process_event( EvToFShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->initiate(); + // History was cleared in termination -> default state + pM->process_event( EvToFShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->clear_shallow_history< E, 0 >(); + // History was cleared -> default state + pM->process_event( EvToFShallow() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM = boost::shared_ptr< HistoryTest >( new HistoryTest() ); + pM->initiate(); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + + // No history has been saved yet -> default state + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + + pM->process_event( EvToH() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const H & >() ); + + pM->process_event( EvToF() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->initiate(); + // History was cleared in termination -> default state + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const B & >() ); + pM->clear_deep_history< E, 0 >(); + // History was cleared -> default state + pM->process_event( EvToFDeep() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + + // Test local history (new with UML 2.0) + pM->initiate(); + // unconsumed_event sanity check + BOOST_REQUIRE_THROW( pM->process_event( EvWhatever() ), std::runtime_error ); + pM->process_event( EvToI() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + pM->process_event( EvToDShallowLocal() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const F & >() ); + pM->process_event( EvToI() ); + pM->process_event( EvToDDeepLocal() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const I & >() ); + + // Given that history transitions and history initial states are implemented + // with the same code we just make a few sanity checks and trust that the + // rest will work just like we tested above. + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const J & >() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const N & >() ); + pM->process_event( EvToM() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const M & >() ); + // Direct inner is K when history is saved -> L + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const L & >() ); + + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const N & >() ); + pM->process_event( EvToQ() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const Q & >() ); + pM->process_event( EvToB() ); + BOOST_REQUIRE_NO_THROW( pM->state_downcast< const Q & >() ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/HistoryTest.vcproj b/src/boost/libs/statechart/test/HistoryTest.vcproj new file mode 100644 index 000000000..f1799cfea --- /dev/null +++ b/src/boost/libs/statechart/test/HistoryTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="HistoryTest" + ProjectGUID="{206654FA-7AA0-4E06-BCFA-DC94D4281755}" + RootNamespace="HistoryTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/HistoryTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/HistoryTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/HistoryTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\HistoryTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InStateReactionTest.cpp b/src/boost/libs/statechart/test/InStateReactionTest.cpp new file mode 100644 index 000000000..351ad13f2 --- /dev/null +++ b/src/boost/libs/statechart/test/InStateReactionTest.cpp @@ -0,0 +1,102 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/in_state_reaction.hpp> +#include <boost/statechart/result.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + +struct E : sc::event< E > {}; +struct F : sc::event< F > {}; +struct G : sc::event< G > {}; +struct H : sc::event< H > {}; +struct I : sc::event< I > {}; + +struct A; +struct InStateReactionTest : sc::state_machine< InStateReactionTest, A > {}; + +struct B; +struct A : sc::simple_state< A, InStateReactionTest, B > +{ + A() : eventCount_( 0 ) {} + + // The following 3 functions could be implemented with one function + // template, but this causes problems with CW and Intel 9.1. + void IncrementCount( const sc::event_base & ) { ++eventCount_; } + void IncrementCount( const E & ) { ++eventCount_; } + void IncrementCount( const G & ) { ++eventCount_; } + + typedef mpl::list< + sc::in_state_reaction< E, A, &A::IncrementCount >, + sc::in_state_reaction< sc::event_base, A, &A::IncrementCount > + > reactions; + + unsigned int eventCount_; +}; + + struct B : sc::simple_state< B, A > + { + B() : eventCount_( 0 ) {} + + void IncrementCount( const F & ) + { + ++eventCount_; + } + + typedef mpl::list< + sc::in_state_reaction< F, B, &B::IncrementCount >, + sc::in_state_reaction< G, A, &A::IncrementCount >, + sc::in_state_reaction< I > + > reactions; + + unsigned int eventCount_; + }; + + + +void RequireEventCounts( + const InStateReactionTest & machine, + unsigned int aCount, unsigned int bCount) +{ + BOOST_REQUIRE( + machine.state_downcast< const A & >().eventCount_ == aCount ); + BOOST_REQUIRE( + machine.state_downcast< const B & >().eventCount_ == bCount ); +} + +int test_main( int, char* [] ) +{ + InStateReactionTest machine; + machine.initiate(); + + RequireEventCounts(machine, 0, 0); + machine.process_event( F() ); + RequireEventCounts(machine, 0, 1); + machine.process_event( E() ); + RequireEventCounts(machine, 1, 1); + machine.process_event( E() ); + machine.process_event( F() ); + RequireEventCounts(machine, 2, 2); + machine.process_event( G() ); + RequireEventCounts(machine, 3, 2); + machine.process_event( H() ); + RequireEventCounts(machine, 4, 2); + machine.process_event( I() ); + RequireEventCounts(machine, 4, 2); + + return 0; +} diff --git a/src/boost/libs/statechart/test/InStateReactionTest.vcproj b/src/boost/libs/statechart/test/InStateReactionTest.vcproj new file mode 100644 index 000000000..a75d77732 --- /dev/null +++ b/src/boost/libs/statechart/test/InStateReactionTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InStateReactionTest" + ProjectGUID="{DAD64722-72C8-4424-9024-185A0D0D897A}" + RootNamespace="InStateReactionTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/InStateReactionTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InStateReactionTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/InStateReactionTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InStateReactionTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest1.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest1.cpp new file mode 100644 index 000000000..e6ccfe8e5 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest1.cpp @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/shallow_history.hpp> + +#include <boost/mpl/list.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +// A does not have history +struct A : sc::simple_state< A, InconsistentHistoryTest, + mpl::list< sc::shallow_history< B > > > {}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest1.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest1.vcproj new file mode 100644 index 000000000..e2ff2db3c --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest1.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest1" + ProjectGUID="{B2739180-6048-4CA7-A96B-ECE182100321}" + RootNamespace="InconsistentHistoryTest1" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest1.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest1.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest1.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest1.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest2.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest2.cpp new file mode 100644 index 000000000..e32067697 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest2.cpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/shallow_history.hpp> +#include <boost/statechart/transition.hpp> + + + +namespace sc = boost::statechart; + + + +struct EvX : sc::event< EvX > {}; + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +// A only has deep history +struct A : sc::simple_state< + A, InconsistentHistoryTest, B, sc::has_deep_history > +{ + typedef sc::transition< EvX, sc::shallow_history< B > > reactions; +}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest2.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest2.vcproj new file mode 100644 index 000000000..62182f48a --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest2.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest2" + ProjectGUID="{7C58D72A-C6EA-4E25-92E8-5ADEB5F61662}" + RootNamespace="InconsistentHistoryTest2" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest2.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest2.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest2.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest2.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest3.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest3.cpp new file mode 100644 index 000000000..0c3a0a997 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest3.cpp @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/deep_history.hpp> + +#include <boost/mpl/list.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +// A does not have history +struct A : sc::simple_state< + A, InconsistentHistoryTest, mpl::list< sc::deep_history< B > > > {}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest3.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest3.vcproj new file mode 100644 index 000000000..2cb7116cc --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest3.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest3" + ProjectGUID="{801027D8-DC4E-48DC-9F98-75BA0B7F2997}" + RootNamespace="InconsistentHistoryTest3" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest3.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest3.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest3.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest3.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest4.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest4.cpp new file mode 100644 index 000000000..ada425c4f --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest4.cpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/deep_history.hpp> +#include <boost/statechart/transition.hpp> + + + +namespace sc = boost::statechart; + + + +struct EvX : sc::event< EvX > {}; + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +// A only has shallow history +struct A : sc::simple_state< + A, InconsistentHistoryTest, B, sc::has_shallow_history > +{ + typedef sc::transition< EvX, sc::deep_history< B > > reactions; +}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest4.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest4.vcproj new file mode 100644 index 000000000..f6bb5d20a --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest4.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest4" + ProjectGUID="{A211FFC9-D4B4-4C3A-900E-044A7519F8E4}" + RootNamespace="InconsistentHistoryTest4" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest4.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest4.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest4.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest4.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest5.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest5.cpp new file mode 100644 index 000000000..da403cc3e --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest5.cpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +struct A : sc::simple_state< A, InconsistentHistoryTest, B > {}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + // A does not have history + machine.clear_shallow_history< A, 0 >(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest5.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest5.vcproj new file mode 100644 index 000000000..ecb302474 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest5.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest5" + ProjectGUID="{BE34C83E-6D4A-4E49-B9BA-EFF47ECBAA39}" + RootNamespace="InconsistentHistoryTest5" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest5.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest5.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest5.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest5.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest6.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest6.cpp new file mode 100644 index 000000000..aa4f5081a --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest6.cpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/custom_reaction.hpp> + + + +namespace sc = boost::statechart; + + + +struct EvX : sc::event< EvX > {}; + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +// A only has deep history +struct A : sc::simple_state< + A, InconsistentHistoryTest, B, sc::has_deep_history > +{ + typedef sc::custom_reaction< EvX > reactions; + + sc::result react( const EvX & ) + { + // A only has deep history + clear_shallow_history< A, 0 >(); + return discard_event(); + } +}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest6.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest6.vcproj new file mode 100644 index 000000000..37573223b --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest6.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest6" + ProjectGUID="{7D2AB32E-930A-4758-8FAF-F5E0A19A411C}" + RootNamespace="InconsistentHistoryTest6" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest6.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest6.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest6.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest6.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest7.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest7.cpp new file mode 100644 index 000000000..a35a214e1 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest7.cpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +struct A : sc::simple_state< A, InconsistentHistoryTest, B > {}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + // A does not have history + machine.clear_deep_history< A, 0 >(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest7.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest7.vcproj new file mode 100644 index 000000000..83dd10f63 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest7.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest7" + ProjectGUID="{41A33CE9-785E-4EC2-9022-A3B229D4935B}" + RootNamespace="InconsistentHistoryTest7" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest7.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest7.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest7.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest7.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest8.cpp b/src/boost/libs/statechart/test/InconsistentHistoryTest8.cpp new file mode 100644 index 000000000..83c7cb327 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest8.cpp @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/custom_reaction.hpp> + + + +namespace sc = boost::statechart; + + + +struct EvX : sc::event< EvX > {}; + +struct A; +struct InconsistentHistoryTest : sc::state_machine< + InconsistentHistoryTest, A > {}; + +struct B; +// A only has deep history +struct A : sc::simple_state< + A, InconsistentHistoryTest, B, sc::has_shallow_history > +{ + typedef sc::custom_reaction< EvX > reactions; + + sc::result react( const EvX & ) + { + // A only has shallow history + clear_deep_history< A, 0 >(); + return discard_event(); + } +}; + + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InconsistentHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InconsistentHistoryTest8.vcproj b/src/boost/libs/statechart/test/InconsistentHistoryTest8.vcproj new file mode 100644 index 000000000..62c4bec82 --- /dev/null +++ b/src/boost/libs/statechart/test/InconsistentHistoryTest8.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InconsistentHistoryTest8" + ProjectGUID="{FDBCBAEF-C973-42C2-BD8B-4796C0A1E6A8}" + RootNamespace="InconsistentHistoryTest8" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest8.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InconsistentHistoryTest8.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InconsistentHistoryTest8.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InconsistentHistoryTest8.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InnermostDefault.hpp b/src/boost/libs/statechart/test/InnermostDefault.hpp new file mode 100644 index 000000000..afbf667c4 --- /dev/null +++ b/src/boost/libs/statechart/test/InnermostDefault.hpp @@ -0,0 +1,81 @@ +#ifndef BOOST_STATECHART_TEST_INNERMOST_DEFAULT_HPP_INCLUDED +#define BOOST_STATECHART_TEST_INNERMOST_DEFAULT_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2004-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state.hpp> + + + +namespace sc = boost::statechart; + + + +////////////////////////////////////////////////////////////////////////////// +template< class MostDerived, class Context > +struct InnermostDefault : sc::state< MostDerived, Context > +{ + typedef sc::state< MostDerived, Context > base_type; + typedef typename base_type::my_context my_context; + typedef InnermostDefault my_base; + + InnermostDefault( my_context ctx ) : base_type( ctx ) + { + this->outermost_context().template ActualEntry< MostDerived >(); + } + + ~InnermostDefault() + { + this->outermost_context().template ActualDestructor< MostDerived >(); + } + + void exit() + { + this->outermost_context().template ActualExitFunction< MostDerived >(); + } +}; + +////////////////////////////////////////////////////////////////////////////// +template< class Context > +struct Default0 : InnermostDefault< + Default0< Context >, typename Context::template orthogonal< 0 > > +{ + typedef InnermostDefault< + Default0, typename Context::template orthogonal< 0 > > base_type; + typedef typename base_type::my_context my_context; + + Default0( my_context ctx ) : base_type( ctx ) {} +}; + +////////////////////////////////////////////////////////////////////////////// +template< class Context > +struct Default1 : InnermostDefault< + Default1< Context >, typename Context::template orthogonal< 1 > > +{ + typedef InnermostDefault< + Default1, typename Context::template orthogonal< 1 > > base_type; + typedef typename base_type::my_context my_context; + + Default1( my_context ctx ) : base_type( ctx ) {} +}; + +////////////////////////////////////////////////////////////////////////////// +template< class Context > +struct Default2 : InnermostDefault< + Default2< Context >, typename Context::template orthogonal< 2 > > +{ + typedef InnermostDefault< + Default2, typename Context::template orthogonal< 2 > > base_type; + typedef typename base_type::my_context my_context; + + Default2( my_context ctx ) : base_type( ctx ) {} +}; + + + +#endif diff --git a/src/boost/libs/statechart/test/InvalidChartTest1.cpp b/src/boost/libs/statechart/test/InvalidChartTest1.cpp new file mode 100644 index 000000000..05ba4cebf --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidChartTest1.cpp @@ -0,0 +1,32 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> + + + +namespace sc = boost::statechart; + + + +struct A; +struct InvalidChartTest : sc::state_machine< InvalidChartTest, A > {}; + +struct A : sc::simple_state< A, InvalidChartTest > {}; + + // A does not have inner states + struct B : sc::simple_state< B, A > {}; + + +int main() +{ + InvalidChartTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidChartTest1.vcproj b/src/boost/libs/statechart/test/InvalidChartTest1.vcproj new file mode 100644 index 000000000..a84a5fe21 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidChartTest1.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidChartTest1" + ProjectGUID="{AA1A7669-702E-4D56-A390-849612EB9CDF}" + RootNamespace="InvalidChartTest1" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidChartTest1.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidChartTest1.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidChartTest1.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidChartTest1.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidChartTest2.cpp b/src/boost/libs/statechart/test/InvalidChartTest2.cpp new file mode 100644 index 000000000..358e9a09c --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidChartTest2.cpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> + + + +namespace sc = boost::statechart; + + + +struct A; +struct InvalidChartTest : sc::state_machine< InvalidChartTest, A > {}; + +struct B; +struct A : sc::simple_state< A, InvalidChartTest, B > {}; + + struct B : sc::simple_state< B, A > {}; + + // A does not have an orthogonal region with the number 1 + struct C : sc::simple_state< C, A::orthogonal< 1 > > {}; + + +int main() +{ + InvalidChartTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidChartTest2.vcproj b/src/boost/libs/statechart/test/InvalidChartTest2.vcproj new file mode 100644 index 000000000..5ea92de73 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidChartTest2.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidChartTest2" + ProjectGUID="{CCB4DBF2-626B-4DA5-AB02-9504B0A97F9A}" + RootNamespace="InvalidChartTest2" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidChartTest2.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidChartTest2.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidChartTest2.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidChartTest2.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidChartTest3.cpp b/src/boost/libs/statechart/test/InvalidChartTest3.cpp new file mode 100644 index 000000000..ea1ff0e57 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidChartTest3.cpp @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> + +#include <boost/mpl/list.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct A; +struct InvalidChartTest : sc::state_machine< InvalidChartTest, A > {}; +struct B; +struct C; +struct A : sc::simple_state< A, InvalidChartTest, mpl::list< B, C > > {}; + +// B resides in the 0th region not the 1st +struct B : sc::simple_state< B, A::orthogonal< 1 > > {}; +struct C : sc::simple_state< C, A::orthogonal< 1 > > {}; + +int main() +{ + InvalidChartTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidChartTest3.vcproj b/src/boost/libs/statechart/test/InvalidChartTest3.vcproj new file mode 100644 index 000000000..4d84ff408 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidChartTest3.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidChartTest3" + ProjectGUID="{7083917A-4A8D-4BEF-A435-61AAF3BA554C}" + RootNamespace="InvalidChartTest3" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidChartTest3.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidChartTest3.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidChartTest3.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidChartTest3.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidResultAssignTest.cpp b/src/boost/libs/statechart/test/InvalidResultAssignTest.cpp new file mode 100644 index 000000000..9330515de --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidResultAssignTest.cpp @@ -0,0 +1,55 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/custom_reaction.hpp> +#include <boost/statechart/result.hpp> + +#include <boost/static_assert.hpp> + + + +namespace sc = boost::statechart; + + + +struct E : sc::event< E > {}; + +struct A; +struct InvalidResultAssignTest : + sc::state_machine< InvalidResultAssignTest, A > {}; + +struct A : sc::simple_state< A, InvalidResultAssignTest > +{ + typedef sc::custom_reaction< E > reactions; + + sc::result react( const E & ) + { + sc::result r( discard_event() ); + // sc::result must not be assignmable + r = discard_event(); + return r; + } +}; + + + +int main() +{ + InvalidResultAssignTest machine; + machine.initiate(); + + #ifdef NDEBUG + // Test only fails in DEBUG mode. Forcing failure... + BOOST_STATIC_ASSERT( false ); + #endif + + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidResultAssignTest.vcproj b/src/boost/libs/statechart/test/InvalidResultAssignTest.vcproj new file mode 100644 index 000000000..e9ce4c347 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidResultAssignTest.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidResultAssignTest" + ProjectGUID="{962F23F9-D433-4825-9945-D5A5C5337B7F}" + RootNamespace="InvalidResultAssignTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidResultAssignTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidResultAssignTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidResultAssignTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidResultAssignTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidResultCopyTest.cpp b/src/boost/libs/statechart/test/InvalidResultCopyTest.cpp new file mode 100644 index 000000000..4b57df1cd --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidResultCopyTest.cpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <libs/statechart/test/ThrowingBoostAssert.hpp> +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/custom_reaction.hpp> +#include <boost/statechart/result.hpp> + +#include <boost/test/test_tools.hpp> + +#include <stdexcept> // std::logic_error + +namespace sc = boost::statechart; + + + +struct E : sc::event< E > {}; + +struct A; +struct InvalidResultCopyTest : + sc::state_machine< InvalidResultCopyTest, A > {}; + +struct A : sc::simple_state< A, InvalidResultCopyTest > +{ + typedef sc::custom_reaction< E > reactions; + + sc::result react( const E & ) + { + sc::result r( discard_event() ); + sc::result rCopy1( r ); + // Ensure the copy is consumed so that we're not accidentally tripping + // the assert in the sc::result dtor + sc::detail::result_utility::get_result( rCopy1 ); + + // We must not make more than one copy of a result value + sc::result rCopy2( r ); + return rCopy2; + } +}; + + + +int test_main( int, char* [] ) +{ + InvalidResultCopyTest machine; + machine.initiate(); + + #ifdef NDEBUG + BOOST_REQUIRE_NO_THROW( machine.process_event( E() ) ); + #else + BOOST_REQUIRE_THROW( machine.process_event( E() ), std::logic_error ); + #endif + + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidResultCopyTest.vcproj b/src/boost/libs/statechart/test/InvalidResultCopyTest.vcproj new file mode 100644 index 000000000..a219625a7 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidResultCopyTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidResultCopyTest" + ProjectGUID="{856A30E8-85E8-4BE4-B208-B5FC395408AF}" + RootNamespace="InvalidResultCopyTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/InvalidResultCopyTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidResultCopyTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/InvalidResultCopyTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidResultCopyTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidResultDefCtorTest.cpp b/src/boost/libs/statechart/test/InvalidResultDefCtorTest.cpp new file mode 100644 index 000000000..270842325 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidResultDefCtorTest.cpp @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/result.hpp> + +#include <boost/static_assert.hpp> + + + +namespace sc = boost::statechart; + + + +int main() +{ + // sc::result has no default ctor + sc::result r; + + #ifdef NDEBUG + // Test only fails in DEBUG mode. Forcing failure... + BOOST_STATIC_ASSERT( false ); + #endif + + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidResultDefCtorTest.vcproj b/src/boost/libs/statechart/test/InvalidResultDefCtorTest.vcproj new file mode 100644 index 000000000..91230858d --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidResultDefCtorTest.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidResultDefCtorTest" + ProjectGUID="{8381EC0A-7D7B-4127-93E8-DFE12F023611}" + RootNamespace="InvalidResultDefCtorTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidResultDefCtorTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidResultDefCtorTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidResultDefCtorTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidResultDefCtorTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidTransitionTest1.cpp b/src/boost/libs/statechart/test/InvalidTransitionTest1.cpp new file mode 100644 index 000000000..814a35315 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidTransitionTest1.cpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2004-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/mpl/list.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvX : sc::event< EvX > {}; + +struct Active; +struct InvalidTransitionTest : sc::state_machine< + InvalidTransitionTest, Active > {}; + +struct Idle0; +struct Idle1; +struct Active : sc::simple_state< + Active, InvalidTransitionTest, mpl::list< Idle0, Idle1 > > {}; + + // Invalid transition between different orthogonal regions. + struct Idle0 : sc::simple_state< Idle0, Active::orthogonal< 0 > > + { + typedef sc::transition< EvX, Idle1 > reactions; + }; + + struct Idle1 : sc::simple_state< Idle1, Active::orthogonal< 1 > > {}; + + +int main() +{ + InvalidTransitionTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidTransitionTest1.vcproj b/src/boost/libs/statechart/test/InvalidTransitionTest1.vcproj new file mode 100644 index 000000000..240d3b9a4 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidTransitionTest1.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidTransitionTest1" + ProjectGUID="{345A4DD5-8B5C-40E4-95D2-4CF5A2621040}" + RootNamespace="InvalidTransitionTest1" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidTransitionTest1.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidTransitionTest1.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidTransitionTest1.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidTransitionTest1.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/InvalidTransitionTest2.cpp b/src/boost/libs/statechart/test/InvalidTransitionTest2.cpp new file mode 100644 index 000000000..670e6362f --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidTransitionTest2.cpp @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2004-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/mpl/list.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvX : sc::event< EvX > {}; + +struct Active; +struct InvalidTransitionTest : sc::state_machine< + InvalidTransitionTest, Active > {}; + +struct Idle0; +struct Idle1; +struct Active : sc::simple_state< + Active, InvalidTransitionTest, mpl::list< Idle0, Idle1 > > {}; + + struct Idle00; + struct Idle0 : sc::simple_state< + Idle0, Active::orthogonal< 0 >, Idle00 > {}; + + struct Idle00 : sc::simple_state< Idle00, Idle0 > {}; + + struct Idle10; + struct Idle1 : sc::simple_state< + Idle1, Active::orthogonal< 1 >, Idle10 > {}; + + // Invalid transition between different orthogonal regions. + struct Idle10 : sc::simple_state< Idle10, Idle1 > + { + typedef sc::transition< EvX, Idle00 > reactions; + }; + + +int main() +{ + InvalidTransitionTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/InvalidTransitionTest2.vcproj b/src/boost/libs/statechart/test/InvalidTransitionTest2.vcproj new file mode 100644 index 000000000..1a04a34a2 --- /dev/null +++ b/src/boost/libs/statechart/test/InvalidTransitionTest2.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="InvalidTransitionTest2" + ProjectGUID="{FCB42B5B-DDE0-4E12-8474-F55DC85606FE}" + RootNamespace="InvalidTransitionTest2" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidTransitionTest2.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/InvalidTransitionTest2.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/InvalidTransitionTest2.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\InvalidTransitionTest2.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/Jamfile.v2 b/src/boost/libs/statechart/test/Jamfile.v2 new file mode 100644 index 000000000..0742412a7 --- /dev/null +++ b/src/boost/libs/statechart/test/Jamfile.v2 @@ -0,0 +1,161 @@ +############################################################################## +# Copyright 2005-2009 Andreas Huber Doenni +# Distributed under the Boost Software License, Version 1.0. (See accompany- +# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +############################################################################## + +project libs/statechart/test ; + +local test_monitor = + ../../../libs/test/build//boost_test_exec_monitor/<link>static ; +# Some platforms have either problems with the automatic detection of the +# threading mode (e.g. vc-7_1 & gcc >= 3.4.0) or don't support single- +# threaded mode (e.g. vc-8_0). We therefore manually turn MT off here +local st-requirements = <define>BOOST_DISABLE_THREADS ; +local dll = <define>BOOST_STATECHART_TEST_DYNAMIC_LINK ; +local dll-export = $(dll) <define>BOOST_STATECHART_TEST_DLL_EXPORT ; + +local normal = ; +local native = <define>BOOST_STATECHART_USE_NATIVE_RTTI ; +local relaxed = <define>BOOST_STATECHART_RELAX_TRANSITION_CONTEXT ; +local both = $(native) $(relaxed) ; + +rule independent-obj-build ( name : cpp-sources + : requirements * ) +{ + local objs ; + + for local cpp-source in $(cpp-sources) + { + obj $(name)$(cpp-source) : $(cpp-source).cpp : $(requirements) ; + objs += $(name)$(cpp-source) ; + } + + return $(objs) ; +} + +rule statechart-st-lib ( name : cpp-sources + : requirements * ) +{ + local reqs = + <threading>single $(st-requirements) + <link>shared\:$(dll-export) $(requirements) ; + + lib $(name) + : [ independent-obj-build $(name) + : $(cpp-sources) + : $(reqs) ] : $(reqs) ; + + return $(name) ; +} + +rule statechart-run ( name : sources + : requirements * ) +{ + return [ run $(sources) $(test_monitor) : : : $(requirements) : $(name) ] ; +} + +rule statechart-st-run ( name : sources + : requirements * ) +{ + return [ statechart-run $(name) : $(sources) + : <threading>single $(st-requirements) $(requirements) ] ; +} + +rule statechart-st-run-variants ( cpp-source ) +{ + local result ; + + result += [ statechart-st-run $(cpp-source)Normal + : $(cpp-source).cpp : $(normal) ] ; + result += [ statechart-st-run $(cpp-source)Native + : $(cpp-source).cpp : $(native) ] ; + result += [ statechart-st-run $(cpp-source)Relaxed + : $(cpp-source).cpp : $(relaxed) ] ; + result += [ statechart-st-run $(cpp-source)Both + : $(cpp-source).cpp : $(both) ] ; + + return $(result) ; +} + +rule statechart-compile-fail ( name : cpp-sources + : requirements * ) +{ + return [ compile-fail $(cpp-sources).cpp : $(requirements) : $(name) ] ; +} + +rule statechart-compile-fail-variants ( cpp-source ) +{ + local result ; + + result += [ statechart-compile-fail $(cpp-source)Normal + : $(cpp-source) : $(normal) ] ; + result += [ statechart-compile-fail $(cpp-source)Native + : $(cpp-source) : $(native) ] ; + result += [ statechart-compile-fail $(cpp-source)Relaxed + : $(cpp-source) : $(relaxed) ] ; + result += [ statechart-compile-fail $(cpp-source)Both + : $(cpp-source) : $(both) ] ; + + return $(result) ; +} + +rule statechart-st-lib-run ( + name : exe-cpp-sources + : lib-cpp-sources + : requirements * ) +{ + return [ statechart-st-run $(name) + : $(exe-cpp-sources).cpp + [ statechart-st-lib $(name)Lib + : $(lib-cpp-sources) : $(requirements) ] + : <link>shared\:$(dll) $(requirements) ] ; +} + +rule statechart-st-compile-example ( name : directory : cpp-sources + ) +{ + return [ link ../example/$(directory)/$(cpp-sources).cpp + : <threading>single $(st-requirements) : $(name)Example ] ; +} + +test-suite statechart + : [ statechart-compile-fail-variants InvalidChartTest1 ] + [ statechart-compile-fail-variants InvalidChartTest2 ] + [ statechart-compile-fail-variants InvalidChartTest3 ] + [ statechart-st-run-variants TransitionTest ] + [ statechart-compile-fail-variants InvalidTransitionTest1 ] + [ statechart-compile-fail-variants InvalidTransitionTest2 ] + [ statechart-st-run-variants InStateReactionTest ] + [ statechart-st-run-variants TerminationTest ] + [ statechart-st-run-variants DeferralTest ] + [ statechart-st-run-variants DeferralBug ] + [ statechart-st-run-variants CustomReactionTest ] + [ statechart-compile-fail-variants InvalidResultAssignTest ] + [ statechart-compile-fail-variants InvalidResultDefCtorTest ] + [ statechart-st-run-variants InvalidResultCopyTest ] + [ statechart-st-run-variants UnconsumedResultTest ] + [ statechart-st-run-variants HistoryTest ] + [ statechart-compile-fail-variants InconsistentHistoryTest1 ] + [ statechart-compile-fail-variants InconsistentHistoryTest2 ] + [ statechart-compile-fail-variants InconsistentHistoryTest3 ] + [ statechart-compile-fail-variants InconsistentHistoryTest4 ] + [ statechart-compile-fail-variants InconsistentHistoryTest5 ] + [ statechart-compile-fail-variants InconsistentHistoryTest6 ] + [ statechart-compile-fail-variants InconsistentHistoryTest7 ] + [ statechart-compile-fail-variants InconsistentHistoryTest8 ] + [ statechart-compile-fail-variants UnsuppDeepHistoryTest ] + [ statechart-st-run-variants StateCastTest ] + [ statechart-st-run-variants TypeInfoTest ] + [ statechart-st-run-variants StateIterationTest ] + [ statechart-st-run-variants FifoSchedulerTest ] + [ statechart-st-run-variants TriggeringEventTest ] + [ statechart-st-lib-run LibTestNormal + : TuTestMain : TuTest : <link>static $(normal) ] + [ statechart-st-lib-run LibTestNative + : TuTestMain : TuTest : <link>static $(native) ] + [ statechart-st-lib-run DllTestNormal + : TuTestMain : TuTest : <link>shared $(normal) ] + [ statechart-st-lib-run DllTestNative + : TuTestMain : TuTest : <link>shared $(native) ] + [ statechart-st-compile-example BitMachine : BitMachine : BitMachine ] + [ statechart-st-compile-example Camera + : Camera : Camera Configuring Main Shooting ] + [ statechart-st-compile-example Handcrafted : Handcrafted : Handcrafted ] + [ statechart-st-compile-example Keyboard : Keyboard : Keyboard : ] + [ statechart-st-compile-example Performance : Performance : Performance ] + [ statechart-st-compile-example PingPong : PingPong : PingPong Player ] + [ statechart-st-compile-example StopWatch : StopWatch : StopWatch ] + [ statechart-st-compile-example StopWatch2 : StopWatch : StopWatch2 ] ; diff --git a/src/boost/libs/statechart/test/OuterOrthogonal.hpp b/src/boost/libs/statechart/test/OuterOrthogonal.hpp new file mode 100644 index 000000000..769e16456 --- /dev/null +++ b/src/boost/libs/statechart/test/OuterOrthogonal.hpp @@ -0,0 +1,115 @@ +#ifndef BOOST_STATECHART_TEST_OUTER_ORTHOGONAL_HPP_INCLUDED +#define BOOST_STATECHART_TEST_OUTER_ORTHOGONAL_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2004-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state.hpp> +#include <boost/mpl/list.hpp> + +#include "InnermostDefault.hpp" + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +////////////////////////////////////////////////////////////////////////////// +template< class MostDerived, class Context, class InitialState0 > +struct Orthogonal0 : sc::state< MostDerived, Context, + mpl::list< + InitialState0, + Default1< MostDerived >, + Default2< MostDerived > > > +{ + typedef sc::state< + MostDerived, Context, mpl::list< InitialState0, + Default1< MostDerived >, Default2< MostDerived > > > base_type; + typedef typename base_type::my_context my_context; + typedef Orthogonal0 my_base; + + Orthogonal0( my_context ctx ) : base_type( ctx ) + { + this->outermost_context().template ActualEntry< MostDerived >(); + } + + ~Orthogonal0() + { + this->outermost_context().template ActualDestructor< MostDerived >(); + } + + void exit() + { + this->outermost_context().template ActualExitFunction< MostDerived >(); + } +}; + +////////////////////////////////////////////////////////////////////////////// +template< class MostDerived, class Context, class InitialState1 > +struct Orthogonal1 : sc::state< MostDerived, Context, + mpl::list< + Default0< MostDerived >, + InitialState1, + Default2< MostDerived > > > +{ + typedef sc::state< + MostDerived, Context, mpl::list< Default0< MostDerived >, + InitialState1, Default2< MostDerived > > > base_type; + typedef typename base_type::my_context my_context; + typedef Orthogonal1 my_base; + + Orthogonal1( my_context ctx ) : base_type( ctx ) + { + this->outermost_context().template ActualEntry< MostDerived >(); + } + + ~Orthogonal1() + { + this->outermost_context().template ActualDestructor< MostDerived >(); + } + + void exit() + { + this->outermost_context().template ActualExitFunction< MostDerived >(); + } +}; + +////////////////////////////////////////////////////////////////////////////// +template< class MostDerived, class Context, class InitialState2 > +struct Orthogonal2 : sc::state< MostDerived, Context, + mpl::list< + Default0< MostDerived >, + Default1< MostDerived >, + InitialState2 > > +{ + typedef sc::state< + MostDerived, Context, mpl::list< Default0< MostDerived >, + Default1< MostDerived >, InitialState2 > > base_type; + typedef typename base_type::my_context my_context; + typedef Orthogonal2 my_base; + + Orthogonal2( my_context ctx ) : base_type( ctx ) + { + this->outermost_context().template ActualEntry< MostDerived >(); + } + + ~Orthogonal2() + { + this->outermost_context().template ActualDestructor< MostDerived >(); + } + + void exit() + { + this->outermost_context().template ActualExitFunction< MostDerived >(); + } +}; + + + +#endif diff --git a/src/boost/libs/statechart/test/StateCastTest.cpp b/src/boost/libs/statechart/test/StateCastTest.cpp new file mode 100644 index 000000000..07099d515 --- /dev/null +++ b/src/boost/libs/statechart/test/StateCastTest.cpp @@ -0,0 +1,203 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/state.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/intrusive_ptr.hpp> + +#include <boost/test/test_tools.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvToB : sc::event< EvToB > {}; +struct EvToF : sc::event< EvToF > {}; +struct EvCheck : sc::event< EvCheck > {}; + +struct A; +struct StateCastTest : sc::state_machine< StateCastTest, A > +{ + template< class State > + void AssertInState() + { + BOOST_REQUIRE( state_downcast< const State * >() != 0 ); + BOOST_REQUIRE_NO_THROW( state_downcast< const State & >() ); + BOOST_REQUIRE( state_cast< const State * >() != 0 ); + BOOST_REQUIRE_NO_THROW( state_cast< const State & >() ); + } + + template< class State > + void AssertNotInState() + { + BOOST_REQUIRE( state_downcast< const State * >() == 0 ); + BOOST_REQUIRE_THROW( state_downcast< const State & >(), std::bad_cast ); + BOOST_REQUIRE( state_cast< const State * >() == 0 ); + BOOST_REQUIRE_THROW( state_cast< const State & >(), std::bad_cast ); + } +}; + +template< class State, class FromState > +void AssertInState( const FromState & theState ) +{ + BOOST_REQUIRE( theState.template state_downcast< const State * >() != 0 ); + BOOST_REQUIRE_NO_THROW( theState.template state_downcast< const State & >() ); + BOOST_REQUIRE( theState.template state_cast< const State * >() != 0 ); + BOOST_REQUIRE_NO_THROW( theState.template state_cast< const State & >() ); +} + +template< class State, class FromState > +void AssertNotInState( const FromState & theState ) +{ + BOOST_REQUIRE( theState.template state_downcast< const State * >() == 0 ); + BOOST_REQUIRE_THROW( theState.template state_downcast< const State & >(), std::bad_cast ); + BOOST_REQUIRE( theState.template state_cast< const State * >() == 0 ); + BOOST_REQUIRE_THROW( theState.template state_cast< const State & >(), std::bad_cast ); +} + +struct B; +struct C; +struct D; +struct A : sc::simple_state< A, StateCastTest, mpl::list< C, D > > +{ + typedef sc::transition< EvToB, B > reactions; +}; + + struct E; + struct C : sc::simple_state< C, A::orthogonal< 0 >, E > {}; + + struct E : sc::state< E, C > + { + typedef sc::custom_reaction< EvCheck > reactions; + + E( my_context ctx ) : my_base( ctx ) + { + post_event( boost::intrusive_ptr< EvCheck >( new EvCheck() ) ); + } + + sc::result react( const EvCheck & ); + }; + + struct F : sc::state< F, C > + { + typedef sc::custom_reaction< EvCheck > reactions; + + F( my_context ctx ) : my_base( ctx ) + { + post_event( boost::intrusive_ptr< EvCheck >( new EvCheck() ) ); + } + + sc::result react( const EvCheck & ); + }; + + struct G; + struct D : sc::simple_state< D, A::orthogonal< 1 >, G > {}; + + struct G : sc::simple_state< G, D > {}; + struct H : sc::simple_state< H, D > {}; + +struct B : sc::simple_state< B, StateCastTest > +{ + typedef sc::transition< EvToF, F > reactions; +}; + +sc::result E::react( const EvCheck & ) +{ + AssertInState< A >( *this ); + AssertNotInState< B >( *this ); + AssertInState< C >( *this ); + AssertInState< D >( *this ); + AssertInState< E >( *this ); + AssertNotInState< F >( *this ); + AssertInState< G >( *this ); + AssertNotInState< H >( *this ); + return discard_event(); +} + +sc::result F::react( const EvCheck & ) +{ + AssertInState< A >( *this ); + AssertNotInState< B >( *this ); + AssertInState< C >( *this ); + AssertInState< D >( *this ); + AssertNotInState< E >( *this ); + AssertInState< F >( *this ); + AssertInState< G >( *this ); + AssertNotInState< H >( *this ); + return discard_event(); +} + + +int test_main( int, char* [] ) +{ + StateCastTest machine; + + machine.AssertNotInState< A >(); + machine.AssertNotInState< B >(); + machine.AssertNotInState< C >(); + machine.AssertNotInState< D >(); + machine.AssertNotInState< E >(); + machine.AssertNotInState< F >(); + machine.AssertNotInState< G >(); + machine.AssertNotInState< H >(); + + machine.initiate(); + + machine.AssertInState< A >(); + machine.AssertNotInState< B >(); + machine.AssertInState< C >(); + machine.AssertInState< D >(); + machine.AssertInState< E >(); + machine.AssertNotInState< F >(); + machine.AssertInState< G >(); + machine.AssertNotInState< H >(); + + machine.process_event( EvToB() ); + + machine.AssertNotInState< A >(); + machine.AssertInState< B >(); + machine.AssertNotInState< C >(); + machine.AssertNotInState< D >(); + machine.AssertNotInState< E >(); + machine.AssertNotInState< F >(); + machine.AssertNotInState< G >(); + machine.AssertNotInState< H >(); + + machine.process_event( EvToF() ); + + machine.AssertInState< A >(); + machine.AssertNotInState< B >(); + machine.AssertInState< C >(); + machine.AssertInState< D >(); + machine.AssertNotInState< E >(); + machine.AssertInState< F >(); + machine.AssertInState< G >(); + machine.AssertNotInState< H >(); + + machine.terminate(); + + machine.AssertNotInState< A >(); + machine.AssertNotInState< B >(); + machine.AssertNotInState< C >(); + machine.AssertNotInState< D >(); + machine.AssertNotInState< E >(); + machine.AssertNotInState< F >(); + machine.AssertNotInState< G >(); + machine.AssertNotInState< H >(); + + return 0; +} diff --git a/src/boost/libs/statechart/test/StateCastTest.vcproj b/src/boost/libs/statechart/test/StateCastTest.vcproj new file mode 100644 index 000000000..86c36c65c --- /dev/null +++ b/src/boost/libs/statechart/test/StateCastTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="StateCastTest" + ProjectGUID="{1826122F-4DB3-4C69-8BB2-E0B18D809FA9}" + RootNamespace="StateCastTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/StateCastTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/StateCastTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/StateCastTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\StateCastTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/StateIterationTest.cpp b/src/boost/libs/statechart/test/StateIterationTest.cpp new file mode 100644 index 000000000..f9d80fc95 --- /dev/null +++ b/src/boost/libs/statechart/test/StateIterationTest.cpp @@ -0,0 +1,150 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + +#include <set> +#include <map> +#include <string> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvToA : sc::event< EvToA > {}; +struct EvToB : sc::event< EvToB > {}; +struct EvToD : sc::event< EvToD > {}; +struct EvToE : sc::event< EvToE > {}; + +struct A; +struct StateIterationTest : sc::state_machine< StateIterationTest, A > +{ + public: + ////////////////////////////////////////////////////////////////////////// + StateIterationTest(); + + void AssertInState( const std::string & stateNames ) const + { + stateNamesCache_.clear(); + + for ( state_iterator currentState = state_begin(); + currentState != state_end(); ++currentState ) + { + const StateNamesMap::const_iterator found = + stateNamesMap_.find( currentState->dynamic_type() ); + BOOST_REQUIRE( found != stateNamesMap_.end() ); + stateNamesCache_.insert( found->second ); + } + + std::string::const_iterator expectedName = stateNames.begin(); + + BOOST_REQUIRE( stateNames.size() == stateNamesCache_.size() ); + + for ( StateNamesCache::const_iterator actualName = + stateNamesCache_.begin(); + actualName != stateNamesCache_.end(); ++actualName, ++expectedName ) + { + BOOST_REQUIRE( ( *actualName )[ 0 ] == *expectedName ); + } + } + + private: + ////////////////////////////////////////////////////////////////////////// + typedef std::map< state_base_type::id_type, std::string > StateNamesMap; + typedef std::set< std::string > StateNamesCache; + + StateNamesMap stateNamesMap_; + mutable StateNamesCache stateNamesCache_; +}; + +struct C; +struct D; +struct B : sc::simple_state< B, StateIterationTest, mpl::list< C, D > > +{ + typedef sc::transition< EvToA, A > reactions; +}; + +struct A : sc::simple_state< A, StateIterationTest > +{ + typedef sc::transition< EvToB, B > reactions; +}; + + struct F; + struct G; + struct E : sc::simple_state< E, B::orthogonal< 1 >, mpl::list< F, G > > + { + typedef sc::transition< EvToD, D > reactions; + }; + + struct F : sc::simple_state< F, E::orthogonal< 0 > > {}; + struct G : sc::simple_state< G, E::orthogonal< 1 > > {}; + + struct C : sc::simple_state< C, B::orthogonal< 0 > > {}; + struct D : sc::simple_state< D, B::orthogonal< 1 > > + { + typedef sc::transition< EvToE, E > reactions; + }; + +StateIterationTest::StateIterationTest() +{ + // We're not using custom type information to make this test work even when + // BOOST_STATECHART_USE_NATIVE_RTTI is defined + stateNamesMap_[ A::static_type() ] = "A"; + stateNamesMap_[ B::static_type() ] = "B"; + stateNamesMap_[ C::static_type() ] = "C"; + stateNamesMap_[ D::static_type() ] = "D"; + stateNamesMap_[ E::static_type() ] = "E"; + stateNamesMap_[ F::static_type() ] = "F"; + stateNamesMap_[ G::static_type() ] = "G"; +} + + +int test_main( int, char* [] ) +{ + StateIterationTest machine; + machine.AssertInState( "" ); + + machine.initiate(); + machine.AssertInState( "A" ); + + machine.process_event( EvToB() ); + machine.AssertInState( "CD" ); + + machine.process_event( EvToA() ); + machine.AssertInState( "A" ); + + machine.process_event( EvToB() ); + machine.AssertInState( "CD" ); + + machine.process_event( EvToE() ); + machine.AssertInState( "CFG" ); + + machine.process_event( EvToD() ); + machine.AssertInState( "CD" ); + + machine.process_event( EvToE() ); + machine.AssertInState( "CFG" ); + + machine.process_event( EvToA() ); + machine.AssertInState( "A" ); + + machine.terminate(); + machine.AssertInState( "" ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/StateIterationTest.vcproj b/src/boost/libs/statechart/test/StateIterationTest.vcproj new file mode 100644 index 000000000..c9efc13c9 --- /dev/null +++ b/src/boost/libs/statechart/test/StateIterationTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="StateIterationTest" + ProjectGUID="{D52BF95D-392C-4535-B332-CB3CC29C8227}" + RootNamespace="StateIterationTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/StateIterationTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/StateIterationTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/StateIterationTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\StateIterationTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/TerminationTest.cpp b/src/boost/libs/statechart/test/TerminationTest.cpp new file mode 100644 index 000000000..220be1bdf --- /dev/null +++ b/src/boost/libs/statechart/test/TerminationTest.cpp @@ -0,0 +1,283 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/termination.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + +#include <set> +#include <map> +#include <string> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvTerminateA : sc::event< EvTerminateA > {}; +struct EvTerminateB : sc::event< EvTerminateB > {}; +struct EvTerminateC : sc::event< EvTerminateC > {}; +struct EvTerminateD : sc::event< EvTerminateD > {}; +struct EvTerminateE : sc::event< EvTerminateE > {}; +struct EvTerminateF : sc::event< EvTerminateF > {}; +struct EvTerminateG : sc::event< EvTerminateG > {}; + +struct A; +struct TerminationTest : sc::state_machine< TerminationTest, A > +{ + public: + ////////////////////////////////////////////////////////////////////////// + TerminationTest(); + + void AssertInState( const std::string & stateNames ) const + { + stateNamesCache_.clear(); + + for ( state_iterator currentState = state_begin(); + currentState != state_end(); ++currentState ) + { + AddName( currentState->dynamic_type() ); + + const state_base_type * outerState = currentState->outer_state_ptr(); + + while ( outerState != 0 ) + { + AddName( outerState->dynamic_type() ); + outerState = outerState->outer_state_ptr(); + } + } + + std::string::const_iterator expectedName = stateNames.begin(); + + BOOST_REQUIRE( stateNames.size() == stateNamesCache_.size() ); + + for ( StateNamesCache::const_iterator actualName = + stateNamesCache_.begin(); actualName != stateNamesCache_.end(); + ++actualName, ++expectedName ) + { + BOOST_REQUIRE( ( *actualName )[ 0 ] == *expectedName ); + } + } + + private: + ////////////////////////////////////////////////////////////////////////// + void AddName( state_base_type::id_type stateType ) const + { + const StateNamesMap::const_iterator found = + stateNamesMap_.find( stateType ); + BOOST_REQUIRE( found != stateNamesMap_.end() ); + stateNamesCache_.insert( found->second ); + } + + typedef std::map< state_base_type::id_type, std::string > StateNamesMap; + typedef std::set< std::string > StateNamesCache; + + StateNamesMap stateNamesMap_; + mutable StateNamesCache stateNamesCache_; +}; + +template< + class MostDerived, + class Context, + class InnerInitial = mpl::list<> > +struct MyState : sc::simple_state< MostDerived, Context, InnerInitial > +{ + public: + MyState() : exitCalled_( false ) {} + + ~MyState() + { + // BOOST_REQUIRE throws an exception when the test fails. If the state + // is destructed as part of a stack unwind, abort() is called what is + // presumably also detected by the test monitor. + BOOST_REQUIRE( exitCalled_ ); + } + + void exit() + { + exitCalled_ = true; + } + + private: + bool exitCalled_; +}; + + +struct B; +struct C; +struct A : MyState< A, TerminationTest, mpl::list< B, C > > +{ + typedef sc::termination< EvTerminateA > reactions; +}; + + struct B : MyState< B, A::orthogonal< 0 > > + { + typedef sc::termination< EvTerminateB > reactions; + }; + + struct D; + struct E; + struct C : MyState< C, A::orthogonal< 1 >, mpl::list< D, E > > + { + typedef sc::termination< EvTerminateC > reactions; + }; + + struct D : MyState< D, C::orthogonal< 0 > > + { + typedef sc::termination< EvTerminateD > reactions; + }; + + struct F; + struct G; + struct E : MyState< E, C::orthogonal< 1 >, mpl::list< F, G > > + { + typedef sc::termination< EvTerminateE > reactions; + }; + + struct F : MyState< F, E::orthogonal< 0 > > + { + typedef sc::termination< EvTerminateF > reactions; + }; + + struct G : MyState< G, E::orthogonal< 1 > > + { + typedef sc::termination< EvTerminateG > reactions; + }; + +TerminationTest::TerminationTest() +{ + // We're not using custom type information to make this test work even when + // BOOST_STATECHART_USE_NATIVE_RTTI is defined + stateNamesMap_[ A::static_type() ] = "A"; + stateNamesMap_[ B::static_type() ] = "B"; + stateNamesMap_[ C::static_type() ] = "C"; + stateNamesMap_[ D::static_type() ] = "D"; + stateNamesMap_[ E::static_type() ] = "E"; + stateNamesMap_[ F::static_type() ] = "F"; + stateNamesMap_[ G::static_type() ] = "G"; +} + + +struct X; +struct TerminationEventBaseTest : + sc::state_machine< TerminationEventBaseTest, X > {}; + +struct X : sc::simple_state< X, TerminationEventBaseTest > +{ + typedef sc::termination< sc::event_base > reactions; +}; + + +int test_main( int, char* [] ) +{ + TerminationTest machine; + machine.AssertInState( "" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.process_event( EvTerminateE() ); + machine.AssertInState( "ABCD" ); + machine.process_event( EvTerminateE() ); + machine.AssertInState( "ABCD" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.process_event( EvTerminateC() ); + machine.AssertInState( "AB" ); + machine.process_event( EvTerminateC() ); + machine.AssertInState( "AB" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.process_event( EvTerminateA() ); + machine.AssertInState( "" ); + machine.process_event( EvTerminateA() ); + machine.AssertInState( "" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.process_event( EvTerminateG() ); + machine.AssertInState( "ABCDEF" ); + machine.process_event( EvTerminateG() ); + machine.AssertInState( "ABCDEF" ); + machine.process_event( EvTerminateF() ); + machine.AssertInState( "ABCD" ); + machine.process_event( EvTerminateF() ); + machine.AssertInState( "ABCD" ); + machine.process_event( EvTerminateD() ); + machine.AssertInState( "AB" ); + machine.process_event( EvTerminateD() ); + machine.AssertInState( "AB" ); + machine.process_event( EvTerminateB() ); + machine.AssertInState( "" ); + machine.process_event( EvTerminateB() ); + machine.AssertInState( "" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.process_event( EvTerminateB() ); + machine.AssertInState( "ACDEFG" ); + machine.process_event( EvTerminateB() ); + machine.AssertInState( "ACDEFG" ); + machine.process_event( EvTerminateD() ); + machine.AssertInState( "ACEFG" ); + machine.process_event( EvTerminateD() ); + machine.AssertInState( "ACEFG" ); + machine.process_event( EvTerminateF() ); + machine.AssertInState( "ACEG" ); + machine.process_event( EvTerminateF() ); + machine.AssertInState( "ACEG" ); + machine.process_event( EvTerminateG() ); + machine.AssertInState( "" ); + machine.process_event( EvTerminateG() ); + machine.AssertInState( "" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.process_event( EvTerminateE() ); + machine.AssertInState( "ABCD" ); + machine.process_event( EvTerminateE() ); + machine.AssertInState( "ABCD" ); + machine.process_event( EvTerminateC() ); + machine.AssertInState( "AB" ); + machine.process_event( EvTerminateC() ); + machine.AssertInState( "AB" ); + machine.process_event( EvTerminateA() ); + machine.AssertInState( "" ); + machine.process_event( EvTerminateA() ); + machine.AssertInState( "" ); + + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.initiate(); + machine.AssertInState( "ABCDEFG" ); + machine.terminate(); + machine.AssertInState( "" ); + machine.terminate(); + machine.AssertInState( "" ); + + + TerminationEventBaseTest eventBaseMachine; + eventBaseMachine.initiate(); + BOOST_REQUIRE( !eventBaseMachine.terminated() ); + eventBaseMachine.process_event( EvTerminateA() ); + BOOST_REQUIRE( eventBaseMachine.terminated() ); + eventBaseMachine.initiate(); + BOOST_REQUIRE( !eventBaseMachine.terminated() ); + eventBaseMachine.process_event( EvTerminateB() ); + BOOST_REQUIRE( eventBaseMachine.terminated() ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/TerminationTest.vcproj b/src/boost/libs/statechart/test/TerminationTest.vcproj new file mode 100644 index 000000000..040dfee88 --- /dev/null +++ b/src/boost/libs/statechart/test/TerminationTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="TerminationTest" + ProjectGUID="{A9921F2C-D8D3-4A4A-87C8-9A34DDD588B2}" + RootNamespace="TerminationTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/TerminationTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/TerminationTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/TerminationTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\TerminationTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/ThrowingBoostAssert.hpp b/src/boost/libs/statechart/test/ThrowingBoostAssert.hpp new file mode 100644 index 000000000..30e86d174 --- /dev/null +++ b/src/boost/libs/statechart/test/ThrowingBoostAssert.hpp @@ -0,0 +1,39 @@ +#ifndef BOOST_STATECHART_TEST_THROWING_BOOST_ASSERT_HPP_INCLUDED +#define BOOST_STATECHART_TEST_THROWING_BOOST_ASSERT_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <string> +#include <stdexcept> + + + +#define BOOST_ENABLE_ASSERT_HANDLER + + + +namespace boost +{ + + +void assertion_failed( + char const * expr, char const * func, char const * file, long ) +{ + throw std::logic_error( + std::string( "\nAssertion failed: \"" ) + expr + "\"\n" + + "File: \"" + file + "\"\n" + + "Function: \"" + func + "\"\n" ); +} + + + +} // namespace boost + + + +#endif diff --git a/src/boost/libs/statechart/test/TransitionTest.cpp b/src/boost/libs/statechart/test/TransitionTest.cpp new file mode 100644 index 000000000..807094031 --- /dev/null +++ b/src/boost/libs/statechart/test/TransitionTest.cpp @@ -0,0 +1,849 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2004-2007 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "OuterOrthogonal.hpp" +#include "InnermostDefault.hpp" + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/null_exception_translator.hpp> +#include <boost/statechart/exception_translator.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/transition.hpp> +#include <boost/statechart/custom_reaction.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + +#include <typeinfo> +#include <string> +#include <vector> +#include <iostream> +#include <algorithm> +#include <stdexcept> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +typedef std::string ActionDescription(); +typedef ActionDescription * ActionDescriptionPtr; +typedef std::vector< ActionDescriptionPtr > ActionDescriptionSequence; +typedef ActionDescriptionSequence::const_iterator SequenceIterator; +typedef void Action( ActionDescriptionSequence & ); +typedef Action * ActionPtr; + +template< class State > +std::string EntryDescription() +{ + static const std::string entry = "Entry: "; + return entry + typeid( State ).name() + "\n"; +} + +template< class State > +std::string ExitFnDescription() +{ + static const std::string exitFunction = "exit(): "; + return exitFunction + typeid( State ).name() + "\n"; +} + +template< class State > +std::string DtorDescription() +{ + static const std::string destructor = "Destructor: "; + return destructor + typeid( State ).name() + "\n"; +} + +template< class Context, class Event > +std::string TransDescription() +{ + static const std::string transition = "Transition: "; + static const std::string event = " with Event: "; + return transition + typeid( Context ).name() + + event + typeid( Event ).name() + "\n"; +} + +template< ActionPtr pAction > +std::string ThrowDescription() +{ + static const std::string throwing = "Throwing exception in "; + ActionDescriptionSequence sequence; + pAction( sequence ); + return throwing + sequence.front()(); +} + + +template< class State > +void Entry( ActionDescriptionSequence & sequence ) +{ + sequence.push_back( &EntryDescription< State > ); +} + +template< class State > +void ExitFn( ActionDescriptionSequence & sequence ) +{ + sequence.push_back( &ExitFnDescription< State > ); +} + +template< class State > +void Dtor( ActionDescriptionSequence & sequence ) +{ + sequence.push_back( &DtorDescription< State > ); +} + +template< class State > +void Exit( ActionDescriptionSequence & sequence ) +{ + ExitFn< State >( sequence ); + Dtor< State >( sequence ); +} + +template< class Context, class Event > +void Trans( ActionDescriptionSequence & sequence ) +{ + sequence.push_back( &TransDescription< Context, Event > ); +} + +template< ActionPtr pAction > +void Throw( ActionDescriptionSequence & sequence ) +{ + sequence.push_back( &ThrowDescription< pAction > ); +} + +const int arrayLength = 30; +typedef ActionPtr ActionArray[ arrayLength ]; + + +class TransitionTestException : public std::runtime_error +{ + public: + TransitionTestException() : std::runtime_error( "Oh la la!" ) {} +}; + + +// This test state machine is a beefed-up version of the one presented in +// "Practical Statecharts in C/C++" by Miro Samek, CMP Books 2002 +struct A : sc::event< A > {}; +struct B : sc::event< B > {}; +struct C : sc::event< C > {}; +struct D : sc::event< D > {}; +struct E : sc::event< E > {}; +struct F : sc::event< F > {}; +struct G : sc::event< G > {}; +struct H : sc::event< H > {}; + + +template< class M > struct S0; +template< class Translator > +struct TransitionTest : sc::state_machine< + TransitionTest< Translator >, S0< TransitionTest< Translator > >, + std::allocator< sc::none >, Translator > +{ + public: + ////////////////////////////////////////////////////////////////////////// + TransitionTest() : pThrowAction_( 0 ), unconsumedEventCount_( 0 ) {} + + ~TransitionTest() + { + // Since state destructors access the state machine object, we need to + // make sure that all states are destructed before this subtype + // portion is destructed. + this->terminate(); + } + + void CompareToExpectedActionSequence( ActionArray & actions ) + { + expectedSequence_.clear(); + + // Copy all non-null pointers in actions into expectedSequence_ + for ( ActionPtr * pCurrent = &actions[ 0 ]; + ( pCurrent != &actions[ arrayLength ] ) && ( *pCurrent != 0 ); + ++pCurrent ) + { + ( *pCurrent )( expectedSequence_ ); + } + + if ( ( expectedSequence_.size() != actualSequence_.size() ) || + !std::equal( expectedSequence_.begin(), + expectedSequence_.end(), actualSequence_.begin() ) ) + { + std::string message = "\nExpected action sequence:\n"; + + for ( SequenceIterator pExpected = expectedSequence_.begin(); + pExpected != expectedSequence_.end(); ++pExpected ) + { + message += ( *pExpected )(); + } + + message += "\nActual action sequence:\n"; + + for ( SequenceIterator pActual = actualSequence_.begin(); + pActual != actualSequence_.end(); ++pActual ) + { + message += ( *pActual )(); + } + + BOOST_FAIL( message.c_str() ); + } + + actualSequence_.clear(); + } + + void ClearActualSequence() + { + actualSequence_.clear(); + } + + void ThrowAction( ActionPtr pThrowAction ) + { + pThrowAction_ = pThrowAction; + } + + template< class State > + void ActualEntry() + { + StoreActualAction< &Entry< State > >(); + } + + template< class State > + void ActualExitFunction() + { + StoreActualAction< &ExitFn< State > >(); + } + + template< class State > + void ActualDestructor() + { + StoreActualAction< &Dtor< State > >(); + } + + template< class Context, class Event > + void ActualTransition() + { + StoreActualAction< &Trans< Context, Event > >(); + } + + void unconsumed_event( const sc::event_base & ) + { + ++unconsumedEventCount_; + } + + unsigned int GetUnconsumedEventCount() const + { + return unconsumedEventCount_; + } + + private: + ////////////////////////////////////////////////////////////////////////// + template< ActionPtr pAction > + void StoreActualAction() + { + if ( pAction == pThrowAction_ ) + { + Throw< pAction >( actualSequence_ ); + throw TransitionTestException(); + } + else + { + pAction( actualSequence_ ); + } + } + + ActionPtr pThrowAction_; + ActionDescriptionSequence actualSequence_; + ActionDescriptionSequence expectedSequence_; + unsigned int unconsumedEventCount_; +}; + +template< class M > struct S1; +template< class M > struct S211; +template< class M > +struct S0 : Orthogonal0< S0< M >, M, S1< M > > +{ + typedef Orthogonal0< S0< M >, M, S1< M > > my_base; + public: + typedef sc::transition< E, S211< M > > reactions; + + S0( typename my_base::my_context ctx ) : my_base( ctx ) {} + + void Transit( const A & evt ) { TransitImpl( evt ); } + void Transit( const B & evt ) { TransitImpl( evt ); } + void Transit( const C & evt ) { TransitImpl( evt ); } + void Transit( const D & evt ) { TransitImpl( evt ); } + void Transit( const F & evt ) { TransitImpl( evt ); } + void Transit( const G & evt ) { TransitImpl( evt ); } + void Transit( const H & evt ) { TransitImpl( evt ); } + + private: + template< class Event > + void TransitImpl( const Event & ) + { + this->outermost_context().template ActualTransition< S0< M >, Event >(); + } +}; + + template< class M > struct S11; + template< class M > struct S21; + template< class M > + struct S2 : Orthogonal2< S2< M >, S0< M >, S21< M > > + { + typedef Orthogonal2< S2< M >, S0< M >, S21< M > > my_base; + typedef mpl::list< + sc::transition< C, S1< M >, S0< M >, &S0< M >::Transit >, + sc::transition< F, S11< M >, S0< M >, &S0< M >::Transit > + > reactions; + + S2( typename my_base::my_context ctx ) : my_base( ctx ) {} + }; + + template< class M > + struct S21 : Orthogonal1< + S21< M >, typename S2< M >::template orthogonal< 2 >, S211< M > > + { + typedef Orthogonal1< + S21< M >, typename S2< M >::template orthogonal< 2 >, S211< M > + > my_base; + typedef mpl::list< + sc::transition< H, S21< M >, S0< M >, &S0< M >::Transit >, + sc::transition< B, S211< M >, S0< M >, &S0< M >::Transit > + > reactions; + + S21( typename my_base::my_context ctx ) : my_base( ctx ) {} + }; + + template< class M > + struct S211 : InnermostDefault< + S211< M >, typename S21< M >::template orthogonal< 1 > > + { + typedef InnermostDefault< + S211< M >, typename S21< M >::template orthogonal< 1 > > my_base; + typedef mpl::list< + sc::transition< D, S21< M >, S0< M >, &S0< M >::Transit >, + sc::transition< G, S0< M > > + > reactions; + + S211( typename my_base::my_context ctx ) : my_base( ctx ) {} + }; + + template< class M > + struct S1 : Orthogonal1< S1< M >, S0< M >, S11< M > > + { + typedef Orthogonal1< S1< M >, S0< M >, S11< M > > my_base; + typedef mpl::list< + sc::transition< A, S1< M >, S0< M >, &S0< M >::Transit >, + sc::transition< B, S11< M >, S0< M >, &S0< M >::Transit >, + sc::transition< C, S2< M >, S0< M >, &S0< M >::Transit >, + sc::transition< D, S0< M > >, + sc::transition< F, S211< M >, S0< M >, &S0< M >::Transit > + > reactions; + + S1( typename my_base::my_context ctx ) : my_base( ctx ) {} + }; + + template< class M > + struct S11 : InnermostDefault< + S11< M >, typename S1< M >::template orthogonal< 1 > > + { + typedef InnermostDefault< + S11< M >, typename S1< M >::template orthogonal< 1 > > my_base; + typedef mpl::list< + sc::transition< G, S211< M >, S0< M >, &S0< M >::Transit >, + sc::custom_reaction< H > + > reactions; + + S11( typename my_base::my_context ctx ) : my_base( ctx ) {} + + sc::result react( const H & ) + { + this->outermost_context().template ActualTransition< S11< M >, H >(); + return this->discard_event(); + } + }; + + +struct X1; +struct TransitionEventBaseTest : + sc::state_machine< TransitionEventBaseTest, X1 > +{ + public: + TransitionEventBaseTest() : actionCallCounter_( 0 ) {} + + void Transit( const sc::event_base & eventBase ) + { + BOOST_REQUIRE( + ( dynamic_cast< const B * >( &eventBase ) != 0 ) || + ( dynamic_cast< const D * >( &eventBase ) != 0 ) ); + ++actionCallCounter_; + } + + unsigned int GetActionCallCounter() const + { + return actionCallCounter_; + } + + private: + unsigned int actionCallCounter_; +}; + +struct X2 : sc::simple_state< X2, TransitionEventBaseTest > +{ + typedef sc::transition< sc::event_base, X1, + TransitionEventBaseTest, &TransitionEventBaseTest::Transit > reactions; +}; + +struct X1 : sc::simple_state< X1, TransitionEventBaseTest > +{ + typedef sc::transition< sc::event_base, X2 > reactions; +}; + +template< class M > +void TestTransitions( M & machine ) +{ + machine.initiate(); + ActionArray init = + { + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > > + }; + machine.CompareToExpectedActionSequence( init ); + + machine.process_event( A() ); + ActionArray a1 = + { + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Trans< S0< M >, A >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > > + }; + machine.CompareToExpectedActionSequence( a1 ); + + machine.process_event( B() ); + ActionArray b1 = + { + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Trans< S0< M >, B >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > > + }; + machine.CompareToExpectedActionSequence( b1 ); + + machine.process_event( C() ); + ActionArray c1 = + { + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Trans< S0< M >, C >, + Entry< S2< M > >, + Entry< Default0< S2< M > > >, + Entry< Default1< S2< M > > >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > > + }; + machine.CompareToExpectedActionSequence( c1 ); + + machine.process_event( D() ); + ActionArray d2 = + { + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Trans< S0< M >, D >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > > + }; + machine.CompareToExpectedActionSequence( d2 ); + + machine.process_event( E() ); + ActionArray e2 = + { + Exit< Default2< S0< M > > >, + Exit< Default1< S0< M > > >, + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Exit< Default1< S2< M > > >, + Exit< Default0< S2< M > > >, + Exit< S2< M > >, + Exit< S0< M > >, + Entry< S0< M > >, + Entry< S2< M > >, + Entry< Default0< S2< M > > >, + Entry< Default1< S2< M > > >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > > + }; + machine.CompareToExpectedActionSequence( e2 ); + + machine.process_event( F() ); + ActionArray f2 = + { + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Exit< Default1< S2< M > > >, + Exit< Default0< S2< M > > >, + Exit< S2< M > >, + Trans< S0< M >, F >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > > + }; + machine.CompareToExpectedActionSequence( f2 ); + + machine.process_event( G() ); + ActionArray g1 = + { + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Trans< S0< M >, G >, + Entry< S2< M > >, + Entry< Default0< S2< M > > >, + Entry< Default1< S2< M > > >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > > + }; + machine.CompareToExpectedActionSequence( g1 ); + + machine.process_event( H() ); + ActionArray h2 = + { + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Trans< S0< M >, H >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > > + }; + machine.CompareToExpectedActionSequence( h2 ); + + BOOST_REQUIRE( machine.GetUnconsumedEventCount() == 0 ); + machine.process_event( A() ); + BOOST_REQUIRE( machine.GetUnconsumedEventCount() == 1 ); + ActionArray a2 = + { + }; + machine.CompareToExpectedActionSequence( a2 ); + + machine.process_event( B() ); + ActionArray b2 = + { + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Trans< S0< M >, B >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > > + }; + machine.CompareToExpectedActionSequence( b2 ); + + machine.process_event( C() ); + ActionArray c2 = + { + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Exit< Default1< S2< M > > >, + Exit< Default0< S2< M > > >, + Exit< S2< M > >, + Trans< S0< M >, C >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > > + }; + machine.CompareToExpectedActionSequence( c2 ); + + machine.process_event( D() ); + ActionArray d1 = + { + Exit< Default2< S0< M > > >, + Exit< Default1< S0< M > > >, + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Exit< S0< M > >, + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > > + }; + machine.CompareToExpectedActionSequence( d1 ); + + machine.process_event( F() ); + ActionArray f1 = + { + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Trans< S0< M >, F >, + Entry< S2< M > >, + Entry< Default0< S2< M > > >, + Entry< Default1< S2< M > > >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > > + }; + machine.CompareToExpectedActionSequence( f1 ); + + machine.process_event( G() ); + ActionArray g2 = + { + Exit< Default2< S0< M > > >, + Exit< Default1< S0< M > > >, + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Exit< Default1< S2< M > > >, + Exit< Default0< S2< M > > >, + Exit< S2< M > >, + Exit< S0< M > >, + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > > + }; + machine.CompareToExpectedActionSequence( g2 ); + + machine.process_event( H() ); + ActionArray h1 = + { + Trans< S11< M >, H > + }; + machine.CompareToExpectedActionSequence( h1 ); + + machine.process_event( E() ); + ActionArray e1 = + { + Exit< Default2< S0< M > > >, + Exit< Default1< S0< M > > >, + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Exit< S0< M > >, + Entry< S0< M > >, + Entry< S2< M > >, + Entry< Default0< S2< M > > >, + Entry< Default1< S2< M > > >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + Entry< S211< M > >, + Entry< Default2< S21< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > > + }; + machine.CompareToExpectedActionSequence( e1 ); + + machine.terminate(); + ActionArray term = + { + Exit< Default2< S0< M > > >, + Exit< Default1< S0< M > > >, + Exit< Default2< S21< M > > >, + Exit< S211< M > >, + Exit< Default0< S21< M > > >, + Exit< S21< M > >, + Exit< Default1< S2< M > > >, + Exit< Default0< S2< M > > >, + Exit< S2< M > >, + Exit< S0< M > > + }; + machine.CompareToExpectedActionSequence( term ); + + machine.ThrowAction( &Entry< Default0< S1< M > > > ); + BOOST_REQUIRE_THROW( machine.initiate(), TransitionTestException ); + ActionArray initThrow1 = + { + Entry< S0< M > >, + Entry< S1< M > >, + &::Throw< &::Entry< Default0< S1< M > > > >, + Dtor< S1< M > >, + Dtor< S0< M > > + }; + machine.CompareToExpectedActionSequence( initThrow1 ); + BOOST_REQUIRE( machine.terminated() ); + + machine.ThrowAction( &Entry< S11< M > > ); + BOOST_REQUIRE_THROW( machine.initiate(), TransitionTestException ); + ActionArray initThrow2 = + { + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + &::Throw< &::Entry< S11< M > > >, + Dtor< Default0< S1< M > > >, + Dtor< S1< M > >, + Dtor< S0< M > > + }; + machine.CompareToExpectedActionSequence( initThrow2 ); + BOOST_REQUIRE( machine.terminated() ); + + machine.ThrowAction( &Trans< S0< M >, A > ); + machine.initiate(); + BOOST_REQUIRE_THROW( machine.process_event( A() ), TransitionTestException ); + ActionArray a1Throw1 = + { + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > >, + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + &::Throw< &::Trans< S0< M >, A > >, + Dtor< Default2< S0< M > > >, + Dtor< Default1< S0< M > > >, + Dtor< S0< M > > + }; + machine.CompareToExpectedActionSequence( a1Throw1 ); + BOOST_REQUIRE( machine.terminated() ); + + machine.ThrowAction( &Entry< S211< M > > ); + machine.initiate(); + BOOST_REQUIRE_THROW( machine.process_event( C() ), TransitionTestException ); + ActionArray c1Throw1 = + { + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > >, + Exit< Default2< S1< M > > >, + Exit< S11< M > >, + Exit< Default0< S1< M > > >, + Exit< S1< M > >, + Trans< S0< M >, C >, + Entry< S2< M > >, + Entry< Default0< S2< M > > >, + Entry< Default1< S2< M > > >, + Entry< S21< M > >, + Entry< Default0< S21< M > > >, + &::Throw< &::Entry< S211< M > > >, + Dtor< Default2< S0< M > > >, + Dtor< Default1< S0< M > > >, + Dtor< Default0< S21< M > > >, + Dtor< S21< M > >, + Dtor< Default1< S2< M > > >, + Dtor< Default0< S2< M > > >, + Dtor< S2< M > >, + Dtor< S0< M > > + }; + machine.CompareToExpectedActionSequence( c1Throw1 ); + BOOST_REQUIRE( machine.terminated() ); + + machine.ThrowAction( &ExitFn< S11< M > > ); + machine.initiate(); + BOOST_REQUIRE_THROW( machine.process_event( C() ), TransitionTestException ); + ActionArray c1Throw2 = + { + Entry< S0< M > >, + Entry< S1< M > >, + Entry< Default0< S1< M > > >, + Entry< S11< M > >, + Entry< Default2< S1< M > > >, + Entry< Default1< S0< M > > >, + Entry< Default2< S0< M > > >, + Exit< Default2< S1< M > > >, + &::Throw< &::ExitFn< S11< M > > >, + Dtor< S11< M > >, + Dtor< Default2< S0< M > > >, + Dtor< Default1< S0< M > > >, + Dtor< Default0< S1< M > > >, + Dtor< S1< M > >, + Dtor< S0< M > > + }; + machine.CompareToExpectedActionSequence( c1Throw2 ); + BOOST_REQUIRE( machine.terminated() ); + BOOST_REQUIRE( machine.GetUnconsumedEventCount() == 1 ); +} + + +int test_main( int, char* [] ) +{ + TransitionTest< sc::null_exception_translator > null_machine; + TestTransitions( null_machine ); + TransitionTest< sc::exception_translator<> > machine; + TestTransitions( machine ); + + TransitionEventBaseTest eventBaseMachine; + eventBaseMachine.initiate(); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X1 & >() ); + eventBaseMachine.process_event( A() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X2 & >() ); + BOOST_REQUIRE( eventBaseMachine.GetActionCallCounter() == 0 ); + eventBaseMachine.process_event( B() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X1 & >() ); + BOOST_REQUIRE( eventBaseMachine.GetActionCallCounter() == 1 ); + eventBaseMachine.process_event( C() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X2 & >() ); + BOOST_REQUIRE( eventBaseMachine.GetActionCallCounter() == 1 ); + eventBaseMachine.process_event( D() ); + BOOST_REQUIRE_NO_THROW( eventBaseMachine.state_cast< const X1 & >() ); + BOOST_REQUIRE( eventBaseMachine.GetActionCallCounter() == 2 ); + + return 0; +} diff --git a/src/boost/libs/statechart/test/TransitionTest.vcproj b/src/boost/libs/statechart/test/TransitionTest.vcproj new file mode 100644 index 000000000..a3ca5fff3 --- /dev/null +++ b/src/boost/libs/statechart/test/TransitionTest.vcproj @@ -0,0 +1,218 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="TransitionTest" + ProjectGUID="{D9103E3E-640D-4AB7-910C-ACA96709ED0A}" + RootNamespace="TransitionTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/TransitionTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/TransitionTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/TransitionTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\TransitionTest.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\InnermostDefault.hpp" + > + </File> + <File + RelativePath=".\OuterOrthogonal.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/TriggeringEventTest.cpp b/src/boost/libs/statechart/test/TriggeringEventTest.cpp new file mode 100644 index 000000000..70fdb620a --- /dev/null +++ b/src/boost/libs/statechart/test/TriggeringEventTest.cpp @@ -0,0 +1,98 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2009 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/state.hpp> +#include <boost/statechart/exception_translator.hpp> +#include <boost/statechart/event.hpp> +#include <boost/statechart/in_state_reaction.hpp> +#include <boost/statechart/transition.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/test/test_tools.hpp> + +#include <memory> // std::allocator + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct EvGoToB : sc::event< EvGoToB > {}; +struct EvDoIt : sc::event< EvDoIt > {}; + +struct A; +struct TriggringEventTest : sc::state_machine< + TriggringEventTest, A, + std::allocator< sc::none >, sc::exception_translator<> > +{ + void Transit(const EvGoToB &) + { + BOOST_REQUIRE(dynamic_cast<const EvGoToB *>(triggering_event()) != 0); + } +}; + +struct B : sc::state< B, TriggringEventTest > +{ + B( my_context ctx ) : my_base( ctx ) + { + BOOST_REQUIRE(dynamic_cast<const EvGoToB *>(triggering_event()) != 0); + } + + ~B() + { + BOOST_REQUIRE(triggering_event() == 0); + } + + void DoIt( const EvDoIt & ) + { + BOOST_REQUIRE(dynamic_cast<const EvDoIt *>(triggering_event()) != 0); + throw std::exception(); + } + + void HandleException( const sc::exception_thrown & ) + { + BOOST_REQUIRE(dynamic_cast<const sc::exception_thrown *>(triggering_event()) != 0); + } + + typedef mpl::list< + sc::in_state_reaction< EvDoIt, B, &B::DoIt >, + sc::in_state_reaction< sc::exception_thrown, B, &B::HandleException > + > reactions; +}; + +struct A : sc::state< A, TriggringEventTest > +{ + typedef sc::transition< + EvGoToB, B, TriggringEventTest, &TriggringEventTest::Transit + > reactions; + + A( my_context ctx ) : my_base( ctx ) + { + BOOST_REQUIRE(triggering_event() == 0); + } + + ~A() + { + BOOST_REQUIRE(dynamic_cast<const EvGoToB *>(triggering_event()) != 0); + } +}; + + +int test_main( int, char* [] ) +{ + TriggringEventTest machine; + machine.initiate(); + machine.process_event(EvGoToB()); + machine.process_event(EvDoIt()); + machine.terminate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/TriggeringEventTest.vcproj b/src/boost/libs/statechart/test/TriggeringEventTest.vcproj new file mode 100644 index 000000000..9e8a1e483 --- /dev/null +++ b/src/boost/libs/statechart/test/TriggeringEventTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="TriggeringEventTest" + ProjectGUID="{DFE5C3C2-0CF9-4709-8393-96201E9A8181}" + RootNamespace="TriggeringEventTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/TriggeringEventTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/TriggeringEventTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/TriggeringEventTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\TriggeringEventTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/TuTest.cpp b/src/boost/libs/statechart/test/TuTest.cpp new file mode 100644 index 000000000..644e1f5a3 --- /dev/null +++ b/src/boost/libs/statechart/test/TuTest.cpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2008 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "TuTest.hpp" + +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/in_state_reaction.hpp> + +#include <stdexcept> + + + +struct Initial : sc::simple_state< Initial, TuTest > +{ + void Whatever( const EvX & ) {} + + typedef sc::in_state_reaction< EvX, Initial, &Initial::Whatever > reactions; +}; + + + +void TuTest::initiate() +{ + sc::state_machine< TuTest, Initial >::initiate(); +} + +void TuTest::unconsumed_event( const sc::event_base & ) +{ + throw std::runtime_error( "Event was not consumed!" ); +} diff --git a/src/boost/libs/statechart/test/TuTest.hpp b/src/boost/libs/statechart/test/TuTest.hpp new file mode 100644 index 000000000..6d7dbff05 --- /dev/null +++ b/src/boost/libs/statechart/test/TuTest.hpp @@ -0,0 +1,55 @@ +#ifndef BOOST_STATECHART_TEST_TU_TEST_HPP_INCLUDED +#define BOOST_STATECHART_TEST_TU_TEST_HPP_INCLUDED +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/event.hpp> +#include <boost/statechart/state_machine.hpp> + +#include <boost/config.hpp> + +#ifdef BOOST_STATECHART_TEST_DYNAMIC_LINK + #ifdef BOOST_STATECHART_TEST_DLL_EXPORT + #define BOOST_STATECHART_DECL BOOST_SYMBOL_EXPORT + #else + #define BOOST_STATECHART_DECL BOOST_SYMBOL_IMPORT + #endif +#endif + +#ifndef BOOST_STATECHART_DECL + #define BOOST_STATECHART_DECL +#endif + + + +namespace sc = boost::statechart; + +#ifdef BOOST_MSVC +# pragma warning( push ) + // class X needs to have dll-interface to be used by clients of class Y +# pragma warning( disable: 4251 ) + // non dll-interface class X used as base for dll-interface class +# pragma warning( disable: 4275 ) +#endif + +struct BOOST_STATECHART_DECL EvX : sc::event< EvX > {}; +struct BOOST_STATECHART_DECL EvY : sc::event< EvY > {}; + +struct Initial; +struct BOOST_STATECHART_DECL TuTest : sc::state_machine< TuTest, Initial > +{ + void initiate(); + void unconsumed_event( const sc::event_base & ); +}; + +#ifdef BOOST_MSVC +# pragma warning( pop ) +#endif + + +#endif diff --git a/src/boost/libs/statechart/test/TuTest.vcproj b/src/boost/libs/statechart/test/TuTest.vcproj new file mode 100644 index 000000000..d91e87d86 --- /dev/null +++ b/src/boost/libs/statechart/test/TuTest.vcproj @@ -0,0 +1,218 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="TuTest" + ProjectGUID="{892D213C-F575-4003-BB0F-5787DA2C407D}" + RootNamespace="TuTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/TuTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/TuTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/TuTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\TuTest.cpp" + > + </File> + <File + RelativePath=".\TuTestMain.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\TuTest.hpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/TuTestMain.cpp b/src/boost/libs/statechart/test/TuTestMain.cpp new file mode 100644 index 000000000..2ef62feac --- /dev/null +++ b/src/boost/libs/statechart/test/TuTestMain.cpp @@ -0,0 +1,25 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include "TuTest.hpp" + +#include <boost/test/test_tools.hpp> + +#include <stdexcept> + + + +int test_main( int, char* [] ) +{ + TuTest machine; + machine.initiate(); + // unconsumed_event sanity check + BOOST_REQUIRE_THROW( machine.process_event( EvY() ), std::runtime_error ); + machine.process_event( EvX() ); + return 0; +} diff --git a/src/boost/libs/statechart/test/TypeInfoTest.cpp b/src/boost/libs/statechart/test/TypeInfoTest.cpp new file mode 100644 index 000000000..0bd63f894 --- /dev/null +++ b/src/boost/libs/statechart/test/TypeInfoTest.cpp @@ -0,0 +1,80 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> + +#include <boost/test/test_tools.hpp> + + + +namespace sc = boost::statechart; + + + +struct A; +struct TypeInfoTest : sc::state_machine< TypeInfoTest, A > {}; + +struct B; +struct A : sc::simple_state< A, TypeInfoTest, B > {}; + + struct B : sc::simple_state< B, A > {}; + + +int test_main( int, char* [] ) +{ + TypeInfoTest machine; + machine.initiate(); + + const TypeInfoTest::state_base_type & activeState = + *machine.state_begin(); + const TypeInfoTest::state_base_type::id_type bType = + activeState.dynamic_type(); + const TypeInfoTest::state_base_type::id_type aType = + activeState.outer_state_ptr()->dynamic_type(); + + BOOST_REQUIRE( bType == B::static_type() ); + BOOST_REQUIRE( bType != A::static_type() ); + BOOST_REQUIRE( aType == A::static_type() ); + BOOST_REQUIRE( aType != B::static_type() ); + + #ifndef BOOST_STATECHART_USE_NATIVE_RTTI + // Ensure that a null custom type id pointer can be of any type + BOOST_REQUIRE( activeState.custom_dynamic_type_ptr< void >() == 0 ); + BOOST_REQUIRE( activeState.custom_dynamic_type_ptr< char >() == 0 ); + BOOST_REQUIRE( activeState.custom_dynamic_type_ptr< bool >() == 0 ); + BOOST_REQUIRE( + activeState.outer_state_ptr()->custom_dynamic_type_ptr< void >() == 0 ); + BOOST_REQUIRE( + activeState.outer_state_ptr()->custom_dynamic_type_ptr< char >() == 0 ); + BOOST_REQUIRE( + activeState.outer_state_ptr()->custom_dynamic_type_ptr< bool >() == 0 ); + + const char * bCustomType = "B"; + const char * aCustomType = "A"; + B::custom_static_type_ptr( bCustomType ); + A::custom_static_type_ptr( aCustomType ); + BOOST_REQUIRE( B::custom_static_type_ptr< char >() == bCustomType ); + BOOST_REQUIRE( A::custom_static_type_ptr< char >() == aCustomType ); + BOOST_REQUIRE( + activeState.custom_dynamic_type_ptr< char >() == bCustomType ); + BOOST_REQUIRE( + activeState.outer_state_ptr()->custom_dynamic_type_ptr< char >() == + aCustomType ); + + // Ensure that a null custom type id pointer can be of any type + bool * pNull = 0; + B::custom_static_type_ptr( pNull ); + A::custom_static_type_ptr( pNull ); + BOOST_REQUIRE( activeState.custom_dynamic_type_ptr< char >() == 0 ); + BOOST_REQUIRE( + activeState.outer_state_ptr()->custom_dynamic_type_ptr< char >() == 0 ); + #endif + + return 0; +} diff --git a/src/boost/libs/statechart/test/TypeInfoTest.vcproj b/src/boost/libs/statechart/test/TypeInfoTest.vcproj new file mode 100644 index 000000000..4a77a5c8e --- /dev/null +++ b/src/boost/libs/statechart/test/TypeInfoTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="TypeInfoTest" + ProjectGUID="{6FBB8140-6B00-4BF1-AD6D-9D394DE3610F}" + RootNamespace="TypeInfoTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/TypeInfoTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/TypeInfoTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/TypeInfoTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\TypeInfoTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/UnconsumedResultTest.cpp b/src/boost/libs/statechart/test/UnconsumedResultTest.cpp new file mode 100644 index 000000000..c9e633e17 --- /dev/null +++ b/src/boost/libs/statechart/test/UnconsumedResultTest.cpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#define BOOST_ENABLE_ASSERT_HANDLER + +static int s_failed_assertions = 0; + +namespace boost +{ + +void assertion_failed( + char const *, char const *, char const *, long ) +{ + ++s_failed_assertions; +} + +} // namespace boost + + +#include <boost/statechart/result.hpp> +#include <boost/test/test_tools.hpp> + + +namespace sc = boost::statechart; + + +void make_unconsumed_result() +{ + // We cannot test sc::result in its natural environment here because a + // failing assert triggers a stack unwind, what will lead to another + // failing assert... + + // Creates a temp sc::result value which is destroyed immediately + sc::detail::result_utility::make_result( sc::detail::do_discard_event ); +} + +int test_main( int, char* [] ) +{ + make_unconsumed_result(); + +#ifdef NDEBUG + BOOST_TEST( s_failed_assertions == 0 ); +#else + BOOST_TEST( s_failed_assertions == 1 ); +#endif + + return 0; +} diff --git a/src/boost/libs/statechart/test/UnconsumedResultTest.vcproj b/src/boost/libs/statechart/test/UnconsumedResultTest.vcproj new file mode 100644 index 000000000..dd043a72c --- /dev/null +++ b/src/boost/libs/statechart/test/UnconsumedResultTest.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="UnconsumedResultTest" + ProjectGUID="{93FEA76A-3C04-4A70-B53B-485490CF38A1}" + RootNamespace="UnconsumedResultTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-gd-1_45.lib" + OutputFile="$(OutDir)/UnconsumedResultTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/UnconsumedResultTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libboost_test_exec_monitor-vc90-mt-1_45.lib" + OutputFile="$(OutDir)/UnconsumedResultTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(ProjectDir)..\..\..\bin.v2\libs\test\build\msvc-9.0\$(ConfigurationName)\asynch-exceptions-on\link-static\threading-multi"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\UnconsumedResultTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/src/boost/libs/statechart/test/UnsuppDeepHistoryTest.cpp b/src/boost/libs/statechart/test/UnsuppDeepHistoryTest.cpp new file mode 100644 index 000000000..f3427c5c8 --- /dev/null +++ b/src/boost/libs/statechart/test/UnsuppDeepHistoryTest.cpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// Copyright 2005-2006 Andreas Huber Doenni +// Distributed under the Boost Software License, Version 1.0. (See accompany- +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +////////////////////////////////////////////////////////////////////////////// + + + +#include <boost/statechart/state_machine.hpp> +#include <boost/statechart/simple_state.hpp> +#include <boost/statechart/deep_history.hpp> + +#include <boost/mpl/list.hpp> + + + +namespace sc = boost::statechart; +namespace mpl = boost::mpl; + + + +struct A; +struct UnsupportedDeepHistoryTest : sc::state_machine< + UnsupportedDeepHistoryTest, A > {}; + +struct B; +struct A : sc::simple_state< + A, UnsupportedDeepHistoryTest, B, sc::has_deep_history > {}; + + struct C; + struct D; + struct B : sc::simple_state< B, A, mpl::list< C, D > > {}; + + struct C : sc::simple_state< C, B::orthogonal< 0 > > {}; + struct D : sc::simple_state< D, B::orthogonal< 1 > > {}; + + +int main() +{ + UnsupportedDeepHistoryTest machine; + machine.initiate(); + return 0; +} diff --git a/src/boost/libs/statechart/test/UnsuppDeepHistoryTest.vcproj b/src/boost/libs/statechart/test/UnsuppDeepHistoryTest.vcproj new file mode 100644 index 000000000..8b5c60a29 --- /dev/null +++ b/src/boost/libs/statechart/test/UnsuppDeepHistoryTest.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="UnsuppDeepHistoryTest" + ProjectGUID="{7B6A4F61-6210-4FDC-BC23-660DA10EE7DD}" + RootNamespace="UnsuppDeepHistoryTest" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectName)Debug" + IntermediateDirectory="$(ProjectName)Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/UnsuppDeepHistoryTest.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="..\..\..\bin\boost\libs\test\build\libboost_test_exec_monitor.lib\vc-7_1\debug\threading-multi" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/UnsuppDeepHistoryTest.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectName)Release" + IntermediateDirectory="$(ProjectName)Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + DisableLanguageExtensions="true" + TreatWChar_tAsBuiltInType="true" + ForceConformanceInForLoopScope="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="0" + WarningLevel="4" + WarnAsError="true" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/UnsuppDeepHistoryTest.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="..\..\..\bin\boost\libs\test\build\libboost_test_exec_monitor.lib\vc-7_1\release\threading-multi" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\UnsuppDeepHistoryTest.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |