Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_ExactMatchFilter.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: May 27, 2021
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7#pragma once
8
11
13public:
14 // -------------------------------------------------------------
15 // Interface methods.
16 // -------------------------------------------------------------
17
19
23 ExactMatchFilter() : _data(nullptr) {}
24
25 bool contains(const void* key, size_t keyLengthInBytes) override;
26
27 bool isValid() override;
28
33 int find(const void* item, size_t itemSize);
34
35 // -------------------------------------------------------------
36 // Sizing helpers
37 // -------------------------------------------------------------
38
42 static constexpr size_t bufferSize(uint8_t itemCount, uint8_t itemSize) { return itemCount * itemSize; }
43
47 static constexpr size_t size(uint8_t itemCount, uint8_t itemSize) {
48 return sizeof(exact_match_filter_data_t) + bufferSize(itemCount, itemSize);
49 }
50
51 constexpr size_t bufferSize() { return bufferSize(_data->itemCount, _data->itemSize); }
52
53 constexpr size_t size() { return size(_data->itemCount, _data->itemSize); }
54
55private:
56 uint8_t* getItem(size_t index);
57
59};
Definition: cs_ExactMatchFilter.h:12
constexpr size_t size()
Definition: cs_ExactMatchFilter.h:53
bool isValid() override
static constexpr size_t bufferSize(uint8_t itemCount, uint8_t itemSize)
Size of the itemArray in bytes.
Definition: cs_ExactMatchFilter.h:42
bool contains(const void *key, size_t keyLengthInBytes) override
uint8_t * getItem(size_t index)
exact_match_filter_data_t * _data
Definition: cs_ExactMatchFilter.h:58
int find(const void *item, size_t itemSize)
if contains(key,itemSize): returns the index of the item else: return -1
ExactMatchFilter(exact_match_filter_data_t *data)
ExactMatchFilter()
Use this default constructor with care, _data is never checked in this class.
Definition: cs_ExactMatchFilter.h:23
constexpr size_t bufferSize()
Definition: cs_ExactMatchFilter.h:51
static constexpr size_t size(uint8_t itemCount, uint8_t itemSize)
Total number of bytes that a filter with the given parameters would occupy.
Definition: cs_ExactMatchFilter.h:47
Used in AssetFiltering as a generic way to query a filter for containment and assetId.
Definition: cs_FilterInterface.h:16
Data content of the exact match filter.
Definition: cs_ExactMatchFilterStructs.h:18
uint8_t itemCount
Definition: cs_ExactMatchFilterStructs.h:19
uint8_t itemSize
Definition: cs_ExactMatchFilterStructs.h:20