Panda3D
 All Classes Functions Variables Enumerations
cachedTypedWritableReferenceCount.cxx
1 // Filename: cachedTypedWritableReferenceCount.cxx
2 // Created by: drose (25Jan05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "cachedTypedWritableReferenceCount.h"
16 
17 TypeHandle CachedTypedWritableReferenceCount::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: CachedTypedWritableReferenceCount::do_test_ref_count_integrity
21 // Access: Protected
22 // Description: Does some easy checks to make sure that the reference
23 // count isn't completely bogus.
24 ////////////////////////////////////////////////////////////////////
25 bool CachedTypedWritableReferenceCount::
26 do_test_ref_count_integrity() const {
27  nassertr(this != NULL, false);
28 
29  // If this assertion fails, we're trying to delete an object that
30  // was just deleted. Possibly you used a real pointer instead of a
31  // PointerTo at some point, and the object was deleted when the
32  // PointerTo went out of scope. Maybe you tried to create an
33  // automatic (local variable) instance of a class that derives from
34  // ReferenceCount. Or maybe your headers are out of sync, and you
35  // need to make clean in direct or some higher tree.
36  nassertr(_cache_ref_count != -100, false);
37 
38  // If this assertion fails, the reference counts are all screwed
39  // up altogether. Maybe some errant code stomped all over memory
40  // somewhere.
41  nassertr(_cache_ref_count >= 0, false);
42 
43  return TypedWritableReferenceCount::do_test_ref_count_integrity();
44 }
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85