source: rrlib_util/patterns/singleton/policies/lifetime/PhoenixSingleton.h @ 44:b8711bbdd13e

Last change on this file since 44:b8711bbdd13e was 44:b8711bbdd13e, checked in by Tobias Föhst <foehst@…>, 8 years ago

Added lifetime policy Longevity for ordered destruction of singletons

File size: 2.8 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20//
21//----------------------------------------------------------------------
22/*!\file    PhoenixSingleton.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2010-10-26
27 *
28 * \brief Contains PhoenixSingleton
29 *
30 * \b PhoenixSingleton
31 *
32 */
33//----------------------------------------------------------------------
34#ifndef __rrlib__util__patterns__singleton__policies__lifetime__PhoenixSingleton_h__
35#define __rrlib__util__patterns__singleton__policies__lifetime__PhoenixSingleton_h__
36
37//----------------------------------------------------------------------
38// External includes (system with <>, local with "")
39//----------------------------------------------------------------------
40#include <cstdlib>
41
42//----------------------------------------------------------------------
43// Internal includes with ""
44//----------------------------------------------------------------------
45
46//----------------------------------------------------------------------
47// Debugging
48//----------------------------------------------------------------------
49#include <cassert>
50
51//----------------------------------------------------------------------
52// Namespace declaration
53//----------------------------------------------------------------------
54namespace rrlib
55{
56namespace util
57{
58namespace singleton
59{
60
61//----------------------------------------------------------------------
62// Forward declarations / typedefs / enums
63//----------------------------------------------------------------------
64
65//----------------------------------------------------------------------
66// Class declaration
67//----------------------------------------------------------------------
68//!
69/*!
70 *
71 */
72template <typename T>
73struct PhoenixSingleton
74{
75  static void ScheduleDestruction(T *, void (*function)())
76  {
77    std::atexit(function);
78  }
79  static void OnDeadReference()
80  {}
81};
82
83//----------------------------------------------------------------------
84// End of namespace declaration
85//----------------------------------------------------------------------
86}
87}
88}
89
90#endif
Note: See TracBrowser for help on using the repository browser.