Replaced many uses of BOOST_STATIC_CONSTANT with their mpl equivalent (mpl::bool_, mpl::integral_c) and adapted all affected code accordingly.

[SVN r22654]
This commit is contained in:
Andreas Huber 2004-04-18 11:10:43 +00:00
parent 9884a10043
commit e6a63844c5
6 changed files with 75 additions and 88 deletions

View File

@ -9,8 +9,7 @@
#include <boost/fsm/detail/state_base.hpp> // orthogonal_position_type
#include <boost/mpl/bool.hpp>
#include <boost/static_assert.hpp>
@ -42,11 +41,9 @@ class deep_history
typedef typename DefaultState::context_type context_type;
typedef typename DefaultState::context_ptr_type context_ptr_type;
typedef typename DefaultState::context_type_list context_type_list;
BOOST_STATIC_CONSTANT(
detail::orthogonal_position_type,
orthogonal_position = DefaultState::orthogonal_position );
typedef typename DefaultState::orthogonal_position orthogonal_position;
BOOST_STATIC_CONSTANT( bool, history_destination = true );
typedef mpl::bool_< true > history_destination;
static void deep_construct(
const context_ptr_type & pContext,

View File

@ -9,18 +9,18 @@
#include <boost/config.hpp>
#include <boost/mpl/apply_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/reverse.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/reverse.hpp>
#include <boost/mpl/long.hpp>
@ -47,14 +47,7 @@ struct outer_constructor
typedef typename to_construct::inner_initial_list inner_initial_list;
typedef typename mpl::pop_front< ContextList >::type inner_context_list;
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x564 ) )
enum { inner_orthogonal_position_c =
mpl::front< inner_context_list >::type::orthogonal_position };
#else
BOOST_STATIC_CONSTANT( long, inner_orthogonal_position_c =
mpl::front< inner_context_list >::type::orthogonal_position );
#endif
typedef mpl::integral_c< long, inner_orthogonal_position_c >
typedef typename mpl::front< inner_context_list >::type::orthogonal_position
inner_orthogonal_position;
typedef typename mpl::erase<
@ -95,7 +88,7 @@ struct inner_constructor
//////////////////////////////////////////////////////////////////////////////
template< class ContextList, class OutermostContext >
struct constructor_impl : public mpl::apply_if<
mpl::equal_to< mpl::size< ContextList >, mpl::integral_c< long, 1 > >,
mpl::equal_to< mpl::size< ContextList >, mpl::long_< 1 > >,
mpl::identity< inner_constructor< ContextList, OutermostContext > >,
mpl::identity< outer_constructor< ContextList, OutermostContext > > > {};

View File

