![]() |
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... | |
BitSetBuffer & | operator= (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_BYTES > | m_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 |
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.
N | The number of bits in the bit set. |
|
private |
|
inline |
Create a bit buffer with all bits set to zero.
|
inline |
Create a bit buffer by copying another buffer.
|
inline |
Get a pointer to the buffer's storage.
|
inline |
Get a pointer to the buffer's storage.
|
inline |
Copy bit buffer contents from another buffer.
|
inline |
Reset all bits in the buffer to off.
|
inline |
Reset the specified bit in the buffer to off.
pos | The index of the bit to turn off. |
|
inline |
Set all bits in the buffer to on.
|
inline |
Set the specified bit in the buffer to on.
pos | The index of the bit to turn on. |
|
inlinestatic |
Get the number of bits in the bit set.
|
inlinestatic |
Get the number of bytes in the bit set.
|
inline |
Get the specified bit in the buffer.
pos | The index of the bit to test. |
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |