PandaRoot
MvdOfflineTBAnalysis_Topix4/mrfdata_8b.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /*============================================================*/
14 /* mrfdata.h */
15 /* MVD Readout Framework Data Storage */
16 /* M.C. Mertens */
17 /*============================================================*/
18 
19 #ifndef __MRFDATA_8b_H__
20 #define __MRFDATA_8b_H__
21 
22 // #include "mrfgal.h"
23 #include <vector>
24 #include "mrfbase.h"
25 #include <string>
26 #include <map>
27 #include <climits>
28 
29 #ifndef __CINT__
30 #include <boost/archive/archive_exception.hpp>
31 #include <boost/serialization/access.hpp>
32 #include <boost/serialization/base_object.hpp>
33 #include <boost/serialization/vector.hpp>
34 #endif
35 
36 //#include "mrf_confitem.h"
37 
39 namespace mrfdata_8b_error {
40 static const UInt_t success = 0;
41 static const UInt_t out_of_bounds = 1;
42 static const UInt_t size_mismatch = 2;
43 static const UInt_t not_found = 4;
44 } // namespace mrfdata_8b_error
45 
47 class TMrfData_8b {
48  public:
49  TMrfData_8b();
50 
51  TMrfData_8b(UInt_t _reglengthbits, UInt_t _reglengthwords, UInt_t _lastreglengthbits, std::vector<UChar_t> _regdata);
52 
53  // TMrfData_8b(const TMrfData_8b& rhs);
54 
55  // TMrfData_8b& operator=(const TMrfData_8b& rhs);
56 
58 
61  void setNumBits(const UInt_t &length);
62 
64 
67  const UInt_t &getNumBits() const;
68 
70 
73  void setNumWords(const UInt_t &length);
74 
76 
79  const UInt_t &getNumWords() const;
80 
82 
86  void setBit(const UInt_t &position, const bool &state);
87 
89 
93  bool getBit(const UInt_t &position) const;
94 
96 
100  const UInt_t &appendBit(const bool &state);
101 
103 
112  void setWord(const UInt_t &position, const UChar_t &dataword, const bool &truncate_ok = false);
113 
115 
125  void setWordMasked(const UInt_t &position, const UChar_t &dataword, const UChar_t &mask = ~0, const bool &truncate_ok = false);
126 
128 
132  const UChar_t &getWord(const UInt_t &position) const;
133 
134  const UChar_t &appendWord(const UChar_t &dataword);
135 
137 
144  void setBitBlock(const UInt_t &position, const UInt_t &length, const UChar_t &value, const UInt_t &offset = 0, const bool &reverse = false);
145 
146  const UInt_t &getBitBlock(const UInt_t &position, const UInt_t &length, const UInt_t &offset = 0, const bool &reverse = false) const;
147 
148  // Copies a size Bits long Data fragment to position.
149  // void copyFragment(const UInt_t sourcestart, const UInt_t destposition, const UInt_t size, const mrf::registertype value);
150 
152 
156  UInt_t bitInBlock(const UInt_t &position) const;
157 
159  // void setItemValue(const std::string& item, const std::map<const std::string, TConfItem>& bitmap, const mrf::registertype& value, const UInt_t& offset = 0);
160 
162  // UInt_t getItemValue(const std::string& item, const std::map<const std::string, TConfItem>& bitmap, const UInt_t& offset = 0) const;
163 
165  void clearDataStream();
166 
168  bool sameDataStream(const TMrfData_8b &other) const;
169 
171 
175  void importBinString(const std::string &data, const UInt_t &offset = 0);
176 
177  // Imports a data stream from a string representing hexadecimal digits
178  /*
179  \param data String consiting only of characters representing hexadecimal digits to be imported as binary data stream.
180  \param offset Optional offset (unit is bits) to change the import start position in the binary data stream.
181  */
182  // void importHexString(const std::string data, const UInt_t offset = 0);
183 
185 
188  const std::string &exportBinString() const;
189 
191 
197  void resample(const UInt_t &offset, const UInt_t &factor, const bool &reverse = false, const UInt_t &cutoff = 0);
198 
199  // Exports a data stream to a string representing hexadecimal digits
200  /*
201  \return A string containing a hexadecimal representation of the binary data stream.
202  */
203  // const std::string exportHexString() const;
204 
206 
209  const UInt_t &getLastError() const;
210 
212 
215  bool lastActionSuccessful() const;
216  // private:
220  static const UInt_t zeroval = 0;
221  mutable UInt_t _bitblock;
222  mutable std::string _data;
223 
224  // Allow serialization to access non-public data members
225 #ifndef __CINT__
226  friend class boost::serialization::access;
227 #endif
228  template <class Archive>
229  void serialize(Archive &ar, const unsigned int)
230  {
231  ar &reglengthbits;
232  ar &reglengthwords;
233  ar &lastreglengthbits;
234  ar &regdata;
235  }
236 
237  // protected:
239 
242  mutable UInt_t errcode;
243 
245  static const UInt_t bitsinablock = sizeof(UChar_t) * CHAR_BIT;
246 
248 
251  std::vector<UChar_t> regdata;
252  // void copyBlock(const UInt_t sourcestart, const UInt_t length, const UInt_t deststart, const UInt_t value);
253 };
254 
255 #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.