CuteHMI - Modbus (CuteHMI.Modbus.2)
cutehmi::modbus::internal::DataContainer< T, N > Class Template Reference

Data container. More...

#include <cutehmi/modbus/internal/DataContainer.hpp>

Classes

class  KeysIterator
 Keys iterator. More...
 

Public Types

typedef T value_type
 
typedef T & reference
 
typedef T * pointer
 
typedef QLinkedList< std::size_tKeysContainer
 

Public Member Functions

 DataContainer ()
 
constexpr std::size_t size () const noexcept
 Get container size. More...
 
const T * at (std::size_t i) const
 Get value at given index. More...
 
T * at (std::size_t i)
 Get value at given index. More...
 
T * value (std::size_t i)
 Get value at given index. More...
 
void insert (std::size_t i, T *value)
 Insert value. More...
 
void clear ()
 Clear container. More...
 
void free ()
 Delete container contents. More...
 
const KeysContainerkeys () const
 Get keys container. More...
 

Public Attributes

const typedef T & const_reference
 
const typedef T * const_pointer
 

Static Public Attributes

static constexpr std::size_t ADDRESS_SPACE = N
 

Protected Member Functions

QReadWriteLocklock () const
 

Friends

class KeysIterator
 

Detailed Description

template<typename T, std::size_t N = 65536>
class cutehmi::modbus::internal::DataContainer< T, N >

Data container.

Member Typedef Documentation

◆ KeysContainer

template<typename T , std::size_t N = 65536>
typedef QLinkedList<std::size_t> cutehmi::modbus::internal::DataContainer< T, N >::KeysContainer

◆ pointer

template<typename T , std::size_t N = 65536>
typedef T* cutehmi::modbus::internal::DataContainer< T, N >::pointer

◆ reference

template<typename T , std::size_t N = 65536>
typedef T& cutehmi::modbus::internal::DataContainer< T, N >::reference

◆ value_type

template<typename T , std::size_t N = 65536>
typedef T cutehmi::modbus::internal::DataContainer< T, N >::value_type

Constructor & Destructor Documentation

◆ DataContainer()

template<typename T , std::size_t N>
cutehmi::modbus::internal::DataContainer< T, N >::DataContainer

Member Function Documentation

◆ at() [1/2]

template<typename T , std::size_t N>
T * cutehmi::modbus::internal::DataContainer< T, N >::at ( std::size_t  i)

Get value at given index.

Parameters
iindex.
Returns
value existing at given index or nullptr if value does not exist.
See also
value().
Remarks
This method is thread-safe.

◆ at() [2/2]

template<typename T , std::size_t N>
const T * cutehmi::modbus::internal::DataContainer< T, N >::at ( std::size_t  i) const

Get value at given index.

Parameters
iindex.
Returns
value existing at given index or nullptr if value does not exist.
See also
value().
Remarks
This method is thread-safe.

◆ clear()

template<typename T , std::size_t N>
void cutehmi::modbus::internal::DataContainer< T, N >::clear

Clear container.

Sets all elements to nullptr. No deletion is performed.

Remarks
This function is thread-safe although it invalidates all iterators.
This method is thread-safe.

◆ free()

template<typename T , std::size_t N>
void cutehmi::modbus::internal::DataContainer< T, N >::free

Delete container contents.

Function deletes all non-null elements and sets all elements to nullptr.

Remarks
This function is thread-safe although it invalidates all iterators.
This method is thread-safe.

◆ insert()

template<typename T , std::size_t N>
void cutehmi::modbus::internal::DataContainer< T, N >::insert ( std::size_t  i,
T *  value 
)

Insert value.

Parameters
iindex.
valuevalue to be inserted.
Remarks
Even tho' this function inserts a value, key iterators remain valid after a call to this function.
This method is thread-safe.

◆ keys()

template<typename T , std::size_t N>
const DataContainer< T, N >::KeysContainer & cutehmi::modbus::internal::DataContainer< T, N >::keys

Get keys container.

Returns
keys container.
Remarks
This method is thread-safe.

◆ lock()

template<typename T , std::size_t N>
QReadWriteLock & cutehmi::modbus::internal::DataContainer< T, N >::lock
protected

◆ size()

template<typename T , std::size_t N>
constexpr std::size_t cutehmi::modbus::internal::DataContainer< T, N >::size
constexprnoexcept

Get container size.

Returns
container size.
Remarks
This method is thread-safe.

◆ value()

template<typename T , std::size_t N>
T * cutehmi::modbus::internal::DataContainer< T, N >::value ( std::size_t  i)

Get value at given index.

If value does not exist it will be default-constructed and inserted into the container.

Parameters
iindex.
Returns
value existing at given index or default-constructed value.
See also
at().
Remarks
Even tho' this function inserts a value, key iterators remain valid after a call to this function.
This method is thread-safe.

Friends And Related Function Documentation

◆ KeysIterator

template<typename T , std::size_t N = 65536>
friend class KeysIterator
friend

Member Data Documentation

◆ ADDRESS_SPACE

template<typename T , std::size_t N = 65536>
constexpr std::size_t cutehmi::modbus::internal::DataContainer< T, N >::ADDRESS_SPACE = N
staticconstexpr

◆ const_pointer

template<typename T , std::size_t N = 65536>
const typedef T* cutehmi::modbus::internal::DataContainer< T, N >::const_pointer

◆ const_reference

template<typename T , std::size_t N = 65536>
const typedef T& cutehmi::modbus::internal::DataContainer< T, N >::const_reference