RangedNumber Class Template Reference

#include <C:/Work/specialnumbers_svn/NumberLib/NumbersLib/RangedNumber.h>

Inheritance diagram for RangedNumber:

ClampedNumber CyclicNumber PingPongNumber

List of all members.


Detailed Description

template<class T>
class luma::numbers::RangedNumber< T >

This class is the base class of numbers that fall in a given range.

Author:
Herman Tulleken (herman.tulleken@gmail.com)

luma/games (http://www.luma.co.za/)

The derrived classes differ by how out of range situations are handled. For example, the ClampedNumber class clamps its values in range, and CyclicNumber cycles it values in range.

A class derrived from this type must guarentee that the value (as returned by the cast operator) is always in the half-open range [min, max).

Parameters:
T T must be a class that supports default construction, and have the stream operator class overloaded. Base classes might specify further requirements.

Definition at line 32 of file RangedNumber.h.


Public Member Functions

virtual void dec (float elapsedTime=1)=0
virtual T getValidValue (const T &value) const =0
getValue () const
 Returns the vlaue of this ranged number.
virtual void inc (float elapsedTime=1)=0
const T & increment () const
 Returns the increment for this RangedNumber.
const T & max () const
 Returns the max value of this RangedNumber.
const T & min () const
 Returns the min value of this RangedNumber.
void modify (const T &max, const T &min, const T &increment)
 Changes the way this RangedNumber works.
virtual operator T () const
 Returns this ClampedNumber's value.
virtual RangedNumber< T > & operator++ ()=0
 Puts this ClampedNumber's value onto the stream.
virtual RangedNumber< T > & operator-- ()=0
 Decrements this RangedNumber by one increment, as specified by the constructor.
virtual RangedNumberoperator= (const T &)
virtual RangedNumberoperator= (const RangedNumber< T > &)
 RangedNumber (const RangedNumber &other)
 RangedNumber (T value, T min, T max, T increment)
 Constructs a new RangedNumber.
virtual void setIncrement (const T &)
void setValue (const T &value)
virtual ~RangedNumber ()
 A virtual destructor is provided so that sub classes can properly be destructed.

Protected Attributes

mIncrement
mMax
mMin
mValue

Constructor & Destructor Documentation

RangedNumber ( value,
min,
max,
increment 
) [inline]

Constructs a new RangedNumber.

Parameters:
value The current value of this RangedNumber. The value must lie in the range [min, max).
min The minimum value of this RangedNumber (inclusive).
max The maximum value of this RangedNumber (exclusive).
increment This is the value used by operator++() and operator--(). In general, this value is such that this RangeNumber's value is always between [min, max - increment].

Definition at line 139 of file RangedNumber.h.

RangedNumber ( const RangedNumber< T > &  other  )  [inline]

Definition at line 148 of file RangedNumber.h.

virtual ~RangedNumber (  )  [inline, virtual]

A virtual destructor is provided so that sub classes can properly be destructed.

Definition at line 80 of file RangedNumber.h.


Member Function Documentation

virtual void dec ( float  elapsedTime = 1  )  [pure virtual]

virtual T getValidValue ( const T &  value  )  const [pure virtual]

T getValue (  )  const [inline]

Returns the vlaue of this ranged number.

Definition at line 215 of file RangedNumber.h.

References RangedNumber::mValue.

Referenced by BufferedBool::getFloatValue().

virtual void inc ( float  elapsedTime = 1  )  [pure virtual]

const T & increment (  )  const [inline]

Returns the increment for this RangedNumber.

Definition at line 186 of file RangedNumber.h.

References RangedNumber::mIncrement.

const T & max (  )  const [inline]

Returns the max value of this RangedNumber.

Definition at line 180 of file RangedNumber.h.

References RangedNumber::mMax.

Referenced by BufferedStep::forceMax(), and BufferedBool::forceValue().

const T & min (  )  const [inline]

Returns the min value of this RangedNumber.

Definition at line 174 of file RangedNumber.h.

References RangedNumber::mMin.

Referenced by BufferedStep::forceMin(), and BufferedBool::forceValue().

void modify ( const T &  max,
const T &  min,
const T &  increment 
) [inline]

operator T (  )  const [inline, virtual]

Returns this ClampedNumber's value.

Definition at line 192 of file RangedNumber.h.

References RangedNumber::mValue.

virtual RangedNumber<T>& operator++ (  )  [pure virtual]

Puts this ClampedNumber's value onto the stream.

Increments this RangedNumber by one increment, as specified by the constructor.

Implemented in ClampedNumber, CyclicNumber, PingPongNumber, ClampedNumber< float >, ClampedNumber< int >, and CyclicNumber< int >.

virtual RangedNumber<T>& operator-- (  )  [pure virtual]

Decrements this RangedNumber by one increment, as specified by the constructor.

Implemented in ClampedNumber, CyclicNumber, PingPongNumber, ClampedNumber< float >, ClampedNumber< int >, and CyclicNumber< int >.

RangedNumber< T > & operator= ( const T &  value  )  [inline, virtual]

Reimplemented in CyclicNumber, PingPongNumber, and CyclicNumber< int >.

Definition at line 166 of file RangedNumber.h.

References RangedNumber::getValidValue(), and RangedNumber::mValue.

RangedNumber< T > & operator= ( const RangedNumber< T > &  other  )  [inline, virtual]

void setIncrement ( const T &  increment  )  [inline, virtual]

void setValue ( const T &  value  )  [inline]


Member Data Documentation

T mIncrement [protected]

T mMax [protected]

T mMin [protected]

T mValue [protected]


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

Generated on Sun Sep 21 20:49:08 2008 for Numbers by  doxygen 1.5.6