Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

JCounter Class Reference

#include <JCounter.hpp>

List of all members.

Public Methods

 JCounter (register unsigned long initial=0, register unsigned long maximum=~0)
 JCounter (const JCounter &src)
virtual ~JCounter ()
const JCounter & operator= (const JCounter &src)
const JCounter & operator= (register unsigned long value)
const JCounter & operator+= (const JCounter &src)
const JCounter & operator-= (const JCounter &src)
const JCounter & operator+= (register unsigned long v)
const JCounter & operator-= (register unsigned long v)
const JCounter & operator++ ()
const JCounter & operator-- ()
const JCounter & operator++ (int)
const JCounter & operator-- (int)
const JCounter & operator~ ()
const JCounter & operator! ()
unsigned long operator() ()
bool operator== (const JCounter &src)
bool operator!= (const JCounter &src)
bool operator> (const JCounter &src)
bool operator>= (const JCounter &src)
bool operator< (const JCounter &src)
bool operator<= (const JCounter &src)
bool operator== (register unsigned long v)
bool operator!= (register unsigned long v)
bool operator> (register unsigned long v)
bool operator>= (register unsigned long v)
bool operator< (register unsigned long v)
bool operator<= (register unsigned long v)
JCounter operator+ (const JCounter &right)
JCounter operator- (const JCounter &right)
JCounter operator * (const JCounter &right)
JCounter operator/ (const JCounter &right)
JCounter operator+ (register unsigned long right)
JCounter operator- (register unsigned long right)
JCounter operator * (register unsigned long right)
JCounter operator/ (register unsigned long right)
 operator unsigned long () const
void setMax (register unsigned long maximum)
void set (register unsigned long value)

Protected Methods

void JCounter::check ()
unsigned long JCounter::verify (_int64 value)
JCounter JCounter::add (register unsigned long right, register unsigned long maximum)
JCounter JCounter::substract (register unsigned long right, register unsigned long maximum)
JCounter JCounter::multiply (register unsigned long right, register unsigned long maximum)
JCounter JCounter::divideBy (register unsigned long right, register unsigned long maximum)

Static Protected Methods

unsigned long JCounter::verify (_int64 value, register unsigned long maximum)

Private Methods

__inline JCounter (ULONG init=0)
__inline JCounter (const JCounter &src)
__inline ~JCounter ()
__inline const JCounter & operator= (const JCounter &src)
__inline const JCounter & operator+= (const JCounter &src)
__inline const JCounter & operator-= (const JCounter &src)
__inline const JCounter & operator+= (ULONG v)
__inline const JCounter & operator-= (ULONG v)
__inline const JCounter & operator++ ()
__inline const JCounter & operator-- ()
__inline const JCounter & operator++ (int)
__inline const JCounter & operator-- (int)
__inline const JCounter & operator~ ()
__inline const JCounter & operator! ()
__inline ULONG operator() ()
__inline bool operator== (const JCounter &src)
__inline bool operator!= (const JCounter &src)
__inline bool operator> (const JCounter &src)
__inline bool operator>= (const JCounter &src)
__inline bool operator< (const JCounter &src)
__inline bool operator<= (const JCounter &src)
__inline bool operator== (ULONG v)
__inline bool operator> (ULONG v)
__inline bool operator>= (ULONG v)
__inline bool operator< (ULONG v)
__inline bool operator<= (ULONG v)

Private Attributes

unsigned long count
unsigned long max

Friends

ostream & operator<< (ostream &os, JCounter &right)
istream & operator>> (istream &is, JCounter &right)
bool operator== (register unsigned long left, const JCounter &right)
bool operator!= (register unsigned long left, const JCounter &right)
bool operator> (register unsigned long left, const JCounter &right)
bool operator>= (register unsigned long left, const JCounter &right)
bool operator< (register unsigned long left, const JCounter &right)
bool operator<= (register unsigned long left, const JCounter &right)
JCounter JCounter::operator+ (register unsigned long left, const JCounter &right)
JCounter JCounter::operator- (register unsigned long left, const JCounter &right)
JCounter JCounter::operator * (register unsigned long left, const JCounter &right)
JCounter JCounter::operator/ (register unsigned long left, const JCounter &right)


Constructor & Destructor Documentation

__inline JCounter::JCounter ULONG    init = 0 [inline, private]
 

Definition at line 7 of file JCounter.hpp.

Referenced by JCounter::add(), JCounter::divideBy(), JCounter::multiply(), JCounter::operator *(), JCounter::operator+(), JCounter::operator-(), JCounter::operator/(), and JCounter::substract().

00007 : cnt( init ) { } 

