Panda3D
memoryUsagePointers.I
1 // Filename: memoryUsagePointers.I
2 // Created by: drose (25May00)
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 ////////////////////////////////////////////////////////////////////
16 // Function: MemoryUsagePointers::Entry::Constructor
17 // Access: Public
18 // Description:
19 ////////////////////////////////////////////////////////////////////
20 INLINE MemoryUsagePointers::Entry::
21 Entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr,
22  TypeHandle type, double age) :
23  _ref_ptr(ref_ptr),
24  _typed_ptr(typed_ptr),
25  _type(type),
26  _age(age)
27 {
28  _ref_ptr->ref();
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: MemoryUsagePointers::Entry::Copy Constructor
33 // Access: Public
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 INLINE MemoryUsagePointers::Entry::
37 Entry(const Entry &copy) :
38  _ref_ptr(copy._ref_ptr),
39  _typed_ptr(copy._typed_ptr),
40  _type(copy._type),
41  _age(copy._age)
42 {
43  _ref_ptr->ref();
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: MemoryUsagePointers::Entry::Copy Assignment Operator
48 // Access: Public
49 // Description:
50 ////////////////////////////////////////////////////////////////////
51 INLINE void MemoryUsagePointers::Entry::
52 operator = (const Entry &copy) {
53  if (_ref_ptr != copy._ref_ptr) {
54  _ref_ptr->unref();
55  _ref_ptr = copy._ref_ptr;
56  // We can't call unref_delete(), because we don't know what kind
57  // of pointer it is precisely. Potential leak.
58  _ref_ptr->ref();
59  }
60  _typed_ptr = copy._typed_ptr;
61  _type = copy._type;
62  _age = copy._age;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: MemoryUsagePointers::Entry::Destructor
67 // Access: Public
68 // Description:
69 ////////////////////////////////////////////////////////////////////
70 INLINE MemoryUsagePointers::Entry::
71 ~Entry() {
72  // We can't call unref_delete(), because we don't know what kind
73  // of pointer it is precisely. Potential leak.
74  _ref_ptr->unref();
75 }
76 
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
A base class for all things that want to be reference-counted.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85