pointerToVoid.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Filename: pointerToVoid.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 POINTERTOVOID_H
  19. #define POINTERTOVOID_H
  20. #include "pandabase.h"
  21. #include "pnotify.h"
  22. ////////////////////////////////////////////////////////////////////
  23. // Class : PointerToVoid
  24. // Description : This is the non-template part of the base class for
  25. // PointerTo and ConstPointerTo. It is necessary so we
  26. // can keep a pointer to a non-template class within the
  27. // ReferenceCount object, to implement weak reference
  28. // pointers--we need to have something to clean up when
  29. // the ReferenceCount object destructs.
  30. //
  31. // This is the base class for PointerToBase<T>.
  32. ////////////////////////////////////////////////////////////////////
  33. class EXPCL_PANDAEXPRESS PointerToVoid {
  34. protected:
  35. INLINE PointerToVoid();
  36. INLINE ~PointerToVoid();
  37. private:
  38. INLINE PointerToVoid(const PointerToVoid &copy);
  39. PUBLISHED:
  40. INLINE bool is_null() const;
  41. INLINE size_t get_hash() const;
  42. public:
  43. // These comparison functions are common to all things PointerTo, so
  44. // they're defined up here.
  45. INLINE bool operator < (const void *other) const;
  46. INLINE bool operator < (const PointerToVoid &other) const;
  47. protected:
  48. // Within the PointerToVoid class, we only store a void pointer.
  49. // This is actually the (To *) pointer that is typecast to (void *)
  50. // from the derived template classes.
  51. // It is tempting to try to store a (ReferenceCount *) pointer here,
  52. // but this is not useful because it prohibits defining, say,
  53. // PT(PandaNode), or a PointerTo any class that inherits virtually
  54. // from ReferenceCount. (You can't downcast past a virtual
  55. // inheritance level, but you can always cross-cast from a void
  56. // pointer.)
  57. void *_void_ptr;
  58. };
  59. #include "pointerToVoid.I"
  60. #endif