dataNodeTransmit.I 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Filename: dataNodeTransmit.I
  2. // Created by: drose (11Mar02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: DataNodeTransmit::Constructor
  16. // Access: Public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE DataNodeTransmit::
  20. DataNodeTransmit() {
  21. }
  22. ////////////////////////////////////////////////////////////////////
  23. // Function: DataNodeTransmit::Copy Constructor
  24. // Access: Public
  25. // Description:
  26. ////////////////////////////////////////////////////////////////////
  27. INLINE DataNodeTransmit::
  28. DataNodeTransmit(const DataNodeTransmit &copy) :
  29. _data(copy._data)
  30. {
  31. }
  32. ////////////////////////////////////////////////////////////////////
  33. // Function: DataNodeTransmit::Copy Assignment Operator
  34. // Access: Public
  35. // Description:
  36. ////////////////////////////////////////////////////////////////////
  37. INLINE void DataNodeTransmit::
  38. operator = (const DataNodeTransmit &copy) {
  39. _data = copy._data;
  40. }
  41. ////////////////////////////////////////////////////////////////////
  42. // Function: DataNodeTransmit::reserve
  43. // Access: Public
  44. // Description: Tells the DataNodeTransmit object how many wires it
  45. // is expected to store data for.
  46. ////////////////////////////////////////////////////////////////////
  47. INLINE void DataNodeTransmit::
  48. reserve(int num_wires) {
  49. _data.reserve(num_wires);
  50. }
  51. ////////////////////////////////////////////////////////////////////
  52. // Function: DataNodeTransmit::get_data
  53. // Access: Public
  54. // Description: Extracts the data for the indicated index, if it has
  55. // been stored, or the empty parameter if it has not.
  56. ////////////////////////////////////////////////////////////////////
  57. INLINE const EventParameter &DataNodeTransmit::
  58. get_data(int index) const {
  59. if (index >= 0 && index < (int)_data.size()) {
  60. return _data[index];
  61. }
  62. static EventParameter empty_parameter;
  63. return empty_parameter;
  64. }
  65. ////////////////////////////////////////////////////////////////////
  66. // Function: DataNodeTransmit::has_data
  67. // Access: Public
  68. // Description: Returns true if the indicated parameter has been
  69. // stored, false otherwise.
  70. ////////////////////////////////////////////////////////////////////
  71. INLINE bool DataNodeTransmit::
  72. has_data(int index) const {
  73. if (index >= 0 && index < (int)_data.size()) {
  74. return !_data[index].is_empty();
  75. }
  76. return false;
  77. }
  78. ////////////////////////////////////////////////////////////////////
  79. // Function: DataNodeTransmit::set_data
  80. // Access: Public
  81. // Description: Sets the data for the indicated parameter.
  82. ////////////////////////////////////////////////////////////////////
  83. INLINE void DataNodeTransmit::
  84. set_data(int index, const EventParameter &data) {
  85. if (index >= (int)_data.size()) {
  86. slot_data(index);
  87. }
  88. nassertv(index >= 0 && index < (int)_data.size());
  89. _data[index] = data;
  90. }