00001 #ifndef _ABSTRACT_FILTERED_NUMBER_H_
00002 #define _ABSTRACT_FILTERED_NUMBER_H_
00003
00004 #include "UpdateableNumber.h"
00005
00006
00007 namespace luma
00008 {
00009 namespace numbers
00010 {
00011
00015 template <class T, unsigned int sampleCount, unsigned int maxOrder>
00016 class AbstractFilteredNumber : public UpdateableNumber<T>
00017 {
00018 public:
00022 virtual T getValue(unsigned int order) const = 0;
00023
00027 virtual T getValue() const;
00028 };
00029
00030 template <class T, unsigned int sampleCount, unsigned int maxOrder>
00031 T AbstractFilteredNumber<T, sampleCount, maxOrder>::getValue() const
00032 {
00033 return getValue(0);
00034 }
00035
00041 template <class T, unsigned int sampleCount>
00042 class AbstractFilteredNumber<T, sampleCount, 0> : public UpdateableNumber<T>
00043 {
00044 private:
00045 T mCurrentValue;
00046 T mInitialValue;
00047
00048
00049 public:
00050 AbstractFilteredNumber(T initialValue);
00051
00056 virtual void setValue(T x, float elapsedTime = 1.0f);
00057
00062 virtual T getValue(unsigned int order) const;
00063
00067 virtual T getValue() const;
00068
00072 virtual void forceValue(T x, float elapsedTime = 1.0f);
00073 };
00074
00075 template <class T, unsigned int sampleCount>
00076 AbstractFilteredNumber<T, sampleCount, 0>::AbstractFilteredNumber(T initialValue):
00077 mInitialValue(initialValue),
00078 mCurrentValue(initialValue)
00079 {
00080 }
00081
00082 template <class T, unsigned int sampleCount>
00083 void AbstractFilteredNumber<T, sampleCount, 0>::setValue(T x, float )
00084 {
00085 mCurrentValue = x;
00086 }
00087
00088 template <class T, unsigned int sampleCount>
00089 void AbstractFilteredNumber<T, sampleCount, 0>::forceValue(T x, float )
00090 {
00091 mCurrentValue = x;
00092 }
00093
00094 template <class T, unsigned int sampleCount>
00095 T AbstractFilteredNumber<T, sampleCount, 0>::getValue() const
00096 {
00097 return getValue(0);
00098 }
00099
00100 template <class T, unsigned int sampleCount>
00101 T AbstractFilteredNumber<T, sampleCount, 0>::getValue(unsigned int order) const
00102 {
00103 if(order == 0)
00104 {
00105 return mCurrentValue;
00106 }
00107
00108 return mInitialValue;
00109 }
00110
00111
00112 }}
00113
00114 #endif //_ABSTRACT_FILTERED_NUMBER_H_