pointerToVoid.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "notify.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. // Within the PointerToVoid class, we only store a void pointer.
  38. // This is actually the (To *) pointer that is typecast to (void *)
  39. // from the derived template classes.
  40. // It is tempting to try to store a (ReferenceCount *) pointer here,
  41. // but this is not useful because it prohibits defining, say,
  42. // PT(PandaNode), or a PointerTo any class that inherits virtually
  43. // from ReferenceCount. (You can't downcast past a virtual
  44. // inheritance level, but you can always cross-cast from a void
  45. // pointer.)
  46. void *_void_ptr;
  47. };
  48. #include "pointerToVoid.I"
  49. #endif