Panda3D
|
00001 // Filename: weakPointerToBase.h 00002 // Created by: drose (27Sep04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef WEAKPOINTERTOBASE_H 00016 #define WEAKPOINTERTOBASE_H 00017 00018 #include "pandabase.h" 00019 #include "pointerToBase.h" 00020 #include "weakPointerToVoid.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : WeakPointerToBase 00024 // Description : This is the base class for PointerTo and 00025 // ConstPointerTo. Don't try to use it directly; use 00026 // either derived class instead. 00027 //////////////////////////////////////////////////////////////////// 00028 template <class T> 00029 class WeakPointerToBase : public WeakPointerToVoid { 00030 public: 00031 typedef T To; 00032 00033 protected: 00034 INLINE WeakPointerToBase(To *ptr); 00035 INLINE WeakPointerToBase(const PointerToBase<T> ©); 00036 INLINE WeakPointerToBase(const WeakPointerToBase<T> ©); 00037 INLINE ~WeakPointerToBase(); 00038 00039 void reassign(To *ptr); 00040 INLINE void reassign(const PointerToBase<To> ©); 00041 INLINE void reassign(const WeakPointerToBase<To> ©); 00042 00043 // No assignment or retrieval functions are declared in 00044 // WeakPointerToBase, because we will have to specialize on const 00045 // vs. non-const later. 00046 00047 public: 00048 // These comparison functions are common to all things PointerTo, so 00049 // they're defined up here. 00050 #ifndef CPPPARSER 00051 #ifndef WIN32_VC 00052 INLINE bool operator == (const To *other) const; 00053 INLINE bool operator != (const To *other) const; 00054 INLINE bool operator > (const To *other) const; 00055 INLINE bool operator <= (const To *other) const; 00056 INLINE bool operator >= (const To *other) const; 00057 INLINE bool operator == (To *other) const; 00058 INLINE bool operator != (To *other) const; 00059 INLINE bool operator > (To *other) const; 00060 INLINE bool operator <= (To *other) const; 00061 INLINE bool operator >= (To *other) const; 00062 00063 INLINE bool operator == (const WeakPointerToBase<To> &other) const; 00064 INLINE bool operator != (const WeakPointerToBase<To> &other) const; 00065 INLINE bool operator > (const WeakPointerToBase<To> &other) const; 00066 INLINE bool operator <= (const WeakPointerToBase<To> &other) const; 00067 INLINE bool operator >= (const WeakPointerToBase<To> &other) const; 00068 00069 INLINE bool operator == (const PointerToBase<To> &other) const; 00070 INLINE bool operator != (const PointerToBase<To> &other) const; 00071 INLINE bool operator > (const PointerToBase<To> &other) const; 00072 INLINE bool operator <= (const PointerToBase<To> &other) const; 00073 INLINE bool operator >= (const PointerToBase<To> &other) const; 00074 #endif // WIN32_VC 00075 INLINE bool operator < (const To *other) const; 00076 INLINE bool operator < (const WeakPointerToBase<To> &other) const; 00077 INLINE bool operator < (const PointerToBase<To> &other) const; 00078 #endif // CPPPARSER 00079 00080 PUBLISHED: 00081 INLINE void clear(); 00082 INLINE void refresh() const; 00083 00084 void output(ostream &out) const; 00085 }; 00086 00087 template<class T> 00088 INLINE ostream &operator <<(ostream &out, const WeakPointerToBase<T> &pointer) { 00089 pointer.output(out); 00090 return out; 00091 } 00092 00093 #include "weakPointerToBase.I" 00094 00095 #endif