Project
Loading...
Searching...
No Matches
PayLoadCont.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
16
17using namespace o2::itsmft;
18
19constexpr size_t PayLoadCont::MinCapacity;
20
22{
23 mBuffer = src.mBuffer;
24 if (src.mPtr) {
25 mPtr = mBuffer.data() + (src.mPtr - src.mBuffer.data());
26 }
27 if (src.mEnd) {
28 mEnd = mBuffer.data() + (src.mEnd - src.mBuffer.data());
29 }
30}
31
33{
34 if (&src != this) {
35 mBuffer = src.mBuffer;
36 if (src.mPtr) {
37 mPtr = mBuffer.data() + (src.mPtr - src.mBuffer.data());
38 }
39 if (src.mEnd) {
40 mEnd = mBuffer.data() + (src.mEnd - src.mBuffer.data());
41 }
42 }
43 return *this;
44}
45
46void PayLoadCont::expand(size_t sz)
47{
49 auto* oldHead = mBuffer.data();
50 if (sz < MinCapacity) {
51 sz = MinCapacity;
52 }
53 if (sz < mBuffer.size()) { // never decrease the size
54 return;
55 }
56 mBuffer.resize(sz);
57 if (oldHead) { // fix the pointers to account for the reallocation
58 int64_t diff = mBuffer.data() - oldHead;
59 mPtr += diff;
60 mEnd += diff;
61 } else { // new buffer
62 clear();
63 }
64}
Declaration of class for continuos buffer of ALPIDE data.
static constexpr size_t MinCapacity
allocate buffer
Definition PayLoadCont.h:35
PayLoadCont & operator=(const PayLoadCont &src)
void clear()
get unused size
Definition PayLoadCont.h:54
void expand(size_t sz)
GLenum src
Definition glcorearb.h:1767