|
void | declareInput () |
|
void | declareOutput () |
|
void | declareInput (SinkBase &sink, const std::string &name, const std::string &desc) |
|
void | declareInput (SinkBase &sink, int n, const std::string &name, const std::string &desc) |
|
void | declareInput (SinkBase &sink, int acquireSize, int releaseSize, const std::string &name, const std::string &desc) |
|
void | declareOutput (SourceBase &source, const std::string &name, const std::string &desc) |
|
void | declareOutput (SourceBase &source, int n, const std::string &name, const std::string &desc) |
|
void | declareOutput (SourceBase &source, int acquireSize, int releaseSize, const std::string &name, const std::string &desc) |
|
void | declareParameter (const std::string &name, const std::string &desc, const std::string &range, const Parameter &defaultValue) |
|
An AccumulatorAlgorithm is a special class of streaming algorithm that behaves in the following way:
- during most of the processing, it just consumes whatever comes in on its defined input (unique), and use that to maintain an internal state
- when the end of the stream is reached, it computes a resulting value and outputs it on its defined source(s).
By subclassing the AccumulatorAlgorithm class, you get all the buffering and data management done for you. In exchange, you just need to implement 2 methods:
- void consume(); which will be called during the processing. When called, you can safely assume that the data has already been acquired on your defined input sink
- void finalProduce(); which will be called at the end of the stream, when all the tokens will have been fed to the consume() method. You will have to explicitly push your result
You will also need to declare your input sink and output source using the specialized declareInputStream
and declareOutputResult
methods, instead of the standard declareInput
and declareOutput
ones.
As an example, please refer to the source code of the TCToTotal algorithm.
WARNING: declaring multiple input streams will result in undefined behavior. Multiple output results are fine, though.
WARNING: if you overload the reset() method, do not forget to call the base class implementation in it.