Skylicht Engine
Loading...
Searching...
No Matches
leakHunter.h
1// Copyright (C) 2013 Michael Zeilfelder
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __LEAK_HUNTER_INCLUDEED__
6
7#include "IrrCompileConfig.h"
8
9#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
10
11#include "irrArray.h"
12
13namespace irr
14{
16
18
23 class LeakHunter
24 {
25 public:
26 friend class IReferenceCounted;
27
29
34 static void clearReferenceCountedObjects()
35 {
36 ReferenceCountedObjects.clear();
37 }
38
40 static inline irr::core::array<const IReferenceCounted*> getReferenceCountedObjects()
41 {
42 return ReferenceCountedObjects;
43 }
44
45 protected:
46 static inline void addObject(const IReferenceCounted* object)
47 {
48 ReferenceCountedObjects.push_back(object);
49 }
50
51 static inline void removeObject(const IReferenceCounted* object)
52 {
53 irr::s32 idx = ReferenceCountedObjects.linear_search(object );
54 if ( idx >= 0 )
55 {
56 irr::core::swap( ReferenceCountedObjects[idx], ReferenceCountedObjects.getLast() );
57 ReferenceCountedObjects.erase( ReferenceCountedObjects.size()-1 );
58 }
59 }
60
61 private:
62 // NOTE: We don't do additional grab()/drop()'s here as we want to supervise reference counted objects and not affect them otherwise.
63 IRRLICHT_API static irr::core::array<const IReferenceCounted*> ReferenceCountedObjects;
64 };
65} // end namespace irr
66
67#endif // _IRR_COMPILE_WITH_LEAK_HUNTER_
68
69#endif
Base class of most objects of the Irrlicht Engine.
Definition IReferenceCounted.h:46
void swap(T1 &a, T2 &b)
swaps the content of the passed parameters
Definition irrMath.h:177
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
signed int s32
32 bit signed variable.
Definition irrTypes.h:66