mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Resolve dependency on trivial_singleton.hpp from boost library
This commit is contained in:
parent
e92f52821d
commit
a3e954c0c9
4 changed files with 301 additions and 220 deletions
|
|
@ -22,9 +22,9 @@ namespace detail
|
|||
public mutex
|
||||
{
|
||||
private:
|
||||
BOOST_TEST_SINGLETON_CONS( functor_mutex_t );
|
||||
MOCK_SINGLETON_CONS(functor_mutex_t);
|
||||
};
|
||||
BOOST_TEST_SINGLETON_INST( functor_mutex )
|
||||
MOCK_SINGLETON_INST(functor_mutex)
|
||||
|
||||
template< typename Signature >
|
||||
struct functor : function< Signature >
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
#define MOCK_MUTEX_HPP_INCLUDED
|
||||
|
||||
#include "../config.hpp"
|
||||
#include <boost/test/utils/trivial_singleton.hpp>
|
||||
#include <turtle/detail/singleton.hpp>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#ifdef MOCK_THREAD_SAFE
|
||||
|
|
@ -97,9 +98,9 @@ namespace detail
|
|||
public mutex
|
||||
{
|
||||
private:
|
||||
BOOST_TEST_SINGLETON_CONS( error_mutex_t );
|
||||
MOCK_SINGLETON_CONS(error_mutex_t);
|
||||
};
|
||||
BOOST_TEST_SINGLETON_INST( error_mutex )
|
||||
MOCK_SINGLETON_INST(error_mutex)
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning( push )
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "context.hpp"
|
||||
#include "child.hpp"
|
||||
#include "mutex.hpp"
|
||||
#include <boost/test/utils/trivial_singleton.hpp>
|
||||
#include "singleton.hpp"
|
||||
#include <boost/optional.hpp>
|
||||
#include <ostream>
|
||||
#include <map>
|
||||
|
|
@ -129,9 +129,9 @@ namespace detail
|
|||
mutable mutex mutex_;
|
||||
|
||||
private:
|
||||
BOOST_TEST_SINGLETON_CONS( root_t );
|
||||
MOCK_SINGLETON_CONS(root_t);
|
||||
};
|
||||
BOOST_TEST_SINGLETON_INST( root )
|
||||
MOCK_SINGLETON_INST(root)
|
||||
}
|
||||
} // mock
|
||||
|
||||
|
|
|
|||
80
include/turtle/detail/singleton.hpp
Normal file
80
include/turtle/detail/singleton.hpp
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// (C) Copyright Gennadiy Rozental 2005-2014.
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision$
|
||||
//
|
||||
// Description : simple helpers for creating cusom output manipulators
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef MOCK_UTILS_TRIVIAL_SIGNLETON_HPP
|
||||
#define MOCK_UTILS_TRIVIAL_SIGNLETON_HPP
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace unit_test {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** singleton ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename Derived>
|
||||
class singleton {
|
||||
public:
|
||||
static Derived& instance() { static Derived the_inst; return the_inst; }
|
||||
|
||||
BOOST_DELETED_FUNCTION(singleton(singleton const&))
|
||||
BOOST_DELETED_FUNCTION(singleton& operator=(singleton const&))
|
||||
|
||||
protected:
|
||||
BOOST_DEFAULTED_FUNCTION(singleton(), {})
|
||||
BOOST_DEFAULTED_FUNCTION(~singleton(), {})
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define MOCK_SINGLETON_CONS( type ) \
|
||||
friend class boost::unit_test::singleton<type>; \
|
||||
type() {} \
|
||||
/**/
|
||||
|
||||
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
|
||||
|
||||
#define MOCK_SINGLETON_INST( inst ) \
|
||||
template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \
|
||||
namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
|
||||
|
||||
#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
|
||||
#define MOCK_SINGLETON_INST( inst ) \
|
||||
static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance();
|
||||
|
||||
#else
|
||||
|
||||
#define MOCK_SINGLETON_INST( inst ) \
|
||||
namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // MOCK_UTILS_TRIVIAL_SIGNLETON_HPP
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue