Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
MutableFilter< SRC > Class Template Reference

#include "lib/iter-explorer.hpp"

Description

template<class SRC>
class lib::iter_explorer::MutableFilter< SRC >

Special variant of the Filter Decorator to allow for dynamic remoulding. This covers a rather specific use case, where we want to remould or even exchange the Filter predicate in the middle of an ongoing iteration. Such a remoulding can be achieved by binding the existing (opaque) filter predicate into a new combined lambda, thereby capturing it by value. After building, this remoulded version can be assigned to the original filter functor, under the assumption that both are roughly compatible. Moreover, since we wrap the actual lambda into an adapter, allowing for generic lambdas to be used as filter predicates, this setup allows for a lot of leeway regarding the concrete predicates.

Note
whenever the filter is remoulded, the invariant is immediately re-established, possibly forwarding the sequence to the next element approved by the new version of the filter.
Remarks
filter predicates can be specified in a wide variety of forms, and will be adapted automatically. This flexibility also holds for any of the additional clauses provided for remoulding the filter. Especially this means that functors of different kinds can be mixed and combined.

Definition at line 1214 of file iter-explorer.hpp.

Public Member Functions

 MutableFilter ()=default
 
template<typename FUN >
 MutableFilter (SRC &&dataSrc, FUN &&filterFun)
 
template<typename COND >
void andFilter (COND &&conjunctiveClause)
 remould existing predicate to require in addition the given clause to hold
 
template<typename COND >
void andNotFilter (COND &&conjunctiveClause)
 remould existing predicate to require in addition the negation of the given clause to hold
 
template<typename COND >
void orFilter (COND &&disjunctiveClause)
 remould existing predicate to require either the old OR the given new clause to hold
 
template<typename COND >
void orNotFilter (COND &&disjunctiveClause)
 remould existing predicate to require either the old OR the negation of a new clause to hold
 
void flipFilter ()
 remould existing predicate to negate the meaning of the existing clause
 
template<typename COND >
void setNewFilter (COND &&entirelyDifferentPredicate)
 replace the existing predicate with the given, entirely different predicate
 
void disableFilter ()
 discard filter predicates and disable any filtering
 
- Public Member Functions inherited from Filter< SRC >
 Filter ()=default
 
template<typename FUN >
 Filter (SRC &&dataSrc, FUN &&filterFun)
 
void expandChildren ()
 refresh state when other layers manipulate the source sequence.
 
bool checkPoint () const
 
SRC::reference yield () const
 
void iterNext ()
 

Private Types

using _Filter = Filter< SRC >
 

Private Member Functions

template<typename COND , class COMB >
void remouldFilter (COND &&additionalClause, COMB buildCombinedClause)
 

Additional Inherited Members

- Protected Types inherited from Filter< SRC >
using FilterPredicate = function< bool(SRC &)>
 
- Protected Member Functions inherited from Filter< SRC >
SRC & srcIter () const
 
bool isDisabled () const
 
void pullFilter ()
 
- Protected Attributes inherited from Filter< SRC >
FilterPredicate predicate_
 

Constructor & Destructor Documentation

◆ MutableFilter() [1/2]

template<class SRC >
MutableFilter ( )
default

◆ MutableFilter() [2/2]

template<class SRC >
template<typename FUN >
MutableFilter ( SRC &&  dataSrc,
FUN &&  filterFun 
)
inline

Definition at line 1225 of file iter-explorer.hpp.

Member Typedef Documentation

◆ _Filter

template<class SRC >
using _Filter = Filter<SRC>
private

Definition at line 1217 of file iter-explorer.hpp.

Member Function Documentation

◆ andFilter()

template<class SRC >
template<typename COND >
void andFilter ( COND &&  conjunctiveClause)
inline

remould existing predicate to require in addition the given clause to hold

Definition at line 1235 of file iter-explorer.hpp.

References MutableFilter< SRC >::remouldFilter().

+ Here is the call graph for this function:

◆ andNotFilter()

template<class SRC >
template<typename COND >
void andNotFilter ( COND &&  conjunctiveClause)
inline

remould existing predicate to require in addition the negation of the given clause to hold

Definition at line 1251 of file iter-explorer.hpp.

References MutableFilter< SRC >::remouldFilter().

+ Here is the call graph for this function:

◆ orFilter()

template<class SRC >
template<typename COND >
void orFilter ( COND &&  disjunctiveClause)
inline

remould existing predicate to require either the old OR the given new clause to hold

Definition at line 1267 of file iter-explorer.hpp.

References MutableFilter< SRC >::remouldFilter().

+ Here is the call graph for this function:

◆ orNotFilter()

template<class SRC >
template<typename COND >
void orNotFilter ( COND &&  disjunctiveClause)
inline

remould existing predicate to require either the old OR the negation of a new clause to hold

Definition at line 1283 of file iter-explorer.hpp.

References MutableFilter< SRC >::remouldFilter().

+ Here is the call graph for this function:

◆ flipFilter()

template<class SRC >
void flipFilter ( )
inline

remould existing predicate to negate the meaning of the existing clause

Definition at line 1298 of file iter-explorer.hpp.

References MutableFilter< SRC >::remouldFilter().

+ Here is the call graph for this function:

◆ setNewFilter()

template<class SRC >
template<typename COND >
void setNewFilter ( COND &&  entirelyDifferentPredicate)
inline

replace the existing predicate with the given, entirely different predicate

Definition at line 1314 of file iter-explorer.hpp.

References MutableFilter< SRC >::remouldFilter().

+ Here is the call graph for this function:

◆ disableFilter()

template<class SRC >
void disableFilter ( )
inline

discard filter predicates and disable any filtering

Definition at line 1328 of file iter-explorer.hpp.

◆ remouldFilter()

template<class SRC >
template<typename COND , class COMB >
void remouldFilter ( COND &&  additionalClause,
COMB  buildCombinedClause 
)
inlineprivate

boilerplate to remould the filter predicate in-place

Parameters
additionalClauseadditional functor object to combine
buildCombinedClausea generic lambda (important!) to define how exactly the old and the new predicate are to be combined
Note
the actual combination logic is handed in as generic lambda, which essentially is a template class, and this allows to bind to any kind of function objects or lambdas. This combination closure requires a specific setup: when invoked with the existing and the new functor as argument, it needs to build a new likewise generic lambda to perform the combined evaluation.
Warning
the handed-in lambda buildCombinedClause must capture its arguments, the existing functors by value. This is the key piece in the puzzle, since it effectively moves the existing functor into a new heap allocated storage.

Definition at line 1352 of file iter-explorer.hpp.

References lib::iter_explorer::ACCEPT_ALL.

Referenced by MutableFilter< SRC >::andFilter(), MutableFilter< SRC >::andNotFilter(), MutableFilter< SRC >::flipFilter(), MutableFilter< SRC >::orFilter(), MutableFilter< SRC >::orNotFilter(), and MutableFilter< SRC >::setNewFilter().

+ Here is the caller graph for this function:
+ Inheritance diagram for MutableFilter< SRC >:
+ Collaboration diagram for MutableFilter< SRC >:

The documentation for this class was generated from the following file: