// Copyright 2010 Christophe Henry // henry UNDERSCORE christophe AT hotmail DOT com // This is an extended version of the state machine available in the boost::mpl library // Distributed under the same license as the original. // Copyright for the original version: // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed // under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // EUML is not supported by backmp11 #define BOOST_MSM_TEST_SKIP_BACKMP11 #include "BackCommon.hpp" #include #ifndef BOOST_MSM_NONSTANDALONE_TEST #define BOOST_TEST_MODULE composite_euml_test #endif #include using namespace std; using namespace boost::msm::front::euml; namespace msm = boost::msm; namespace { // A "complicated" event type that carries some data. enum DiskTypeEnum { DISK_CD=0, DISK_DVD=1 }; // events BOOST_MSM_EUML_EVENT(play) BOOST_MSM_EUML_EVENT(end_pause) BOOST_MSM_EUML_EVENT(stop) BOOST_MSM_EUML_EVENT(pause) BOOST_MSM_EUML_EVENT(open_close) BOOST_MSM_EUML_EVENT(next_song) BOOST_MSM_EUML_EVENT(previous_song) BOOST_MSM_EUML_EVENT(region2_evt) // A "complicated" event type that carries some data. BOOST_MSM_EUML_DECLARE_ATTRIBUTE(std::string,cd_name) BOOST_MSM_EUML_DECLARE_ATTRIBUTE(DiskTypeEnum,cd_type) BOOST_MSM_EUML_ATTRIBUTES((attributes_ << cd_name << cd_type ), cd_detected_attributes) BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(cd_detected,cd_detected_attributes) //states BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,entry_counter) BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,exit_counter) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Empty) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Open) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Stopped) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Paused) // State machine attributes. BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,start_next_song_counter) BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,start_prev_song_guard_counter) BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,start_playback_counter) BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,can_close_drawer_counter) BOOST_MSM_EUML_DECLARE_ATTRIBUTE(unsigned int,test_fct_counter) // Playing is now a state machine itself. // It has 5 substates BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Song1) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Song2) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Song3) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Region2State1) BOOST_MSM_EUML_STATE(( ++state_(entry_counter),++state_(exit_counter),attributes_ << entry_counter << exit_counter),Region2State2) template