Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/test/utils/trivial_singleton.hpp @ 44

Last change on this file since 44 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.9 KB
Line 
1//  (C) Copyright Gennadiy Rozental 2005.
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: trivial_singleton.hpp,v $
9//
10//  Version     : $Revision: 1.3 $
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 <boost/noncopyable.hpp>
19
20#include <boost/test/detail/suppress_warnings.hpp>
21
22//____________________________________________________________________________//
23
24namespace boost {
25
26namespace unit_test {
27
28// ************************************************************************** //
29// **************                   singleton                  ************** //
30// ************************************************************************** //
31
32template<typename Derived>
33class singleton : private boost::noncopyable {
34public:
35    static Derived& instance() { static Derived the_inst; return the_inst; }   
36protected:
37    singleton()  {}
38    ~singleton() {}
39};
40
41} // namespace unit_test
42
43#define BOOST_TEST_SINGLETON_CONS( type )       \
44friend class boost::unit_test::singleton<type>; \
45type() {}                                       \
46/**/
47
48#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
49
50#define BOOST_TEST_SINGLETON_INST( inst ) \
51template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \
52namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
53
54#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
55#define BOOST_TEST_SINGLETON_INST( inst ) \
56static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance();
57
58#else
59
60#define BOOST_TEST_SINGLETON_INST( inst ) \
61namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
62
63#endif
64
65} // namespace boost
66
67//____________________________________________________________________________//
68
69#include <boost/test/detail/enable_warnings.hpp>
70
71// ***************************************************************************
72//  Revision History :
73// 
74//  $Log: trivial_singleton.hpp,v $
75//  Revision 1.3  2006/01/01 17:29:38  dgregor
76//  Work around anonymous namespace bug in Apple GCC 3.3
77//
78//  Revision 1.2  2005/06/15 07:21:51  schoepflin
79//  Tru64 needs an explicit instantiation of the singleton template. Otherwise we
80//  end up with multiple singleton instances.
81//
82//  Revision 1.1  2005/02/20 08:27:08  rogeeff
83//  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
84//
85// ***************************************************************************
86
87#endif // BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
Note: See TracBrowser for help on using the repository browser.