JCounter::JCounter const JCounter &    src [inline, private]
 

Definition at line 8 of file JCounter.hpp.

00008 : cnt( src.cnt ) { } 

JCounter::~JCounter   [inline, private]
 

Definition at line 9 of file JCounter.hpp.

00009 { }

JCounter::JCounter register unsigned long    initial = 0,
register unsigned long    maximum = ~0
[inline]
 

Definition at line 7 of file JCounter.cpp.

00008    : count( initial ), max( maximum )
00009   {
00010     check();
00011   }

JCounter::JCounter const JCounter &    src [inline]
 

virtual JCounter::~JCounter   [inline, virtual]
 


Member Function Documentation

JCounter JCounter::JCounter::add register unsigned long    right,
register unsigned long    maximum
[inline, protected]
 

Definition at line 179 of file JCounter.hpp.

00180   {                              
00181     register ULONG val = verify( ( _int64 )count + ( _int64 )right, maximum );
00182     return JCounter( val );
00183   }

void JCounter::JCounter::check   [inline, protected]
 

Definition at line 157 of file JCounter.hpp.

00158   {
00159     count = (  ( count >= max ) ? max : count  );
00160   }

JCounter JCounter::JCounter::divideBy register unsigned long    right,
register unsigned long    maximum
[inline, protected]
 

Definition at line 197 of file JCounter.hpp.

00198   {
00199     if ( right == 0 ) return JCounter( maximum );
00200     register ULONG val = verify( ( _int64 )count / ( _int64 )right, maximum );
00201     return JCounter( val );
00202   }

JCounter JCounter::JCounter::multiply register unsigned long    right,
register unsigned long    maximum
[inline, protected]
 

Definition at line 191 of file JCounter.hpp.

00192   {
00193     register ULONG val = verify( ( _int64 )count * ( _int64 )right, maximum );
00194     return JCounter( val );
00195   }

JCounter JCounter::JCounter::substract register unsigned long    right,
register unsigned long    maximum
[inline, protected]
 

Definition at line 185 of file JCounter.hpp.

00186   {
00187     register ULONG val = verify( ( _int64 )count - ( _int64 )right, maximum );
00188     return JCounter( val );
00189   }

unsigned long JCounter::JCounter::verify _int64    value,
register unsigned long    maximum
[inline, static, protected]
 

Definition at line 170 of file JCounter.hpp.

00171   {
00172     if ( value <= 0       ) return 0;
00173     if ( value >= maximum ) return maximum;
00174 
00175     return (ULONG)value;
00176   }

unsigned long JCounter::JCounter::verify _int64    value [inline, protected]
 

Definition at line 162 of file JCounter.hpp.

00163   {
00164     if ( value <= 0   ) return 0;
00165     if ( value >= max ) return max;
00166 
00167     return (ULONG)value;
00168   }

JCounter JCounter::operator * register unsigned long    right [inline]
 

Definition at line 144 of file JCounter.cpp.

00144 { return multiply(  right, max ); }

JCounter JCounter::operator * const JCounter &    right [inline]
 

Definition at line 132 of file JCounter.cpp.

00133   { 
00134     return multiply(  right.count, MAX( max, right.max ) ); 
00135   }

JCounter::operator unsigned long   const [inline]
 

Definition at line 139 of file JCounter.hpp.

00140   {
00141      return count;
00142   }

const JCounter& JCounter::operator!   [inline]
 

const JCounter & JCounter::operator!   [inline, private]
 

Definition at line 30 of file JCounter.hpp.

00030 { cnt = 0;  return *this; }

bool JCounter::operator!= register unsigned long    v [inline]
 

Definition at line 115 of file JCounter.cpp.

00115 { return (count != v); }

bool JCounter::operator!= const JCounter &    src [inline]
 

bool JCounter::operator!= const JCounter &    src [inline, private]
 

Definition at line 36 of file JCounter.hpp.

00036 { return (cnt == src.cnt); }

unsigned long JCounter::operator()   [inline]
 

unsigned long JCounter::operator()   [inline, private]
 

Definition at line 32 of file JCounter.hpp.

00032 { return cnt; }

JCounter JCounter::operator+ register unsigned long    right [inline]
 

Definition at line 142 of file JCounter.cpp.

00142 { return add(       right, max ); }

JCounter JCounter::operator+ const JCounter &    right [inline]
 

Definition at line 122 of file JCounter.cpp.

00123   { 
00124     return add(       right.count, MAX( max, right.max ) ); 
00125   }

const JCounter& JCounter::operator++ int    [inline]
 

const JCounter& JCounter::operator++   [inline]
 

