| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
BitmapRange< T, Diff, NBITS > Class Template Reference
eProsima Fast DDS API Reference » Shared Utilities

Template class to hold a range of items using a custom bitmap. More...

`#include <fixed_size_bitmap.hpp>`

## Public Types

using | bitmap_type = std::array<uint32_t, NITEMS>

## Public Member Functions

| BitmapRange () noexcept
| Default constructor.
| BitmapRange (T base) noexcept
| Base-specific constructor.
| BitmapRange (T base, uint32_t max_bits) noexcept
| Range specific constructor.
T | base () const noexcept
| Get base of the range.
void | base (T base) noexcept
| Set a new base for the range.
void | base (T base, uint32_t max_bits) noexcept
| Set a new base and maximum bits for the range.
void | base_update (T base) noexcept
| Set a new base for the range, keeping old values where possible.
bool | empty () const noexcept
| Returns whether the range is empty (i.e.
T | max () const noexcept
| Returns the highest value set in the range.
T | min () const noexcept
| Returns the lowest value set in the range.
bool | is_set (const T &item) const noexcept
| Checks if an element is present in the bitmap.
bool | add (const T &item) noexcept
| Adds an element to the range.
void | add_range (const T &from, const T &to)
| Adds a range of elements to the range.
void | remove (const T &item) noexcept
| Removes an element from the range.
void | bitmap_get (uint32_t &num_bits, bitmap_type &bitmap, uint32_t &num_longs_used) const noexcept
| Gets the current value of the bitmap.
void | bitmap_set (uint32_t num_bits, const uint32_t *bitmap) noexcept
| Sets the current value of the bitmap.
template<class UnaryFunc>
void | for_each (UnaryFunc f) const
| Apply a function on every item on the range.

## Protected Attributes

T | base_
| Holds base value of the range.
T | range_max_
| Holds maximum allowed value of the range.
bitmap_type | bitmap_
| Holds the bitmap values.
uint32_t | num_bits_
| Holds the highest bit set in the bitmap.

## Detailed Description

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>
class eprosima::fastdds::BitmapRange< T, Diff, NBITS >

Template class to hold a range of items using a custom bitmap.

Template Parameters

  T | Type of the elements in the range. Should have >= operator and T + uint32_t returning T.
  Diff | Functor calculating the difference of two T. The result should be assignable to a uint32_t.
  NBITS | Size in bits of the bitmap. Range of items will be [base, base + NBITS - 1].

## Member Typedef Documentation

## ◆ bitmap_type

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

using bitmap_type = std::array<uint32_t, NITEMS>

## Constructor & Destructor Documentation

## ◆ BitmapRange() [1/3]

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

BitmapRange | ( |  | ) |

inline noexcept

Default constructor.

Constructs an empty range with default base.

## ◆ BitmapRange() [2/3]

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

BitmapRange | ( | T | base | ) |

inline explicit noexcept

Base-specific constructor.

Constructs an empty range with specified base.

Parameters

  base | Specific base value for the created range.

## ◆ BitmapRange() [3/3]

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

BitmapRange | ( | T | base,
|  | uint32_t | max_bits )

inline noexcept

Range specific constructor.

Constructs an empty range with specified base and maximum bits.

Parameters

  base | Specific base value for the created range.
  max_bits | Specific maximum number of bits.

## Member Function Documentation

## ◆ add()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

bool add | ( | const T & | item | ) |

inline noexcept

Adds an element to the range.

Adds an element to the bitmap if it is in the allowed range.

Parameters

  item | Value to be added.

Returns
  true if the item has been added (i.e. is in the allowed range), false otherwise.

## ◆ add_range()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void add_range | ( | const T & | from,
|  | const T & | to )

inline

Adds a range of elements to the range.

Add all elements in [from, to) to the range. Equivalent to for(T i = from; i < to; i++) add(i);

Parameters

  from | Starting value of the range to add.
  to | Ending value of the range to add.

## ◆ base() [1/3]

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

T base | ( |  | ) | const

inline noexcept

Get base of the range.

Returns
  a copy of the range base.

## ◆ base() [2/3]

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void base | ( | T | base | ) |

inline noexcept

Set a new base for the range.

This method resets the range and sets a new value for its base.

Parameters

  base | New base value to set.

## ◆ base() [3/3]

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void base | ( | T | base,
|  | uint32_t | max_bits )

inline noexcept

Set a new base and maximum bits for the range.

This method resets the range and sets a new value for its base, as long as a maximum number of bits.

Parameters

  base | New base value to set.
  max_bits | New maximum number of bits.

## ◆ base_update()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void base_update | ( | T | base | ) |

inline noexcept

Set a new base for the range, keeping old values where possible.

This method implements a sliding window mechanism for changing the base of the range.

Parameters

  base | New base value to set.

## ◆ bitmap_get()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void bitmap_get | ( | uint32_t & | num_bits,
|  | bitmap_type & | bitmap,
|  | uint32_t & | num_longs_used ) const

inline noexcept

Gets the current value of the bitmap.

This method is designed to be used when performing serialization of a bitmap range.

Parameters

  num_bits | Upon return, it will contain the number of significant bits in the bitmap.
  bitmap | Upon return, it will contain the current value of the bitmap.
  num_longs_used | Upon return, it will contain the number of valid elements on the returned bitmap.

## ◆ bitmap_set()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void bitmap_set | ( | uint32_t | num_bits,
|  | const uint32_t * | bitmap )

inline noexcept

Sets the current value of the bitmap.

This method is designed to be used when performing deserialization of a bitmap range.

Parameters

  num_bits | Number of significant bits in the input bitmap.
  bitmap | Points to the beginning of a uint32_t array holding the input bitmap.

## ◆ empty()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

bool empty | ( |  | ) | const

inline noexcept

Returns whether the range is empty (i.e.

has all bits unset).

Returns
  true if the range is empty, false otherwise.

## ◆ for_each()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>
template<class UnaryFunc>

void for_each | ( | UnaryFunc | f | ) | const

inline

Apply a function on every item on the range.

Parameters

  f | Function to apply on each item.

## ◆ is_set()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

bool is_set | ( | const T & | item | ) | const

inline noexcept

Checks if an element is present in the bitmap.

Parameters

  item | Value to be checked.

Returns
  true if the item is present in the bitmap, false otherwise.

## ◆ max()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

T max | ( |  | ) | const

inline noexcept

Returns the highest value set in the range.

Returns
  the highest value set in the range. If the range is empty, the result is undetermined.

## ◆ min()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

T min | ( |  | ) | const

inline noexcept

Returns the lowest value set in the range.

Returns
  the lowest value set in the range. If the range is empty, the result is undetermined.

## ◆ remove()

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

void remove | ( | const T & | item | ) |

inline noexcept

Removes an element from the range.

Removes an element from the bitmap.

Parameters

  item | Value to be removed.

## Member Data Documentation

## ◆ base_

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

T base_

protected

Holds base value of the range.

## ◆ bitmap_

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

bitmap_type bitmap_

protected

Holds the bitmap values.

## ◆ num_bits_

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

uint32_t num_bits_

protected

Holds the highest bit set in the bitmap.

## ◆ range_max_

template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>

T range_max_

protected

Holds maximum allowed value of the range.

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

- include/fastdds/utils/fixed_size_bitmap.hpp