Panda3D
pointerToVoid.I
1 // Filename: pointerToVoid.I
2 // Created by: drose (27Sep04)
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: PointerToVoid::Constructor
18 // Access: Protected
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE PointerToVoid::
22 PointerToVoid() {
23  _void_ptr = (void *)NULL;
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: PointerToVoid::Destructor
28 // Access: Protected
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE PointerToVoid::
32 ~PointerToVoid() {
33  nassertv(_void_ptr == (void *)NULL);
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: PointerToVoid::Copy Constructor
38 // Access: Private
39 // Description: Don't use this constructor.
40 ////////////////////////////////////////////////////////////////////
41 INLINE PointerToVoid::
42 PointerToVoid(const PointerToVoid &) {
43  nassertv(false);
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: PointerToVoid::is_null
48 // Access: Published
49 // Description: Returns true if the PointerTo is a NULL pointer,
50 // false otherwise. (Direct comparison to a NULL
51 // pointer also works.)
52 ////////////////////////////////////////////////////////////////////
53 INLINE bool PointerToVoid::
54 is_null() const {
55  return (_void_ptr == (void *)NULL);
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: PointerToVoid::get_hash
60 // Access: Public
61 // Description:
62 ////////////////////////////////////////////////////////////////////
63 INLINE size_t PointerToVoid::
64 get_hash() const {
65  return (size_t)_void_ptr;
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: PointerToVoid::Less-than operator
70 // Access: Public
71 // Description:
72 ////////////////////////////////////////////////////////////////////
73 INLINE bool PointerToVoid::
74 operator < (const void *other) const {
75  return _void_ptr < other;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: PointerToVoid::Less-than operator
80 // Access: Public
81 // Description:
82 ////////////////////////////////////////////////////////////////////
83 INLINE bool PointerToVoid::
84 operator < (const PointerToVoid &other) const {
85  return _void_ptr < other._void_ptr;
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: PointerToVoid::operator ==
90 // Access: Public
91 // Description:
92 ////////////////////////////////////////////////////////////////////
93 INLINE bool PointerToVoid::
94 operator == (const PointerToVoid &other) const {
95  return _void_ptr == other._void_ptr;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: PointerToVoid::operator !=
100 // Access: Public
101 // Description:
102 ////////////////////////////////////////////////////////////////////
103 INLINE bool PointerToVoid::
104 operator != (const PointerToVoid &other) const {
105  return _void_ptr != other._void_ptr;
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: PointerToVoid::swap
110 // Access: Public
111 // Description: Swaps the contents of this PointerTo with the other,
112 // without touching the reference counts.
113 //
114 // For internal use only. Use the global swap()
115 // function instead.
116 ////////////////////////////////////////////////////////////////////
117 INLINE void PointerToVoid::
118 swap(PointerToVoid &other) NOEXCEPT {
119  AtomicAdjust::Pointer temp = _void_ptr;
120  _void_ptr = other._void_ptr;
121  other._void_ptr = temp;
122 }
This is the non-template part of the base class for PointerTo and ConstPointerTo. ...
Definition: pointerToVoid.h:36
bool is_null() const
Returns true if the PointerTo is a NULL pointer, false otherwise.
Definition: pointerToVoid.I:54
void swap(PointerToVoid &other) NOEXCEPT
Swaps the contents of this PointerTo with the other, without touching the reference counts...