@ -25,8 +25,7 @@ namespace detail
//////////////////////////////////////////////////////////////////////////////
template< orthogonal_position_type noOfOrthogonalRegions,
class Allocator, class RttiPolicy >
template< class NoOfOrthogonalRegions, class Allocator, class RttiPolicy >
class node_state : public state_base< Allocator, RttiPolicy >
{
typedef state_base< Allocator, RttiPolicy > base_type;
@ -38,7 +37,7 @@ class node_state : public state_base< Allocator, RttiPolicy >
base_type( idProvider )
{
for ( orthogonal_position_type pos = 0;
pos < noOfOrthogonalRegions; ++pos )
pos < NoOfOrthogonalRegions::value; ++pos )
{
pInnerStates[ pos ] = 0;
}
@ -54,14 +53,14 @@ class node_state : public state_base< Allocator, RttiPolicy >
void add_inner_state( orthogonal_position_type position,
base_type * pInnerState )
{
BOOST_ASSERT( ( position < noOfOrthogonalRegions ) &&
BOOST_ASSERT( ( position < NoOfOrthogonalRegions::value ) &&
( pInnerStates[ position ] == 0 ) );
pInnerStates[ position ] = pInnerState;
}
void remove_inner_state( orthogonal_position_type position )
{
BOOST_ASSERT( position < noOfOrthogonalRegions );
BOOST_ASSERT( position < NoOfOrthogonalRegions::value );
pInnerStates[ position ] = 0;
}
@ -75,7 +74,7 @@ class node_state : public state_base< Allocator, RttiPolicy >
( get_pointer( *pUnstableState ) == this ) )
{
for ( base_type ** pState = &pInnerStates[ 0 ];
pState != &pInnerStates[ noOfOrthogonalRegions ]; ++pState )
pState != &pInnerStates[ NoOfOrthogonalRegions::value ]; ++pState )
{
BOOST_ASSERT( *pState == 0 );
}
@ -86,7 +85,7 @@ class node_state : public state_base< Allocator, RttiPolicy >
else
{
// Destroy inner states in the reverse order of construction
for ( base_type ** pState = &pInnerStates[ noOfOrthogonalRegions ];
for ( base_type ** pState = &pInnerStates[ NoOfOrthogonalRegions::value ];
pState != &pInnerStates[ 0 ]; )
{
--pState;
@ -102,7 +101,7 @@ class node_state : public state_base< Allocator, RttiPolicy >
private:
//////////////////////////////////////////////////////////////////////////
base_type * pInnerStates[ noOfOrthogonalRegions ];
base_type * pInnerStates[ NoOfOrthogonalRegions::value ];
};

View File

@ -9,8 +9,7 @@
#include <boost/fsm/detail/state_base.hpp> // orthogonal_position_type
#include <boost/mpl/bool.hpp>
#include <boost/static_assert.hpp>
@ -42,11 +41,9 @@ class shallow_history
typedef typename DefaultState::context_type context_type;
typedef typename DefaultState::context_ptr_type context_ptr_type;
typedef typename DefaultState::context_type_list context_type_list;
BOOST_STATIC_CONSTANT(
detail::orthogonal_position_type,
orthogonal_position = DefaultState::orthogonal_position );
typedef typename DefaultState::orthogonal_position orthogonal_position;
BOOST_STATIC_CONSTANT( bool, history_destination = true );
typedef mpl::bool_< true > history_destination;
static void deep_construct(
const context_ptr_type & pContext,

View File

@ -23,15 +23,21 @@
#include <boost/mpl/empty.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/find_if.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/find_if.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/clear.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/or.hpp>
#include <boost/get_pointer.hpp>
#include <boost/intrusive_ptr.hpp>
@ -72,14 +78,8 @@ struct simple_state_base_type
rtti_policy_type;
typedef typename detail::make_list< InnerInitial >::type
inner_initial_list;
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x564 ) )
enum { inner_initial_list_size =
mpl::size< inner_initial_list >::type::value };
#else
BOOST_STATIC_CONSTANT( long, inner_initial_list_size =
mpl::size< inner_initial_list >::type::value );
#endif
typedef typename mpl::size< inner_initial_list >::type
inner_initial_list_size;
public:
typedef typename mpl::apply_if<
@ -198,9 +198,9 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
template< detail::orthogonal_position_type innerOrthogonalPosition >
struct orthogonal
{
BOOST_STATIC_CONSTANT(
typedef mpl::integral_c<
detail::orthogonal_position_type,
inner_orthogonal_position = innerOrthogonalPosition );
innerOrthogonalPosition > inner_orthogonal_position;
typedef MostDerived inner_context_type;
};
@ -353,7 +353,7 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
check_store_shallow_history< stores_shallow_history >();
check_store_deep_history< stores_deep_history >();
pContext_->remove_inner_state( orthogonal_position );
pContext_->remove_inner_state( orthogonal_position::value );
}
}
@ -362,21 +362,19 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
// The following declarations should be private.
// They are only public because many compilers lack template friends.
//////////////////////////////////////////////////////////////////////////
BOOST_STATIC_CONSTANT(
detail::orthogonal_position_type,
orthogonal_position = Context::inner_orthogonal_position );
typedef typename Context::inner_orthogonal_position orthogonal_position;
// If you receive a
// "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or similar
// compiler error here then this state resides in a non-existent
// orthogonal region of the outer state.
BOOST_STATIC_ASSERT(
orthogonal_position < context_type::no_of_orthogonal_regions );
BOOST_STATIC_ASSERT( ( mpl::less<
orthogonal_position,
typename context_type::no_of_orthogonal_regions >::value ) );
typedef MostDerived inner_context_type;
BOOST_STATIC_CONSTANT(
detail::orthogonal_position_type,
inner_orthogonal_position = 0 );
typedef mpl::integral_c< detail::orthogonal_position_type, 0 >
inner_orthogonal_position;
typedef typename context_type::state_base_type state_base_type;
typedef typename context_type::event_base_type event_base_type;
@ -389,9 +387,11 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
typedef intrusive_ptr< inner_context_type > inner_context_ptr_type;
typedef typename detail::make_list< InnerInitial >::type
inner_initial_list;
BOOST_STATIC_CONSTANT(
typedef typename mpl::size< inner_initial_list >::type
inner_initial_list_size;
typedef mpl::integral_c<
detail::orthogonal_position_type,
no_of_orthogonal_regions = mpl::size< inner_initial_list >::value );
inner_initial_list_size::value > no_of_orthogonal_regions;
typedef typename mpl::push_front<
typename context_type::context_type_list,
context_type >::type context_type_list;
@ -404,7 +404,7 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
// direct or indirect inner states have two or more orthogonal regions.
// Please consult the documentation on how to work around this limitation.
BOOST_STATIC_ASSERT(
( mpl::size< inner_initial_list >::value <= 1 ) ||
( no_of_orthogonal_regions::value <= 1 ) ||
( !context_type::inherited_deep_history ) );
BOOST_STATIC_CONSTANT( bool, shallow_history =
@ -418,7 +418,7 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
BOOST_STATIC_CONSTANT( bool, stores_deep_history =
inherited_deep_history && mpl::empty< inner_initial_list >::value );
BOOST_STATIC_CONSTANT( bool, history_destination = false );
typedef mpl::bool_< false > history_destination;
virtual result react_impl(
const event_base_type & evt,
@ -492,7 +492,8 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
{
BOOST_ASSERT( get_pointer( pContext ) != 0 );
pContext_ = pContext;
base_type::set_context( orthogonal_position, get_pointer( pContext ) );
base_type::set_context(
orthogonal_position::value, get_pointer( pContext ) );
}
template< class InnerList >
@ -626,10 +627,11 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
// connector (or from a direct or indirect inner state). Since the
// outer state has never been left no history has ever been saved.
BOOST_STATIC_ASSERT( (
!DestinationState::history_destination ||
!is_same<
typename DestinationState::context_type,
common_context_type >::value ) );
mpl::or_<
mpl::not_< typename DestinationState::history_destination >,
mpl::not_< is_same<
typename DestinationState::context_type,
common_context_type > > >::value ) );
termination_state_type & terminationState(
context< termination_state_type >() );
@ -650,9 +652,10 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
// "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or
// similar compiler error here then you tried to make an invalid
// transition between different orthogonal regions.
BOOST_STATIC_ASSERT(
termination_state_type::orthogonal_position ==
mpl::front< context_list_type >::type::orthogonal_position );
BOOST_STATIC_ASSERT( ( mpl::equal_to<
typename termination_state_type::orthogonal_position,
typename mpl::front< context_list_type >::type::orthogonal_position
>::value ) );
detail::constructor<
context_list_type, outermost_context_type >::construct(
@ -742,9 +745,9 @@ class simple_state : public detail::simple_state_base_type< MostDerived,
// list of its outer state.
BOOST_STATIC_ASSERT( ( is_same<
current_inner,
typename mpl::at_c<
typename mpl::at<
typename current_inner::context_type::inner_initial_list,
current_inner::orthogonal_position >::type >::value ) );
typename current_inner::orthogonal_position >::type >::value ) );
current_inner::reserve_history_slot( outermostContext );
current_inner::deep_construct( pInnerContext, outermostContext );

