Calico
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups
cal::scaling_lens< Lens, Factor, T > Struct Template Reference

A lens that scales the value by a factor before storing or accessing it. More...

#include <lens.hpp>

+ Inheritance diagram for cal::scaling_lens< Lens, Factor, T >:

Public Types

typedef Factor factor_type
 The type of the factor to be multiplied.
 
typedef Lens internal_type
 The type of the lens being wrapped.
 
typedef T value_type
 The value type accepted by the lens.
 

Public Member Functions

 scaling_lens (internal_type &&data, factor_type &&factor)
 Wraps a lens.
 
internal_type data ()
 Returns the internal lens.
 
const internal_typedata () const
 Returns the internal lens.
 
const factor_typefactor () const
 Returns the factor to be multiplied.
 
 operator value_type () const
 Gets the value through the lens.
 
scaling_lens< Lens, Factor, T > & operator%= (const value_type &x)
 Modulo assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator&= (const value_type &x)
 Bitwise AND assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator*= (const value_type &x)
 Multiplication assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator++ ()
 Pre-increments through the lens.
 
scaling_lens< Lens, Factor, T > & operator+= (const value_type &x)
 Addition assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator-- ()
 Pre-decrements through the lens.
 
scaling_lens< Lens, Factor, T > & operator-= (const value_type &x)
 Subtraction assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator/= (const value_type &x)
 Division assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator<<= (const value_type &x)
 Bitwise left shift assignment through the lens.
 
scaling_lensoperator= (const value_type &x)
 Puts a value through the lens.
 
scaling_lensoperator= (value_type &&x)
 Puts a value through the lens (rvalue version).
 
scaling_lens< Lens, Factor, T > & operator>>= (const value_type &x)
 Bitwise right shift assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator^= (const value_type &x)
 Bitwise XOR assignment through the lens.
 
scaling_lens< Lens, Factor, T > & operator|= (const value_type &x)
 Bitwise OR assignment through the lens.
 

Detailed Description

template<class Lens, class Factor, class T = typename lens_traits<Lens>::value_type>
struct cal::scaling_lens< Lens, Factor, T >

A lens that scales the value by a factor before storing or accessing it.

If L is the scaling_lens, x is the internal lens, and k is the factor to be multiplied, the following relationships are satisfied:

L       ==    x / k
L = c  <==>   x = c * k