The BLOCKS SDK
TouchList< Type > Class Template Reference

Description

template<typename Type>
class TouchList< Type >

Utility class to hold a list of TouchSurface::Touch objects with different indices and blockUIDs, where each touch has a mapping to some kind of user-supplied data value.

The Type template is a user-defined type of object that will be stored for each touch element. The type must be default-constructable and copyable.

Public Member Functions

 TouchList ()=default
 Creates an empty touch list. More...
 
 ~TouchList ()=default
 Destructor. More...
 
int size () const noexcept
 Returns the number of entries in the touch list. More...
 
Type & getValue (const TouchSurface::Touch &touch)
 Returns the user data object that corresponds to the given touch. More...
 
bool contains (const TouchSurface::Touch &touch) const noexcept
 Returns true if a touch is already in the list. More...
 
void updateTouch (const TouchSurface::Touch &touch)
 Updates the entry for the given touch, copying in the new state. More...
 
const TouchEntryfind (const TouchSurface::Touch &touch) const noexcept
 If a touch is in the list, returns a pointer to the TouchEntry. More...
 
TouchEntryfind (const TouchSurface::Touch &touch) noexcept
 
TouchEntrybegin () noexcept
 Allows iterator access to the list of touch entries. More...
 
const TouchEntrybegin () const noexcept
 
TouchEntryend () noexcept
 Allows iterator access to the list of touch entries. More...
 
const TouchEntryend () const noexcept
 
TouchEntryoperator[] (const int index)
 Retrieve a reference to particular item in the list of touch entries. More...
 
void clear () noexcept
 Resets all contents, doest not generate any call-backs. More...
 

Classes

struct  TouchEntry
 Holds the current state of a touch, along with the user-data associated with it. More...
 

Constructor & Destructor Documentation

◆ TouchList()

template<typename Type >
TouchList< Type >::TouchList ( )
default

Creates an empty touch list.

◆ ~TouchList()

template<typename Type >
TouchList< Type >::~TouchList ( )
default

Destructor.

Member Function Documentation

◆ size()

template<typename Type >
int TouchList< Type >::size ( ) const
noexcept

Returns the number of entries in the touch list.

◆ getValue()

template<typename Type >
Type& TouchList< Type >::getValue ( const TouchSurface::Touch touch)

Returns the user data object that corresponds to the given touch.

This will also update the stored state of the TouchEntry::touch value for this touch index.

References TouchList< Type >::find().

◆ contains()

template<typename Type >
bool TouchList< Type >::contains ( const TouchSurface::Touch touch) const
noexcept

Returns true if a touch is already in the list.

References TouchList< Type >::find().

Referenced by TouchList< Type >::updateTouch().

◆ updateTouch()

template<typename Type >
void TouchList< Type >::updateTouch ( const TouchSurface::Touch touch)

Updates the entry for the given touch, copying in the new state.

If no entry with the same index and blockUID exists then a new entry is created. If given a touch which is a touch-end, this will remove any corresponding entries from the list.

References TouchList< Type >::contains(), TouchList< Type >::find(), and TouchSurface::Touch::isTouchEnd.

◆ find() [1/2]

template<typename Type >
const TouchEntry* TouchList< Type >::find ( const TouchSurface::Touch touch) const
noexcept

If a touch is in the list, returns a pointer to the TouchEntry.

Otherwise, returns nullptr.

Referenced by TouchList< Type >::contains(), TouchList< Type >::find(), TouchList< Type >::getValue(), and TouchList< Type >::updateTouch().

◆ find() [2/2]

template<typename Type >
TouchEntry* TouchList< Type >::find ( const TouchSurface::Touch touch)
noexcept

◆ begin() [1/2]

template<typename Type >
TouchEntry* TouchList< Type >::begin ( )
noexcept

Allows iterator access to the list of touch entries.

◆ begin() [2/2]

template<typename Type >
const TouchEntry* TouchList< Type >::begin ( ) const
noexcept

◆ end() [1/2]

template<typename Type >
TouchEntry* TouchList< Type >::end ( )
noexcept

Allows iterator access to the list of touch entries.

◆ end() [2/2]

template<typename Type >
const TouchEntry* TouchList< Type >::end ( ) const
noexcept

◆ operator[]()

template<typename Type >
TouchEntry& TouchList< Type >::operator[] ( const int  index)

Retrieve a reference to particular item in the list of touch entries.

◆ clear()

template<typename Type >
void TouchList< Type >::clear ( )
noexcept

Resets all contents, doest not generate any call-backs.


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