Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

base::bitptr_t< PtrType > Class Template Reference

Encapsulation of lower bit manipulation of a pointer. More...

#include <bitptr.h>

List of all members.

Public Member Functions

 bitptr_t ()
 Default constructor.
 bitptr_t (PtrType *ptr)
 Pointer constructor.
 bitptr_t (uintptr_t mask)
 Bits constructor.
 bitptr_t (intptr_t mask)
 Bits constructor, only a wrapper for convenience.
 bitptr_t (PtrType *ptr, uintptr_t mask)
 Pointer and bits constructor.
 bitptr_t (PtrType *ptr, intptr_t mask)
 Pointer and bits constructor, wrapper for convenience only.
 bitptr_t (bitptr_t< PtrType > ptr, uintptr_t mask)
 IntPtr and new bits for int part.
 bitptr_t (bitptr_t< PtrType > ptr, intptr_t mask)
 IntPtr and new bits for int part, wrapper for convenience only.
 bitptr_t (PtrType *ptr, bitptr_t bits)
 IntPtr and new bits for int part.
uintptr_t getBits () const
 Read the int bits only.
uintptr_t getBits (uintptr_t mask) const
 Read some bits only from the int bits.
intptr_t getBits (intptr_t mask) const
 Read some bits only from the int bits, wrapper for convenience only.
PtrType * getPtr () const
 Read the pointer part.
void addBits (uintptr_t mask)
 Add bits and don't touche the pointer part.
void addBits (intptr_t mask)
 Add bits and don't touche the pointer part, for convenience only.
void delBits (uintptr_t mask)
 Delete bits and don't touch the pointer part.
void delBits (intptr_t mask)
 Delete bits and don't touch the pointer part, for convenience only.
void setPtr (PtrType *ptr)
 Set the pointer part and keep the int part.

Private Attributes

bitptr_u value
 value & ~3 is the pointer and value & 3 is the int part


Detailed Description

template<class PtrType>
class base::bitptr_t< PtrType >

Encapsulation of lower bit manipulation of a pointer.

bitptr_t protects operation on the 2 lower bits of a pointer. These bits may contain data. Valid operation is done only on those 2 bits. Name IntPtr chosen because it is a hybrid type both an int and a pointer. Name in lower case because it is a wrapper around a pointer/int basic scalar type.


Constructor & Destructor Documentation

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t  )  [inline]
 

Default constructor.

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t PtrType *  ptr  )  [inline]
 

Pointer constructor.

Parameters:
ptr,: pointer to represent.
Precondition:
ptr is 32 bit aligned.

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t uintptr_t  mask  )  [inline]
 

Bits constructor.

Parameters:
mask,: bits of the int part.
Precondition:
mask <= 3.

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t intptr_t  mask  )  [inline]
 

Bits constructor, only a wrapper for convenience.

Parameters:
mask,: bits of the int part.
Precondition:
mask <= 3 and mask >= 0

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t PtrType *  ptr,
uintptr_t  mask
[inline]
 

Pointer and bits constructor.

Parameters:
ptr,: pointer to represent.
mask,: bits of the int part.
Precondition:
  • ptr is 32 bits aligned.
  • mask <= 3

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t PtrType *  ptr,
intptr_t  mask
[inline]
 

Pointer and bits constructor, wrapper for convenience only.

Parameters:
ptr,: pointer to represent.
mask,: bits of the int part.
Precondition:
  • ptr is 32 bits aligned.
  • mask <= 3 and mask >= 0

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t bitptr_t< PtrType >  ptr,
uintptr_t  mask
[inline]
 

IntPtr and new bits for int part.

Takes pointer from ptr and bits from mask

Parameters:
ptr,: pointer part to take.
mask,: bits of the int part.
Precondition:
mask <= 3

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t bitptr_t< PtrType >  ptr,
intptr_t  mask
[inline]
 

IntPtr and new bits for int part, wrapper for convenience only.

Takes pointer from ptr and bits from mask

Parameters:
ptr,: pointer part to take.
mask,: bits of the int part.
Precondition:
mask <= 3 and mask >= 0

template<class PtrType>
base::bitptr_t< PtrType >::bitptr_t PtrType *  ptr,
bitptr_t< PtrType >  bits
[inline]
 

IntPtr and new bits for int part.

Takes pointer from ptr and bits from mask

Parameters:
ptr,: pointer part to take.
bits,: bits of the int part.


Member Function Documentation

template<class PtrType>
void base::bitptr_t< PtrType >::addBits intptr_t  mask  )  [inline]
 

Add bits and don't touche the pointer part, for convenience only.

Parameters:
mask,: bits to add.
Precondition:
mask <= 3 and mask >= 0

template<class PtrType>
void base::bitptr_t< PtrType >::addBits uintptr_t  mask  )  [inline]
 

Add bits and don't touche the pointer part.

Parameters:
mask,: bits to add.
Precondition:
mask <= 3

template<class PtrType>
void base::bitptr_t< PtrType >::delBits intptr_t  mask  )  [inline]
 

Delete bits and don't touch the pointer part, for convenience only.

Parameters:
mask,: bits to remove.
Precondition:
mask <= 3 and mask >= 0

template<class PtrType>
void base::bitptr_t< PtrType >::delBits uintptr_t  mask  )  [inline]
 

Delete bits and don't touch the pointer part.

Parameters:
mask,: bits to remove.
Precondition:
mask <= 3

template<class PtrType>
intptr_t base::bitptr_t< PtrType >::getBits intptr_t  mask  )  const [inline]
 

Read some bits only from the int bits, wrapper for convenience only.

Parameters:
mask,: mask to read the bits.
Precondition:
mask <= 3 and mask >= 0

template<class PtrType>
uintptr_t base::bitptr_t< PtrType >::getBits uintptr_t  mask  )  const [inline]
 

Read some bits only from the int bits.

Parameters:
mask,: mask to read the bits.
Precondition:
mask <= 3

template<class PtrType>
uintptr_t base::bitptr_t< PtrType >::getBits  )  const [inline]
 

Read the int bits only.

Returns:
the int part of IntPtr.

template<class PtrType>
PtrType* base::bitptr_t< PtrType >::getPtr  )  const [inline]
 

Read the pointer part.

Returns:
a clean pointer aligned on 32 bits.

template<class PtrType>
void base::bitptr_t< PtrType >::setPtr PtrType *  ptr  )  [inline]
 

Set the pointer part and keep the int part.

Parameters:
ptr,: new pointer value.
Precondition:
ptr is 32 bits aligned.


Member Data Documentation

template<class PtrType>
bitptr_u base::bitptr_t< PtrType >::value [private]
 

value & ~3 is the pointer and value & 3 is the int part


The documentation for this class was generated from the following file:
Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2