pointerToBase.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. PUBLISHED:
  46. INLINE void clear();
  47. void output(ostream &out) const;
  48. };
  49. template<class T>
  50. INLINE ostream &operator <<(ostream &out, const PointerToBase<T> &pointer) {
  51. pointer.output(out);
  52. return out;
  53. }
  54. #include "pointerToBase.I"
  55. #endif