IOLink 1.16.1
Loading...
Searching...
No Matches
iolink::LookUpTable Class Reference

A look-up table. More...

#include <iolink/LookUpTable.h>

Public Member Functions

 LookUpTable ()
 Build an empty look-up table.
 
 LookUpTable (DataType dtype, size_t count)
 Build an uninitialized look-up table.
 
 LookUpTable (DataType dtype, const void *src, size_t count)
 Build a new Look Up Table object.
 
template<typename T >
 LookUpTable (std::initializer_list< T > init)
 Build a look-up table from an initializer list.
 
template<typename InputIt >
 LookUpTable (InputIt first, InputIt last)
 Build a look-up table from an iterator.
 
 LookUpTable (const LookUpTable &other)
 
LookUpTableoperator= (const LookUpTable &other)
 
 LookUpTable (LookUpTable &&other) noexcept
 
LookUpTableoperator= (LookUpTable &&other) noexcept
 
DataType dtype () const
 Get the data type of the look-up table.
 
size_t count () const
 Get the number of values in the look-up table.
 
void read (size_t offset, void *dst, size_t count) const
 Read data from the look-up table.
 
template<typename T >
at (size_t index) const
 Read a single value from the look-up table.
 
size_t bufferSize () const
 Get the size of the internal buffer in bytes.
 
void * buffer ()
 Get a pointer to the internal buffer.
 
const void * buffer () const
 Get a pointer to the internal buffer.
 

Detailed Description

A look-up table.

A read only look-up table consisting of a data type, a number of elements, and a buffer of data.

Constructor & Destructor Documentation

◆ LookUpTable() [1/4]

iolink::LookUpTable::LookUpTable ( DataType  dtype,
size_t  count 
)

Build an uninitialized look-up table.

Parameters
dtypeThe data type of the look-up table.
countThe number of values in the look-up table.

◆ LookUpTable() [2/4]

iolink::LookUpTable::LookUpTable ( DataType  dtype,
const void *  src,
size_t  count 
)

Build a new Look Up Table object.

Parameters
dtypeThe data type of the look-up table.
srcThe source buffer to copy data from.
countThe number of values in the look-up table.

◆ LookUpTable() [3/4]

template<typename T >
iolink::LookUpTable::LookUpTable ( std::initializer_list< T >  init)
inline

Build a look-up table from an initializer list.

The type of the LookUpTable will be inferred from the type of the initializer list. A list of vectors will produce a LUT of vectors, and a list of scalars will produce a LUT of scalars.

Template Parameters
TThe type of the initializer list, from which the look-up table will be inferred.
Parameters
initThe initializer list to build the look-up table from.

◆ LookUpTable() [4/4]

template<typename InputIt >
iolink::LookUpTable::LookUpTable ( InputIt  first,
InputIt  last 
)
inline

Build a look-up table from an iterator.

The type of the LUT will be inferred from the type of the given iterator.

Template Parameters
InputItThe iterator type.
Parameters
firstThe first iterator.
lastThe last iterator.

Member Function Documentation

◆ at()

template<typename T >
T iolink::LookUpTable::at ( size_t  index) const
inline

Read a single value from the look-up table.

Warning
Requesting a value type not fitting the template type will result in undefined behavior.
Template Parameters
TThe type of the value to read.
Parameters
indexThe index of the value to read.
Returns
The value at the specified index.
Exceptions
InvalidArgumentWhen the index is out of bounds.

◆ read()

void iolink::LookUpTable::read ( size_t  offset,
void *  dst,
size_t  count 
) const

Read data from the look-up table.

Parameters
offsetThe offset in elements from the beginning of the look-up table.
dstThe destination buffer, where read data will be written.
countThe number of elements to read.
Exceptions
InvalidArgumentWhen the band of data to read is out of bounds.

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