Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes | List of all members
SurgSim::Device::BitSetBuffer< N > Class Template Reference

A bit set corresponding to a contiguous memory buffer. More...

#include <SurgSim/Devices/MultiAxis/BitSetBuffer.h>

Public Member Functions

 BitSetBuffer ()
 Create a bit buffer with all bits set to zero. More...
 
 BitSetBuffer (const BitSetBuffer &other)
 Create a bit buffer by copying another buffer. More...
 
BitSetBufferoperator= (const BitSetBuffer &other)
 Copy bit buffer contents from another buffer. More...
 
void set ()
 Set all bits in the buffer to on. More...
 
void set (size_t pos)
 Set the specified bit in the buffer to on. More...
 
void reset ()
 Reset all bits in the buffer to off. More...
 
void reset (size_t pos)
 Reset the specified bit in the buffer to off. More...
 
bool test (size_t pos) const
 Get the specified bit in the buffer. More...
 
void * getPointer ()
 Get a pointer to the buffer's storage. More...
 
const void * getPointer () const
 Get a pointer to the buffer's storage. More...
 

Static Public Member Functions

static size_t size ()
 Get the number of bits in the bit set. More...
 
static size_t sizeBytes ()
 Get the number of bytes in the bit set. More...
 

Private Types

typedef unsigned char value_type
 

Private Attributes

std::array< value_type, NUM_BYTESm_bytes
 

Static Private Attributes

static const size_t ELEMENT_BYTES = sizeof(value_type)
 
static const size_t ELEMENT_BITS = ELEMENT_BYTES * 8
 
static const size_t NUM_BITS = N
 
static const size_t NUM_BYTES = (NUM_BITS + ELEMENT_BITS - 1) / ELEMENT_BITS
 

Detailed Description

template<size_t N>
class SurgSim::Device::BitSetBuffer< N >

A bit set corresponding to a contiguous memory buffer.

A std::bitset {almost} does everything we need, but we need to also access the storage as bytes.

The method names are generally stolen straight from std::bitset.

Template Parameters
NThe number of bits in the bit set.

Member Typedef Documentation

template<size_t N>
typedef unsigned char SurgSim::Device::BitSetBuffer< N >::value_type
private

Constructor & Destructor Documentation

template<size_t N>
SurgSim::Device::BitSetBuffer< N >::BitSetBuffer ( )
inline

Create a bit buffer with all bits set to zero.

template<size_t N>
SurgSim::Device::BitSetBuffer< N >::BitSetBuffer ( const BitSetBuffer< N > &  other)
inline

Create a bit buffer by copying another buffer.

Member Function Documentation

template<size_t N>
void* SurgSim::Device::BitSetBuffer< N >::getPointer ( )
inline

Get a pointer to the buffer's storage.

template<size_t N>
const void* SurgSim::Device::BitSetBuffer< N >::getPointer ( ) const
inline

Get a pointer to the buffer's storage.

template<size_t N>
BitSetBuffer& SurgSim::Device::BitSetBuffer< N >::operator= ( const BitSetBuffer< N > &  other)
inline

Copy bit buffer contents from another buffer.

template<size_t N>
void SurgSim::Device::BitSetBuffer< N >::reset ( )
inline

Reset all bits in the buffer to off.

template<size_t N>
void SurgSim::Device::BitSetBuffer< N >::reset ( size_t  pos)
inline

Reset the specified bit in the buffer to off.

Parameters
posThe index of the bit to turn off.
template<size_t N>
void SurgSim::Device::BitSetBuffer< N >::set ( )
inline

Set all bits in the buffer to on.

template<size_t N>
void SurgSim::Device::BitSetBuffer< N >::set ( size_t  pos)
inline

Set the specified bit in the buffer to on.

Parameters
posThe index of the bit to turn on.
template<size_t N>
static size_t SurgSim::Device::BitSetBuffer< N >::size ( )
inlinestatic

Get the number of bits in the bit set.

template<size_t N>
static size_t SurgSim::Device::BitSetBuffer< N >::sizeBytes ( )
inlinestatic

Get the number of bytes in the bit set.

template<size_t N>
bool SurgSim::Device::BitSetBuffer< N >::test ( size_t  pos) const
inline

Get the specified bit in the buffer.

Parameters
posThe index of the bit to test.

Member Data Documentation

template<size_t N>
const size_t SurgSim::Device::BitSetBuffer< N >::ELEMENT_BITS = ELEMENT_BYTES * 8
staticprivate
template<size_t N>
const size_t SurgSim::Device::BitSetBuffer< N >::ELEMENT_BYTES = sizeof(value_type)
staticprivate
template<size_t N>
std::array<value_type, NUM_BYTES> SurgSim::Device::BitSetBuffer< N >::m_bytes
private
template<size_t N>
const size_t SurgSim::Device::BitSetBuffer< N >::NUM_BITS = N
staticprivate
template<size_t N>
const size_t SurgSim::Device::BitSetBuffer< N >::NUM_BYTES = (NUM_BITS + ELEMENT_BITS - 1) / ELEMENT_BITS
staticprivate

The documentation for this class was generated from the following file: