Panda3D
 All Classes Functions Variables Enumerations
nodePointerTo.h
1 // Filename: nodePointerTo.h
2 // Created by: drose (07May05)
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 #ifndef NODEPOINTERTO_H
16 #define NODEPOINTERTO_H
17 
18 #include "pandabase.h"
19 #include "nodePointerToBase.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : NodePointerTo
23 // Description : This implements the special NodePointerTo template
24 // class, which works just like PointerTo except it
25 // manages the objects node_ref_count instead of the
26 // normal ref_count.
27 ////////////////////////////////////////////////////////////////////
28 template <class T>
29 class NodePointerTo : public NodePointerToBase<T> {
30 public:
31  // By hiding this template from interrogate, we improve compile-time
32  // speed and memory utilization.
33 #ifndef CPPPARSER
34  typedef TYPENAME NodePointerToBase<T>::To To;
35  INLINE NodePointerTo(To *ptr = (To *)NULL);
36  INLINE NodePointerTo(const NodePointerTo<T> &copy);
37  INLINE ~NodePointerTo();
38 
39 #ifdef USE_MOVE_SEMANTICS
40  INLINE NodePointerTo(NodePointerTo<T> &&from) NOEXCEPT;
41  INLINE NodePointerTo<T> &operator = (NodePointerTo<T> &&from) NOEXCEPT;
42 #endif
43 
44  INLINE To &operator *() const;
45  INLINE To *operator -> () const;
46 
47  // MSVC.NET 2005 insists that we use T *, and not To *, here.
48  INLINE operator T *() const;
49 
50  INLINE To *p() const;
51 
52  INLINE NodePointerTo<T> &operator = (To *ptr);
53  INLINE NodePointerTo<T> &operator = (const NodePointerTo<T> &copy);
54 #endif // CPPPARSER
55 };
56 
57 
58 ////////////////////////////////////////////////////////////////////
59 // Class : NodeConstPointerTo
60 // Description : A NodeConstPointerTo is similar to a NodePointerTo,
61 // except it keeps a const pointer to the thing.
62 ////////////////////////////////////////////////////////////////////
63 template <class T>
65 public:
66  // By hiding this template from interrogate, we improve compile-time
67  // speed and memory utilization.
68 #ifndef CPPPARSER
69  typedef TYPENAME NodePointerToBase<T>::To To;
70  INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL);
71  INLINE NodeConstPointerTo(const NodePointerTo<T> &copy);
72  INLINE NodeConstPointerTo(const NodeConstPointerTo<T> &copy);
73  INLINE ~NodeConstPointerTo();
74 
75 #ifdef USE_MOVE_SEMANTICS
76  INLINE NodeConstPointerTo(NodePointerTo<T> &&from) NOEXCEPT;
77  INLINE NodeConstPointerTo(NodeConstPointerTo<T> &&from) NOEXCEPT;
78  INLINE NodeConstPointerTo<T> &operator = (NodePointerTo<T> &&from) NOEXCEPT;
79  INLINE NodeConstPointerTo<T> &operator = (NodeConstPointerTo<T> &&from) NOEXCEPT;
80 #endif
81 
82  INLINE const To &operator *() const;
83  INLINE const To *operator -> () const;
84  INLINE operator const T *() const;
85 
86  INLINE const To *p() const;
87 
88  INLINE NodeConstPointerTo<T> &operator = (const To *ptr);
89  INLINE NodeConstPointerTo<T> &operator = (const NodePointerTo<T> &copy);
90  INLINE NodeConstPointerTo<T> &operator = (const NodeConstPointerTo<T> &copy);
91 #endif // CPPPARSER
92 };
93 
94 template <class T>
95 void swap(NodePointerTo<T> &one, NodePointerTo<T> &two) NOEXCEPT {
96  one.swap(two);
97 }
98 
99 template <class T>
100 void swap(NodeConstPointerTo<T> &one, NodeConstPointerTo<T> &two) NOEXCEPT {
101  one.swap(two);
102 }
103 
104 #define NPT(type) NodePointerTo< type >
105 #define NCPT(type) NodeConstPointerTo< type >
106 
107 #include "nodePointerTo.I"
108 
109 #endif
This is similar to PointerToBase, but it manages objects of type NodeReferenceCount or NodeCachedRefe...
const To * p() const
Returns an ordinary pointer instead of a NodeConstPointerTo.
To * p() const
Returns an ordinary pointer instead of a NodePointerTo.
A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const pointer to the thing...
Definition: nodePointerTo.h:64
This implements the special NodePointerTo template class, which works just like PointerTo except it m...
Definition: nodePointerTo.h:29