CProcessingElement

Name

CProcessingElement -- Abstract base class for a CSP processing element

Synopsis


#include <CProcessingElement>

class CProcessingElement
{
public:
virtual ~CProcessingElement() {}

virtual void operator()()  = 0;
virtual void process(void* pData, size_t nBytes) = 0;
};

        

DESCRIPTION

Processing elements contain flow of control that typically accepts data, processes it and then sends resulting data to a subsequent stage of the data processing pipeline. Concrete CProcessingElements often construct with parameters that include a CReceiver to receive the data, a CSender to send processed data and a CProcessor to do the actual processing.

In the prototoypical processing element, the operator() method will use the objects' CReceiver to obtain work elements. process would then be called which would, in turn, call the process method of an encapsulated CProcessor object.

operator() would also be responsible for knowing when the last work item has been received and shutting down the object after that has been processed. In a typical, application, an empty data item might be a flag that there are no more data items and the processor's process would, in turn, be responsible for notifying subsequent stages of the computation, if appropriate.

Concrete classes must implement both operator() and process.

METHODS

virtual = 0 void operator()();

This method is supposed to implement the flow of control of the processing element. Normally this is a loop with the logic like the pseudocode below


do {
workItem = getWorkItem()
process(workItemData, workItemSize)
free the Work item
} while(workItem is not end of data)
Shutdown the object
                        

virtual =0 void process(void* pData, size_t nBytes);

Processes a work item of data received by operator(). Normally, implementations of this method have the form:


outputData = processTheData(pData, nBytes)
sendToNextStage(outputData)