Project
Loading...
Searching...
No Matches
PayloadDecoder.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_PAYLOAD_DECODER_H
13#define O2_MCH_RAW_PAYLOAD_DECODER_H
14
18#include <map>
19#include <cstdlib>
20#include <gsl/span>
21
22namespace o2
23{
24namespace mch
25{
26namespace raw
27{
28bool hasOrbitJump(uint32_t orb1, uint32_t orb2)
29{
30 return std::abs(static_cast<long int>(orb1 - orb2)) > 1;
31}
32
33using Payload = Page;
34
36
37template <typename T>
39{
40 public:
44 PayloadDecoder(DecodedDataHandlers decodedDataHandlers);
45
48 size_t process(uint32_t orbit, Payload payload);
49
50 private:
51 uint32_t mOrbit;
52 DecodedDataHandlers mDecodedDataHandlers;
53};
54
55template <typename T>
57 : mDecodedDataHandlers(decodedDataHandlers)
58{
59}
60
61template <typename T>
62size_t PayloadDecoder<T>::process(uint32_t orbit, Payload payload)
63{
64 if (hasOrbitJump(orbit, mOrbit)) {
65 static_cast<T*>(this)->reset();
66 }
67 mOrbit = orbit;
68 return static_cast<T*>(this)->append(payload);
69}
70
71} // namespace raw
72} // namespace mch
73} // namespace o2
74
75#endif
uint64_t orbit
Definition RawEventData.h:6
Definition of the RAW Data Header.
Decoder for MCH Raw Data Format.
size_t process(uint32_t orbit, Payload payload)
PayloadDecoder(DecodedDataHandlers decodedDataHandlers)
void append(const char *msg, std::string &to)
gsl::span< const std::byte > Page
Definition PageDecoder.h:25
bool hasOrbitJump(uint32_t orb1, uint32_t orb2)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...