21 : reglengthbits(0), reglengthwords(0), lastreglengthbits(0), errcode(0)
25 TMrfData_8b::TMrfData_8b(UInt_t _reglengthbits, UInt_t _reglengthwords, UInt_t _lastreglengthbits, std::vector<u_int8_t> _regdata)
97 void TMrfData_8b::setWord(
const UInt_t& position,
const u_int8_t &dataword,
const bool& truncate_ok)
101 regdata.at(position) = dataword;
106 bitmask |= bitmask << 1;
108 regdata.at(position) = (dataword & bitmask);
109 if (!(dataword & (~bitmask)) || truncate_ok) {
120 void TMrfData_8b::setWordMasked(
const UInt_t& position,
const u_int8_t &dataword,
const u_int8_t &mask,
const bool& truncate_ok)
123 regdata.at(position) = dataword;
126 u_int8_t bitmask = 1;
128 bitmask |= bitmask << 1;
131 regdata.at(position) &= (~ mask);
132 regdata.at(position) |= (dataword & mask);
133 regdata.at(position) &= bitmask;
134 if (!((dataword & mask) & (~bitmask)) || truncate_ok) {
168 for (i = 0; i < length; ++
i) {
172 for (i = 0; i < length; ++
i) {
178 const UInt_t&
TMrfData_8b::getBitBlock(
const UInt_t& position,
const UInt_t& length,
const UInt_t& offset,
const bool& reverse)
const
183 for (i = 0; i < length; ++
i) {
188 for (i = 0; i < length; ++
i) {
249 return (position / bitsinablock);
266 UInt_t reglength = data.length();
270 for (i = 0; i < reglength; ++
i) {
271 setBit(offset + i, (data.compare(i, 1,
"1") == 0));
303 std::vector<u_int8_t> tmp =
regdata;
304 UInt_t newlength = 0;
306 for (UInt_t i = offset; i <
getNumBits(); i += factor) {
307 setBit((i - offset) / factor,
getIntBit(bitsinablock - 1 - (i % bitsinablock), tmp.at(i / bitsinablock)));
311 for (UInt_t i = offset; i <
getNumBits(); i += factor) {
312 setBit((i - offset) / factor,
getIntBit(i % bitsinablock, tmp.at(i / bitsinablock)));
static const UInt_t out_of_bounds
void setNumWords(const UInt_t &length)
Sets the length of the register to lengths words.
void setWordMasked(const UInt_t &position, const UChar_t &dataword, const UChar_t &mask=~0, const bool &truncate_ok=false)
Sets a subset of bits in a word based on a mask.
static const UInt_t zeroval
void setBit(const UInt_t &position, const bool &state)
Sets or resets the bit at position.
const UInt_t & appendBit(const bool &state)
Appends a bit to the data stream.
bool lastActionSuccessful() const
Returns True if the last action completed successfullly, False otherwise.
static const UInt_t bitsinablock
Number of bits stored in each data word.
const std::string & exportBinString() const
Exports a data stream to a string representing binary digits.
void resample(const UInt_t &offset, const UInt_t &factor, const bool &reverse=false, const UInt_t &cutoff=0)
Extracts binary data from returned oversampled data.
const UInt_t & getNumBits() const
Retrieves the length of the register in bits.
void setBitBlock(const UInt_t &position, const UInt_t &length, const UChar_t &value, const UInt_t &offset=0, const bool &reverse=false)
Sets a bit block of given length to the least significant bits of value.
Base interface class for data storage and manipulation. Compatible with IO classes from MRF Suite...
std::vector< UChar_t > regdata
Internal storage for data structure.
UInt_t registertype
Register content data type.
void setWord(const UInt_t &position, const UChar_t &dataword, const bool &truncate_ok=false)
Sets a complete data word at position to value.
void clearDataStream()
Sets a bitfield within the data storage based on the configuration stored in the map parameter bitmap...
const UInt_t & getBitBlock(const UInt_t &position, const UInt_t &length, const UInt_t &offset=0, const bool &reverse=false) const
UInt_t bitInBlock(const UInt_t &position) const
Returns the word index which holds bit position.
const UChar_t & getWord(const UInt_t &position) const
Retrieves the word found at position.
void setNumBits(const UInt_t &length)
Sets the length of the binary data stream.
void importBinString(const std::string &data, const UInt_t &offset=0)
Imports a data stream from a string representing binary digits.
UInt_t errcode
Internal error code.
const UInt_t & getLastError() const
Returns an integer with errorflags of all errors occured after last successful command.
const UChar_t & appendWord(const UChar_t &dataword)
bool getBit(const UInt_t &position) const
Determines if bit at position is set.
const UInt_t & getNumWords() const
Retrieves the length of the register in words.
bool sameDataStream(const TMrfData_8b &other) const
Checks data streams for equality.