Panda3D
nodePointerTo.h
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 nodePointerTo.h
10  * @author drose
11  * @date 2005-05-07
12  */
13 
14 #ifndef NODEPOINTERTO_H
15 #define NODEPOINTERTO_H
16 
17 #include "pandabase.h"
18 #include "nodePointerToBase.h"
19 
20 /**
21  * This implements the special NodePointerTo template class, which works just
22  * like PointerTo except it manages the objects node_ref_count instead of the
23  * normal ref_count.
24  */
25 template <class T>
26 class NodePointerTo : public NodePointerToBase<T> {
27 public:
28  // By hiding this template from interrogate, we improve compile-time speed
29  // and memory utilization.
30 #ifndef CPPPARSER
31  typedef typename NodePointerToBase<T>::To To;
32  INLINE NodePointerTo(To *ptr = nullptr);
33  INLINE NodePointerTo(const NodePointerTo<T> &copy);
34  INLINE NodePointerTo(NodePointerTo<T> &&from) noexcept;
35 
36  INLINE NodePointerTo<T> &operator = (NodePointerTo<T> &&from) noexcept;
37 
38  INLINE To &operator *() const;
39  INLINE To *operator -> () const;
40 
41  // MSVC.NET 2005 insists that we use T *, and not To *, here.
42  INLINE operator T *() const;
43 
44  INLINE To *p() const;
45 
46  INLINE NodePointerTo<T> &operator = (To *ptr);
47  INLINE NodePointerTo<T> &operator = (const NodePointerTo<T> &copy);
48 #endif // CPPPARSER
49 };
50 
51 
52 /**
53  * A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const
54  * pointer to the thing.
55  */
56 template <class T>
58 public:
59  // By hiding this template from interrogate, we improve compile-time speed
60  // and memory utilization.
61 #ifndef CPPPARSER
62  typedef typename NodePointerToBase<T>::To To;
63  INLINE NodeConstPointerTo(const To *ptr = nullptr);
64  INLINE NodeConstPointerTo(const NodePointerTo<T> &copy);
65  INLINE NodeConstPointerTo(const NodeConstPointerTo<T> &copy);
66  INLINE NodeConstPointerTo(NodePointerTo<T> &&from) noexcept;
67  INLINE NodeConstPointerTo(NodeConstPointerTo<T> &&from) noexcept;
68 
69  INLINE NodeConstPointerTo<T> &operator = (NodePointerTo<T> &&from) noexcept;
70  INLINE NodeConstPointerTo<T> &operator = (NodeConstPointerTo<T> &&from) noexcept;
71 
72  INLINE const To &operator *() const;
73  INLINE const To *operator -> () const;
74  INLINE operator const T *() const;
75 
76  INLINE const To *p() const;
77 
78  INLINE NodeConstPointerTo<T> &operator = (const To *ptr);
79  INLINE NodeConstPointerTo<T> &operator = (const NodePointerTo<T> &copy);
80  INLINE NodeConstPointerTo<T> &operator = (const NodeConstPointerTo<T> &copy);
81 #endif // CPPPARSER
82 };
83 
84 template <class T>
85 void swap(NodePointerTo<T> &one, NodePointerTo<T> &two) noexcept {
86  one.swap(two);
87 }
88 
89 template <class T>
90 void swap(NodeConstPointerTo<T> &one, NodeConstPointerTo<T> &two) noexcept {
91  one.swap(two);
92 }
93 
94 #define NPT(type) NodePointerTo< type >
95 #define NCPT(type) NodeConstPointerTo< type >
96 
97 #include "nodePointerTo.I"
98 
99 #endif
NodeConstPointerTo::p
const To * p() const
Returns an ordinary pointer instead of a NodeConstPointerTo.
Definition: nodePointerTo.I:260
nodePointerTo.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
nodePointerToBase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePointerTo
This implements the special NodePointerTo template class, which works just like PointerTo except it m...
Definition: nodePointerTo.h:26
NodeConstPointerTo
A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const pointer to the thing.
Definition: nodePointerTo.h:57
NodePointerToBase
This is similar to PointerToBase, but it manages objects of type NodeReferenceCount or NodeCachedRefe...
Definition: nodePointerToBase.h:31
NodePointerTo::p
To * p() const
Returns an ordinary pointer instead of a NodePointerTo.
Definition: nodePointerTo.I:103