pointerToBase.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Filename: pointerToBase.h
  2. // Created by: drose (27Sep04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef POINTERTOBASE_H
  19. #define POINTERTOBASE_H
  20. #include "pandabase.h"
  21. #include "pointerToVoid.h"
  22. #include "referenceCount.h"
  23. #include "typedef.h"
  24. #include "memoryUsage.h"
  25. #include "config_express.h"
  26. ////////////////////////////////////////////////////////////////////
  27. // Class : PointerToBase
  28. // Description : This is the base class for PointerTo and
  29. // ConstPointerTo. Don't try to use it directly; use
  30. // either derived class instead.
  31. ////////////////////////////////////////////////////////////////////
  32. template <class T>
  33. class PointerToBase : public PointerToVoid {
  34. public:
  35. typedef T To;
  36. protected:
  37. INLINE PointerToBase(To *ptr);
  38. INLINE PointerToBase(const PointerToBase<T> &copy);
  39. INLINE ~PointerToBase();
  40. void reassign(To *ptr);
  41. INLINE void reassign(const PointerToBase<To> &copy);
  42. // No assignment or retrieval functions are declared in
  43. // PointerToBase, because we will have to specialize on const
  44. // vs. non-const later.
  45. public:
  46. // These comparison functions are common to all things PointerTo, so
  47. // they're defined up here.
  48. #ifndef CPPPARSER
  49. #ifndef WIN32_VC
  50. INLINE bool operator == (const To *other) const;
  51. INLINE bool operator != (const To *other) const;
  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 == (To *other) const;
  56. INLINE bool operator != (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 == (const PointerToBase<To> &other) const;
  61. INLINE bool operator != (const PointerToBase<To> &other) const;
  62. INLINE bool operator > (const PointerToBase<To> &other) const;
  63. INLINE bool operator <= (const PointerToBase<To> &other) const;
  64. INLINE bool operator >= (const PointerToBase<To> &other) const;
  65. #endif // WIN32_VC
  66. INLINE bool operator < (const To *other) const;
  67. INLINE bool operator < (const PointerToBase<To> &other) const;
  68. #endif // CPPPARSER
  69. INLINE size_t get_hash() const;
  70. PUBLISHED:
  71. INLINE bool is_null() const;
  72. INLINE void clear();
  73. void output(ostream &out) const;
  74. };
  75. template<class T>
  76. INLINE ostream &operator <<(ostream &out, const PointerToBase<T> &pointer) {
  77. pointer.output(out);
  78. return out;
  79. }
  80. #include "pointerToBase.I"
  81. #endif