Panda3D
 All Classes Functions Variables Enumerations
pointerToBase.h
1 // Filename: pointerToBase.h
2 // Created by: drose (27Sep04)
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 POINTERTOBASE_H
16 #define POINTERTOBASE_H
17 
18 #include "pandabase.h"
19 #include "pointerToVoid.h"
20 #include "referenceCount.h"
21 #include "typedef.h"
22 #include "memoryUsage.h"
23 #include "config_express.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : PointerToBase
27 // Description : This is the base class for PointerTo and
28 // ConstPointerTo. Don't try to use it directly; use
29 // either derived class instead.
30 ////////////////////////////////////////////////////////////////////
31 template <class T>
32 class PointerToBase : public PointerToVoid {
33 public:
34  typedef T To;
35 
36 protected:
37  INLINE PointerToBase(To *ptr);
38  INLINE PointerToBase(const PointerToBase<T> &copy);
39  INLINE ~PointerToBase();
40 
41 #ifdef USE_MOVE_SEMANTICS
42  INLINE PointerToBase(PointerToBase<T> &&from) NOEXCEPT;
43  INLINE void reassign(PointerToBase<To> &&from) NOEXCEPT;
44 #endif
45 
46  INLINE void reassign(To *ptr);
47  INLINE void reassign(const PointerToBase<To> &copy);
48 
49 #ifdef DO_MEMORY_USAGE
50  void update_type(To *ptr);
51 #endif // DO_MEMORY_USAGE
52 
53  // No assignment or retrieval functions are declared in
54  // PointerToBase, because we will have to specialize on const
55  // vs. non-const later.
56 
57 PUBLISHED:
58  INLINE void clear();
59 
60  void output(ostream &out) const;
61 };
62 
63 template<class T>
64 INLINE ostream &operator <<(ostream &out, const PointerToBase<T> &pointer) {
65  pointer.output(out);
66  return out;
67 }
68 
69 #include "pointerToBase.I"
70 
71 #endif
void output(ostream &out) const
A handy function to output PointerTo&#39;s as a hex pointer followed by a reference count.
void clear()
A convenient way to set the PointerTo object to NULL.
This is the base class for PointerTo and ConstPointerTo.
Definition: pointerToBase.h:32
This is the non-template part of the base class for PointerTo and ConstPointerTo. ...
Definition: pointerToVoid.h:36