Panda3D
Loading...
Searching...
No Matches
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 */
25template <class T>
27public:
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 */
56template <class T>
58public:
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
84template <class T>
85void swap(NodePointerTo<T> &one, NodePointerTo<T> &two) noexcept {
86 one.swap(two);
87}
88
89template <class T>
90void 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
A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const pointer to the thing.
const To * p() const
Returns an ordinary pointer instead of a NodeConstPointerTo.
This is similar to PointerToBase, but it manages objects of type NodeReferenceCount or NodeCachedRefe...
This implements the special NodePointerTo template class, which works just like PointerTo except it m...
To * p() const
Returns an ordinary pointer instead of a NodePointerTo.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.