blob: 6fba5c9396d7474f7d056f6a2f1e08dbad0c7b7c [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (C) Copyright Gennadiy Rozental 2005-2008.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6// See http://www.boost.org/libs/test for the library home page.
7//
8// File : $RCSfile$
9//
10// Version : $Revision: 49312 $
11//
12// Description : simple helpers for creating cusom output manipulators
13// ***************************************************************************
14
15#ifndef BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
16#define BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
17
18#include <ndnboost/config.hpp>
19#include <ndnboost/detail/workaround.hpp>
20
21#include <ndnboost/noncopyable.hpp>
22
23#include <ndnboost/test/detail/suppress_warnings.hpp>
24
25//____________________________________________________________________________//
26
27namespace ndnboost {
28
29namespace unit_test {
30
31// ************************************************************************** //
32// ************** singleton ************** //
33// ************************************************************************** //
34
35template<typename Derived>
36class singleton : private ndnboost::noncopyable {
37public:
38 static Derived& instance() { static Derived the_inst; return the_inst; }
39protected:
40 singleton() {}
41 ~singleton() {}
42};
43
44} // namespace unit_test
45
46#define BOOST_TEST_SINGLETON_CONS( type ) \
47friend class ndnboost::unit_test::singleton<type>; \
48type() {} \
49/**/
50
51#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
52
53#define BOOST_TEST_SINGLETON_INST( inst ) \
54template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \
55namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
56
57#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
58#define BOOST_TEST_SINGLETON_INST( inst ) \
59static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance();
60
61#else
62
63#define BOOST_TEST_SINGLETON_INST( inst ) \
64namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
65
66#endif
67
68} // namespace ndnboost
69
70//____________________________________________________________________________//
71
72#include <ndnboost/test/detail/enable_warnings.hpp>
73
74#endif // BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER