16 #ifndef AGX_BITARRAY_H
17 #define AGX_BITARRAY_H
24 # pragma warning(push)
25 # pragma warning(disable: 6011)
34 #define BITARRAY_BIT_INDEX(bit) ((bit) / CHAR_BIT)
37 #define BITARRAY_BIT_MASK(bit) (1 << (bit % CHAR_BIT))
49 static const unsigned short result = ( val / 8.0 - ( int )( val / 8.0 ) ) == 0 ? (
int )( val / 8.0 ) : (
int )( val / 8.0 ) + 1;
54 #if defined(__INTEL_COMPILER) || defined(__clang__)
57 static const unsigned short result = ( val / 8.0 - ( int )( val / 8.0 ) ) == 0 ? (
int )( val / 8.0 ) : (
int )( val / 8.0 ) + 1;
65 double const BITS=8.0;
69 static const unsigned short result;
73 const unsigned short BitSize<val>::result = (
unsigned short)(( val / BITS - (
int )( val / BITS ) ) == 0 ? ( int )( val / BITS ) : ( int )( val / BITS ) + 1);
84 template <
size_t NUM_BITS>
90 memset( m_data, 0, NUM_BYTES );
129 agxAssert1( m_bitArray,
"Null reference to bitarray" );
130 agxAssert1( m_bitArray->
size() > m_index,
"Out of bounds indexing of bitarray" );
132 return m_bitArray->
get( m_index );
139 agxAssert1( m_bitArray,
"Null reference to bitarray" );
140 agxAssert1( m_bitArray->
size() > m_index,
"Out of bounds indexing of bitarray" );
142 m_bitArray->
set( m_index, val );
148 m_index = other.m_index;
149 m_bitArray = other.m_bitArray;
154 if (
this == &other )
157 m_index = other.m_index;
158 m_bitArray = other.m_bitArray;
185 agxAssert1( m_bitArray,
"Null reference to bitarray" );
186 agxAssert1( m_bitArray->
size() > m_index,
"Out of bounds indexing of bitarray" );
188 return m_bitArray->
get( m_index );
193 m_index = other.m_index;
194 m_bitArray = other.m_bitArray;
199 if (
this == &other )
202 m_index = other.m_index;
203 m_bitArray = other.m_bitArray;
245 NUM_BYTES = int(BitSize<NUM_BITS>::result)
250 char m_data[NUM_BYTES];
253 #ifdef BITARRAY_BIT_MASK
254 #undef BITARRAY_BIT_MASK
259 # pragma warning(pop)
#define BITARRAY_BIT_INDEX(bit)
#define BITARRAY_BIT_MASK(bit)
Class which is a reference into an existing bitarray.
const_reference(const BitArray *array, size_t index)
const_reference & operator=(const const_reference &other)
assignment operator
const_reference(const const_reference &other)
Copy constructor.
Class which is a reference into an existing bitarray.
reference & operator=(const reference &other)
assignment operator
reference & operator=(const bool val)
Assignment of a bool value into the bitarray index.
reference(BitArray *array, size_t index)
reference(const reference &other)
Copy constructor.
Class for stack-storage of a (at compile time) specified number of bits with a minimal size of storag...
BitArray(const BitArray &)
void set(size_t n, bool flag)
Set the n:th bit in the bitarray to flag.
BitArray()
Constructor, initializes all bits to zero.
BitArray & operator=(const BitArray &)
reference operator[](size_t bit)
const_reference operator[](size_t bit) const
#define agxAssert1(expr, msg)
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
The agx namespace contains the dynamics/math part of the AGX Dynamics API.