eggObject.I 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Filename: eggObject.I
  2. // Created by: drose (10Feb99)
  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. ////////////////////////////////////////////////////////////////////
  19. // Function: EggObject::Constructor
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE EggObject::
  24. EggObject() {
  25. }
  26. ////////////////////////////////////////////////////////////////////
  27. // Function: EggObject::Copy constructor
  28. // Access: Public
  29. // Description:
  30. ////////////////////////////////////////////////////////////////////
  31. INLINE EggObject::
  32. EggObject(const EggObject &copy) :
  33. TypedReferenceCount(copy),
  34. _user_data(copy._user_data)
  35. {
  36. }
  37. ////////////////////////////////////////////////////////////////////
  38. // Function: EggObject::Copy assignment operator
  39. // Access: Public
  40. // Description:
  41. ////////////////////////////////////////////////////////////////////
  42. INLINE EggObject &EggObject::
  43. operator = (const EggObject &copy) {
  44. TypedReferenceCount::operator = (copy);
  45. _user_data = copy._user_data;
  46. return *this;
  47. }
  48. ////////////////////////////////////////////////////////////////////
  49. // Function: EggObject::set_user_data
  50. // Access: Public
  51. // Description: Sets the user data associated with this object. This
  52. // may be any EggUserData-derived object. The egg
  53. // library will do nothing with this pointer, except to
  54. // hold its reference count and return the pointer on
  55. // request.
  56. //
  57. // This pointer is also copied by the copy assignment
  58. // operator and copy constructor.
  59. ////////////////////////////////////////////////////////////////////
  60. INLINE void EggObject::
  61. set_user_data(EggUserData *user_data) {
  62. _user_data = user_data;
  63. }
  64. ////////////////////////////////////////////////////////////////////
  65. // Function: EggObject::get_user_data
  66. // Access: Public
  67. // Description: Returns the user data pointer previously stored on
  68. // this object, or NULL if nothing was previously
  69. // stored.
  70. ////////////////////////////////////////////////////////////////////
  71. INLINE EggUserData *EggObject::
  72. get_user_data() const {
  73. return _user_data;
  74. }
  75. ////////////////////////////////////////////////////////////////////
  76. // Function: EggObject::has_user_data
  77. // Access: Public
  78. // Description: Returns true if the user data pointer has been set,
  79. // false otherwise.
  80. ////////////////////////////////////////////////////////////////////
  81. INLINE bool EggObject::
  82. has_user_data() const {
  83. return !_user_data.is_null();
  84. }
  85. ////////////////////////////////////////////////////////////////////
  86. // Function: EggObject::has_user_data
  87. // Access: Public
  88. // Description: Returns true if the user data pointer has been set
  89. // and is of the indicated type, false otherwise.
  90. ////////////////////////////////////////////////////////////////////
  91. INLINE bool EggObject::
  92. has_user_data(TypeHandle type) const {
  93. return !_user_data.is_null() && _user_data->is_of_type(type);
  94. }
  95. ////////////////////////////////////////////////////////////////////
  96. // Function: EggObject::clear_user_data
  97. // Access: Public
  98. // Description: Resets the user data pointer to NULL.
  99. ////////////////////////////////////////////////////////////////////
  100. INLINE void EggObject::
  101. clear_user_data() {
  102. _user_data.clear();
  103. }