diff -r 000000000000 -r bde4ae8d615e os/ossrv/ossrv_pub/boost_apis/boost/test/utils/callback.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/test/utils/callback.hpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,337 @@ +// (C) Copyright Gennadiy Rozental 2005. +// Use, modification, and distribution are subject to 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) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile: callback.hpp,v $ +// +// Version : $Revision: 1.7 $ +// +// Description : +// *************************************************************************** + +#ifndef BOOST_TEST_CALLBACK_020505GER +#define BOOST_TEST_CALLBACK_020505GER + +// Boost +#include +#include +#include + +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(BOOST_INTEL, <= 700) +# define BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR +#endif + +//____________________________________________________________________________// + +namespace boost { + +namespace unit_test { + +namespace ut_detail { + +struct unused {}; + +template +struct invoker { + template + R invoke( Functor& f ) { return f(); } + template + R invoke( Functor& f, T1 t1 ) { return f( t1 ); } + template + R invoke( Functor& f, T1 t1, T2 t2 ) { return f( t1, t2 ); } + template + R invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { return f( t1, t2, t3 ); } +}; + +//____________________________________________________________________________// + +template<> +struct invoker { + template + unused invoke( Functor& f ) { f(); return unused(); } + template + unused invoke( Functor& f, T1 t1 ) { f( t1 ); return unused(); } + template + unused invoke( Functor& f, T1 t1, T2 t2 ) { f( t1, t2 ); return unused(); } + template + unused invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { f( t1, t2, t3 ); return unused(); } +}; + +//____________________________________________________________________________// + +} // namespace ut_detail + +// ************************************************************************** // +// ************** unit_test::callback0 ************** // +// ************************************************************************** // + +namespace ut_detail { + +template +struct callback0_impl { + virtual ~callback0_impl() {} + + virtual R invoke() = 0; +}; + +//____________________________________________________________________________// + +template +struct callback0_impl_t : callback0_impl { + // Constructor + explicit callback0_impl_t( Functor f ) : m_f( f ) {} + + virtual R invoke() { return invoker().invoke( m_f ); } + +private: + // Data members + Functor m_f; +}; + +//____________________________________________________________________________// + +} // namespace ut_detail + +template +class callback0 { +public: + // Constructors + callback0() {} +#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR + callback0( callback0 const& rhs ) : m_impl( rhs.m_impl ) {} +#endif + + template + callback0( Functor f ) + : m_impl( new ut_detail::callback0_impl_t( f ) ) {} + + void operator=( callback0 const& rhs ) { m_impl = rhs.m_impl; } + + template + void operator=( Functor f ) { m_impl.reset( new ut_detail::callback0_impl_t( f ) ); } + + R operator()() const { return m_impl->invoke(); } + + bool operator!() const { return !m_impl; } + +private: + // Data members + boost::shared_ptr > m_impl; +}; + +// ************************************************************************** // +// ************** unit_test::callback1 ************** // +// ************************************************************************** // + +namespace ut_detail { + +template +struct callback1_impl { + virtual ~callback1_impl() {} + + virtual R invoke( T1 t1 ) = 0; +}; + +//____________________________________________________________________________// + +template +struct callback1_impl_t : callback1_impl { + // Constructor + explicit callback1_impl_t( Functor f ) : m_f( f ) {} + + virtual R invoke( T1 t1 ) { return invoker().invoke( m_f, t1 ); } + +private: + // Data members + Functor m_f; +}; + +//____________________________________________________________________________// + +} // namespace ut_detail + +template +class callback1 { +public: + // Constructors + callback1() {} +#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR + callback1( callback1 const& rhs ) : m_impl( rhs.m_impl ) {} +#endif + + template + callback1( Functor f ) + : m_impl( new ut_detail::callback1_impl_t( f ) ) {} + + void operator=( callback1 const& rhs ) { m_impl = rhs.m_impl; } + + template + void operator=( Functor f ) { m_impl.reset( new ut_detail::callback1_impl_t( f ) ); } + + R operator()( T1 t1 ) const { return m_impl->invoke( t1 ); } + + bool operator!() const { return !m_impl; } + +private: + // Data members + boost::shared_ptr > m_impl; +}; + +// ************************************************************************** // +// ************** unit_test::callback2 ************** // +// ************************************************************************** // + +namespace ut_detail { + +template +struct callback2_impl { + virtual ~callback2_impl() {} + + virtual R invoke( T1 t1, T2 t2 ) = 0; +}; + +//____________________________________________________________________________// + +template +struct callback2_impl_t : callback2_impl { + // Constructor + explicit callback2_impl_t( Functor f ) : m_f( f ) {} + + virtual R invoke( T1 t1, T2 t2 ) { return invoker().template invoke( m_f, t1, t2 ); } + +private: + // Data members + Functor m_f; +}; + +//____________________________________________________________________________// + +} // namespace ut_detail + +template +class callback2 { +public: + // Constructors + callback2() {} +#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR + callback2( callback2 const& rhs ) : m_impl( rhs.m_impl ) {} +#endif + + template + callback2( Functor f ) : m_impl( new ut_detail::callback2_impl_t( f ) ) {} + + void operator=( callback2 const& rhs ) { m_impl = rhs.m_impl; } + + template + void operator=( Functor f ) { m_impl.reset( new ut_detail::callback2_impl_t( f ) ); } + + R operator()( T1 t1, T2 t2 ) const { return m_impl->invoke( t1, t2 ); } + + bool operator!() const { return !m_impl; } + +private: + // Data members + boost::shared_ptr > m_impl; +}; + +// ************************************************************************** // +// ************** unit_test::callback3 ************** // +// ************************************************************************** // + +namespace ut_detail { + +template +struct callback3_impl { + virtual ~callback3_impl() {} + + virtual R invoke( T1 t1, T2 t2, T3 t3 ) = 0; +}; + +//____________________________________________________________________________// + +template +struct callback3_impl_t : callback3_impl { + // Constructor + explicit callback3_impl_t( Functor f ) : m_f( f ) {} + + virtual R invoke( T1 t1, T2 t2, T3 t3 ) { return invoker().invoke( m_f, t1, t2, t3 ); } + +private: + // Data members + Functor m_f; +}; + +//____________________________________________________________________________// + +} // namespace ut_detail + +template +class callback3 { +public: + // Constructors + callback3() {} +#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR + callback3( callback3 const& rhs ) : m_impl( rhs.m_impl ) {} +#endif + + template + callback3( Functor f ) + : m_impl( new ut_detail::callback3_impl_t( f ) ) {} + + void operator=( callback3 const& rhs ) { m_impl = rhs.m_impl; } + + template + void operator=( Functor f ) { m_impl.reset( new ut_detail::callback3_impl_t( f ) ); } + + R operator()( T1 t1, T2 t2, T3 t3 ) const { return m_impl->invoke( t1, t2, t3 ); } + + bool operator!() const { return !m_impl; } + +private: + // Data members + boost::shared_ptr > m_impl; +}; + +} // namespace unit_test + +} // namespace boost + +#undef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR + +//____________________________________________________________________________// + +#include + +// ************************************************************************** // +// Revision History: +// +// $Log: callback.hpp,v $ +// Revision 1.7 2006/02/21 04:27:16 rogeeff +// rev back +// +// Revision 1.6 2006/01/28 08:57:03 rogeeff +// VC6.0 workaround removed +// +// Revision 1.5 2005/04/13 05:09:00 rogeeff +// Intel 7.1 bug fix +// +// Revision 1.4 2005/04/12 06:50:06 rogeeff +// suppress warnings +// +// Revision 1.3 2005/03/22 07:05:18 rogeeff +// minor vc7.1 workaround +// +// Revision 1.2 2005/02/24 19:28:17 turkanis +// removed redundant copy ctors, except for VC6 +// +// Revision 1.1 2005/02/20 08:27:08 rogeeff +// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates +// +// ************************************************************************** // + +#endif // BOOST_TEST_CALLBACK_020505GER