pointerDataAttribute.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Filename: pointerDataAttribute.h
  2. // Created by: jason (07Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, 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://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef POINTERDATAATTRIBUTE_H
  19. #define POINTERDATAATTRIBUTE_H
  20. #include <pandabase.h>
  21. #include <nodeAttribute.h>
  22. #include <indent.h>
  23. template<class PtrType>
  24. class PointerDataTransition;
  25. ////////////////////////////////////////////////////////////////////
  26. // Class : PointerDataTransition
  27. // Description :
  28. ////////////////////////////////////////////////////////////////////
  29. template<class PtrType>
  30. class PointerDataAttribute : public NodeAttribute {
  31. public:
  32. INLINE PointerDataAttribute();
  33. INLINE PointerDataAttribute(PtrType* ptr);
  34. INLINE PointerDataAttribute(const PointerDataAttribute<PtrType> &copy);
  35. INLINE void operator = (const PointerDataAttribute<PtrType> &copy);
  36. public:
  37. INLINE void set_value(PtrType* ptr);
  38. INLINE PtrType* get_value() const;
  39. virtual TypeHandle get_handle() const;
  40. virtual void output(ostream &out) const;
  41. virtual void write(ostream &out, int indent_level = 0) const;
  42. protected:
  43. virtual int internal_compare_to(const NodeAttribute *other) const;
  44. private:
  45. PtrType* _ptr;
  46. public:
  47. virtual TypeHandle get_type() const {
  48. return get_class_type();
  49. }
  50. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  51. static TypeHandle get_class_type() {
  52. return _type_handle;
  53. }
  54. static void init_type() {
  55. NodeAttribute::init_type();
  56. register_type(_type_handle,
  57. string("PointerDataAttribute<") +
  58. get_type_handle(PtrType).get_name() + ">",
  59. NodeAttribute::get_class_type());
  60. }
  61. private:
  62. static TypeHandle _type_handle;
  63. friend class PointerDataTransition<PtrType>;
  64. //Variable is just to make the compiler happy for the default
  65. //constructor
  66. static PtrType* _null_ptr;
  67. };
  68. #include "pointerDataAttribute.I"
  69. #endif