Panda3D
|
00001 // Filename: pointerToBase.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 POINTERTOBASE_H 00016 #define POINTERTOBASE_H 00017 00018 #include "pandabase.h" 00019 #include "pointerToVoid.h" 00020 #include "referenceCount.h" 00021 #include "typedef.h" 00022 #include "memoryUsage.h" 00023 #include "config_express.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : PointerToBase 00027 // Description : This is the base class for PointerTo and 00028 // ConstPointerTo. Don't try to use it directly; use 00029 // either derived class instead. 00030 //////////////////////////////////////////////////////////////////// 00031 template <class T> 00032 class PointerToBase : public PointerToVoid { 00033 public: 00034 typedef T To; 00035 00036 protected: 00037 INLINE PointerToBase(To *ptr); 00038 INLINE PointerToBase(const PointerToBase<T> ©); 00039 INLINE ~PointerToBase(); 00040 00041 INLINE void reassign(To *ptr); 00042 INLINE void reassign(const PointerToBase<To> ©); 00043 00044 #ifdef DO_MEMORY_USAGE 00045 void update_type(To *ptr); 00046 #endif // DO_MEMORY_USAGE 00047 00048 // No assignment or retrieval functions are declared in 00049 // PointerToBase, because we will have to specialize on const 00050 // vs. non-const later. 00051 00052 PUBLISHED: 00053 INLINE void clear(); 00054 00055 void output(ostream &out) const; 00056 }; 00057 00058 template<class T> 00059 INLINE ostream &operator <<(ostream &out, const PointerToBase<T> &pointer) { 00060 pointer.output(out); 00061 return out; 00062 } 00063 00064 #include "pointerToBase.I" 00065 00066 #endif