onOffAttribute.I 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Filename: onOffAttribute.I
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. ////////////////////////////////////////////////////////////////////
  6. // Function: OnOffAttribute::Constructor
  7. // Access: Public
  8. // Description:
  9. ////////////////////////////////////////////////////////////////////
  10. INLINE OnOffAttribute::
  11. OnOffAttribute(bool is_on) {
  12. _is_on = is_on;
  13. }
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: OnOffAttribute::Copy Constructor
  16. // Access: Public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE OnOffAttribute::
  20. OnOffAttribute(const OnOffAttribute &copy) :
  21. NodeAttribute(copy),
  22. _is_on(copy._is_on)
  23. {
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: OnOffAttribute::Copy Assignment Operator
  27. // Access: Public
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE void OnOffAttribute::
  31. operator = (const OnOffAttribute &copy) {
  32. NodeAttribute::operator = (copy);
  33. _is_on = copy._is_on;
  34. }
  35. ////////////////////////////////////////////////////////////////////
  36. // Function: OnOffAttribute::set_on
  37. // Access: Public
  38. // Description: Changes the attribute to an 'on' attribute;
  39. // this turns on the attribute for all nodes at this
  40. // point and below. However, this particular function
  41. // does not change the attribute value itself, and is
  42. // thus only appropriate for derived attribute types
  43. // that do not actually carry an attribute value.
  44. // Derived types that *do* have an attribute value
  45. // should override this function to accept a value
  46. // parameter of the appropriate type.
  47. ////////////////////////////////////////////////////////////////////
  48. INLINE void OnOffAttribute::
  49. set_on() {
  50. _is_on = true;
  51. }
  52. ////////////////////////////////////////////////////////////////////
  53. // Function: OnOffAttribute::set_off
  54. // Access: Public
  55. // Description: Changes the attribute to an 'off' attribute; this
  56. // turns off the attribute for all nodes at this point
  57. // and below.
  58. ////////////////////////////////////////////////////////////////////
  59. INLINE void OnOffAttribute::
  60. set_off() {
  61. _is_on = false;
  62. }
  63. ////////////////////////////////////////////////////////////////////
  64. // Function: OnOffAttribute::is_on
  65. // Access: Public
  66. // Description: Returns true if the attribute is on, false if it is
  67. // not.
  68. ////////////////////////////////////////////////////////////////////
  69. INLINE bool OnOffAttribute::
  70. is_on() const {
  71. return _is_on;
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: OnOffAttribute::is_off
  75. // Access: Public
  76. // Description: Returns true if the attribute is off, false if it is
  77. // not.
  78. ////////////////////////////////////////////////////////////////////
  79. INLINE bool OnOffAttribute::
  80. is_off() const {
  81. return !_is_on;
  82. }