Public Types | Static Public Member Functions | Static Protected Member Functions | List of all members
typeLimiter< D > Class Template Reference

Class for ensuring that variable of type D remains within limits of type S. More...

#include <TypeUtils.h>

Public Types

typedef D(* value_t) (D)
 Definition that simplifies.
 

Static Public Member Functions

template<class S , class T >
static T callback ()
 

Static Protected Member Functions

template<class S , class T >
static T limitInteger (T x)
 
template<class S , class T >
static T limitFloat (T x)
 

Detailed Description

template<class D>
class drain::typeLimiter< D >

Class for ensuring that variable of type D remains within limits of type S.

Returns a function pointer of type typeLimiter::value_t .

Limiter::value_t limit = Type::call<typeLimiter>(t); // t is type_info, char or std::string.
double d = limit(12345.6789);

With images of type drain::image::Image, use convenient function:

Limiter::value_t limit = img.getEncoding().getLimiter<double>();

Member Function Documentation

◆ callback()

static T callback ( )
inlinestatic
Template Parameters
S- type selector
T- destination type

◆ limitFloat()

static T limitFloat ( x)
inlinestaticprotected
Template Parameters
S- type selector
T- target value type (float or double)

◆ limitInteger()

static T limitInteger ( x)
inlinestaticprotected
Template Parameters
S- type selector
T- target value type (integer type)

Note: expecting T > S, ie. S is a narrower basetype.


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