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 #ifndef __MRFDATA_8b_H__
8 #define __MRFDATA_8b_H__
9 
10 // #include "mrfgal.h"
11 #include <vector>
12 #include "mrfbase.h"
13 #include <string>
14 #include <map>
15 #include <climits>
16 
17 #ifndef __CINT__
18 #include <boost/archive/archive_exception.hpp>
19 #include <boost/serialization/access.hpp>
20 #include <boost/serialization/base_object.hpp>
21 #include <boost/serialization/vector.hpp>
22 #endif
23 
24 //#include "mrf_confitem.h"
25 
27 namespace mrfdata_8b_error {
28 static const UInt_t success = 0;
29 static const UInt_t out_of_bounds = 1;
30 static const UInt_t size_mismatch = 2;
31 static const UInt_t not_found = 4;
32 } // namespace mrfdata_8b_error
33 
35 class TMrfData_8b {
36  public:
37  TMrfData_8b();
38 
39  TMrfData_8b(UInt_t _reglengthbits, UInt_t _reglengthwords, UInt_t _lastreglengthbits, std::vector<UChar_t> _regdata);
40 
41  // TMrfData_8b(const TMrfData_8b& rhs);
42 
43  // TMrfData_8b& operator=(const TMrfData_8b& rhs);
44 
46 
49  void setNumBits(const UInt_t &length);
50 
52 
55  const UInt_t &getNumBits() const;
56 
58 
61  void setNumWords(const UInt_t &length);
62 
64 
67  const UInt_t &getNumWords() const;
68 
70 
74  void setBit(const UInt_t &position, const bool &state);
75 
77 
81  bool getBit(const UInt_t &position) const;
82 
84 
88  const UInt_t &appendBit(const bool &state);
89 
91 
100  void setWord(const UInt_t &position, const UChar_t &dataword, const bool &truncate_ok = false);
101 
103 
113  void setWordMasked(const UInt_t &position, const UChar_t &dataword, const UChar_t &mask = ~0, const bool &truncate_ok = false);
114 
116 
120  const UChar_t &getWord(const UInt_t &position) const;
121 
122  const UChar_t &appendWord(const UChar_t &dataword);
123 
125 
132  void setBitBlock(const UInt_t &position, const UInt_t &length, const UChar_t &value, const UInt_t &offset = 0, const bool &reverse = false);
133 
134  const UInt_t &getBitBlock(const UInt_t &position, const UInt_t &length, const UInt_t &offset = 0, const bool &reverse = false) const;
135 
136  // Copies a size Bits long Data fragment to position.
137  // void copyFragment(const UInt_t sourcestart, const UInt_t destposition, const UInt_t size, const mrf::registertype value);
138 
140 
144  UInt_t bitInBlock(const UInt_t &position) const;
145 
147  // void setItemValue(const std::string& item, const std::map<const std::string, TConfItem>& bitmap, const mrf::registertype& value, const UInt_t& offset = 0);
148 
150  // UInt_t getItemValue(const std::string& item, const std::map<const std::string, TConfItem>& bitmap, const UInt_t& offset = 0) const;
151 
153  void clearDataStream();
154 
156  bool sameDataStream(const TMrfData_8b &other) const;
157 
159 
163  void importBinString(const std::string &data, const UInt_t &offset = 0);
164 
165  // Imports a data stream from a string representing hexadecimal digits
166  /*
167  \param data String consiting only of characters representing hexadecimal digits to be imported as binary data stream.
168  \param offset Optional offset (unit is bits) to change the import start position in the binary data stream.
169  */
170  // void importHexString(const std::string data, const UInt_t offset = 0);
171 
173 
176  const std::string &exportBinString() const;
177 
179 
185  void resample(const UInt_t &offset, const UInt_t &factor, const bool &reverse = false, const UInt_t &cutoff = 0);
186 
187  // Exports a data stream to a string representing hexadecimal digits
188  /*
189  \return A string containing a hexadecimal representation of the binary data stream.
190  */
191  // const std::string exportHexString() const;
192 
194 
197  const UInt_t &getLastError() const;
198 
200 
203  bool lastActionSuccessful() const;
204  // private:
208  static const UInt_t zeroval = 0;
209  mutable UInt_t _bitblock;
210  mutable std::string _data;
211 
212  // Allow serialization to access non-public data members
213 #ifndef __CINT__
214  friend class boost::serialization::access;
215 #endif
216  template <class Archive>
217  void serialize(Archive &ar, const unsigned int)
218  {
219  ar &reglengthbits;
220  ar &reglengthwords;
221  ar &lastreglengthbits;
222  ar &regdata;
223  }
224 
225  // protected:
227 
230  mutable UInt_t errcode;
231 
233  static const UInt_t bitsinablock = sizeof(UChar_t) * CHAR_BIT;
234 
236 
239  std::vector<UChar_t> regdata;
240  // void copyBlock(const UInt_t sourcestart, const UInt_t length, const UInt_t deststart, const UInt_t value);
241 };
242 
243 #endif // __MRFDATA_8b_H__
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 serialize(Archive &ar, const unsigned int)
Error flags set by TMrfData_8b functions.
UInt_t errcode
Internal error code.