45 DataConnections::const_iterator ci;
46 for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) {
47 const DataConnection &connect = (*ci);
49 inputs[connect._parent_index].
get_data(connect._output_index);
50 if (!data.is_empty()) {
51 new_input.
set_data(connect._input_index, data);
56 if (dgraph_cat.is_spam()) {
57 bool any_data =
false;
58 Wires::const_iterator wi;
59 for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
60 const string &name = (*wi).first;
61 const WireDef &def = (*wi).second;
62 if (new_input.
has_data(def._index)) {
65 << *
this <<
" receives:\n";
68 dgraph_cat.spam(
false)
69 <<
" " << name <<
" = " << new_input.
get_data(def._index)
76 do_transmit_data(trav, new_input, output);
79 if (dgraph_cat.is_spam()) {
80 bool any_data =
false;
81 Wires::const_iterator wi;
82 for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) {
83 const string &name = (*wi).first;
84 const WireDef &def = (*wi).second;
88 << *
this <<
" transmits:\n";
91 dgraph_cat.spam(
false)
92 <<
" " << name <<
" = " << output.
get_data(def._index)
106 Wires::const_iterator wi;
107 for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
108 const string &name = (*wi).first;
109 const WireDef &def = (*wi).second;
110 out << name <<
" " << def._data_type <<
"\n";
120 Wires::const_iterator wi;
121 for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) {
122 const string &name = (*wi).first;
123 const WireDef &def = (*wi).second;
124 out << name <<
" " << def._data_type <<
"\n";
134 DataConnections::const_iterator ci;
135 for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) {
136 const DataConnection &connect = (*ci);
137 nassertv(connect._parent_index >= 0 && connect._parent_index <
get_num_parents());
141 Wires::const_iterator wi;
143 for (wi = _input_wires.begin(); wi != _input_wires.end() && !found; ++wi) {
144 const string &name = (*wi).first;
145 const WireDef &def = (*wi).second;
146 if (def._index == connect._input_index) {
147 out << name <<
" " << def._data_type <<
" from " 148 << *
get_parent(connect._parent_index) <<
"\n";
169 define_input(
const string &name,
TypeHandle data_type) {
171 nassertr(_data_connections.empty(), 0);
174 wi = _input_wires.find(name);
175 if (wi != _input_wires.end()) {
177 WireDef &def = (*wi).second;
178 def._data_type = data_type;
183 WireDef &def = _input_wires[name];
184 def._data_type = data_type;
185 def._index = _input_wires.size() - 1;
202 define_output(
const string &name,
TypeHandle data_type) {
204 nassertr(_data_connections.empty(), 0);
207 wi = _output_wires.find(name);
208 if (wi != _output_wires.end()) {
210 WireDef &def = (*wi).second;
211 def._data_type = data_type;
216 WireDef &def = _output_wires[name];
217 def._data_type = data_type;
218 def._index = _output_wires.size() - 1;
229 PandaNode::parents_changed();
253 _data_connections.clear();
255 int num_datanode_parents = 0;
257 Wires::const_iterator wi;
258 for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
259 const string &name = (*wi).first;
260 const WireDef &input_def = (*wi).second;
263 for (
int i = 0; i < num_parents; i++) {
265 if (parent_node->
is_of_type(DataNode::get_class_type())) {
267 num_datanode_parents++;
268 Wires::const_iterator pi;
269 pi = data_node->_output_wires.find(name);
270 if (pi != data_node->_output_wires.end()) {
271 const WireDef &output_def = (*pi).second;
273 if (output_def._data_type != input_def._data_type) {
275 <<
"Ignoring mismatched type for connection " << name
276 <<
" between " << *data_node <<
" and " << *
this <<
"\n";
279 dc._parent_index = i;
280 dc._output_index = output_def._index;
281 dc._input_index = input_def._index;
282 _data_connections.push_back(dc);
289 if (dgraph_cat.is_debug()) {
291 <<
"Multiple connections found for " << name <<
" into " << *
this 298 num_datanode_parents != 0) {
300 <<
"No data connected to " << *
this <<
"\n";
319 PandaNode::fillin(scan, manager);
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A basic node of the scene graph or data graph.
The fundamental type of node for the data graph.
void write_connections(std::ostream &out) const
Writes to the indicated ostream a list of all the connections currently showing between this DataNode...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An optional parameter associated with an event.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_num_parents
Returns the number of parent nodes this node has.
void write_inputs(std::ostream &out) const
Writes to the indicated ostream a list of all the inputs this DataNode might expect to receive.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
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.
get_parent
Returns the nth parent node of this node.
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 is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
void transmit_data(DataGraphTraverser *trav, const DataNodeTransmit inputs[], DataNodeTransmit &output)
Collects the data from all of the parent nodes and puts it into one DataNodeTransmit object,...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
int get_num_inputs() const
Returns the number of different inputs that have been defined for this node using define_input().
Encapsulates the data generated from (or sent into) any particular DataNode.
void write_outputs(std::ostream &out) const
Writes to the indicated ostream a list of all the outputs this DataNode might generate.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...