Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
DsLiveData< T, S > Class Template Reference

LiveData is an observable data holder class. More...

#include <ds_live_data.h>

Inheritance diagram for DsLiveData< T, S >:
[legend]

Public Member Functions

 DsLiveData ()
 Default constructor.
 
 DsLiveData (const DsLiveData &rhs)=delete
 
DsLiveDataoperator= (const DsLiveData &rhs)=delete
 
void observe (DsView *view, const lambda< bool(T &)> &callback)
 Registers a new observer.
 
void remove (DsView *view)
 Removes the registered observer.
 
void invalidate (void)
 Marks the contained data as invalid. The observer callbacks will not be called for updates until the data is valid again.
 
void post (void)
 Posts the same value again.
 
void post (const T &value)
 Posts a new value.
 
T & value (void)
 Returns a reference to the contained value.
 

Detailed Description

template<typename T, size_t S = 8>
class DsLiveData< T, S >

LiveData is an observable data holder class.

LiveData is aware of the state of an observer class. It only updates the observers that are currently visible on the screen. The observer callbacks are called in the UI thread. The class allows new data to be posted from any thread.

Parameters
TData type
SMaximum number of observers. Default is 8.

Member Function Documentation

◆ observe()

template<typename T , size_t S = 8>
void DsLiveData< T, S >::observe ( DsView view,
const lambda< bool(T &)> &  callback 
)
inline

Registers a new observer.

Parameters
viewPointer to the window providing the visible / hidden status.
callbackLambda of type bool(T&). The parameter T is a reference to the data contained by the LiveData. If the lambda returns true, the live data will be invalidated. No further updates will be sent to the views observing it. This is used for sending one time events to the UI.

◆ post()

template<typename T , size_t S = 8>
void DsLiveData< T, S >::post ( const T &  value)
inline

Posts a new value.

Parameters
valueNew value

◆ remove()

template<typename T , size_t S = 8>
void DsLiveData< T, S >::remove ( DsView view)
inline

Removes the registered observer.

Parameters
viewPointer to the DsView class

◆ value()

template<typename T , size_t S = 8>
T & DsLiveData< T, S >::value ( void  )
inline

Returns a reference to the contained value.

Parameters
valueReference of type T

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