Panda3D
 All Classes Functions Variables Enumerations
memoryInfo.I
1 // Filename: memoryInfo.I
2 // Created by: drose (04Jun01)
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 ////////////////////////////////////////////////////////////////////
17 // Function: MemoryInfo::get_void_ptr
18 // Access: Public
19 // Description: Returns the data pointer as a void pointer. This
20 // should always be non-NULL.
21 ////////////////////////////////////////////////////////////////////
22 void *MemoryInfo::get_void_ptr() const {
23  if (_void_ptr != (void *)NULL) {
24  return _void_ptr;
25  }
26  if (_ref_ptr == (void *)NULL) {
27  return _typed_ptr;
28  }
29  if (_typed_ptr == (void *)NULL) {
30  return _ref_ptr;
31  }
32  return ((void *)_ref_ptr < (void *)_typed_ptr) ? (void *)_ref_ptr : (void *)_typed_ptr;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: MemoryInfo::get_ref_ptr
37 // Access: Public
38 // Description: Returns the data pointer as a ReferenceCount pointer.
39 // This may be NULL if the data pointer does not
40 // represent a ReferenceCount object.
41 ////////////////////////////////////////////////////////////////////
42 ReferenceCount *MemoryInfo::get_ref_ptr() const {
43  return _ref_ptr;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: MemoryInfo::get_typed_ptr
48 // Access: Public
49 // Description: Returns the data pointer as a TypedObject pointer.
50 // This may be NULL if the data pointer does not
51 // represent a pointer to a TypedObject.
52 ////////////////////////////////////////////////////////////////////
53 TypedObject *MemoryInfo::get_typed_ptr() const {
54  return _typed_ptr;
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: MemoryInfo::is_size_known
59 // Access: Public
60 // Description: Returns true if the size of the memory block
61 // referenced by this pointer is known. Most pointers'
62 // sizes should be known, but some may not be.
63 ////////////////////////////////////////////////////////////////////
64 bool MemoryInfo::is_size_known() const {
65  return (_flags & F_size_known) != 0;
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: MemoryInfo::get_size
70 // Access: Public
71 // Description: Returns the size in bytes of the memory block
72 // referenced by this pointer, if it is known. Returns
73 // zero if the size is not known.
74 ////////////////////////////////////////////////////////////////////
75 size_t MemoryInfo::get_size() const {
76  return _size;
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: MemoryInfo::get_time
81 // Access: Public
82 // Description: Returns the time in seconds (based on the
83 // GlobalClock) at which the pointer was allocated.
84 ////////////////////////////////////////////////////////////////////
85 double MemoryInfo::get_time() const {
86  return _time;
87 }
88 
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.