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

C:/temp/src/j2k/Fred/JCounter.cpp

Go to the documentation of this file.
00001 #ifndef __JCounter_CPP__
00002 #define __JCounter_CPP__
00003 
00004 #include "JCounter.hpp"
00005 
00006   // Default Constructor
00007   inline  JCounter::JCounter( register ULONG initial, register ULONG maximum )
00008    : count( initial ), max( maximum )
00009   {
00010     check();
00011   }
00012 
00013   // Copy Constructor
00014   inline  JCounter::JCounter( const JCounter& src )
00015    : count( src.count ), max( src.max ) { }
00016 
00017   // Destructor
00018   inline  JCounter::~JCounter() { }
00019 
00020   // Assign operator
00021   inline  const JCounter&  JCounter::operator =  ( const JCounter& src )
00022   {
00023     count = src.count;
00024     max   = src.max;
00025     return *this;
00026   }
00027 
00028   inline  const JCounter&  JCounter::operator =  ( register ULONG value )
00029   {
00030     count = value;
00031     check();
00032     return *this;
00033   }
00034 
00035   // Add and Subtract operator
00036   inline  const JCounter&  JCounter::operator += ( const JCounter& src ) 
00037   {
00038     count = verify( count + src.count );
00039     return *this; 
00040   }
00041 
00042   inline  const JCounter&  JCounter::operator -= ( const JCounter& src ) 
00043   { 
00044     count = verify( count - src.count );  
00045     return *this; 
00046   }
00047 
00048   inline  const JCounter&  JCounter::operator += ( register ULONG v ) 
00049   {
00050     count = verify( count +  v );  
00051     return *this; 
00052   }
00053 
00054   inline  const JCounter&  JCounter::operator -= ( register ULONG v ) 
00055   {
00056     count = verify( count -  v );  
00057     return *this; 
00058   }
00059 
00060   // Pre update                                        
00061   inline  const JCounter&  JCounter::operator ++ ( ) 
00062   {  
00063     ++count;    
00064     check();  
00065     return *this; 
00066   }
00067 
00068   inline  const JCounter&  JCounter::operator -- ( ) 
00069   {  
00070     --count;    
00071     check();  
00072     return *this; 
00073   }
00074 
00075   // Post update
00076   inline  const JCounter&  JCounter::operator ++ ( int )
00077   {  
00078     count++;    
00079     check();  
00080     return *this; 
00081   }
00082 
00083   inline  const JCounter&  JCounter::operator -- ( int )
00084   {  
00085     count--;    
00086     check();  
00087     return *this; 
00088   }
00089 
00090   // Get Maximum
00091   inline  const JCounter&  JCounter::operator ~  ( ) 
00092   {
00093     count = (ULONG)(~0);
00094     return *this; 
00095   }
00096  
00097   // Get Minimum
00098   inline  const JCounter&  JCounter::operator !  ( )
00099   {
00100     count = 0;
00101     return *this; 
00102   }
00103 
00104   inline  ULONG            JCounter::operator() ( ) { return count; }
00105 
00106   // Compare operators:
00107   inline  BOOL  JCounter::operator == ( const JCounter& src ) { return (count == src.count); }
00108   inline  BOOL  JCounter::operator != ( const JCounter& src ) { return (count == src.count); }
00109   inline  BOOL  JCounter::operator >  ( const JCounter& src ) { return (count >  src.count); }
00110   inline  BOOL  JCounter::operator >= ( const JCounter& src ) { return (count >= src.count); }
00111   inline  BOOL  JCounter::operator <  ( const JCounter& src ) { return (count <  src.count); }
00112   inline  BOOL  JCounter::operator <= ( const JCounter& src ) { return (count <= src.count); }
00113 
00114   inline  BOOL  JCounter::operator == ( register ULONG v ) { return (count == v); }
00115   inline  BOOL  JCounter::operator != ( register ULONG v ) { return (count != v); }
00116   inline  BOOL  JCounter::operator >  ( register ULONG v ) { return (count >  v); }
00117   inline  BOOL  JCounter::operator >= ( register ULONG v ) { return (count >= v); }
00118   inline  BOOL  JCounter::operator <  ( register ULONG v ) { return (count <  v); }
00119   inline  BOOL  JCounter::operator <= ( register ULONG v ) { return (count <= v); }
00120 
00121   // Arithmetic operator
00122   inline JCounter  JCounter::operator + ( const JCounter& right ) 
00123   { 
00124     return add(       right.count, MAX( max, right.max ) ); 
00125   }
00126 
00127   inline JCounter  JCounter::operator - ( const JCounter& right ) 
00128   { 
00129     return substract( right.count, MAX( max, right.max ) ); 
00130   }
00131 
00132   inline JCounter  JCounter::operator * ( const JCounter& right ) 
00133   { 
00134     return multiply(  right.count, MAX( max, right.max ) ); 
00135   }
00136 
00137   inline JCounter  JCounter::operator / ( const JCounter& right ) 
00138   {
00139     return divideBy(  right.count, MAX( max, right.max ) ); 
00140   }
00141 
00142   inline JCounter  JCounter::operator + ( register ULONG right ) { return add(       right, max ); }
00143   inline JCounter  JCounter::operator - ( register ULONG right ) { return substract( right, max ); }
00144   inline JCounter  JCounter::operator * ( register ULONG right ) { return multiply(  right, max ); }
00145   inline JCounter  JCounter::operator / ( register ULONG right ) { return divideBy(  right, max ); }
00146 
00147  
00148 #endif

Generated on Sun Oct 14 18:46:32 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001