#include <TAPsCircularCounter.hpp>


Public Member Functions | |
| CircularCounter (T v1, T v2, T v3) | |
| CircularCounter () | |
| Default Ctor. | |
| void | CountDown (T v) |
| void | CountDown () |
| T | CountDownAndReturnTheCountValue (T v) |
| T | CountDownAndReturnTheCountValue () |
| void | CountUp (T v) |
| void | CountUp () |
| T | CountUpAndReturnTheCountValue (T v) |
| T | CountUpAndReturnTheCountValue () |
| T | GetValueCurrent () const |
| T | GetValueHighest () const |
| T | GetValueLowest () const |
| void | SetValueCurrent (T v) |
| void | SetValueHighest (T v) |
| void | SetValueLowest (T v) |
| virtual | ~CircularCounter () |
| Destructor. | |
Protected Member Functions | |
| void | CheckCountDown () |
| void | CheckCountUp () |
Protected Attributes | |
| T | m_tCurrent |
| T | m_tHighest |
| T | m_tLowest |
Friends | |
| std::ostream & | operator<< (std::ostream &output, CircularCounter< T > const &ctr) |
Definition at line 25 of file TAPsCircularCounter.hpp.
| CircularCounter< T >::CircularCounter | ( | ) | [inline] |
Default Ctor.
Definition at line 45 of file TAPsCircularCounter.hpp.
00045 : m_tCurrent(0) 00046 { 00047 if ( typeid(T) == typeid(unsigned char) ) { 00048 m_tLowest = 0; 00049 m_tHighest = static_cast<unsigned char>( UCHAR_MAX ); 00050 } 00051 else if ( typeid(T) == typeid(char) ) { 00052 m_tLowest = static_cast<char>( CHAR_MIN ); 00053 m_tHighest = static_cast<char>( CHAR_MAX ); 00054 } 00055 else if ( typeid(T) == typeid(unsigned short) ) { 00056 m_tLowest = 0; 00057 m_tHighest = static_cast<unsigned short>( USHRT_MAX ); 00058 } 00059 else if ( typeid(T) == typeid(short) ) { 00060 m_tLowest = static_cast<short>( SHRT_MIN ); 00061 m_tHighest = static_cast<short>( SHRT_MAX ); 00062 } 00063 else if ( typeid(T) == typeid(unsigned int) ) { 00064 m_tLowest = 0; 00065 m_tHighest = static_cast<unsigned int>( UINT_MAX ); 00066 } 00067 else if ( typeid(T) == typeid(int) ) { 00068 m_tLowest = static_cast<int>( INT_MIN ); 00069 m_tHighest = static_cast<int>( INT_MAX ); 00070 } 00071 else if ( typeid(T) == typeid(unsigned long) ) { 00072 m_tLowest = 0; 00073 m_tHighest = static_cast<unsigned long>( ULONG_MAX ); 00074 } 00075 else if ( typeid(T) == typeid(long) ) { 00076 m_tLowest = static_cast<long>( LONG_MIN ); 00077 m_tHighest = static_cast<long>( LONG_MAX ); 00078 } 00079 }
| CircularCounter< T >::CircularCounter | ( | T | v1, | |
| T | v2, | |||
| T | v3 | |||
| ) | [inline] |
The highest, current, and lowest value can be passed in any order.
Definition at line 84 of file TAPsCircularCounter.hpp.
00085 { 00086 if ( v1 >= v2 ) { 00087 if ( v1 >= v3 ) { 00088 m_tHighest = v1; 00089 if ( v2 >= v3 ) { 00090 m_tCurrent = v2; 00091 m_tLowest = v3; 00092 } 00093 else { 00094 m_tCurrent = v3; 00095 m_tLowest = v2; 00096 } 00097 } 00098 else { 00099 m_tHighest = v3; 00100 m_tCurrent = v1; 00101 m_tLowest = v2; 00102 } 00103 } 00104 else { 00105 if ( v2 >= v3 ) { 00106 m_tHighest = v2; 00107 if ( v1 >= v3 ) { 00108 m_tCurrent = v1; 00109 m_tLowest = v3; 00110 } 00111 else { 00112 m_tCurrent = v3; 00113 m_tLowe st = v1; 00114 } 00115 } 00116 else { 00117 m_tHighest = v3; 00118 m_tCurrent = v2; 00119 m_tLowe st = v1; 00120 } 00121 } 00122 }
| virtual CircularCounter< T >::~CircularCounter | ( | ) | [inline, virtual] |
| void CircularCounter< T >::CheckCountDown | ( | ) | [inline, protected] |
Definition at line 203 of file TAPsCircularCounter.hpp.
00204 { if ( m_tCurrent < m_tLowest ) m_tCurrent = m_tHighest; }
| void CircularCounter< T >::CheckCountUp | ( | ) | [inline, protected] |
Definition at line 201 of file TAPsCircularCounter.hpp.
00202 { if ( m_tCurrent > m_tHighest ) m_tCurrent = m_tLowest; }
| void CircularCounter< T >::CountDown | ( | T | v | ) | [inline] |
Definition at line 167 of file TAPsCircularCounter.hpp.
00168 { 00169 m_tCurrent -= v; 00170 CheckCountDown(); 00171 }
| void CircularCounter< T >::CountDown | ( | ) | [inline] |
Definition at line 162 of file TAPsCircularCounter.hpp.
00163 { 00164 --m_tCurrent; 00165 CheckCountDown(); 00166 }
| T CircularCounter< T >::CountDownAndReturnTheCountValue | ( | T | v | ) | [inline] |
Definition at line 191 of file TAPsCircularCounter.hpp.
00192 { 00193 m_tCurrent -= v; 00194 CheckCountDown(); 00195 return m_tCurrent; 00196 }
| T CircularCounter< T >::CountDownAndReturnTheCountValue | ( | ) | [inline] |
Definition at line 185 of file TAPsCircularCounter.hpp.
00186 { 00187 --m_tCurrent; 00188 CheckCountDown(); 00189 return m_tCurrent; 00190 }
| void CircularCounter< T >::CountUp | ( | T | v | ) | [inline] |
Definition at line 157 of file TAPsCircularCounter.hpp.
00158 { 00159 m_tCurrent += v; 00160 CheckCountUp(); 00161 }
| void CircularCounter< T >::CountUp | ( | ) | [inline] |
Definition at line 152 of file TAPsCircularCounter.hpp.
00153 { 00154 ++m_tCurrent; 00155 CheckCountUp(); 00156 }
| T CircularCounter< T >::CountUpAndReturnTheCountValue | ( | T | v | ) | [inline] |
Definition at line 179 of file TAPsCircularCounter.hpp.
00180 { 00181 m_tCurrent += v; 00182 CheckCountUp(); 00183 return m_tCurrent; 00184 }
| T CircularCounter< T >::CountUpAndReturnTheCountValue | ( | ) | [inline] |
Definition at line 173 of file TAPsCircularCounter.hpp.
00174 { 00175 ++m_tCurrent; 00176 CheckCountUp(); 00177 return m_tCurrent; 00178 }
| T CircularCounter< T >::GetValueCurrent | ( | ) | const [inline] |
| T CircularCounter< T >::GetValueHighest | ( | ) | const [inline] |
| T CircularCounter< T >::GetValueLowest | ( | ) | const [inline] |
| void CircularCounter< T >::SetValueCurrent | ( | T | v | ) | [inline] |
Definition at line 137 of file TAPsCircularCounter.hpp.
00138 { 00139 if ( v > m_tHighest ) m_tCurrent = m_tHighest; 00140 else if ( v < m_tLowest ) m_tCurrent = m_tLowest; 00141 else m_tCurrent = v; 00142 }
| void CircularCounter< T >::SetValueHighest | ( | T | v | ) | [inline] |
Definition at line 143 of file TAPsCircularCounter.hpp.
00144 { 00145 if ( m_tHighest > m_tLowest ) m_tHighest = v; 00146 if ( m_tHighest < m_tCurrent ) m_tCurrent = v; 00147 }
| void CircularCounter< T >::SetValueLowest | ( | T | v | ) | [inline] |
Definition at line 132 of file TAPsCircularCounter.hpp.
00133 { 00134 if ( m_tLowest < m_tHighest ) m_tLowest = v; 00135 if ( m_tLowest > m_tCurrent ) m_tCurrent = v; 00136 }
| std::ostream& operator<< | ( | std::ostream & | output, | |
| CircularCounter< T > const & | ctr | |||
| ) | [friend] |
Definition at line 31 of file TAPsCircularCounter.hpp.
00032 { 00033 output << "CircularCounter<" << typeid(T).name() << ">" 00034 << " Highest Value (" << ctr.m_tHighest 00035 << ") Current Value (" << ctr.m_tCurrent 00036 << ") Lowest Value (" << ctr.m_tLowest; 00037 << ")\n"; 00038 return output; 00039 }
T CircularCounter< T >::m_tCurrent [protected] |
Definition at line 208 of file TAPsCircularCounter.hpp.
T CircularCounter< T >::m_tHighest [protected] |
Definition at line 209 of file TAPsCircularCounter.hpp.
T CircularCounter< T >::m_tLowest [protected] |
Definition at line 207 of file TAPsCircularCounter.hpp.
1.5.6