Panda3D
 All Classes Functions Variables Enumerations
weakPointerToBase.h
1 // Filename: weakPointerToBase.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 WEAKPOINTERTOBASE_H
16 #define WEAKPOINTERTOBASE_H
17 
18 #include "pandabase.h"
19 #include "pointerToBase.h"
20 #include "weakPointerToVoid.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : WeakPointerToBase
24 // Description : This is the base class for PointerTo and
25 // ConstPointerTo. Don't try to use it directly; use
26 // either derived class instead.
27 ////////////////////////////////////////////////////////////////////
28 template <class T>
30 public:
31  typedef T To;
32 
33 protected:
34  INLINE WeakPointerToBase(To *ptr);
35  INLINE WeakPointerToBase(const PointerToBase<T> &copy);
36  INLINE WeakPointerToBase(const WeakPointerToBase<T> &copy);
37  INLINE ~WeakPointerToBase();
38 
39  void reassign(To *ptr);
40  INLINE void reassign(const PointerToBase<To> &copy);
41  INLINE void reassign(const WeakPointerToBase<To> &copy);
42 
43  // No assignment or retrieval functions are declared in
44  // WeakPointerToBase, because we will have to specialize on const
45  // vs. non-const later.
46 
47 public:
48  // These comparison functions are common to all things PointerTo, so
49  // they're defined up here.
50 #ifndef CPPPARSER
51 #ifndef WIN32_VC
52  INLINE bool operator == (const To *other) const;
53  INLINE bool operator != (const To *other) const;
54  INLINE bool operator > (const To *other) const;
55  INLINE bool operator <= (const To *other) const;
56  INLINE bool operator >= (const To *other) const;
57  INLINE bool operator == (To *other) const;
58  INLINE bool operator != (To *other) const;
59  INLINE bool operator > (To *other) const;
60  INLINE bool operator <= (To *other) const;
61  INLINE bool operator >= (To *other) const;
62 
63  INLINE bool operator == (const WeakPointerToBase<To> &other) const;
64  INLINE bool operator != (const WeakPointerToBase<To> &other) const;
65  INLINE bool operator > (const WeakPointerToBase<To> &other) const;
66  INLINE bool operator <= (const WeakPointerToBase<To> &other) const;
67  INLINE bool operator >= (const WeakPointerToBase<To> &other) const;
68 
69  INLINE bool operator == (const PointerToBase<To> &other) const;
70  INLINE bool operator != (const PointerToBase<To> &other) const;
71  INLINE bool operator > (const PointerToBase<To> &other) const;
72  INLINE bool operator <= (const PointerToBase<To> &other) const;
73  INLINE bool operator >= (const PointerToBase<To> &other) const;
74 #endif // WIN32_VC
75  INLINE bool operator < (const To *other) const;
76  INLINE bool operator < (const WeakPointerToBase<To> &other) const;
77  INLINE bool operator < (const PointerToBase<To> &other) const;
78 #endif // CPPPARSER
79 
80 PUBLISHED:
81  INLINE void clear();
82  INLINE void refresh() const;
83 
84  void output(ostream &out) const;
85 };
86 
87 template<class T>
88 INLINE ostream &operator <<(ostream &out, const WeakPointerToBase<T> &pointer) {
89  pointer.output(out);
90  return out;
91 }
92 
93 #include "weakPointerToBase.I"
94 
95 #endif
void output(ostream &out) const
A handy function to output PointerTo&#39;s as a hex pointer followed by a reference count.
This is the specialization of PointerToVoid for weak pointers.
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
void refresh() const
Informs the WeakPointerTo object that its pointer is no longer deleted.
This is the base class for PointerTo and ConstPointerTo.