6 #include <AutoLocker.h>
9 #include "ObjectTracker.h"
11 static char sTrackerBuffer
[sizeof(ObjectTracker
)];
14 ObjectTrackable::ObjectTrackable()
16 ObjectTracker
* tracker
= ObjectTracker::GetDefault();
18 tracker
->AddTrackable(this);
22 ObjectTrackable::~ObjectTrackable()
24 ObjectTracker
* tracker
= ObjectTracker::GetDefault();
26 tracker
->RemoveTrackable(this);
33 ObjectTracker::ObjectTracker()
34 : fLock("object tracker"),
40 ObjectTracker::~ObjectTracker()
42 ObjectTrackable
* trackable
= fTrackables
.First();
44 WARN(("ObjectTracker: WARNING: There are still undeleted objects:\n"));
46 for (; trackable
; trackable
= fTrackables
.GetNext(trackable
)) {
47 WARN((" trackable: %p: type: `%s'\n", trackable
,
48 typeid(*trackable
).name()));
56 ObjectTracker::InitDefault()
59 sTracker
= new(sTrackerBuffer
) ObjectTracker
;
65 ObjectTracker::ExitDefault()
68 sTracker
->~ObjectTracker();
75 ObjectTracker::GetDefault()
82 ObjectTracker::AddTrackable(ObjectTrackable
* trackable
)
85 AutoLocker
<Locker
> _(fLock
);
86 fTrackables
.Insert(trackable
);
92 ObjectTracker::RemoveTrackable(ObjectTrackable
* trackable
)
95 AutoLocker
<Locker
> _(fLock
);
96 fTrackables
.Remove(trackable
);
101 ObjectTracker
* ObjectTracker::sTracker
= NULL
;