Panda3D
memoryInfo.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file memoryInfo.I
10  * @author drose
11  * @date 2001-06-04
12  */
13 
14 /**
15  * Returns the data pointer as a void pointer. This should always be non-
16  * NULL.
17  */
18 void *MemoryInfo::get_void_ptr() const {
19  if (_void_ptr != nullptr) {
20  return _void_ptr;
21  }
22  if (_ref_ptr == nullptr) {
23  return _typed_ptr;
24  }
25  if (_typed_ptr == nullptr) {
26  return _ref_ptr;
27  }
28  return ((void *)_ref_ptr < (void *)_typed_ptr) ? (void *)_ref_ptr : (void *)_typed_ptr;
29 }
30 
31 /**
32  * Returns the data pointer as a ReferenceCount pointer. This may be NULL if
33  * the data pointer does not represent a ReferenceCount object.
34  */
35 ReferenceCount *MemoryInfo::get_ref_ptr() const {
36  return _ref_ptr;
37 }
38 
39 /**
40  * Returns the data pointer as a TypedObject pointer. This may be NULL if the
41  * data pointer does not represent a pointer to a TypedObject.
42  */
43 TypedObject *MemoryInfo::get_typed_ptr() const {
44  return _typed_ptr;
45 }
46 
47 /**
48  * Returns true if the size of the memory block referenced by this pointer is
49  * known. Most pointers' sizes should be known, but some may not be.
50  */
51 bool MemoryInfo::is_size_known() const {
52  return (_flags & F_size_known) != 0;
53 }
54 
55 /**
56  * Returns the size in bytes of the memory block referenced by this pointer,
57  * if it is known. Returns zero if the size is not known.
58  */
59 size_t MemoryInfo::get_size() const {
60  return _size;
61 }
62 
63 /**
64  * Returns the time in seconds (based on the GlobalClock) at which the pointer
65  * was allocated.
66  */
67 double MemoryInfo::get_time() const {
68  return _time;
69 }
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:88
A base class for all things that want to be reference-counted.