Project
Loading...
Searching...
No Matches
DataBlock.h
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
12#ifndef O2_MCH_RAW_ENCODER_DATABLOCK_H
13#define O2_MCH_RAW_ENCODER_DATABLOCK_H
14
15#include <cstdint>
16#include <vector>
17#include <gsl/span>
18#include <functional>
19#include <iostream>
20#include <optional>
21
22namespace o2::mch::raw
23{
24
27 uint32_t orbit;
28 uint16_t bc;
29 uint16_t solarId;
30 uint64_t payloadSize;
31};
32
34struct DataBlock {
36 gsl::span<const std::byte> payload;
37 uint64_t size() const
38 {
39 return sizeof(header) + payload.size();
40 }
41};
42
47 std::optional<uint64_t> offset;
48};
49
51void appendDataBlockHeader(std::vector<std::byte>& outBuffer, DataBlockHeader header);
52
54int forEachDataBlockRef(gsl::span<const std::byte> buffer,
55 std::function<void(DataBlockRef blockRef)> f);
56
58int countHeaders(gsl::span<const std::byte> buffer);
59
60std::ostream& operator<<(std::ostream& os, const DataBlockHeader& header);
61std::ostream& operator<<(std::ostream& os, const DataBlockRef& ref);
62std::ostream& operator<<(std::ostream& os, const DataBlock& block);
63
64bool operator<(const DataBlockHeader& a, const DataBlockHeader& b);
65bool operator<(const DataBlockRef& a, const DataBlockRef& rhs);
66
67} // namespace o2::mch::raw
68
69#endif
GLuint buffer
Definition glcorearb.h:655
GLdouble f
Definition glcorearb.h:310
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
int countHeaders(gsl::span< const std::byte > buffer)
Count the headers in the input buffer.
Definition DataBlock.cxx:42
void appendDataBlockHeader(std::vector< std::byte > &outBuffer, DataBlockHeader header)
Convert the header into bytes.
Definition DataBlock.cxx:17
int forEachDataBlockRef(gsl::span< const std::byte > buffer, std::function< void(DataBlockRef ref)> f)
Definition DataBlock.cxx:23
bool operator<(const observer_ptr< W1 > &p1, const observer_ptr< W2 > &p2)
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)
A lightweight struct to describe a MCH Raw Data Block.
Definition DataBlock.h:26
a DataBlockRef is a pair (DataBlock,offset) The offset is an offset into some external buffer
Definition DataBlock.h:45
std::optional< uint64_t > offset
Definition DataBlock.h:47
A DataBlock is a pair (DataBlockHeader,payload)
Definition DataBlock.h:34
uint64_t size() const
Definition DataBlock.h:37
DataBlockHeader header
Definition DataBlock.h:35
gsl::span< const std::byte > payload
Definition DataBlock.h:36