Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/boost/msm/back/dispatch_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
#include <boost/type_traits/is_same.hpp>

#include <boost/msm/event_traits.hpp>
#include <boost/msm/back/traits.hpp>
#include <boost/msm/back/metafunctions.hpp>
#include <boost/msm/back/common_types.hpp>

BOOST_MPL_HAS_XXX_TRAIT_DEF(is_frow)

namespace boost { namespace msm { namespace back
{

Expand Down
15 changes: 1 addition & 14 deletions include/boost/msm/back/metafunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,7 @@
#include <boost/msm/mpl_graph/incidence_list_graph.hpp>
#include <boost/msm/mpl_graph/depth_first_search.hpp>

BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_creation)
BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_exit)
BOOST_MPL_HAS_XXX_TRAIT_DEF(concrete_exit_state)
BOOST_MPL_HAS_XXX_TRAIT_DEF(composite_tag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(not_real_row_tag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(event_blocking_flag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_entry_state)
BOOST_MPL_HAS_XXX_TRAIT_DEF(completion_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_exception_thrown)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_message_queue)
BOOST_MPL_HAS_XXX_TRAIT_DEF(activate_deferred_events)
BOOST_MPL_HAS_XXX_TRAIT_DEF(wrapped_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(active_state_switch_policy)
#include <boost/msm/back/traits.hpp>

namespace boost { namespace msm { namespace back
{
Expand Down
15 changes: 1 addition & 14 deletions include/boost/msm/back/state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <boost/msm/active_state_switching_policies.hpp>
#include <boost/msm/row_tags.hpp>
#include <boost/msm/msm_grammar.hpp>
#include <boost/msm/back/traits.hpp>
#include <boost/msm/back/fold_to_list.hpp>
#include <boost/msm/back/metafunctions.hpp>
#include <boost/msm/back/history_policies.hpp>
Expand All @@ -66,20 +67,6 @@
#include <boost/msm/back/no_fsm_check.hpp>
#include <boost/msm/back/queue_container_deque.hpp>

BOOST_MPL_HAS_XXX_TRAIT_DEF(accept_sig)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_automatic_create)
BOOST_MPL_HAS_XXX_TRAIT_DEF(non_forwarding_flag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(direct_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(initial_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(final_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(do_serialize)
BOOST_MPL_HAS_XXX_TRAIT_DEF(history_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(fsm_check)
BOOST_MPL_HAS_XXX_TRAIT_DEF(compile_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(queue_container_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(using_declared_table)
BOOST_MPL_HAS_XXX_TRAIT_DEF(event_queue_before_deferred_queue)

#ifndef BOOST_MSM_CONSTRUCTOR_ARG_SIZE
#define BOOST_MSM_CONSTRUCTOR_ARG_SIZE 5 // default max number of arguments for constructors
#endif
Expand Down
50 changes: 50 additions & 0 deletions include/boost/msm/back/traits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2008 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)

#ifndef BOOST_MSM_BACK_TRAITS_H
#define BOOST_MSM_BACK_TRAITS_H

#include <boost/mpl/has_xxx.hpp>

// Metafunctions
BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_creation)
BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_exit)
BOOST_MPL_HAS_XXX_TRAIT_DEF(concrete_exit_state)
BOOST_MPL_HAS_XXX_TRAIT_DEF(composite_tag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(not_real_row_tag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(event_blocking_flag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_entry_state)
BOOST_MPL_HAS_XXX_TRAIT_DEF(completion_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_exception_thrown)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_message_queue)
BOOST_MPL_HAS_XXX_TRAIT_DEF(activate_deferred_events)
BOOST_MPL_HAS_XXX_TRAIT_DEF(wrapped_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(active_state_switch_policy)

// State machine
BOOST_MPL_HAS_XXX_TRAIT_DEF(accept_sig)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_automatic_create)
BOOST_MPL_HAS_XXX_TRAIT_DEF(non_forwarding_flag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(direct_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(initial_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(final_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(do_serialize)
BOOST_MPL_HAS_XXX_TRAIT_DEF(history_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(fsm_check)
BOOST_MPL_HAS_XXX_TRAIT_DEF(compile_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(queue_container_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(using_declared_table)
BOOST_MPL_HAS_XXX_TRAIT_DEF(event_queue_before_deferred_queue)

// Dispatch table
BOOST_MPL_HAS_XXX_TRAIT_DEF(is_frow)

#endif // BOOST_MSM_BACK_TRAITS_H
3 changes: 1 addition & 2 deletions include/boost/msm/back11/dispatch_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
#include <boost/type_traits/is_same.hpp>

#include <boost/msm/event_traits.hpp>
#include <boost/msm/back/traits.hpp>
#include <boost/msm/back11/metafunctions.hpp>
#include <boost/msm/back/common_types.hpp>

BOOST_MPL_HAS_XXX_TRAIT_DEF(is_frow)

namespace boost { namespace msm { namespace back11
{

Expand Down
15 changes: 1 addition & 14 deletions include/boost/msm/back11/metafunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,7 @@
#include <boost/msm/mpl_graph/incidence_list_graph.hpp>
#include <boost/msm/mpl_graph/depth_first_search.hpp>

BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_creation)
BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_exit)
BOOST_MPL_HAS_XXX_TRAIT_DEF(concrete_exit_state)
BOOST_MPL_HAS_XXX_TRAIT_DEF(composite_tag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(not_real_row_tag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(event_blocking_flag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_entry_state)
BOOST_MPL_HAS_XXX_TRAIT_DEF(completion_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_exception_thrown)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_message_queue)
BOOST_MPL_HAS_XXX_TRAIT_DEF(activate_deferred_events)
BOOST_MPL_HAS_XXX_TRAIT_DEF(wrapped_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(active_state_switch_policy)
#include <boost/msm/back/traits.hpp>

namespace boost { namespace msm { namespace back11
{
Expand Down
23 changes: 5 additions & 18 deletions include/boost/msm/back11/state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <boost/msm/active_state_switching_policies.hpp>
#include <boost/msm/row_tags.hpp>
#include <boost/msm/msm_grammar.hpp>
#include <boost/msm/back/traits.hpp>
#include <boost/msm/back/fold_to_list.hpp>
#include <boost/msm/back11/metafunctions.hpp>
#include <boost/msm/back/history_policies.hpp>
Expand All @@ -69,20 +70,6 @@
#include <boost/msm/back/queue_container_deque.hpp>
#include <boost/msm/back11/dispatch_table.hpp>

BOOST_MPL_HAS_XXX_TRAIT_DEF(accept_sig)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_automatic_create)
BOOST_MPL_HAS_XXX_TRAIT_DEF(non_forwarding_flag)
BOOST_MPL_HAS_XXX_TRAIT_DEF(direct_entry)
BOOST_MPL_HAS_XXX_TRAIT_DEF(initial_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(final_event)
BOOST_MPL_HAS_XXX_TRAIT_DEF(do_serialize)
BOOST_MPL_HAS_XXX_TRAIT_DEF(history_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(fsm_check)
BOOST_MPL_HAS_XXX_TRAIT_DEF(compile_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(queue_container_policy)
BOOST_MPL_HAS_XXX_TRAIT_DEF(using_declared_table)
BOOST_MPL_HAS_XXX_TRAIT_DEF(event_queue_before_deferred_queue)

#ifndef BOOST_MSM_CONSTRUCTOR_ARG_SIZE
#define BOOST_MSM_CONSTRUCTOR_ARG_SIZE 5 // default max number of arguments for constructors
#endif
Expand Down Expand Up @@ -449,7 +436,7 @@ class state_machine : //public Derived
BOOST_ASSERT(state == (current_state));
// if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active
if (has_pseudo_exit<T1>::type::value &&
!is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
!back11::is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
{
return ::boost::msm::back::HANDLED_FALSE;
}
Expand Down Expand Up @@ -530,7 +517,7 @@ class state_machine : //public Derived

// if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active
if (has_pseudo_exit<T1>::type::value &&
!is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
!back11::is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
{
return ::boost::msm::back::HANDLED_FALSE;
}
Expand Down Expand Up @@ -595,7 +582,7 @@ class state_machine : //public Derived

// if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active
if (has_pseudo_exit<T1>::type::value &&
!is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
!back11::is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
{
return ::boost::msm::back::HANDLED_FALSE;
}
Expand Down Expand Up @@ -662,7 +649,7 @@ class state_machine : //public Derived

// if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active
if (has_pseudo_exit<T1>::type::value &&
!is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
!back11::is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm))
{
return ::boost::msm::back::HANDLED_FALSE;
}
Expand Down
38 changes: 19 additions & 19 deletions test/Anonymous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// http://www.boost.org/LICENSE_1_0.txt)

// back-end
#include <boost/msm/back/state_machine.hpp>
#include "BackCommon.hpp"
//front-end
#include <boost/msm/front/state_machine_def.hpp>

#ifndef BOOST_MSM_NONSTANDALONE_TEST
#define BOOST_TEST_MODULE MyTest
#define BOOST_TEST_MODULE anonymous_test
#endif
#include <boost/test/unit_test.hpp>

Expand Down Expand Up @@ -136,26 +136,26 @@ namespace
}
};
// Pick a back-end
typedef msm::back::state_machine<my_machine_> my_machine;
typedef get_test_machines<my_machine_> my_machines;

//static char const* const state_names[] = { "State1", "State2", "State3", "State4" };


BOOST_AUTO_TEST_CASE( anonymous_test )
BOOST_AUTO_TEST_CASE_TEMPLATE ( anonymous_test, my_machine, my_machines )
{
my_machine p;

// needed to start the highest-level SM. This will call on_entry and mark the start of the SM
// in this case it will also immediately trigger all anonymous transitions
p.start();
BOOST_CHECK_MESSAGE(p.current_state()[0] == 3,"State4 should be active"); //State4
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State1&>().exit_counter == 1,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State1&>().entry_counter == 1,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State2&>().exit_counter == 1,"State2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State2&>().entry_counter == 1,"State2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State3&>().exit_counter == 1,"State3 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State3&>().entry_counter == 1,"State3 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State4&>().entry_counter == 1,"State4 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State1&>().exit_counter == 1,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State1&>().entry_counter == 1,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State2&>().exit_counter == 1,"State2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State2&>().entry_counter == 1,"State2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State3&>().exit_counter == 1,"State3 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State3&>().entry_counter == 1,"State3 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State4&>().entry_counter == 1,"State4 entry not called correctly");
BOOST_CHECK_MESSAGE(p.always_true_counter == 1,"guard not called correctly");
BOOST_CHECK_MESSAGE(p.always_false_counter == 1,"guard not called correctly");
BOOST_CHECK_MESSAGE(p.state2_to_state3_counter == 1,"action not called correctly");
Expand All @@ -165,14 +165,14 @@ namespace
// this event will bring us back to the initial state and thus, a new "loop" will be started
p.process_event(event1());
BOOST_CHECK_MESSAGE(p.current_state()[0] == 3,"State4 should be active"); //State4
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State1&>().exit_counter == 2,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State1&>().entry_counter == 2,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State2&>().exit_counter == 2,"State2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State2&>().entry_counter == 2,"State2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State3&>().exit_counter == 2,"State3 exit not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State3&>().entry_counter == 2,"State3 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State4&>().entry_counter == 2,"State4 entry not called correctly");
BOOST_CHECK_MESSAGE(p.get_state<my_machine_::State4&>().exit_counter == 1,"State4 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State1&>().exit_counter == 2,"State1 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State1&>().entry_counter == 2,"State1 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State2&>().exit_counter == 2,"State2 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State2&>().entry_counter == 2,"State2 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State3&>().exit_counter == 2,"State3 exit not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State3&>().entry_counter == 2,"State3 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State4&>().entry_counter == 2,"State4 entry not called correctly");
BOOST_CHECK_MESSAGE(p.template get_state<my_machine_::State4&>().exit_counter == 1,"State4 exit not called correctly");
BOOST_CHECK_MESSAGE(p.always_true_counter == 2,"guard not called correctly");
BOOST_CHECK_MESSAGE(p.always_false_counter == 2,"guard not called correctly");
BOOST_CHECK_MESSAGE(p.state2_to_state3_counter == 2,"action not called correctly");
Expand Down
10 changes: 5 additions & 5 deletions test/Back11AnonymousAndGuard.cpp → test/AnonymousAndGuard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#include <boost/msm/back/state_machine.hpp>
#include "BackCommon.hpp"
#include <boost/msm/front/euml/common.hpp>
#include <boost/msm/front/functor_row.hpp>
#include <boost/msm/front/state_machine_def.hpp>
Expand All @@ -23,7 +23,7 @@
#endif

#ifndef BOOST_MSM_NONSTANDALONE_TEST
#define BOOST_TEST_MODULE back11_anonymous_and_guard_test
#define BOOST_TEST_MODULE anonymous_and_guard_test
#endif
#include <boost/test/unit_test.hpp>

Expand Down Expand Up @@ -86,9 +86,9 @@ struct Bug : public bmf::state_machine_def<Bug> {
};

// backend
typedef boost::msm::back::state_machine<Bug> MyStateMachine;
typedef get_test_machines<Bug> MyStateMachines;

BOOST_AUTO_TEST_CASE(back11_anonymous_and_guard_test1)
BOOST_AUTO_TEST_CASE_TEMPLATE(anonymous_and_guard_test1, MyStateMachine, MyStateMachines)
{
MyStateMachine sm;
sm.start();
Expand All @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(back11_anonymous_and_guard_test1)
BOOST_CHECK_MESSAGE(sm.current_state()[1] == 3, "Completed should be active");
}

BOOST_AUTO_TEST_CASE(back11_anonymous_and_guard_test2)
BOOST_AUTO_TEST_CASE_TEMPLATE(anonymous_and_guard_test2, MyStateMachine, MyStateMachines)
{
MyStateMachine sm;
sm.start();
Expand Down
Loading