const JCounter & JCounter::operator++ int    [inline, private]
 

Definition at line 23 of file JCounter.hpp.

00023 { cnt++;  return *this; }

const JCounter & JCounter::operator++   [inline, private]
 

Definition at line 19 of file JCounter.hpp.

00019 {     ++cnt;  return *this; }

const JCounter & JCounter::operator+= register unsigned long    v [inline]
 

Definition at line 48 of file JCounter.cpp.

00049   {
00050     count = verify( count +  v );  
00051     return *this; 
00052   }

const JCounter& JCounter::operator+= const JCounter &    src [inline]
 

__inline const JCounter& JCounter::operator+= ULONG    v [inline, private]
 

Definition at line 15 of file JCounter.hpp.

00015 { cnt += v;  return *this; }

const JCounter & JCounter::operator+= const JCounter &    src [inline, private]
 

Definition at line 12 of file JCounter.hpp.

00012 { cnt += src.cnt;  return *this; }

JCounter JCounter::operator- register unsigned long    right [inline]
 

Definition at line 143 of file JCounter.cpp.

00143 { return substract( right, max ); }

JCounter JCounter::operator- const JCounter &    right [inline]
 

Definition at line 127 of file JCounter.cpp.

00128   { 
00129     return substract( right.count, MAX( max, right.max ) ); 
00130   }

const JCounter& JCounter::operator-- int    [inline]
 

const JCounter& JCounter::operator--   [inline]
 

const JCounter & JCounter::operator-- int    [inline, private]
 

Definition at line 24 of file JCounter.hpp.

00024 { cnt--;  return *this; }

const JCounter & JCounter::operator--   [inline, private]
 

Definition at line 20 of file JCounter.hpp.

00020 {     --cnt;  return *this; }

const JCounter & JCounter::operator-= register unsigned long    v [inline]
 

Definition at line 54 of file JCounter.cpp.

00055   {
00056     count = verify( count -  v );  
00057     return *this; 
00058   }

const JCounter& JCounter::operator-= const JCounter &    src [inline]
 

__inline const JCounter& JCounter::operator-= ULONG    v [inline, private]
 

Definition at line 16 of file JCounter.hpp.

00016 { cnt -= v;  return *this; }

const JCounter & JCounter::operator-= const JCounter &    src [inline, private]
 

Definition at line 13 of file JCounter.hpp.

00013 { cnt -= src.cnt;  return *this; }

JCounter JCounter::operator/ register unsigned long    right [inline]
 

Definition at line 145 of file JCounter.cpp.

00145 { return divideBy(  right, max ); }

JCounter JCounter::operator/ const JCounter &    right [inline]
 

Definition at line 137 of file JCounter.cpp.

00138   {
00139     return divideBy(  right.count, MAX( max, right.max ) ); 
00140   }

bool JCounter::operator< register unsigned long    v [inline]
 

Definition at line 118 of file JCounter.cpp.

00118 { return (count <  v); }

bool JCounter::operator< const JCounter &    src [inline]
 

__inline bool JCounter::operator< ULONG    v [inline, private]
 

Definition at line 45 of file JCounter.hpp.

00045 { return (cnt <  v); }

bool JCounter::operator< const JCounter &    src [inline, private]
 

Definition at line 39 of file JCounter.hpp.

00039 { return (cnt <  src.cnt); }

bool JCounter::operator<= register unsigned long    v [inline]
 

Definition at line 119 of file JCounter.cpp.

00119 { return (count <= v); }

bool JCounter::operator<= const JCounter &    src [inline]
 

__inline bool JCounter::operator<= ULONG    v [inline, private]
 

Definition at line 46 of file JCounter.hpp.

00046 { return (cnt <= v); }

bool JCounter::operator<= const JCounter &    src [inline, private]
 

Definition at line 40 of file JCounter.hpp.

00040 { return (cnt <= src.cnt); }

const JCounter & JCounter::operator= register unsigned long    value [inline]
 

Definition at line 28 of file JCounter.cpp.

00029   {
00030     count = value;
00031     check();
00032     return *this;
00033   }

const JCounter& JCounter::operator= const JCounter &    src [inline]
 

const JCounter & JCounter::operator= const JCounter &    src [inline, private]
 

Definition at line 11 of file JCounter.hpp.

00011 { cnt = src.cnt; }

bool JCounter::operator== register unsigned long    v [inline]
 

Definition at line 114 of file JCounter.cpp.

00114 { return (count == v); }

bool JCounter::operator== const JCounter &    src [inline]
 

__inline bool JCounter::operator== ULONG    v [inline, private]
 

Definition at line 42 of file JCounter.hpp.

00042 { return (cnt == v); }

bool JCounter::operator== const JCounter &    src [inline, private]
 

Definition at line 35 of file JCounter.hpp.

00035 { return (cnt == src.cnt); }

bool JCounter::operator> register unsigned long    v [inline]
 

Definition at line 116 of file JCounter.cpp.

00116 { return (count >  v); }

bool JCounter::operator> const JCounter &    src [inline]
 

__inline bool JCounter::operator> ULONG    v [inline, private]
 

Definition at line 43 of file JCounter.hpp.

00043 { return (cnt >  v); }

bool JCounter::operator> const JCounter &    src [inline, private]
 

Definition at line 37 of file JCounter.hpp.

00037 { return (cnt >  src.cnt); }

bool JCounter::operator>= register unsigned long    v [inline]
 

Definition at line 117 of file JCounter.cpp.

00117 { return (count >= v); }

bool JCounter::operator>= const JCounter &    src [inline]
 

__inline bool JCounter::operator>= ULONG    v [inline, private]
 

Definition at line 44 of file JCounter.hpp.

00044 { return (cnt >= v); }

bool JCounter::operator>= const JCounter &    src [inline, private]
 

Definition at line 38 of file JCounter.hpp.

00038 { return (cnt >= src.cnt); }

const JCounter& JCounter::operator~   [inline]
 

const JCounter & JCounter::operator~   [inline, private]
 

Definition at line 27 of file JCounter.hpp.

00027 { cnt = (ULONG)(~0); return *this; }

void JCounter::set register unsigned long    value [inline]
 

Definition at line 150 of file JCounter.hpp.

00151   {
00152      count = verify( (_int64)value );
00153   }

void JCounter::setMax register unsigned long    maximum [inline]
 

Definition at line 145 of file JCounter.hpp.

00146   {
00147      max = maximum;
00148   }


Friends And Related Function Documentation

JCounter JCounter::operator * register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 124 of file JCounter.hpp.

00125   {
00126     register ULONG val = verify( ( _int64 )left * ( _int64 )right.count, right.max );
00127     return JCounter( val );
00128   }

JCounter JCounter::operator+ register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 112 of file JCounter.hpp.

00113   {
00114     register ULONG val = verify( ( _int64 )left + ( _int64 )right.count, right.max );
00115     return JCounter( val );
00116   }

JCounter JCounter::operator- register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 118 of file JCounter.hpp.

00119   {
00120     register ULONG val = verify( ( _int64 )left - ( _int64 )right.count, right.max );
00121     return JCounter( val );
00122   }

JCounter JCounter::operator/ register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 130 of file JCounter.hpp.

00131   {
00132     if ( right.count == 0 ) return JCounter( right.max );
00133     register ULONG val = verify( ( _int64 )left / ( _int64 )right.count, right.max );
00134     return JCounter( val );
00135   }

bool operator!= register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 105 of file JCounter.hpp.

00105 { return ( left != right.count ); }

bool operator< register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 108 of file JCounter.hpp.

00108 { return ( left <  right.count ); }

ostream& operator<< ostream &    os,
JCounter &    right
[friend]
 

Definition at line 89 of file JCounter.hpp.

00090   {
00091      return os << right.count;
00092   }

bool operator<= register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 109 of file JCounter.hpp.

00109 { return ( left <= right.count ); }

bool operator== register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 104 of file JCounter.hpp.

00104 { return ( left == right.count ); }

bool operator> register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 106 of file JCounter.hpp.

00106 { return ( left >  right.count ); }

bool operator>= register unsigned long    left,
const JCounter &    right
[friend]
 

Definition at line 107 of file JCounter.hpp.

00107 { return ( left >= right.count ); }

istream& operator>> istream &    is,
JCounter &    right
[friend]
 

Definition at line 94 of file JCounter.hpp.

00095   {
00096      return is >> right.count;
00097   }


Member Data Documentation

unsigned long JCounter::count [private]
 

Definition at line 205 of file JCounter.hpp.

Referenced by JCounter::operator *(), JCounter::operator+(), JCounter::operator-(), JCounter::operator/(), operator *(), operator!=(), operator+(), operator-(), operator/(), operator<(), operator<<(), operator<=(), operator==(), operator>(), operator>=(), and operator>>().

unsigned long JCounter::max [private]
 

Definition at line 206 of file JCounter.hpp.

Referenced by JCounter::operator *(), JCounter::operator+(), JCounter::operator-(), JCounter::operator/(), operator *(), operator+(), operator-(), and operator/().


The documentation for this class was generated from the following files:
Generated on Sun Oct 14 18:48:46 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001