source: rrlib_util/patterns/singleton/policies/lifetime/NoDestruction.h @ 7:6ec39e2cd404

Last change on this file since 7:6ec39e2cd404 was 7:6ec39e2cd404, checked in by Tobias Föhst <foehst@…>, 9 years ago

Added singleton holder and several policies for construction and lifetime

File size: 2.7 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) AG Robotersysteme TU Kaiserslautern
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    NoDestruction.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2010-10-26
27 *
28 * \brief Contains NoDestruction
29 *
30 * \b NoDestruction
31 *
32 */
33//----------------------------------------------------------------------
34#ifndef _rrlib_util_patterns_singleton_NoDestruction_h_
35#define _rrlib_util_patterns_singleton_NoDestruction_h_
36
37//----------------------------------------------------------------------
38// External includes (system with <>, local with "")
39//----------------------------------------------------------------------
40
41//----------------------------------------------------------------------
42// Internal includes with ""
43//----------------------------------------------------------------------
44
45//----------------------------------------------------------------------
46// Debugging
47//----------------------------------------------------------------------
48#include <cassert>
49
50//----------------------------------------------------------------------
51// Namespace declaration
52//----------------------------------------------------------------------
53namespace rrlib
54{
55namespace util
56{
57
58//----------------------------------------------------------------------
59// Forward declarations / typedefs / enums
60//----------------------------------------------------------------------
61
62//----------------------------------------------------------------------
63// Class declaration
64//----------------------------------------------------------------------
65//!
66/*!
67 *
68 */
69template <typename T>
70struct NoDestruction
71{
72  static void ScheduleDestruction(void (*function)())
73  {}
74  static void OnDeadReference()
75  {
76    throw std::logic_error("Dead reference detected!");
77  }
78};
79
80//----------------------------------------------------------------------
81// End of namespace declaration
82//----------------------------------------------------------------------
83}
84}
85
86#endif
Note: See TracBrowser for help on using the repository browser.