![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
This module provides filters that can be attached to serial channels in order to extend their functionality by processing their inputs and/or outputs. A filter is an object that behaves as a channel; it is attached to another channel that produces or absorbes the data, while it only changes or monitorizes those data.

Classes | |
| class | elementa::base::SerChIFilter< F > |
| A filter for InSerCh. It filters their inputs after getting or putbacking'em. More... | |
| class | elementa::base::SerChOFilter< F > |
| A filter for output channels. It processes their outputs before writing them. More... | |
| class | elementa::base::SerChIOFilter< FI, FO > |
| A double filter for input/output channels. More... | |
| class | elementa::base::SerChFilt_Loc |
| A filter to keep a location on a channel. More... | |
| class | elementa::base::SerChFilt_Demux |
| A filter that serves data from multiple input channels. More... | |
| class | elementa::base::SerChFilt_Divert |
| A filter that sends a copy of the readings of an InSerCh to another channel. More... | |
Functions | |
| elementa::base::ELE_CLASS_ENUM (SerChBufOp, kUFlow, kUnderflow, kPBackFail, kOverflow) | |
| The different buffer operations that may produce the filter to be called. | |
| template<class F > | |
| SerChDatum | elementa::base::serch_filtered_uflow (InSerCh &wrappingchin_, InSerCh &chin_, F &filter_) |
| Intended to implement uflow() in input or inout channels filtered by FILTER_. More... | |
| template<class F > | |
| SerChDatum | elementa::base::serch_filtered_underflow (InSerCh &wrappingchin_, InSerCh &chin_, F &filter_) |
| Intended to implement underflow() in input/inout chnnels filtered by FILTER_. More... | |
| template<class F > | |
| SerChDatum | elementa::base::serch_filtered_pbackfail (InSerCh &wrappingchin_, InSerCh &chin_, F &filter_, SerChDatum c) |
| Intended to implement pbackfail() in input/inout chnnels filtered by FILTER_. More... | |
| template<class F > | |
| SerChDatum | elementa::base::serch_filtered_overflow (OutSerCh &wrappingchout_, OutSerCh &chout_, F &filter_, SerChDatum c) |
| Intended to implement overflow() in output/inout chnnels filtered by FILTER_. More... | |
| template<class F > | |
| SerChIFilter< F > | elementa::base::make_schfiltI (InSerCh &sch, const F &f) |
| Creator of a SerChIFilter that deduces automatically the type of the filter. More... | |
| template<class F > | |
| SerChOFilter< F > | elementa::base::make_schfiltO (OutSerCh &sch, const F &f) |
| Creator of a SerChOFilter that deduces automatically the type of the filter. More... | |
| template<class FI , class FO > | |
| SerChIOFilter< FI, FO > | elementa::base::make_schfiltIO (InOutSerCh &sch, const FI &f1, const FO &f2) |
| Creator of a SerChIOFilter that deduces automatically the type of the filter. More... | |
Variables | |
| std::function< SerChDatum(RootSerCh &, SerChBufOp, SerChDatum) > | elementa::base::serchfilt_null |
| Change nothing in the flow of the channel. | |
| std::function< SerChDatum(RootSerCh &, SerChBufOp, SerChDatum) > | elementa::base::serchfilt_toupper |
| Change to uppercase everything flowing through the channel. | |
| std::function< SerChDatum(RootSerCh &, SerChBufOp, SerChDatum) > | elementa::base::serchfilt_tolower |
| Change to lowercase everything flowing through the channel. | |
| class elementa::base::SerChIFilter |
A filter for InSerCh. It filters their inputs after getting or putbacking'em.
| F | is the filter. It must be copy-constructible and callable with the prototype SerChDatum(InSerCh &, SerChBufOp, SerChDatum). |


Public Member Functions | |
| SerChIFilter (InSerCh &inch, const F &filter=F{}) | |
| Constructor. More... | |
| SerChIFilter (SerChIFilter &&oth) | |
| Move constructor from another with same filters. Share same channel. More... | |
| InSerCh & | channel (void) noexcept |
| Getter for the referenced channel. More... | |
| F & | filter (void) noexcept |
| Getter for the internal filter function. More... | |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Getter for the internal filter function.
Definition at line 149 of file filters.h.
Referenced by elementa::base::SerChFilt_Loc::get_loc().
| class elementa::base::SerChOFilter |
A filter for output channels. It processes their outputs before writing them.
| F | is the filter. It must be copy-constructible and callable with the prototype SerChDatum(InSerCh &, SerChBufOp, SerChDatum). |


Public Member Functions | |
| SerChOFilter (OutSerCh &chout, const F &filter=F{}) | |
| Constructor. More... | |
| SerChOFilter (SerChOFilter &&oth) | |
| Move constructor from another with same filters. Share same channel. More... | |
| OutSerCh & | channel (void) noexcept |
| Getter for the referenced channel. More... | |
| F & | filter (void) noexcept |
| Getter for the internal filter function. More... | |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Getter for the internal filter function.
Definition at line 231 of file filters.h.
Referenced by elementa::base::SerChFilt_Loc::get_loc().
| class elementa::base::SerChIOFilter |
A double filter for input/output channels.
| FI,FO | are the filters. They must be copy-constructible and callable with the prototype SerChDatum(InSerCh &, SerChBufOp, SerChDatum). |


Public Member Functions | |
| SerChIOFilter (InOutSerCh &chinout, const FI &filterin=FI{}, const FO &filterout=FO{}) | |
| Constructor More... | |
| SerChIOFilter (SerChIOFilter &&oth) | |
| Move constructor from another with same filters. Share same channel. More... | |
| OutSerCh & | channel (void) noexcept |
| Getter for the referenced channel. More... | |
| FI & | filterIn (void) noexcept |
| Getter for the internal input filter function. More... | |
| FO & | filterOut (void) noexcept |
| Getter for the internal output filter function. More... | |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
| class elementa::base::SerChFilt_Loc |
A filter to keep a location on a channel.
The specific kind of location class to use is in the constructor.

Static Public Member Functions | |
| template<class L > | |
| static SerChIFilter< SerChFilt_Loc > | make_filtch (InSerCh &isch) |
| Return a SerChIFilter that uses a new location object of class L. More... | |
| template<class L > | |
| static SerChOFilter< SerChFilt_Loc > | make_filtch (OutSerCh &osch) |
| Return a SerChOFilter that uses a new location object of class L. More... | |
| template<class L > | |
| static L & | get_loc (SerChIFilter< SerChFilt_Loc > &fch) |
| Get the downcast location object of class L from the filtered channel. More... | |
| template<class L > | |
| static L & | get_loc (SerChOFilter< SerChFilt_Loc > &fch) |
| Get the downcast location object of class L from the filtered channel. More... | |
Public Attributes | |
| SerChLoc::Ptr | ploc |
| Location object, updated by the () operator. More... | |
Public Member Functions | |
| SerChFilt_Loc (const SerChLoc &loc=SerChLocText{}) | |
| Default constructor. By default, SerChLocText is used for locations. More... | |
| SerChFilt_Loc (const SerChLoc::Ptr &pl) | |
| Constructor from an already existing location object. More... | |
| SerChDatum | operator() (RootSerCh &, SerChBufOp op, SerChDatum c) |
|
inline |
Default constructor. By default, SerChLocText is used for locations.
A clone of the given location object is stored here.
|
inline |
|
inlinestatic |
Return a SerChIFilter that uses a new location object of class L.
|
inlinestatic |
Return a SerChOFilter that uses a new location object of class L.
|
inlinestatic |
Get the downcast location object of class L from the filtered channel.
Definition at line 451 of file filters.h.
References elementa::base::SerChIFilter< F >::filter().
|
inlinestatic |
Get the downcast location object of class L from the filtered channel.
Definition at line 456 of file filters.h.
References elementa::base::SerChOFilter< F >::filter().
| SerChLoc::Ptr elementa::base::SerChFilt_Loc::ploc |
| class elementa::base::SerChFilt_Demux |
A filter that serves data from multiple input channels.
The user selects which channel is providing data at each time through a predicate function.
Public Types | |
| using | SelPred = std::function< InSerCh &(void) > |
| Prototype of the predicate used for selecting a channel from the list. More... | |
Public Member Functions | |
| SerChFilt_Demux (SelPred pred) | |
| Constructor: it admits the selection predicate. More... | |
| SerChDatum | operator() (RootSerCh &, SerChBufOp op, SerChDatum c) |
| Each time this method is called, the predicate function is called. | |
| using elementa::base::SerChFilt_Demux::SelPred = std::function< InSerCh & (void) > |
| class elementa::base::SerChFilt_Divert |
A filter that sends a copy of the readings of an InSerCh to another channel.
The channel is used normally as an input channel, but, in addition to serve chars to the user, sends those very chars to another output channel. If the user calls peek() or pbackfail(), the result will not be diverted to the other output channel; that only happens if the user calls get() or read().
Public Member Functions | |
| SerChFilt_Divert (OutSerCh &div) | |
| Constructor. More... | |
| SerChDatum | operator() (RootSerCh &, SerChBufOp op, SerChDatum c) |
| SerChDatum elementa::base::serch_filtered_uflow | ( | InSerCh & | wrappingchin_, |
| InSerCh & | chin_, | ||
| F & | filter_ | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Intended to implement uflow() in input or inout channels filtered by FILTER_.
This function is of private use of the SerCh*Filter classes, not intended to be called by the final user. It is here since it is needed by the template classes SerCh*Filter.
| F | must be a FunctionObject callable like SerChFilterProc. |
Definition at line 563 of file filters.h.
References ELE_CODE_TRACE_OFF, elementa::base::kSerChEOF, elementa::base::serch_copy_st(), and elementa::base::serch_st_to_string().
| SerChDatum elementa::base::serch_filtered_underflow | ( | InSerCh & | wrappingchin_, |
| InSerCh & | chin_, | ||
| F & | filter_ | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Intended to implement underflow() in input/inout chnnels filtered by FILTER_.
This function is of private use of the SerCh*Filter classes, not intended to be called by the final user. It is here since it is needed by the template classes SerCh*Filter.
| F | must be a FunctionObject callable like SerChFilterProc. |
Definition at line 586 of file filters.h.
References ELE_CODE_TRACE_OFF, elementa::base::kSerChEOF, elementa::base::serch_copy_st(), and elementa::base::serch_st_to_string().
| SerChDatum elementa::base::serch_filtered_pbackfail | ( | InSerCh & | wrappingchin_, |
| InSerCh & | chin_, | ||
| F & | filter_, | ||
| SerChDatum | c | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Intended to implement pbackfail() in input/inout chnnels filtered by FILTER_.
This function is of private use of the SerCh*Filter classes, not intended to be called by the final user. It is here since it is needed by the template classes SerCh*Filter.
| F | must be a FunctionObject callable like SerChFilterProc. |
Definition at line 609 of file filters.h.
References ELE_CODE_TRACE_OFF, elementa::base::kSerChEOF, elementa::base::serch_copy_st(), and elementa::base::serch_st_to_string().
| SerChDatum elementa::base::serch_filtered_overflow | ( | OutSerCh & | wrappingchout_, |
| OutSerCh & | chout_, | ||
| F & | filter_, | ||
| SerChDatum | c | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Intended to implement overflow() in output/inout chnnels filtered by FILTER_.
This function is of private use of the SerCh*Filter classes, not intended to be called by the final user. It is here since it is needed by the template classes SerCh*Filter.
| F | must be a FunctionObject callable like SerChFilterProc. |
Definition at line 641 of file filters.h.
References elementa::base::kSerChEOF, and elementa::base::serch_copy_st().
| SerChIFilter< F > elementa::base::make_schfiltI | ( | InSerCh & | sch, |
| const F & | f | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Creator of a SerChIFilter that deduces automatically the type of the filter.
| SerChOFilter< F > elementa::base::make_schfiltO | ( | OutSerCh & | sch, |
| const F & | f | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Creator of a SerChOFilter that deduces automatically the type of the filter.
| SerChIOFilter< FI, FO > elementa::base::make_schfiltIO | ( | InOutSerCh & | sch, |
| const FI & | f1, | ||
| const FO & | f2 | ||
| ) |
#include <elementa/base/serial_channels/filters.h>
Creator of a SerChIOFilter that deduces automatically the type of the filter.