Overview

Your process must always create all of its outputs in case any of them are needed. However, it may often be the case that one or more process output Ports is not "Listened" - that is, it it neither Linked to some input Port nor logged by the user. For some outputs, there may be a non-negligible computational saving in choosing not to write real data to them - indeed, you may avoid massive computations if a particular output is not going to be seen by anyone.

You must check this flag in EVENT_INIT_POSTCONNECT; before this, its value is undefined.

Example

This is derived from the test component "listened", which was accessible at time of writing here.

C++ Source Code (against 1199)
class COMPONENT_CLASS_CPP : public Process { // output port numeric::Output output; ... }; Symbol COMPONENT_CLASS_CPP::event(Event* event) { switch(event->type) { ... case EVENT_INIT_POSTCONNECT: { // get listened state of port listened = output.getFlags() & F_LISTENED; bout << "listened == " << listened << D_INFO; ... } case EVENT_RUN_SERVICE: { // only do the work if somebody's listening... if (listenedA) { // access content p_data = (DOUBLE*) outputA.getContent(); doMassiveComputation(p_data); } ... } } // not serviced return S_NULL; }