Panda3D

Loading...
Searching...
No Matches
pointerToBase.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 pointerToBase.h
10 * @author drose
11 * @date 2004-09-27
12 */
13
14#ifndef POINTERTOBASE_H
15#define POINTERTOBASE_H
16
17#include "pandabase.h"
18#include "pointerToVoid.h"
19#include "referenceCount.h"
20#include "typedef.h"
21#include "memoryUsage.h"
22#include "config_express.h"
23
24/**
25 * This is the base class for PointerTo and ConstPointerTo. Don't try to use
26 * it directly; use either derived class instead.
27 */
28 template <class T>
29 class PointerToBase : public PointerToVoid {
30 public:
31 typedef T To;
32
33 protected:
34 ALWAYS_INLINE constexpr PointerToBase() noexcept = default;
35 INLINE PointerToBase(To *ptr);
36 INLINE PointerToBase(const PointerToBase<T> &copy);
37 INLINE PointerToBase(PointerToBase<T> &&from) noexcept;
38 template<class Y>
39 INLINE PointerToBase(PointerToBase<Y> &&r) noexcept;
40
41 INLINE ~PointerToBase();
42
43 INLINE void reassign(To *ptr);
44 INLINE void reassign(const PointerToBase<To> &copy);
45 INLINE void reassign(PointerToBase<To> &&from) noexcept;
46 template<class Y>
47 INLINE void reassign(PointerToBase<Y> &&from) noexcept;
48
49 INLINE void update_type(To *ptr);
50
51 // No assignment or retrieval functions are declared in PointerToBase,
52 // because we will have to specialize on const vs. non-const later.
53
54 // This is needed to be able to access the privates of other instantiations.
55 template<typename Y> friend class PointerToBase;
56 template<typename Y> friend class WeakPointerToBase;
57
58PUBLISHED:
59 ALWAYS_INLINE void clear();
60
61 void output(std::ostream &out) const;
62};
63
64 template<class T>
65INLINE std::ostream &operator <<(std::ostream &out, const PointerToBase<T> &pointer) {
66 pointer.output(out);
67 return out;
68}
69
70#include "pointerToBase.I"
71
72#endif
PointerToBase
This is the base class for PointerTo and ConstPointerTo.
Definition pointerToBase.h:29
PointerToBase::output
void output(std::ostream &out) const
A handy function to output PointerTo's as a hex pointer followed by a reference count.
Definition pointerToBase.I:219
PointerToBase::clear
void clear()
A convenient way to set the PointerTo object to NULL.
Definition pointerToBase.I:209
config_express.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
memoryUsage.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerToBase.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerToVoid.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedef.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.