16 #ifndef AGX_BITARRAY_H 17 #define AGX_BITARRAY_H 24 # pragma warning(push) 25 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer 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;
224 reference result(
this, bit );
229 const_reference result(
this, bit );
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)
BitArray(const BitArray &)
reference & operator=(const reference &other)
assignment operator
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...
const_reference(const const_reference &other)
Copy constructor.
const_reference(const BitArray *array, size_t index)
reference operator[](size_t bit)
Class which is a reference into an existing bitarray.
BitArray()
Constructor, initializes all bits to zero.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Class which is a reference into an existing bitarray.
BitArray & operator=(const BitArray &)
const_reference & operator=(const 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)
#define BITARRAY_BIT_INDEX(bit)
#define agxAssert1(expr, msg)
#define BITARRAY_BIT_MASK(bit)
#define DOXYGEN_END_INTERNAL_BLOCK()
const_reference operator[](size_t bit) const
#define DOXYGEN_START_INTERNAL_BLOCK()