Audio Processing Framework (APF) version 0.5.0
Public Member Functions | List of all members
apf::BlockParameter< T > Class Template Reference

Hold current and old value of any type. More...

#include <apf/misc.h>

Public Member Functions

template<typename... Args>
 BlockParameter (Args &&... args)
 Constructor. Any arguments are forwarded to both old and current value. More...
 
template<typename Arg >
T & operator= (Arg &&arg)
 Assignment operator. More...
 
const T & get () const
 Get current value. More...
 
const T & old () const
 Get old value. More...
 
 operator const T & () const
 Conversion operator. For avoiding to call get() all the time. More...
 
bool changed () const
 Check if value has changed between before the last assignment and now. More...
 
both_proxy both () const
 
bool no_multiple_assignments () const
 
bool exactly_one_assignment () const
 
Operators which do not change the old value:
BlockParameteroperator+= (const T &rhs)
 
BlockParameteroperator-= (const T &rhs)
 
BlockParameteroperator*= (const T &rhs)
 
BlockParameteroperator/= (const T &rhs)
 
BlockParameteroperator%= (const T &rhs)
 
BlockParameteroperator&= (const T &rhs)
 
BlockParameteroperator|= (const T &rhs)
 
BlockParameteroperator<<= (const T &rhs)
 
BlockParameteroperator>>= (const T &rhs)
 
BlockParameteroperator++ ()
 
BlockParameteroperator-- ()
 
operator++ (int)
 
operator-- (int)
 

Detailed Description

template<typename T>
class apf::BlockParameter< T >

Hold current and old value of any type.

A new value can be assigned with operator=(). The current and old value can be obtained with get() and old(), respectively. To find out if the old and current value are different, use changed(). BlockParameter is supposed to avoid pairs of variables where one represents an old value and the other a new one. The old value of BlockParameter is updated in operator=() (and only there).

Attention
It's not possible to use operator=() without updating the old value. To avoid the unintended use of operator=(), use
#include <cassert>
bp = 23;
assert(bp.exactly_one_assignment());
Hold current and old value of any type.
Definition: misc.h:99
This is of course only checked if NDEBUG is undefined.
Template Parameters
TThe contained type.

Definition at line 98 of file misc.h.

Constructor & Destructor Documentation

◆ BlockParameter()

template<typename T >
template<typename... Args>
apf::BlockParameter< T >::BlockParameter ( Args &&...  args)
inlineexplicit

Constructor. Any arguments are forwarded to both old and current value.

Definition at line 103 of file misc.h.

Member Function Documentation

◆ operator=()

template<typename T >
template<typename Arg >
T & apf::BlockParameter< T >::operator= ( Arg &&  arg)
inline

Assignment operator.

As a side effect, the old value is updated to the former current value.

Definition at line 111 of file misc.h.

◆ get()

template<typename T >
const T & apf::BlockParameter< T >::get ( ) const
inline

Get current value.

Definition at line 121 of file misc.h.

Referenced by apf::BlockParameter< T >::changed(), and apf::BlockParameter< T >::operator const T &().

◆ old()

template<typename T >
const T & apf::BlockParameter< T >::old ( ) const
inline

Get old value.

Definition at line 122 of file misc.h.

Referenced by apf::BlockParameter< T >::changed().

◆ operator const T &()

template<typename T >
apf::BlockParameter< T >::operator const T & ( ) const
inline

Conversion operator. For avoiding to call get() all the time.

Definition at line 125 of file misc.h.

References apf::BlockParameter< T >::get().

◆ changed()

template<typename T >
bool apf::BlockParameter< T >::changed ( ) const
inline

Check if value has changed between before the last assignment and now.

Definition at line 128 of file misc.h.

References apf::BlockParameter< T >::get(), and apf::BlockParameter< T >::old().

◆ operator+=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator+= ( const T &  rhs)
inline

Definition at line 132 of file misc.h.

◆ operator-=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator-= ( const T &  rhs)
inline

Definition at line 133 of file misc.h.

◆ operator*=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator*= ( const T &  rhs)
inline

Definition at line 134 of file misc.h.

◆ operator/=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator/= ( const T &  rhs)
inline

Definition at line 135 of file misc.h.

◆ operator%=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator%= ( const T &  rhs)
inline

Definition at line 136 of file misc.h.

◆ operator&=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator&= ( const T &  rhs)
inline

Definition at line 137 of file misc.h.

◆ operator|=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator|= ( const T &  rhs)
inline

Definition at line 138 of file misc.h.

◆ operator<<=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator<<= ( const T &  rhs)
inline

Definition at line 139 of file misc.h.

◆ operator>>=()

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator>>= ( const T &  rhs)
inline

Definition at line 140 of file misc.h.

◆ operator++() [1/2]

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator++ ( )
inline

Definition at line 142 of file misc.h.

◆ operator--() [1/2]

template<typename T >
BlockParameter & apf::BlockParameter< T >::operator-- ( )
inline

Definition at line 143 of file misc.h.

◆ operator++() [2/2]

template<typename T >
T apf::BlockParameter< T >::operator++ ( int  )
inline

Definition at line 144 of file misc.h.

◆ operator--() [2/2]

template<typename T >
T apf::BlockParameter< T >::operator-- ( int  )
inline

Definition at line 145 of file misc.h.

◆ both()

template<typename T >
both_proxy apf::BlockParameter< T >::both ( ) const
inline

Definition at line 174 of file misc.h.

◆ no_multiple_assignments()

template<typename T >
bool apf::BlockParameter< T >::no_multiple_assignments ( ) const
inline

Definition at line 177 of file misc.h.

◆ exactly_one_assignment()

template<typename T >
bool apf::BlockParameter< T >::exactly_one_assignment ( ) const
inline

Definition at line 184 of file misc.h.


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