Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
AssetFilter Class Reference

Class that contains all data required for an asset filter: More...

#include <cs_AssetFilter.h>

Inheritance diagram for AssetFilter:
Collaboration diagram for AssetFilter:

Public Member Functions

 AssetFilter (uint8_t *data)
 
 ~AssetFilter ()=default
 
asset_filter_runtime_data_truntimedata ()
 Get the runtime data. More...
 
AssetFilterData filterdata ()
 Get the filter data. More...
 
size_t size () override
 Number of bytes of the data, according to the metadata contained in it. More...
 
bool contains (const void *key, size_t keyLengthInBytes) override
 
bool isValid () override
 
bool filterAcceptsScannedDevice (const scanned_device_t &asset)
 Returns true if the device passes the filter according to its metadata settings. More...
 
asset_id_t getAssetId (const scanned_device_t &asset)
 Returns a asset_id_t based on the configured selection of data in metadata.outputType.inFormat. More...
 

Public Attributes

uint8_t * _data
 

Private Member Functions

virtual asset_id_t assetId (const void *key, size_t keyLengthInBytes, uint32_t *startCrc=nullptr)
 A assetId is generated as crc32 from filtered input data. More...
 
template<class ReturnType , class ExpressionType >
ReturnType prepareFilterInputAndCallDelegate (const scanned_device_t &device, AssetFilterInput filterInputDescription, ExpressionType delegateExpression, ReturnType defaultValue)
 This method extracts the filters 'input description', prepares the input according to that description and calls the delegate with the prepared data. More...
 
- Private Member Functions inherited from FilterInterface
virtual ~FilterInterface ()=default
 
virtual bool contains (const void *key, size_t keyLengthInBytes)=0
 
virtual size_t size ()=0
 
virtual bool isValid ()=0
 

Detailed Description

Class that contains all data required for an asset filter:

  • Runtime data.
  • persisted data (filterdata).

Constructor & Destructor Documentation

◆ AssetFilter()

AssetFilter::AssetFilter ( uint8_t *  data)
inline

◆ ~AssetFilter()

AssetFilter::~AssetFilter ( )
default

Member Function Documentation

◆ assetId()

virtual asset_id_t AssetFilter::assetId ( const void *  key,
size_t  keyLengthInBytes,
uint32_t *  startCrc = nullptr 
)
privatevirtual

A assetId is generated as crc32 from filtered input data.

For output type MAC the data is prepended with a fixed value to avoid collisions with filters with assetId output based on MAC.

◆ contains()

bool AssetFilter::contains ( const void *  key,
size_t  keyLengthInBytes 
)
overridevirtual

Implements FilterInterface.

◆ filterAcceptsScannedDevice()

bool AssetFilter::filterAcceptsScannedDevice ( const scanned_device_t asset)

Returns true if the device passes the filter according to its metadata settings.

Returns false otherwise.

◆ filterdata()

AssetFilterData AssetFilter::filterdata ( )

Get the filter data.

◆ getAssetId()

asset_id_t AssetFilter::getAssetId ( const scanned_device_t asset)

Returns a asset_id_t based on the configured selection of data in metadata.outputType.inFormat.

If the data is not sufficient, a default constructed object is returned. (Data not sufficient can be detected: filterInputResult will return false in that case.)

◆ isValid()

bool AssetFilter::isValid ( )
overridevirtual

Implements FilterInterface.

◆ prepareFilterInputAndCallDelegate()

template<class ReturnType , class ExpressionType >
ReturnType AssetFilter::prepareFilterInputAndCallDelegate ( const scanned_device_t device,
AssetFilterInput  filterInputDescription,
ExpressionType  delegateExpression,
ReturnType  defaultValue 
)
private

This method extracts the filters 'input description', prepares the input according to that description and calls the delegate with the prepared data.

delegateExpression should be of the form (FilterInterface&, void*, size_t) -> ReturnType.

The argument that is passed into delegateExpression is based on the AssetFilterInputType of the assetFilter. Buffers are only allocated when strictly necessary. (E.g. MacAddress is already available in the device, but for MaskedAdDataType a buffer of 31 bytes needs to be allocated on the stack.)

The delegate return type is left as free template parameter so that this template can be used for both contains and assetId return values.

◆ runtimedata()

asset_filter_runtime_data_t * AssetFilter::runtimedata ( )

Get the runtime data.

◆ size()

size_t AssetFilter::size ( )
overridevirtual

Number of bytes of the data, according to the metadata contained in it.

Implements FilterInterface.

Member Data Documentation

◆ _data

uint8_t* AssetFilter::_data

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