GrPPI
1.0
Generic and Reusable Parallel Pattern Interface
|
The filter (or stream filter) is a streaming pattern that discards items from a data stream based on a predicate, so that only data items satisfying (keep) or dissatisfying (discard) the predicate are passed to the next stage. This streaming pattern can only be used inside another pattern and consequently does not take an execution policy itself, but uses the execution policy of its enclosing pattern.
The interface to the filter pattern is provided by functions grppi::keep()
and grppi::discard()
.
There is a single variant:
The central element in a filter is the Predicate. The operation may be any C++ callable entity. This operation, is a unary operation taking a data item and returning value that is contextually convertible to bool
. Thus, a predicate pred
is any operation, that given a value x
of type T
, makes the following valid:
A composable filter has a single element:
The input values will be generated by the upper level pattern, which will be also responsible for consuming the output values.
Example: A filter stage in a pipeline.
Note: For brevity we do not show here the details of other stages.
For composing complex patterns, the keep()
and discard()
functions may be used to create an object that may be supplied to another pattern to build a composed pattern.
Example: A composable filter stage in a pipeline.
Note: For brevity we do not show here the details of other stages.