Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PayLoadCont.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PayLoadCont.cxx
1 // @file PayLoadCont.cxx
2 // @brief Implementation of class for continuos buffer of ALPIDE data
3 // @sa <O2/Detectors/ITSMFT/common/reconstruction/src/PayLoadCont.cxx>
4 // <03608ff89>
5 
6 #include "PayLoadCont.h"
7 
8 using namespace mvtx;
9 
10 constexpr size_t PayLoadCont::MinCapacity;
11 
12 //________________________________________________________________________________
14 {
15  mBuffer = src.mBuffer;
16  if (src.mPtr) {
17  mPtr = mBuffer.data() + (src.mPtr - src.mBuffer.data());
18  }
19  if (src.mEnd) {
20  mEnd = mBuffer.data() + (src.mEnd - src.mBuffer.data());
21  }
22 }
23 
24 //________________________________________________________________________________
26 {
27  if (&src != this) {
28  mBuffer = src.mBuffer;
29  if (src.mPtr) {
30  mPtr = mBuffer.data() + (src.mPtr - src.mBuffer.data());
31  }
32  if (src.mEnd) {
33  mEnd = mBuffer.data() + (src.mEnd - src.mBuffer.data());
34  }
35  }
36  return *this;
37 }
38 
39 //________________________________________________________________________________
40 void PayLoadCont::expand(size_t sz)
41 {
43  auto* oldHead = mBuffer.data();
44  if (sz < MinCapacity) {
45  sz = MinCapacity;
46  }
47  if (sz < mBuffer.size()) { // never decrease the size
48  return;
49  }
50  mBuffer.resize(sz);
51  if (oldHead) { // fix the pointers to account for the reallocation
52  int64_t diff = mBuffer.data() - oldHead;
53  mPtr += diff;
54  mEnd += diff;
55  } else { // new buffer
56  clear();
57  }
58 }