16 #include "dataNodeTransmit.h" 17 #include "config_dgraph.h" 50 DataConnections::const_iterator ci;
51 for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) {
52 const DataConnection &connect = (*ci);
54 inputs[connect._parent_index].
get_data(connect._output_index);
56 new_input.
set_data(connect._input_index, data);
61 if (dgraph_cat.is_spam()) {
62 bool any_data =
false;
63 Wires::const_iterator wi;
64 for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
65 const string &name = (*wi).first;
66 const WireDef &def = (*wi).second;
67 if (new_input.
has_data(def._index)) {
70 << *
this <<
" receives:\n";
73 dgraph_cat.spam(
false)
74 <<
" " << name <<
" = " << new_input.
get_data(def._index)
81 do_transmit_data(trav, new_input, output);
84 if (dgraph_cat.is_spam()) {
85 bool any_data =
false;
86 Wires::const_iterator wi;
87 for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) {
88 const string &name = (*wi).first;
89 const WireDef &def = (*wi).second;
93 << *
this <<
" transmits:\n";
96 dgraph_cat.spam(
false)
97 <<
" " << name <<
" = " << output.
get_data(def._index)
113 Wires::const_iterator wi;
114 for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
115 const string &name = (*wi).first;
116 const WireDef &def = (*wi).second;
117 out << name <<
" " << def._data_type <<
"\n";
129 Wires::const_iterator wi;
130 for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) {
131 const string &name = (*wi).first;
132 const WireDef &def = (*wi).second;
133 out << name <<
" " << def._data_type <<
"\n";
146 DataConnections::const_iterator ci;
147 for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) {
148 const DataConnection &connect = (*ci);
149 nassertv(connect._parent_index >= 0 && connect._parent_index <
get_num_parents());
153 Wires::const_iterator wi;
155 for (wi = _input_wires.begin(); wi != _input_wires.end() && !found; ++wi) {
156 const string &name = (*wi).first;
157 const WireDef &def = (*wi).second;
158 if (def._index == connect._input_index) {
159 out << name <<
" " << def._data_type <<
" from " 160 << *
get_parent(connect._parent_index) <<
"\n";
186 define_input(
const string &name,
TypeHandle data_type) {
188 nassertr(_data_connections.empty(), 0);
191 wi = _input_wires.find(name);
192 if (wi != _input_wires.end()) {
195 WireDef &def = (*wi).second;
196 def._data_type = data_type;
201 WireDef &def = _input_wires[name];
202 def._data_type = data_type;
203 def._index = _input_wires.size() - 1;
225 define_output(
const string &name,
TypeHandle data_type) {
227 nassertr(_data_connections.empty(), 0);
230 wi = _output_wires.find(name);
231 if (wi != _output_wires.end()) {
234 WireDef &def = (*wi).second;
235 def._data_type = data_type;
240 WireDef &def = _output_wires[name];
241 def._data_type = data_type;
242 def._index = _output_wires.size() - 1;
257 PandaNode::parents_changed();
289 _data_connections.clear();
291 int num_datanode_parents = 0;
293 Wires::const_iterator wi;
294 for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
295 const string &name = (*wi).first;
296 const WireDef &input_def = (*wi).second;
299 for (
int i = 0; i < num_parents; i++) {
301 if (parent_node->
is_of_type(DataNode::get_class_type())) {
303 num_datanode_parents++;
304 Wires::const_iterator pi;
305 pi = data_node->_output_wires.find(name);
306 if (pi != data_node->_output_wires.end()) {
307 const WireDef &output_def = (*pi).second;
309 if (output_def._data_type != input_def._data_type) {
311 <<
"Ignoring mismatched type for connection " << name
312 <<
" between " << *data_node <<
" and " << *
this <<
"\n";
315 dc._parent_index = i;
316 dc._output_index = output_def._index;
317 dc._input_index = input_def._index;
318 _data_connections.push_back(dc);
325 if (dgraph_cat.is_debug()) {
327 <<
"Multiple connections found for " << name <<
" into " << *
this 334 num_datanode_parents != 0) {
336 <<
"No data connected to " << *
this <<
"\n";
360 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.
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.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void write_inputs(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.
bool is_empty() const
Returns true if the EventParameter is the empty parameter, storing nothing, or false otherwise...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void write_connections(ostream &out) const
Writes to the indicated ostream a list of all the connections currently showing between this DataNode...
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.
int get_num_parents(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of parent nodes this node has.
PandaNode * get_parent(int n, Thread *current_thread=Thread::get_current_thread()) const
Returns the nth parent node of this node.
void write_outputs(ostream &out) const
Writes to the indicated ostream a list of all the outputs this DataNode might generate.
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.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...