forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodePointerTo.h
More file actions
99 lines (80 loc) · 2.96 KB
/
nodePointerTo.h
File metadata and controls
99 lines (80 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file nodePointerTo.h
* @author drose
* @date 2005-05-07
*/
#ifndef NODEPOINTERTO_H
#define NODEPOINTERTO_H
#include "pandabase.h"
#include "nodePointerToBase.h"
/**
* This implements the special NodePointerTo template class, which works just
* like PointerTo except it manages the objects node_ref_count instead of the
* normal ref_count.
*/
template <class T>
class NodePointerTo : public NodePointerToBase<T> {
public:
// By hiding this template from interrogate, we improve compile-time speed
// and memory utilization.
#ifndef CPPPARSER
typedef typename NodePointerToBase<T>::To To;
INLINE NodePointerTo(To *ptr = nullptr);
INLINE NodePointerTo(const NodePointerTo<T> ©);
INLINE NodePointerTo(NodePointerTo<T> &&from) noexcept;
INLINE NodePointerTo<T> &operator = (NodePointerTo<T> &&from) noexcept;
INLINE To &operator *() const;
INLINE To *operator -> () const;
// MSVC.NET 2005 insists that we use T *, and not To *, here.
INLINE operator T *() const;
INLINE To *p() const;
INLINE NodePointerTo<T> &operator = (To *ptr);
INLINE NodePointerTo<T> &operator = (const NodePointerTo<T> ©);
#endif // CPPPARSER
};
/**
* A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const
* pointer to the thing.
*/
template <class T>
class NodeConstPointerTo : public NodePointerToBase<T> {
public:
// By hiding this template from interrogate, we improve compile-time speed
// and memory utilization.
#ifndef CPPPARSER
typedef typename NodePointerToBase<T>::To To;
INLINE NodeConstPointerTo(const To *ptr = nullptr);
INLINE NodeConstPointerTo(const NodePointerTo<T> ©);
INLINE NodeConstPointerTo(const NodeConstPointerTo<T> ©);
INLINE NodeConstPointerTo(NodePointerTo<T> &&from) noexcept;
INLINE NodeConstPointerTo(NodeConstPointerTo<T> &&from) noexcept;
INLINE NodeConstPointerTo<T> &operator = (NodePointerTo<T> &&from) noexcept;
INLINE NodeConstPointerTo<T> &operator = (NodeConstPointerTo<T> &&from) noexcept;
INLINE const To &operator *() const;
INLINE const To *operator -> () const;
INLINE operator const T *() const;
INLINE const To *p() const;
INLINE NodeConstPointerTo<T> &operator = (const To *ptr);
INLINE NodeConstPointerTo<T> &operator = (const NodePointerTo<T> ©);
INLINE NodeConstPointerTo<T> &operator = (const NodeConstPointerTo<T> ©);
#endif // CPPPARSER
};
template <class T>
void swap(NodePointerTo<T> &one, NodePointerTo<T> &two) noexcept {
one.swap(two);
}
template <class T>
void swap(NodeConstPointerTo<T> &one, NodeConstPointerTo<T> &two) noexcept {
one.swap(two);
}
#define NPT(type) NodePointerTo< type >
#define NCPT(type) NodeConstPointerTo< type >
#include "nodePointerTo.I"
#endif