BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
autoDeletable.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 
6 #ifndef BALL_CONCEPT_AUTODELETABLE_H
7 #define BALL_CONCEPT_AUTODELETABLE_H
8 
9 #ifndef BALL_CONFIG_CONFIG_H
10 # include <BALL/CONFIG/config.h>
11 #endif
12 
13 #ifndef BALL_COMMON_COMMON_H
14 # include <BALL/COMMON/debug.h>
15 #endif
16 
17 #ifndef BALL_COMMON_GLOBAL_H
18 # include <BALL/COMMON/global.h>
19 #endif
20 
21 #include <cstdlib>
22 #include <new>
23 #include <iostream>
24 
25 namespace BALL
26 {
27 
59  {
60  public:
61 
66 
69  virtual ~AutoDeletable()
70  ;
71 
79  void* operator new(size_t size)
80  ;
81 
88  void operator delete(void* ptr)
89  ;
90 
98  void* operator new(size_t size, void* ptr)
99  ;
100 
107  void operator delete(void* ptr, void*)
108  ;
109 
111 
115 
122  void setAutoDeletable(bool enable)
123  ;
124 
125  /* This is required for cleaning up in case we want to
126  valgrind our stuff -- otherwise we get "still reachable"
127  blocks through this ptr.
128  */
129  static void clearLastPtr() { last_ptr_ = 0; }
131 
135 
142  bool isAutoDeletable() const
143  ;
145 
146 
147  protected:
148 
149  /*_ Default constructor.
150  Should be called by subclasses only. There's no need to construct
151  AutoDeletable objects by themselves.
152  */
153  AutoDeletable()
154  ;
155 
156  /*_ Copy constructor.
157  */
158  AutoDeletable(const AutoDeletable& auto_deletable, bool deep = false)
159  ;
160 
161 
162  private:
163 
164  /*_ Flag describing whether the object may be deleted automatically.
165  */
166  bool enabled_;
167 
168  /*_ The last new pointer.
169  This pointe ris used internally to determine whether a given
170  instance of AutoDeletable was constructed statically or dynamically.
171  */
172  static void* last_ptr_;
173  };
174 
175 # ifndef BALL_NO_INLINE_FUNCTIONS
176 # include <BALL/CONCEPT/autoDeletable.iC>
177 # endif
178 
179 } // namespace BALL
180 
181 #endif // BALL_CONCEPT_AUTODELETABLE_H
static void clearLastPtr()
#define BALL_EXPORT
Definition: COMMON/global.h:50