View File

@ -10,10 +10,10 @@
#include <boost/fsm/event.hpp>
#include <boost/fsm/detail/rtti_policy.hpp>
#include <boost/fsm/exception_translator.hpp>
#include <boost/fsm/result.hpp>
#include <boost/fsm/detail/rtti_policy.hpp>
#include <boost/fsm/detail/state_base.hpp>
#include <boost/fsm/detail/constructor.hpp>
#include <boost/fsm/detail/avoid_unused_warning.hpp>
@ -22,6 +22,7 @@
#include <boost/mpl/clear.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/type_traits/is_pointer.hpp>
@ -66,8 +67,7 @@ namespace detail
template< orthogonal_position_type noOfOrthogonalRegions,
class Allocator, class RttiPolicy >
template< class NoOfOrthogonalRegions, class Allocator, class RttiPolicy >
class node_state;
template< class Allocator, class RttiPolicy >
class leaf_state;
@ -187,7 +187,7 @@ class history_key
{
return history_key(
HistorizedState::context_type::static_type(),
HistorizedState::orthogonal_position );
HistorizedState::orthogonal_position::value );
}
typename RttiPolicy::id_type history_context_type() const
@ -402,12 +402,10 @@ class state_machine : noncopyable
// They are only public because many compilers lack template friends.
//////////////////////////////////////////////////////////////////////////
typedef MostDerived inner_context_type;
BOOST_STATIC_CONSTANT(
detail::orthogonal_position_type,
inner_orthogonal_position = 0 );
BOOST_STATIC_CONSTANT(
detail::orthogonal_position_type,
no_of_orthogonal_regions = 1 );
typedef mpl::integral_c< detail::orthogonal_position_type, 0 >
inner_orthogonal_position;
typedef mpl::integral_c< detail::orthogonal_position_type, 1 >
no_of_orthogonal_regions;
typedef MostDerived outermost_context_type;
typedef MostDerived * inner_context_ptr_type;
@ -584,7 +582,7 @@ class state_machine : noncopyable
store_history_impl(
shallowHistoryMap_,
history_key_type::make_history_key< historized_state >(),
reinterpret_cast< void (*)() >( 0 ) );
0 );
}
template< class DefaultState >
@ -641,7 +639,7 @@ class state_machine : noncopyable
store_history_impl(
deepHistoryMap_,
history_key_type::make_history_key< historized_state >(),
reinterpret_cast< void (*)() >( 0 ) );
0 );
}
template< class DefaultState >
@ -852,9 +850,9 @@ class state_machine : noncopyable
return **pUnstableState_;
}
template< detail::orthogonal_position_type noOfOrthogonalRegions >
template< class NoOfOrthogonalRegions >
void add_impl( const detail::node_state<
noOfOrthogonalRegions, allocator_type, rtti_policy_type > & ) {}
NoOfOrthogonalRegions, allocator_type, rtti_policy_type > & ) {}
void add_impl(
detail::leaf_state< allocator_type, rtti_policy_type > & theState )