9 #include <tbb/atomic.h>
12 #include <boost/function.hpp>
14 #ifndef USE_VLD_MEMORY_TRACKING
15 #define DT_OBJECT_DEBUGGING_ENABLED
20 #ifdef DT_OBJECT_TRACKING_ENABLED
21 #include <tbb/spin_mutex.h>
27 template <
typename D,
bool Enable = false>
30 template <
typename D,
bool Enable = false>
34 #ifndef DT_OBJECT_DEBUGGING_ENABLED
35 #define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
36 #define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE(type)
37 #define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE2(type)
40 template <
typename D,
bool Enable>
49 class DtObjectContainer;
55 template <
typename D,
bool Enable>
66 static std::string Print(std::string regex =
"");
67 static std::string PrettyPrintSize(
size_t);
68 static std::string DetectLeaks();
75 const DtObjectContainer* container = 0);
82 const DtObjectContainer* container = 0);
94 size_t size()
const {
return mySize; }
100 const DtObjectContainer*
objects()
const {
return myObjects; }
123 #ifdef DT_OBJECT_TRACKING_ENABLED
130 typedef tbb::spin_mutex
Mutex;
131 typedef std::list<const DtObjectTracker*> TrackableList;
132 typedef TrackableList::iterator Handle;
134 typedef boost::function<void (const DtObjectTracker&)> IterateFunction;
137 void remove(Handle h);
139 void iterate(
const IterateFunction&)
const;
140 void print(std::ostream&,
unsigned width = 0)
const;
143 mutable Mutex myMutex;
144 TrackableList myTrackables;
150 virtual std::string debugText()
const;
160 template <
typename D,
bool Enable>
163 DtObjectContainer::Handle myHandle;
173 template <
typename D,
bool Enable>
192 #ifdef DT_OBJECT_TRACKING_ENABLED
205 #ifdef DT_OBJECT_TRACKING_ENABLED
216 #ifdef DT_OBJECT_TRACKING_ENABLED
230 #ifdef DT_OBJECT_TRACKING_ENABLED
231 static DtObjectContainer theObjectContainer;
232 return &theObjectContainer;
239 template <
typename D>
248 template <
typename D,
bool Enabled>
255 #define DT_NAME_OBJECT_DEBUGGER(type, name) \
257 struct DtObjectDebuggerLabel< type > \
259 static inline std::string value() \
265 #define DT_DEFINE_OBJECT_DEBUGGER_NAME(type) \
267 struct DtObjectDebuggerLabel< type > \
269 static inline std::string value() \
275 #define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE(type) \
276 template <typename T> \
277 struct DtObjectDebuggerLabel< type <T> > \
279 static inline std::string value() \
281 std::string name( #type "<" ); \
282 name += DtObjectDebuggerLabel<T>::value(); \
288 #define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE2(type) \
289 template <typename T1, typename T2> \
290 struct DtObjectDebuggerLabel< type <T1,T2> > \
292 static inline std::string value() \
294 std::string name( #type "<" ); \
295 name += DtObjectDebuggerLabel<T1>::value(); \
297 name += DtObjectDebuggerLabel<T2>::value(); \
const bool myEnableFlag
Definition: objectCounter.h:112
unsigned long long CounterType
Definition: objectCounter.h:58
voidpf void uLong size
Definition: ioapi.h:39
static DtObjectCounter::CounterType ObjectCount()
Definition: objectCounter.h:177
Default on in debug, off in release.
Definition: objectCounter.h:31
Single static counter.
Definition: objectCounter.h:52
size_t size() const
Size of each counter piece of data.
Definition: objectCounter.h:94
static DtObjectCounter theStaticCount
Definition: objectCounter.h:226
static const DtObjectContainer * ObjectContainer()
Definition: objectCounter.h:182
const DtObjectContainer * myObjects
Track individual objects.
Definition: objectCounter.h:115
CounterType total() const
Total number of objects ever created.
Definition: objectCounter.h:91
const size_t mySize
Definition: objectCounter.h:111
DtObjectDebugger()
Definition: objectCounter.h:188
tbb::atomic< CounterType > AtomicType
Definition: objectCounter.h:59
OpenThreads::Mutex Mutex
Definition: DtOsgThreadingUtils.h:12
boost::function< std::string()> NameFunction
Definition: objectCounter.h:61
Definition: objectCounter.h:240
DtObjectDebugger(const DtObjectDebugger &)
Definition: objectCounter.h:201
void decrement()
Decrement this counter.
Definition: objectCounter.h:107
static DtObjectContainer * ObjectContainerMutable()
Definition: objectCounter.h:228
AtomicType myTotal
Definition: objectCounter.h:110
size_t totalSize() const
Total size in bytes of all data.
Definition: objectCounter.h:97
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
Definition: objectCounter.h:169
const DtObjectContainer * objects() const
Access tracked objects.
Definition: objectCounter.h:100
~DtObjectDebugger()
Definition: objectCounter.h:214
CounterType increment()
Increment this counter.
Definition: objectCounter.h:104
static std::string value()
Definition: objectCounter.h:242
CounterType value() const
Current value of counter.
Definition: objectCounter.h:88
void print(double **a, int r, int c, char *str)