FairRoot/PandaRoot
MvdOfflineTBAnalysis_Topix4/mrfdata_8b.h
Go to the documentation of this file.
1 /*============================================================*/
2 /* mrfdata.h */
3 /* MVD Readout Framework Data Storage */
4 /* M.C. Mertens */
5 /*============================================================*/
6 
7 
8 #ifndef __MRFDATA_8b_H__
9 #define __MRFDATA_8b_H__
10 
11 
12 // #include "mrfgal.h"
13 #include <vector>
14 #include "mrfbase.h"
15 #include <string>
16 #include <map>
17 #include <climits>
18 
19 #ifndef __CINT__
20 #include <boost/archive/archive_exception.hpp>
21 #include <boost/serialization/access.hpp>
22 #include <boost/serialization/base_object.hpp>
23 #include <boost/serialization/vector.hpp>
24 #endif
25 
26 //#include "mrf_confitem.h"
27 
29 namespace mrfdata_8b_error {
30  static const UInt_t success = 0;
31  static const UInt_t out_of_bounds = 1;
32  static const UInt_t size_mismatch = 2;
33  static const UInt_t not_found = 4;
34 }
35 
36 
39 {
40  public:
41  TMrfData_8b();
42 
43  TMrfData_8b(UInt_t _reglengthbits,UInt_t _reglengthwords,UInt_t _lastreglengthbits,std::vector<UChar_t> _regdata );
44 
45  //TMrfData_8b(const TMrfData_8b& rhs);
46 
47  //TMrfData_8b& operator=(const TMrfData_8b& rhs);
48 
50 
53  void setNumBits(const UInt_t& length);
54 
56 
59  const UInt_t& getNumBits() const;
60 
62 
65  void setNumWords(const UInt_t& length);
66 
68 
71  const UInt_t& getNumWords() const;
72 
74 
78  void setBit(const UInt_t& position, const bool& state);
79 
81 
85  bool getBit(const UInt_t& position) const;
86 
88 
92  const UInt_t& appendBit(const bool& state);
93 
95 
104  void setWord(const UInt_t& position, const UChar_t& dataword, const bool& truncate_ok = false);
105 
107 
117  void setWordMasked(const UInt_t& position, const UChar_t& dataword, const UChar_t& mask = ~0, const bool& truncate_ok = false);
118 
120 
124  const UChar_t& getWord(const UInt_t& position) const;
125 
126  const UChar_t& appendWord(const UChar_t &dataword);
127 
129 
136  void setBitBlock(const UInt_t& position, const UInt_t& length, const UChar_t& value, const UInt_t& offset = 0, const bool& reverse = false);
137 
138  const UInt_t& getBitBlock(const UInt_t& position, const UInt_t& length, const UInt_t& offset = 0, const bool& reverse = false) const;
139 
140  // Copies a size Bits long Data fragment to position.
141  //void copyFragment(const UInt_t sourcestart, const UInt_t destposition, const UInt_t size, const mrf::registertype value);
142 
144 
148  UInt_t bitInBlock(const UInt_t& position) const;
149 
151  //void setItemValue(const std::string& item, const std::map<const std::string, TConfItem>& bitmap, const mrf::registertype& value, const UInt_t& offset = 0);
152 
154  //UInt_t getItemValue(const std::string& item, const std::map<const std::string, TConfItem>& bitmap, const UInt_t& offset = 0) const;
155 
157  void clearDataStream();
158 
160  bool sameDataStream(const TMrfData_8b& other) const;
161 
163 
167  void importBinString(const std::string& data, const UInt_t& offset = 0);
168 
169  // Imports a data stream from a string representing hexadecimal digits
170  /*
171  \param data String consiting only of characters representing hexadecimal digits to be imported as binary data stream.
172  \param offset Optional offset (unit is bits) to change the import start position in the binary data stream.
173  */
174  //void importHexString(const std::string data, const UInt_t offset = 0);
175 
177 
180  const std::string& exportBinString() const;
181 
183 
189  void resample(const UInt_t& offset, const UInt_t& factor, const bool& reverse = false, const UInt_t& cutoff = 0);
190 
191  // Exports a data stream to a string representing hexadecimal digits
192  /*
193  \return A string containing a hexadecimal representation of the binary data stream.
194  */
195  //const std::string exportHexString() const;
196 
198 
201  const UInt_t& getLastError() const;
202 
204 
207  bool lastActionSuccessful() const;
208 // private:
212  static const UInt_t zeroval = 0;
213  mutable UInt_t _bitblock;
214  mutable std::string _data;
215 
216  // Allow serialization to access non-public data members
217  #ifndef __CINT__
219  #endif
220  template<class Archive>
221  void serialize(Archive & ar, const unsigned int )
222  {
223  ar & reglengthbits;
224  ar & reglengthwords;
225  ar & lastreglengthbits;
226  ar & regdata;
227 
228  }
229 
230 // protected:
232 
235  mutable UInt_t errcode;
236 
238  static const UInt_t bitsinablock = sizeof(UChar_t) * CHAR_BIT;
239 
241 
244  std::vector<UChar_t> regdata;
245  //void copyBlock(const UInt_t sourcestart, const UInt_t length, const UInt_t deststart, const UInt_t value);
246 };
247 
248 
249 
250 #endif // __MRFDATA_8b_H__
251 
void setNumWords(const UInt_t &length)
Sets the length of the register to lengths words.
friend class boost::serialization::access
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.
void setBit(const UInt_t &position, const bool &state)
Sets or resets the bit at position.
TVector3 offset(2, 0, 0)
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.
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...
void serialize(Archive &ar, const unsigned int)
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.
Error flags set by TMrfData_8b functions.
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.