ADTF
Loading...
Searching...
No Matches
adtf::filter::private_implementations::cSubstreamNameFilter Class Reference

#include <substream_name_filter.h>

Classes

struct  tFilterBase
 
struct  tPlain
 
struct  tPrefix
 
struct  tRegex
 
struct  tRegexFilterBase
 
struct  tStreamFilter
 
struct  tWildcard
 

Public Types

enum class  tFilterMode : uint8_t {
  Plain = 0 , PrefixTrim = 1 , Prefix = 2 , Wildcard = 3 ,
  Regex = 4
}
 
using tFilter = std::variant<tPlain, tPrefix, tWildcard, tRegex>
 Variant holding the filter specialization.
 
using tStreamAttributes = std::map<std::string, std::variant<bool, double, std::string>>
 Storage type for additional stream attributes.
 

Public Member Functions

 cSubstreamNameFilter () noexcept
 
 cSubstreamNameFilter (const cSubstreamNameFilter &)
 
 cSubstreamNameFilter (cSubstreamNameFilter &&) noexcept
 
 cSubstreamNameFilter (std::string_view strFileName, std::optional< tFilterMode > oTextModeOverride)
 
 cSubstreamNameFilter (std::vector< tStreamFilter > oStreamFilters) noexcept
 
 ~cSubstreamNameFilter ()
 
void Reset (std::vector< tStreamFilter > oStreamFilters={}) noexcept
 
void AddFilter (const tFilter &oFilter, const tStreamAttributes &oAttributes={})
 
void AddFilterFile (std::string_view strFileName, std::optional< tFilterMode > oTextModeOverride)
 
void SaveFiltersToFile (std::string_view strFileName, std::optional< tFilterMode > oTextModeOverride)
 
tResult RemoveFilter (const tFilter &oFilter) noexcept
 
std::vector< tStreamFilterGetStreamFilters () const &noexcept
 
std::vector< tStreamFilter > && GetStreamFilters () &&noexcept
 
bool Matches (std::string_view strName) const noexcept
 
bool PrefixMatches (std::string_view strName) const
 
void Select (std::string_view strPrefix, const adtf::streaming::ant::IStreamType &oType, const std::function< void(std::string_view, uint32_t, const tStreamFilter &, const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::IStreamType > &)> &fnSelectedCallback, bool bInverseMatch=false) const
 
void Select (const adtf::streaming::ant::IStreamType &oType, const std::function< void(std::string_view, uint32_t, const tStreamFilter &, const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::IStreamType > &)> &fnSelectedCallback, bool bInverseMatch=false) const
 

Static Public Member Functions

static std::string WildcardToRegex (std::string_view strString)
 
static std::string EscapeRegularExpression (std::string_view strString)
 

Detailed Description

Utility class to define substream name filters either from file or from string. Allows to match the substreams defined from streamtypes against these filters.

Member Enumeration Documentation

◆ tFilterMode

Legacy: Supported filter modes. Only required if filters are imported from legacy text files.

Constructor & Destructor Documentation

◆ cSubstreamNameFilter() [1/5]

adtf::filter::private_implementations::cSubstreamNameFilter::cSubstreamNameFilter ( )
noexcept

CTOR

◆ cSubstreamNameFilter() [2/5]

adtf::filter::private_implementations::cSubstreamNameFilter::cSubstreamNameFilter ( const cSubstreamNameFilter & )

Copy CTOR

◆ cSubstreamNameFilter() [3/5]

adtf::filter::private_implementations::cSubstreamNameFilter::cSubstreamNameFilter ( cSubstreamNameFilter && )
noexcept

Move CTOR

◆ cSubstreamNameFilter() [4/5]

adtf::filter::private_implementations::cSubstreamNameFilter::cSubstreamNameFilter ( std::string_view strFileName,
std::optional< tFilterMode > oTextModeOverride )

Construct a new cSubstreamNameFilter from a given input file.

Parameters
strFileNameThe file path.
oTextModeOverrideSpecifies the filtermode if a text file is passed. In this case, the filtermode must be set!

◆ cSubstreamNameFilter() [5/5]

adtf::filter::private_implementations::cSubstreamNameFilter::cSubstreamNameFilter ( std::vector< tStreamFilter > oStreamFilters)
noexcept

Construct a new cSubstreamNameFilter from an existing filter set.

Parameters
oStreamFiltersThe filter set to be imported.

◆ ~cSubstreamNameFilter()

adtf::filter::private_implementations::cSubstreamNameFilter::~cSubstreamNameFilter ( )

DTOR

Member Function Documentation

◆ AddFilter()

void adtf::filter::private_implementations::cSubstreamNameFilter::AddFilter ( const tFilter & oFilter,
const tStreamAttributes & oAttributes = {} )

Adds a filter.

Parameters
oFilterThe filter to be added.
oAttributesAdditional attributes.

◆ AddFilterFile()

void adtf::filter::private_implementations::cSubstreamNameFilter::AddFilterFile ( std::string_view strFileName,
std::optional< tFilterMode > oTextModeOverride )

Adds filters loaded from file.

Parameters
strFileNameThe file path.
oTextModeOverrideSpecifies the filtermode if a text file is passed. In this case, the filtermode must be set!

◆ EscapeRegularExpression()

static std::string adtf::filter::private_implementations::cSubstreamNameFilter::EscapeRegularExpression ( std::string_view strString)
static

Escapes a string so that it is usable as regular expression so that characters are not interpreted as regular expression characters.

Parameters
strStringThe string.

◆ GetStreamFilters() [1/2]

std::vector< tStreamFilter > && adtf::filter::private_implementations::cSubstreamNameFilter::GetStreamFilters ( ) &&
noexcept

Get the filters (by move).

◆ GetStreamFilters() [2/2]

std::vector< tStreamFilter > adtf::filter::private_implementations::cSubstreamNameFilter::GetStreamFilters ( ) const &
noexcept

Get the filters (by copy).

◆ Matches()

bool adtf::filter::private_implementations::cSubstreamNameFilter::Matches ( std::string_view strName) const
noexcept

Checks if any filter matches a name.

Parameters
strNameThe name.

◆ PrefixMatches()

bool adtf::filter::private_implementations::cSubstreamNameFilter::PrefixMatches ( std::string_view strName) const

Determines whether a given name (prefix-)matches a substreamname filter.

Parameters
strNameThe name.

◆ RemoveFilter()

tResult adtf::filter::private_implementations::cSubstreamNameFilter::RemoveFilter ( const tFilter & oFilter)
noexcept

Removes a filter.

Parameters
oFilterThe filter to be added.

◆ Reset()

void adtf::filter::private_implementations::cSubstreamNameFilter::Reset ( std::vector< tStreamFilter > oStreamFilters = {})
noexcept

Resets all filters to a predefined set of filters.

Parameters
oStreamFiltersThe filter set to be set.

◆ SaveFiltersToFile()

void adtf::filter::private_implementations::cSubstreamNameFilter::SaveFiltersToFile ( std::string_view strFileName,
std::optional< tFilterMode > oTextModeOverride )

Saves the filters to file.

Parameters
strFileNameThe file path.
oTextModeOverrideSpecifies the filtermode if a text file is passed. In this case, the filtermode must be set! For text files, only filters matching the filtermode will be written to the file. This does not apply for Regex filtermode which tries to convert other filters to regular expressions.

◆ Select() [1/2]

void adtf::filter::private_implementations::cSubstreamNameFilter::Select ( const adtf::streaming::ant::IStreamType & oType,
const std::function< void(std::string_view, uint32_t, const tStreamFilter &, const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::IStreamType > &)> & fnSelectedCallback,
bool bInverseMatch = false ) const

Filters substreams from streamtype and calls back a function on them.

Parameters
oTypeThe streamtype.
fnSelectedCallbackThe callback function.
bInverseMatchIf set to true, the callback is invoked for substreams that do not match any filter instead of those that do.

◆ Select() [2/2]

void adtf::filter::private_implementations::cSubstreamNameFilter::Select ( std::string_view strPrefix,
const adtf::streaming::ant::IStreamType & oType,
const std::function< void(std::string_view, uint32_t, const tStreamFilter &, const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::IStreamType > &)> & fnSelectedCallback,
bool bInverseMatch = false ) const

Filters substreams from streamtype and calls back a function on them.

Parameters
strPrefixA prefix which will be prepended to the substream names.
oTypeThe streamtype.
fnSelectedCallbackThe callback function.
bInverseMatchIf set to true, the callback is invoked for substreams that do not match any filter instead of those that do.

◆ WildcardToRegex()

static std::string adtf::filter::private_implementations::cSubstreamNameFilter::WildcardToRegex ( std::string_view strString)
static

Transforms a string containing wildcards to a regex string.

Parameters
strStringThe string.

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