Panda3D
 All Classes Functions Variables Enumerations
dataNodeTransmit.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: DataNodeTransmit::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE DataNodeTransmit::
22 DataNodeTransmit() {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: DataNodeTransmit::Copy Constructor
27 // Access: Public
28 // Description:
29 ////////////////////////////////////////////////////////////////////
30 INLINE DataNodeTransmit::
31 DataNodeTransmit(const DataNodeTransmit &copy) :
32  _data(copy._data)
33 {
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: DataNodeTransmit::Copy Assignment Operator
38 // Access: Public
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 INLINE void DataNodeTransmit::
42 operator = (const DataNodeTransmit &copy) {
43  _data = copy._data;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: DataNodeTransmit::reserve
48 // Access: Public
49 // Description: Tells the DataNodeTransmit object how many wires it
50 // is expected to store data for.
51 ////////////////////////////////////////////////////////////////////
52 INLINE void DataNodeTransmit::
53 reserve(int num_wires) {
54  _data.reserve(num_wires);
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: DataNodeTransmit::get_data
59 // Access: Public
60 // Description: Extracts the data for the indicated index, if it has
61 // been stored, or the empty parameter if it has not.
62 ////////////////////////////////////////////////////////////////////
64 get_data(int index) const {
65  if (index >= 0 && index < (int)_data.size()) {
66  return _data[index];
67  }
68  static EventParameter empty_parameter;
69  return empty_parameter;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: DataNodeTransmit::has_data
74 // Access: Public
75 // Description: Returns true if the indicated parameter has been
76 // stored, false otherwise.
77 ////////////////////////////////////////////////////////////////////
78 INLINE bool DataNodeTransmit::
79 has_data(int index) const {
80  if (index >= 0 && index < (int)_data.size()) {
81  return !_data[index].is_empty();
82  }
83  return false;
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: DataNodeTransmit::set_data
88 // Access: Public
89 // Description: Sets the data for the indicated parameter.
90 ////////////////////////////////////////////////////////////////////
91 INLINE void DataNodeTransmit::
92 set_data(int index, const EventParameter &data) {
93  if (index >= (int)_data.size()) {
94  slot_data(index);
95  }
96  nassertv(index >= 0 && index < (int)_data.size());
97  _data[index] = data;
98 }
An optional parameter associated with an event.
void reserve(int num_wires)
Tells the DataNodeTransmit object how many wires it is expected to store data for.
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
const EventParameter & get_data(int index) const
Extracts the data for the indicated index, if it has been stored, or the empty parameter if it has no...
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
Encapsulates the data generated from (or sent into) any particular DataNode.