Project
Loading...
Searching...
No Matches
O2FormatParser.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 ALGORITHM_O2FORMATPARSER_H
13#define ALGORITHM_O2FORMATPARSER_H
14
19
20#include "HeaderStack.h"
21
22namespace o2
23{
24
25namespace algorithm
26{
27
57template <
58 typename InputListT, typename GetPointerFctT, typename GetSizeFctT, typename InsertFctT, // (const auto&, ptr, size)
59 typename... HeaderStackTypes // pairs of HeaderType and CallbackType
60 >
61int parseO2Format(const InputListT& list,
62 GetPointerFctT getPointer,
63 GetSizeFctT getSize,
64 InsertFctT insert,
65 HeaderStackTypes&&... stackArgs)
66{
67 const o2::header::DataHeader* dh = nullptr;
68 for (auto& part : list) {
69 if (!dh) {
70 // new header - payload pair, read DataHeader
71 dh = o2::header::get<o2::header::DataHeader*>(getPointer(part), getSize(part));
72 if (!dh) {
73 return -ENOMSG;
74 }
76 getSize(part),
77 stackArgs...);
78 } else {
79 insert(*dh, getPointer(part), getSize(part));
80 dh = nullptr;
81 }
82 }
83 if (dh) {
84 return -ENOMSG;
85 }
86 return list.size() / 2;
87}
88
89} // namespace algorithm
90
91} // namespace o2
92
93#endif // ALGORITHM_O2FORMATPARSER_H
Utilities for the O2 header stack.
int parseO2Format(const InputListT &list, GetPointerFctT getPointer, GetSizeFctT getSize, InsertFctT insert, HeaderStackTypes &&... stackArgs)
void dispatchHeaderStackCallback(PtrType ptr, SizeType size, HeaderType header, HeaderCallbackType onHeader, MoreTypes &&... types)
Definition HeaderStack.h:90
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition list.h:40
the main header struct
Definition DataHeader.h:618