Added boost header
This commit is contained in:
31
test/external/boost/statechart/detail/avoid_unused_warning.hpp
vendored
Normal file
31
test/external/boost/statechart/detail/avoid_unused_warning.hpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_AVOID_UNUSED_WARNING_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_AVOID_UNUSED_WARNING_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)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
template< typename T >
|
||||
inline void avoid_unused_warning( const T & ) {}
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
139
test/external/boost/statechart/detail/constructor.hpp
vendored
Normal file
139
test/external/boost/statechart/detail/constructor.hpp
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_CONSTRUCTOR_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_CONSTRUCTOR_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/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/equal_to.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>
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
template< class ContextList, class OutermostContextBase >
|
||||
struct constructor;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class ContextList, class OutermostContextBase >
|
||||
struct outer_constructor
|
||||
{
|
||||
typedef typename mpl::front< ContextList >::type to_construct;
|
||||
typedef typename to_construct::context_ptr_type context_ptr_type;
|
||||
typedef typename to_construct::inner_context_ptr_type
|
||||
inner_context_ptr_type;
|
||||
|
||||
typedef typename to_construct::inner_initial_list inner_initial_list;
|
||||
typedef typename mpl::pop_front< ContextList >::type inner_context_list;
|
||||
typedef typename mpl::front< inner_context_list >::type::orthogonal_position
|
||||
inner_orthogonal_position;
|
||||
typedef typename mpl::advance<
|
||||
typename mpl::begin< inner_initial_list >::type,
|
||||
inner_orthogonal_position >::type to_construct_iter;
|
||||
|
||||
typedef typename mpl::erase<
|
||||
inner_initial_list,
|
||||
to_construct_iter,
|
||||
typename mpl::end< inner_initial_list >::type
|
||||
>::type first_inner_initial_list;
|
||||
|
||||
typedef typename mpl::erase<
|
||||
inner_initial_list,
|
||||
typename mpl::begin< inner_initial_list >::type,
|
||||
typename mpl::next< to_construct_iter >::type
|
||||
>::type last_inner_initial_list;
|
||||
|
||||
static void construct(
|
||||
const context_ptr_type & pContext,
|
||||
OutermostContextBase & outermostContextBase )
|
||||
{
|
||||
const inner_context_ptr_type pInnerContext =
|
||||
to_construct::shallow_construct( pContext, outermostContextBase );
|
||||
to_construct::template deep_construct_inner<
|
||||
first_inner_initial_list >( pInnerContext, outermostContextBase );
|
||||
constructor< inner_context_list, OutermostContextBase >::construct(
|
||||
pInnerContext, outermostContextBase );
|
||||
to_construct::template deep_construct_inner<
|
||||
last_inner_initial_list >( pInnerContext, outermostContextBase );
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class ContextList, class OutermostContextBase >
|
||||
struct inner_constructor
|
||||
{
|
||||
typedef typename mpl::front< ContextList >::type to_construct;
|
||||
typedef typename to_construct::context_ptr_type context_ptr_type;
|
||||
|
||||
static void construct(
|
||||
const context_ptr_type & pContext,
|
||||
OutermostContextBase & outermostContextBase )
|
||||
{
|
||||
to_construct::deep_construct( pContext, outermostContextBase );
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class ContextList, class OutermostContextBase >
|
||||
struct constructor_impl : public mpl::eval_if<
|
||||
mpl::equal_to< mpl::size< ContextList >, mpl::long_< 1 > >,
|
||||
mpl::identity< inner_constructor< ContextList, OutermostContextBase > >,
|
||||
mpl::identity< outer_constructor< ContextList, OutermostContextBase > > >
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class ContextList, class OutermostContextBase >
|
||||
struct constructor :
|
||||
constructor_impl< ContextList, OutermostContextBase >::type {};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class CommonContext, class DestinationState >
|
||||
struct make_context_list
|
||||
{
|
||||
typedef typename mpl::reverse< typename mpl::push_front<
|
||||
typename mpl::erase<
|
||||
typename DestinationState::context_type_list,
|
||||
typename mpl::find<
|
||||
typename DestinationState::context_type_list,
|
||||
CommonContext
|
||||
>::type,
|
||||
typename mpl::end<
|
||||
typename DestinationState::context_type_list
|
||||
>::type
|
||||
>::type,
|
||||
DestinationState
|
||||
>::type >::type type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
92
test/external/boost/statechart/detail/counted_base.hpp
vendored
Normal file
92
test/external/boost/statechart/detail/counted_base.hpp
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_COUNTED_BASE_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_COUNTED_BASE_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/detail/atomic_count.hpp>
|
||||
#include <boost/config.hpp> // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
template< bool NeedsLocking >
|
||||
struct count_base
|
||||
{
|
||||
count_base() : count_( 0 ) {}
|
||||
mutable boost::detail::atomic_count count_;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct count_base< false >
|
||||
{
|
||||
count_base() : count_( 0 ) {}
|
||||
mutable long count_;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< bool NeedsLocking = true >
|
||||
class counted_base : private count_base< NeedsLocking >
|
||||
{
|
||||
typedef count_base< NeedsLocking > base_type;
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool ref_counted() const
|
||||
{
|
||||
return base_type::count_ != 0;
|
||||
}
|
||||
|
||||
long ref_count() const
|
||||
{
|
||||
return base_type::count_;
|
||||
}
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
counted_base() {}
|
||||
~counted_base() {}
|
||||
|
||||
// do nothing copy implementation is intentional (the number of
|
||||
// referencing pointers of the source and the destination is not changed
|
||||
// through the copy operation)
|
||||
counted_base( const counted_base & ) : base_type() {}
|
||||
counted_base & operator=( const counted_base & ) { return *this; }
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The following declarations should be private.
|
||||
// They are only public because many compilers lack template friends.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void add_ref() const
|
||||
{
|
||||
++base_type::count_;
|
||||
}
|
||||
|
||||
bool release() const
|
||||
{
|
||||
BOOST_ASSERT( base_type::count_ > 0 );
|
||||
return --base_type::count_ == 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
84
test/external/boost/statechart/detail/leaf_state.hpp
vendored
Normal file
84
test/external/boost/statechart/detail/leaf_state.hpp
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_LEAF_STATE_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_LEAF_STATE_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/state_base.hpp>
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class Allocator, class RttiPolicy >
|
||||
class leaf_state : public state_base< Allocator, RttiPolicy >
|
||||
{
|
||||
typedef state_base< Allocator, RttiPolicy > base_type;
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
leaf_state( typename RttiPolicy::id_provider_type idProvider ) :
|
||||
base_type( idProvider )
|
||||
{
|
||||
}
|
||||
|
||||
~leaf_state() {}
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The following declarations should be private.
|
||||
// They are only public because many compilers lack template friends.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void set_list_position(
|
||||
typename base_type::state_list_type::iterator listPosition )
|
||||
{
|
||||
listPosition_ = listPosition;
|
||||
}
|
||||
|
||||
typedef typename base_type::leaf_state_ptr_type
|
||||
direct_state_base_ptr_type;
|
||||
|
||||
virtual void remove_from_state_list(
|
||||
typename base_type::state_list_type::iterator & statesEnd,
|
||||
typename base_type::node_state_base_ptr_type & pOutermostUnstableState,
|
||||
bool performFullExit )
|
||||
{
|
||||
--statesEnd;
|
||||
swap( *listPosition_, *statesEnd );
|
||||
( *listPosition_ )->set_list_position( listPosition_ );
|
||||
direct_state_base_ptr_type & pState = *statesEnd;
|
||||
// Because the list owns the leaf_state, this leads to the immediate
|
||||
// termination of this state.
|
||||
pState->exit_impl( pState, pOutermostUnstableState, performFullExit );
|
||||
}
|
||||
|
||||
virtual void exit_impl(
|
||||
direct_state_base_ptr_type & pSelf,
|
||||
typename base_type::node_state_base_ptr_type & pOutermostUnstableState,
|
||||
bool performFullExit ) = 0;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typename base_type::state_list_type::iterator listPosition_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
72
test/external/boost/statechart/detail/memory.hpp
vendored
Normal file
72
test/external/boost/statechart/detail/memory.hpp
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_MEMORY_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_MEMORY_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/detail/avoid_unused_warning.hpp>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/detail/allocator_utilities.hpp>
|
||||
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
template< class MostDerived, class Allocator >
|
||||
void * allocate( std::size_t size )
|
||||
{
|
||||
avoid_unused_warning( size );
|
||||
// The assert below fails when memory is allocated for an event<>,
|
||||
// simple_state<> or state<> subtype object, *and* the first template
|
||||
// parameter passed to one of these templates is not equal to the most-
|
||||
// derived object being constructed.
|
||||
// The following examples apply to all these subtypes:
|
||||
// // Example 1
|
||||
// struct A {};
|
||||
// struct B : sc::simple_state< A, /* ... */ >
|
||||
// // Above, the first template parameter must be equal to the most-
|
||||
// // derived type
|
||||
//
|
||||
// // Example 2
|
||||
// struct A : sc::event< A >
|
||||
// struct B : A { /* ... */ };
|
||||
// void f() { delete new B(); }
|
||||
// // Above the most-derived type being constructed is B, but A was passed
|
||||
// // as the most-derived type to event<>.
|
||||
BOOST_ASSERT( size == sizeof( MostDerived ) );
|
||||
return typename boost::detail::allocator::rebind_to<
|
||||
Allocator, MostDerived
|
||||
>::type().allocate( 1, static_cast< MostDerived * >( 0 ) );
|
||||
}
|
||||
|
||||
template< class MostDerived, class Allocator >
|
||||
void deallocate( void * pObject )
|
||||
{
|
||||
return typename boost::detail::allocator::rebind_to<
|
||||
Allocator, MostDerived
|
||||
>::type().deallocate( static_cast< MostDerived * >( pObject ), 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
156
test/external/boost/statechart/detail/node_state.hpp
vendored
Normal file
156
test/external/boost/statechart/detail/node_state.hpp
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_NODE_STATE_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_NODE_STATE_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/state_base.hpp>
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/assert.hpp> // BOOST_ASSERT
|
||||
|
||||
#include <algorithm> // std::find_if
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
template< class Allocator, class RttiPolicy >
|
||||
class node_state_base : public state_base< Allocator, RttiPolicy >
|
||||
{
|
||||
typedef state_base< Allocator, RttiPolicy > base_type;
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
node_state_base( typename RttiPolicy::id_provider_type idProvider ) :
|
||||
base_type( idProvider )
|
||||
{
|
||||
}
|
||||
|
||||
~node_state_base() {}
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The following declarations should be private.
|
||||
// They are only public because many compilers lack template friends.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typedef base_type state_base_type;
|
||||
typedef intrusive_ptr< node_state_base > direct_state_base_ptr_type;
|
||||
virtual void exit_impl(
|
||||
direct_state_base_ptr_type & pSelf,
|
||||
typename base_type::node_state_base_ptr_type & pOutermostUnstableState,
|
||||
bool performFullExit ) = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class OrthogonalRegionCount, class Allocator, class RttiPolicy >
|
||||
class node_state : public node_state_base< Allocator, RttiPolicy >
|
||||
{
|
||||
typedef node_state_base< Allocator, RttiPolicy > base_type;
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
node_state( typename RttiPolicy::id_provider_type idProvider ) :
|
||||
base_type( idProvider )
|
||||
{
|
||||
for ( orthogonal_position_type pos = 0;
|
||||
pos < OrthogonalRegionCount::value; ++pos )
|
||||
{
|
||||
pInnerStates[ pos ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~node_state() {}
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The following declarations should be private.
|
||||
// They are only public because many compilers lack template friends.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typedef typename base_type::state_base_type state_base_type;
|
||||
|
||||
void add_inner_state( orthogonal_position_type position,
|
||||
state_base_type * pInnerState )
|
||||
{
|
||||
BOOST_ASSERT( ( position < OrthogonalRegionCount::value ) &&
|
||||
( pInnerStates[ position ] == 0 ) );
|
||||
pInnerStates[ position ] = pInnerState;
|
||||
}
|
||||
|
||||
void remove_inner_state( orthogonal_position_type position )
|
||||
{
|
||||
BOOST_ASSERT( position < OrthogonalRegionCount::value );
|
||||
pInnerStates[ position ] = 0;
|
||||
}
|
||||
|
||||
virtual void remove_from_state_list(
|
||||
typename state_base_type::state_list_type::iterator & statesEnd,
|
||||
typename state_base_type::node_state_base_ptr_type &
|
||||
pOutermostUnstableState,
|
||||
bool performFullExit )
|
||||
{
|
||||
state_base_type ** const pPastEnd =
|
||||
&pInnerStates[ OrthogonalRegionCount::value ];
|
||||
// We must not iterate past the last inner state because *this* state
|
||||
// will no longer exist when the last inner state has been removed
|
||||
state_base_type ** const pFirstNonNull = std::find_if(
|
||||
&pInnerStates[ 0 ], pPastEnd, &node_state::is_not_null );
|
||||
|
||||
if ( pFirstNonNull == pPastEnd )
|
||||
{
|
||||
// The state does not have inner states but is still alive, this must
|
||||
// be the outermost unstable state then.
|
||||
BOOST_ASSERT( get_pointer( pOutermostUnstableState ) == this );
|
||||
typename state_base_type::node_state_base_ptr_type pSelf =
|
||||
pOutermostUnstableState;
|
||||
pSelf->exit_impl( pSelf, pOutermostUnstableState, performFullExit );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Destroy inner states in the reverse order of construction
|
||||
for ( state_base_type ** pState = pPastEnd; pState != pFirstNonNull; )
|
||||
{
|
||||
--pState;
|
||||
|
||||
// An inner orthogonal state might have been terminated long before,
|
||||
// that's why we have to check for 0 pointers
|
||||
if ( *pState != 0 )
|
||||
{
|
||||
( *pState )->remove_from_state_list(
|
||||
statesEnd, pOutermostUnstableState, performFullExit );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef typename base_type::direct_state_base_ptr_type
|
||||
direct_state_base_ptr_type;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static bool is_not_null( const state_base_type * pInner )
|
||||
{
|
||||
return pInner != 0;
|
||||
}
|
||||
|
||||
state_base_type * pInnerStates[ OrthogonalRegionCount::value ];
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
121
test/external/boost/statechart/detail/reaction_dispatcher.hpp
vendored
Normal file
121
test/external/boost/statechart/detail/reaction_dispatcher.hpp
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef BOOST_STATECHART_REACTION_DISPATCHER_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_REACTION_DISPATCHER_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/result.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
#include <boost/cast.hpp> // boost::polymorphic_downcast
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class Event >
|
||||
struct no_context
|
||||
{
|
||||
void no_function( const Event & );
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template<
|
||||
class Reactions, class State, class EventBase, class Event,
|
||||
class ActionContext, class IdType >
|
||||
class reaction_dispatcher
|
||||
{
|
||||
private:
|
||||
struct without_action
|
||||
{
|
||||
static result react( State & stt, const EventBase & )
|
||||
{
|
||||
return Reactions::react_without_action( stt );
|
||||
}
|
||||
};
|
||||
|
||||
struct base_with_action
|
||||
{
|
||||
static result react( State & stt, const EventBase & evt )
|
||||
{
|
||||
return Reactions::react_with_action( stt, evt );
|
||||
}
|
||||
};
|
||||
|
||||
struct base
|
||||
{
|
||||
static result react(
|
||||
State & stt, const EventBase & evt, const IdType & )
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_same< ActionContext, detail::no_context< Event > >,
|
||||
without_action, base_with_action
|
||||
>::type reaction;
|
||||
return reaction::react( stt, evt );
|
||||
}
|
||||
};
|
||||
|
||||
struct derived_with_action
|
||||
{
|
||||
static result react( State & stt, const EventBase & evt )
|
||||
{
|
||||
return Reactions::react_with_action(
|
||||
stt, *polymorphic_downcast< const Event * >( &evt ) );
|
||||
}
|
||||
};
|
||||
|
||||
struct derived
|
||||
{
|
||||
static result react(
|
||||
State & stt, const EventBase & evt, const IdType & eventType )
|
||||
{
|
||||
if ( eventType == Event::static_type() )
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_same< ActionContext, detail::no_context< Event > >,
|
||||
without_action, derived_with_action
|
||||
>::type reaction;
|
||||
return reaction::react( stt, evt );
|
||||
}
|
||||
else
|
||||
{
|
||||
return detail::result_utility::make_result( detail::no_reaction );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
static reaction_result react(
|
||||
State & stt, const EventBase & evt, const IdType & eventType )
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_same< Event, EventBase >, base, derived
|
||||
>::type reaction;
|
||||
return result_utility::get_result(
|
||||
reaction::react( stt, evt, eventType ) );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
208
test/external/boost/statechart/detail/rtti_policy.hpp
vendored
Normal file
208
test/external/boost/statechart/detail/rtti_policy.hpp
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <typeinfo> // std::type_info
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
struct id_provider
|
||||
{
|
||||
const void * pCustomId_;
|
||||
#if defined( BOOST_ENABLE_ASSERT_HANDLER ) || !defined( NDEBUG )
|
||||
const std::type_info * pCustomIdType_;
|
||||
#endif
|
||||
};
|
||||
|
||||
template< class MostDerived >
|
||||
struct id_holder
|
||||
{
|
||||
static id_provider idProvider_;
|
||||
};
|
||||
|
||||
template< class MostDerived >
|
||||
id_provider id_holder< MostDerived >::idProvider_;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
struct rtti_policy
|
||||
{
|
||||
#ifdef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
class id_type
|
||||
{
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
explicit id_type( const std::type_info & id ) : id_( id ) {}
|
||||
|
||||
bool operator==( id_type right ) const
|
||||
{
|
||||
return id_ == right.id_ != 0;
|
||||
}
|
||||
bool operator!=( id_type right ) const { return !( *this == right ); }
|
||||
|
||||
bool operator<( id_type right ) const
|
||||
{
|
||||
return id_.before( right.id_ ) != 0;
|
||||
}
|
||||
bool operator>( id_type right ) const { return right < *this; }
|
||||
bool operator>=( id_type right ) const { return !( *this < right ); }
|
||||
bool operator<=( id_type right ) const { return !( right < *this ); }
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
const std::type_info & id_;
|
||||
};
|
||||
|
||||
typedef bool id_provider_type; // dummy
|
||||
#else
|
||||
typedef const void * id_type;
|
||||
typedef const id_provider * id_provider_type;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template< class Base >
|
||||
class rtti_base_type : public Base
|
||||
{
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
typedef rtti_policy::id_type id_type;
|
||||
|
||||
id_type dynamic_type() const
|
||||
{
|
||||
#ifdef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
return id_type( typeid( *this ) );
|
||||
#else
|
||||
return idProvider_;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
template< typename CustomId >
|
||||
const CustomId * custom_dynamic_type_ptr() const
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
( idProvider_->pCustomId_ == 0 ) ||
|
||||
( *idProvider_->pCustomIdType_ == typeid( CustomId ) ) );
|
||||
return static_cast< const CustomId * >( idProvider_->pCustomId_ );
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#ifdef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
rtti_base_type( id_provider_type ) {}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT( 4 ) )
|
||||
// We make the destructor virtual for GCC because with this compiler
|
||||
// there is currently no way to disable the "has virtual functions but
|
||||
// non-virtual destructor" warning on a class by class basis. Although
|
||||
// it can be done on the compiler command line with
|
||||
// -Wno-non-virtual-dtor, this is undesirable as this would also
|
||||
// suppress legitimate warnings for types that are not states.
|
||||
virtual ~rtti_base_type() {}
|
||||
#else
|
||||
~rtti_base_type() {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// For typeid( *this ) to return a value that corresponds to the most-
|
||||
// derived type, we need to have a vptr. Since this type does not
|
||||
// contain any virtual functions we need to artificially declare one so.
|
||||
virtual void dummy() {}
|
||||
#else
|
||||
rtti_base_type(
|
||||
id_provider_type idProvider
|
||||
) :
|
||||
idProvider_( idProvider )
|
||||
{
|
||||
}
|
||||
|
||||
~rtti_base_type() {}
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
id_provider_type idProvider_;
|
||||
#endif
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template< class MostDerived, class Base >
|
||||
class rtti_derived_type : public Base
|
||||
{
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
static id_type static_type()
|
||||
{
|
||||
#ifdef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
return id_type( typeid( const MostDerived ) );
|
||||
#else
|
||||
return &id_holder< MostDerived >::idProvider_;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
template< class CustomId >
|
||||
static const CustomId * custom_static_type_ptr()
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
( id_holder< MostDerived >::idProvider_.pCustomId_ == 0 ) ||
|
||||
( *id_holder< MostDerived >::idProvider_.pCustomIdType_ ==
|
||||
typeid( CustomId ) ) );
|
||||
return static_cast< const CustomId * >(
|
||||
id_holder< MostDerived >::idProvider_.pCustomId_ );
|
||||
}
|
||||
|
||||
template< class CustomId >
|
||||
static void custom_static_type_ptr( const CustomId * pCustomId )
|
||||
{
|
||||
#if defined( BOOST_ENABLE_ASSERT_HANDLER ) || !defined( NDEBUG )
|
||||
id_holder< MostDerived >::idProvider_.pCustomIdType_ =
|
||||
&typeid( CustomId );
|
||||
#endif
|
||||
id_holder< MostDerived >::idProvider_.pCustomId_ = pCustomId;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
~rtti_derived_type() {}
|
||||
|
||||
#ifdef BOOST_STATECHART_USE_NATIVE_RTTI
|
||||
rtti_derived_type() : Base( false ) {}
|
||||
#else
|
||||
rtti_derived_type() : Base( &id_holder< MostDerived >::idProvider_ ) {}
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
191
test/external/boost/statechart/detail/state_base.hpp
vendored
Normal file
191
test/external/boost/statechart/detail/state_base.hpp
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
#ifndef BOOST_STATECHART_DETAIL_STATE_BASE_HPP_INCLUDED
|
||||
#define BOOST_STATECHART_DETAIL_STATE_BASE_HPP_INCLUDED
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#include <boost/statechart/result.hpp>
|
||||
#include <boost/statechart/event.hpp>
|
||||
|
||||
#include <boost/statechart/detail/counted_base.hpp>
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/detail/allocator_utilities.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4702 ) // unreachable code (in release mode only)
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace statechart
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
|
||||
template< class Allocator, class RttiPolicy >
|
||||
class leaf_state;
|
||||
template< class Allocator, class RttiPolicy >
|
||||
class node_state_base;
|
||||
|
||||
typedef unsigned char orthogonal_position_type;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template< class Allocator, class RttiPolicy >
|
||||
class state_base :
|
||||
#ifndef NDEBUG
|
||||
noncopyable,
|
||||
#endif
|
||||
public RttiPolicy::template rtti_base_type<
|
||||
// Derived class objects will be created, handled and destroyed by exactly
|
||||
// one thread --> locking is not necessary
|
||||
counted_base< false > >
|
||||
{
|
||||
typedef typename RttiPolicy::template rtti_base_type<
|
||||
counted_base< false > > base_type;
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void exit() {}
|
||||
|
||||
virtual const state_base * outer_state_ptr() const = 0;
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
state_base( typename RttiPolicy::id_provider_type idProvider ) :
|
||||
base_type( idProvider ),
|
||||
deferredEvents_( false )
|
||||
{
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT( 4 ) )
|
||||
// We make the destructor virtual for GCC because with this compiler there
|
||||
// is currently no way to disable the "has virtual functions but
|
||||
// non-virtual destructor" warning on a class by class basis. Although it
|
||||
// can be done on the compiler command line with -Wno-non-virtual-dtor,
|
||||
// this is undesirable as this would also suppress legitimate warnings for
|
||||
// types that are not states.
|
||||
virtual ~state_base() {}
|
||||
#else
|
||||
// This destructor is not virtual for performance reasons. The library
|
||||
// ensures that a state object is never deleted through a state_base
|
||||
// pointer but only through a pointer to the most-derived type.
|
||||
~state_base() {}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The following declarations should be private.
|
||||
// They are only protected because many compilers lack template friends.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void defer_event()
|
||||
{
|
||||
deferredEvents_ = true;
|
||||
}
|
||||
|
||||
bool deferred_events() const
|
||||
{
|
||||
return deferredEvents_;
|
||||
}
|
||||
|
||||
template< class Context >
|
||||
void set_context( orthogonal_position_type position, Context * pContext )
|
||||
{
|
||||
pContext->add_inner_state( position, this );
|
||||
}
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The following declarations should be private.
|
||||
// They are only public because many compilers lack template friends.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual detail::reaction_result react_impl(
|
||||
const event_base & evt,
|
||||
typename RttiPolicy::id_type eventType ) = 0;
|
||||
|
||||
typedef intrusive_ptr< node_state_base< Allocator, RttiPolicy > >
|
||||
node_state_base_ptr_type;
|
||||
typedef intrusive_ptr< leaf_state< Allocator, RttiPolicy > >
|
||||
leaf_state_ptr_type;
|
||||
typedef std::list<
|
||||
leaf_state_ptr_type,
|
||||
typename boost::detail::allocator::rebind_to<
|
||||
Allocator, leaf_state_ptr_type >::type
|
||||
> state_list_type;
|
||||
|
||||
virtual void remove_from_state_list(
|
||||
typename state_list_type::iterator & statesEnd,
|
||||
node_state_base_ptr_type & pOutermostUnstableState,
|
||||
bool performFullExit ) = 0;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool deferredEvents_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template< class Allocator, class RttiPolicy >
|
||||
inline void intrusive_ptr_add_ref(
|
||||
const ::boost::statechart::detail::state_base< Allocator, RttiPolicy > * pBase )
|
||||
{
|
||||
pBase->add_ref();
|
||||
}
|
||||
|
||||
template< class Allocator, class RttiPolicy >
|
||||
inline void intrusive_ptr_release(
|
||||
const ::boost::statechart::detail::state_base< Allocator, RttiPolicy > * pBase )
|
||||
{
|
||||
if ( pBase->release() )
|
||||
{
|
||||
// The state_base destructor is *not* virtual for performance reasons
|
||||
// but intrusive_ptr< state_base > objects are nevertheless used to point
|
||||
// to states. This assert ensures that such a pointer is never the last
|
||||
// one referencing a state object.
|
||||
BOOST_ASSERT( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
} // namespace detail
|
||||
} // namespace statechart
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user