GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — AliceO2/Algorithm/include/Algorithm/O2FormatParser.h at dev · sgorbuno/AliceO2 Expand file tree/ Copy pathO2FormatParser.hMore file actions 92 lines (83 loc) · 3.15 KB / Copy pathO2FormatParser.hFile metadata and controls92 lines (83 loc) · 3.15 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 // Copyright CERN and copyright holders of ALICE O2. This software is // distributed under the terms of the GNU General Public License v3 (GPL // Version 3), copied verbatim in the file "COPYING". // // See http://alice-o2.web.cern.ch/license for full licensing information. // // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. #ifndef ALGORITHM_O2FORMATPARSER_H #define ALGORITHM_O2FORMATPARSER_H /// @file O2FormatParser.h /// @author Matthias Richter /// @since 2017-10-18 /// @brief Parser for the O2 data format #include "HeaderStack.h" namespace o2 { namespace algorithm { /** * parse an input list and try to interpret in O2 data format * O2 format consist of header-payload message pairs. The header message * always starts with the DataHeader, optionally there can be more * headers in the header stack. * * The following callbacks are mandadory to be provided, e.g. through lambdas * - insert function with signature (const DataHeader&, ptr, size) * auto insertFct = [&] (const auto & dataheader, * auto ptr, * auto size) { * // do something with dataheader and buffer * }; * - getter for the message pointer, e.g. provided std::pair is used * auto getPointerFct = [] (const auto & arg) {return arg.first;}; * - getter for the message size, e.g. provided std::pair is used * auto getSizeFct = [] (const auto & arg) {return arg.second;}; * * Optionally, also the header stack can be parsed by specifying further * arguments. For every header supposed to be parsed, a pair of a dummy object * and callback has to be specified, e.g. * // handler callback for MyHeaderStruct * auto onMyHeaderStruct = [&] (const auto & mystruct) { * // do something with mystruct * }; // end handler callback * * parseO2Format(list, insertFct, MyHeaderStruct(), onMyHeaderStruct); * */ template < typename InputListT, typename GetPointerFctT, typename GetSizeFctT, typename InsertFctT, // (const auto&, ptr, size) typename... HeaderStackTypes // pairs of HeaderType and CallbackType > int parseO2Format(const InputListT& list, GetPointerFctT getPointer, GetSizeFctT getSize, InsertFctT insert, HeaderStackTypes&&... stackArgs) { const o2::header::DataHeader* dh = nullptr; for (auto& part : list) { if (!dh) { // new header - payload pair, read DataHeader dh = o2::header::get<o2::header::DataHeader*>(getPointer(part), getSize(part)); if (!dh) { return -ENOMSG; } o2::algorithm::dispatchHeaderStackCallback(getPointer(part), getSize(part), stackArgs...); } else { insert(*dh, getPointer(part), getSize(part)); dh = nullptr; } } if (dh) { return -ENOMSG; } return list.size() / 2; } } // namespace algorithm } // namespace o2 #endif // ALGORITHM_O2FORMATPARSER_H |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |