OpaqueInteger< T, Dummy > Class Template Reference

OpaqueInteger is a wrapper for a primitive integer type. More...

#include <OpaqueInteger.h>

List of all members.

Public Member Functions

 OpaqueInteger ()
 OpaqueInteger (T t)
int operator== (OpaqueInteger< T, Dummy > other) const
int operator!= (OpaqueInteger< T, Dummy > other) const
int operator< (OpaqueInteger< T, Dummy > other) const
int operator> (OpaqueInteger< T, Dummy > other) const
int operator<= (OpaqueInteger< T, Dummy > other) const
int operator>= (OpaqueInteger< T, Dummy > other) const
OpaqueInteger< T, Dummy > operator++ ()
OpaqueInteger< T, Dummy > operator++ (int)
OpaqueInteger< T, Dummy > operator-- ()
OpaqueInteger< T, Dummy > operator-- (int)
OpaqueInteger< T, Dummy > operator *= (OpaqueInteger< T, Dummy > i)
OpaqueInteger< T, Dummy > operator/= (OpaqueInteger< T, Dummy > i)
OpaqueInteger< T, Dummy > operator+= (OpaqueInteger< T, Dummy > i)
OpaqueInteger< T, Dummy > operator-= (OpaqueInteger< T, Dummy > i)
OpaqueInteger< T, Dummy > operator%= (OpaqueInteger< T, Dummy > i)
OpaqueInteger< T, Dummy > operator *= (T t)
OpaqueInteger< T, Dummy > operator/= (T t)
OpaqueInteger< T, Dummy > operator+= (T t)
OpaqueInteger< T, Dummy > operator-= (T t)
OpaqueInteger< T, Dummy > operator%= (T t)
OpaqueInteger< T, Dummy > operator>>= (int i)
OpaqueInteger< T, Dummy > operator<<= (int i)
OpaqueInteger< T, Dummy > operator>> (int i) const
OpaqueInteger< T, Dummy > operator<< (int i) const
OpaqueInteger< T, Dummy > operator% (T i) const
OpaqueInteger< T, Dummy > operator/ (T i) const
OpaqueInteger< T, Dummy > operator * (T i) const
OpaqueInteger< T, Dummy > operator+ (T t) const
OpaqueInteger< T, Dummy > operator- (T t) const
OpaqueInteger< T, Dummy > operator% (OpaqueInteger< T, Dummy > i) const
OpaqueInteger< T, Dummy > operator/ (OpaqueInteger< T, Dummy > i) const
OpaqueInteger< T, Dummy > operator * (OpaqueInteger< T, Dummy > i) const
OpaqueInteger< T, Dummy > operator+ (OpaqueInteger< T, Dummy > i) const
OpaqueInteger< T, Dummy > operator- (OpaqueInteger< T, Dummy > i) const
getWrapped () const

Protected Attributes

val


Detailed Description

template<class T, class Dummy>
class OpaqueInteger< T, Dummy >

OpaqueInteger is a wrapper for a primitive integer type.

It is not meant to be used directly; instead, use the macros at the end of this file. If an operation you need isn't here all ready, please add it. However, do NOT add an automatic cast operator or implicit constructor. The point of this class is to help prevent implicit conversions between values with different semantics. For example:

    DEFINE_OPAQUE_INTEGER(Apple,uint);
    DEFINE_OPAQUE_INTEGER(Orange,uint);

    Apple apple_jack,apple_seed(20);
    Orange oj;

    apple_jack = apple_seed+2; // legal
    oj = apple_jack;            // won't compile, can't compare apples&oranges

Note that in a non-debug build, the macro expands to a simple typedef, so there is no performance penalty for using it. However, this also means that you have to be careful with overloading to avoid release-build breakage.

// TODO: extend the mechanism to be able to handle inheritance (e.g. BTreeId isa PageOwnerId).

Definition at line 63 of file OpaqueInteger.h.


Constructor & Destructor Documentation

template<class T, class Dummy>
OpaqueInteger< T, Dummy >::OpaqueInteger (  )  [inline]

Definition at line 68 of file OpaqueInteger.h.

00069     {
00070         // NOTE:  the default constructor should NOT
00071         // initialize to 0, because this doesn't match the non-DEBUG
00072         // behavior, AND actually breaks some  code (scary but true)
00073     }

template<class T, class Dummy>
OpaqueInteger< T, Dummy >::OpaqueInteger ( t  )  [inline, explicit]

Definition at line 75 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00076     {
00077         val = t;
00078     }


Member Function Documentation

template<class T, class Dummy>
int OpaqueInteger< T, Dummy >::operator== ( OpaqueInteger< T, Dummy >  other  )  const [inline]

Definition at line 80 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00081     {
00082         return val == other.val;
00083     }

template<class T, class Dummy>
int OpaqueInteger< T, Dummy >::operator!= ( OpaqueInteger< T, Dummy >  other  )  const [inline]

Definition at line 85 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00086     {
00087         return val != other.val;
00088     }

template<class T, class Dummy>
int OpaqueInteger< T, Dummy >::operator< ( OpaqueInteger< T, Dummy >  other  )  const [inline]

Definition at line 90 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00091     {
00092         return val < other.val;
00093     }

template<class T, class Dummy>
int OpaqueInteger< T, Dummy >::operator> ( OpaqueInteger< T, Dummy >  other  )  const [inline]

Definition at line 95 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00096     {
00097         return val > other.val;
00098     }

template<class T, class Dummy>
int OpaqueInteger< T, Dummy >::operator<= ( OpaqueInteger< T, Dummy >  other  )  const [inline]

Definition at line 100 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00101     {
00102         return val <= other.val;
00103     }

template<class T, class Dummy>
int OpaqueInteger< T, Dummy >::operator>= ( OpaqueInteger< T, Dummy >  other  )  const [inline]

Definition at line 105 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00106     {
00107         return val >= other.val;
00108     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator++ (  )  [inline]

Definition at line 110 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00111     {
00112         return OpaqueInteger<T,Dummy>(++val);
00113     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator++ ( int   )  [inline]

Definition at line 115 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00116     {
00117         return OpaqueInteger<T,Dummy>(val++);
00118     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-- (  )  [inline]

Definition at line 120 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00121     {
00122         return OpaqueInteger<T,Dummy>(--val);
00123     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-- ( int   )  [inline]

Definition at line 125 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00126     {
00127         return OpaqueInteger<T,Dummy>(val--);
00128     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator *= ( OpaqueInteger< T, Dummy >  i  )  [inline]

Definition at line 130 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00131     {
00132         val *= i.val;
00133         return *this;
00134     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/= ( OpaqueInteger< T, Dummy >  i  )  [inline]

Definition at line 136 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00137     {
00138         val /= i.val;
00139         return *this;
00140     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+= ( OpaqueInteger< T, Dummy >  i  )  [inline]

Definition at line 142 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00143     {
00144         val += i.val;
00145         return *this;
00146     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-= ( OpaqueInteger< T, Dummy >  i  )  [inline]

Definition at line 148 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00149     {
00150         val -= i.val;
00151         return *this;
00152     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator%= ( OpaqueInteger< T, Dummy >  i  )  [inline]

Definition at line 154 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00155     {
00156         val %= i.val;
00157         return *this;
00158     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator *= ( t  )  [inline]

Definition at line 160 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00161     {
00162         val *= t;
00163         return *this;
00164     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/= ( t  )  [inline]

Definition at line 166 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00167     {
00168         val /= t;
00169         return *this;
00170     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+= ( t  )  [inline]

Definition at line 172 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00173     {
00174         val += t;
00175         return *this;
00176     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-= ( t  )  [inline]

Definition at line 178 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00179     {
00180         val -= t;
00181         return *this;
00182     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator%= ( t  )  [inline]

Definition at line 184 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00185     {
00186         val %= t;
00187         return *this;
00188     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator>>= ( int  i  )  [inline]

Definition at line 190 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00191     {
00192         val >>= i;
00193         return *this;
00194     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator<<= ( int  i  )  [inline]

Definition at line 196 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00197     {
00198         val >>= i;
00199         return *this;
00200     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator>> ( int  i  )  const [inline]

Definition at line 202 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00203     {
00204         return OpaqueInteger<T,Dummy>(val >> i);
00205     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator<< ( int  i  )  const [inline]

Definition at line 207 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00208     {
00209         return OpaqueInteger<T,Dummy>(val << i);
00210     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator% ( i  )  const [inline]

Definition at line 212 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00213     {
00214         return OpaqueInteger<T,Dummy>(val % i);
00215     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/ ( i  )  const [inline]

Definition at line 217 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00218     {
00219         return OpaqueInteger<T,Dummy>(val / i);
00220     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator * ( i  )  const [inline]

Definition at line 222 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00223     {
00224         return OpaqueInteger<T,Dummy>(val * i);
00225     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+ ( t  )  const [inline]

Definition at line 227 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00228     {
00229         return OpaqueInteger<T,Dummy>(val+t);
00230     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator- ( t  )  const [inline]

Definition at line 232 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00233     {
00234         return OpaqueInteger<T,Dummy>(val-t);
00235     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator% ( OpaqueInteger< T, Dummy >  i  )  const [inline]

Definition at line 237 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00238     {
00239         return OpaqueInteger<T,Dummy>(val % i.val);
00240     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/ ( OpaqueInteger< T, Dummy >  i  )  const [inline]

Definition at line 242 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00243     {
00244         return OpaqueInteger<T,Dummy>(val / i.val);
00245     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator * ( OpaqueInteger< T, Dummy >  i  )  const [inline]

Definition at line 247 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00248     {
00249         return OpaqueInteger<T,Dummy>(val * i.val);
00250     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+ ( OpaqueInteger< T, Dummy >  i  )  const [inline]

Definition at line 252 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00253     {
00254         return OpaqueInteger<T,Dummy>(val+i.val);
00255     }

template<class T, class Dummy>
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator- ( OpaqueInteger< T, Dummy >  i  )  const [inline]

Definition at line 257 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

00258     {
00259         return OpaqueInteger<T,Dummy>(val-i.val);
00260     }

template<class T, class Dummy>
T OpaqueInteger< T, Dummy >::getWrapped (  )  const [inline]

Definition at line 262 of file OpaqueInteger.h.

References OpaqueInteger< T, Dummy >::val.

Referenced by opaqueToInt().

00263     {
00264         return val;
00265     }


Member Data Documentation

template<class T, class Dummy>
T OpaqueInteger< T, Dummy >::val [protected]

Definition at line 66 of file OpaqueInteger.h.

Referenced by OpaqueInteger< T, Dummy >::getWrapped(), OpaqueInteger< T, Dummy >::OpaqueInteger(), OpaqueInteger< T, Dummy >::operator *(), OpaqueInteger< T, Dummy >::operator *=(), OpaqueInteger< T, Dummy >::operator!=(), OpaqueInteger< T, Dummy >::operator%(), OpaqueInteger< T, Dummy >::operator%=(), OpaqueInteger< T, Dummy >::operator+(), OpaqueInteger< T, Dummy >::operator++(), OpaqueInteger< T, Dummy >::operator+=(), OpaqueInteger< T, Dummy >::operator-(), OpaqueInteger< T, Dummy >::operator--(), OpaqueInteger< T, Dummy >::operator-=(), OpaqueInteger< T, Dummy >::operator/(), OpaqueInteger< T, Dummy >::operator/=(), OpaqueInteger< T, Dummy >::operator<(), OpaqueInteger< T, Dummy >::operator<<(), OpaqueInteger< T, Dummy >::operator<<=(), OpaqueInteger< T, Dummy >::operator<=(), OpaqueInteger< T, Dummy >::operator==(), OpaqueInteger< T, Dummy >::operator>(), OpaqueInteger< T, Dummy >::operator>=(), OpaqueInteger< T, Dummy >::operator>>(), and OpaqueInteger< T, Dummy >::operator>>=().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:40 2009 for Fennel by  doxygen 1.5.1