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/HeaderStack.h at dev · mchwes/AliceO2 Expand file tree/ Copy pathHeaderStack.hMore file actions 170 lines (154 loc) · 5.23 KB / Copy pathHeaderStack.hFile metadata and controls170 lines (154 loc) · 5.23 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 // Copyright 2019-2020 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // // This software is distributed under the terms of the GNU General Public // License v3 (GPL Version 3), copied verbatim in the file "COPYING". // // 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_HEADERSTACK_H #define ALGORITHM_HEADERSTACK_H /// @file HeaderStack.h /// @author Matthias Richter /// @since 2017-09-19 /// @brief Utilities for the O2 header stack // the implemented functionality relies on o2::header::get defined in // DataHeader.h; all O2 headers inherit from BaseHeader, this is required // to check the consistency of the header stack, also the next-header-flag // is part of the BaseHeader #include "Headers/DataHeader.h" // for o2::header::get namespace o2 { namespace algorithm { /** * Generic utility for the O2 header stack, redirect to header specific callbacks * * The O2 header stack consists of one or more headers. The DataHeader is the * first one and mandatory. Other optional headers can be recursively extracted * from a buffer with one call to this utility function. For each header a pair * of type and callback has to be provided. The header type can be provided as * a dummy parameter, the callback with a lambda or any callable object. * * Usage: * dispatchHeaderStackCallback(ptr, size, * MyHeader(), * [] (const auto & h) { * // do something with h * } */ template < typename PtrType, typename SizeType, typename HeaderType, typename HeaderCallbackType, typename... MoreTypes> void dispatchHeaderStackCallback(PtrType ptr, SizeType size, HeaderType header, HeaderCallbackType onHeader, MoreTypes&&... types); // template specialization: handler for one pair of type and callback template < typename PtrType, typename SizeType, typename HeaderType, typename HeaderCallbackType> void dispatchHeaderStackCallback(PtrType ptr, SizeType size, HeaderType /*dummy*/, HeaderCallbackType onHeader) { const HeaderType* h = o2::header::get<HeaderType*>(ptr, size); if (h) { onHeader(*h); } } // an empty function in case no StackTypes have been provided to call template <typename PtrType, typename SizeType> void dispatchHeaderStackCallback(PtrType ptr, SizeType size) { } // actual implementation template < typename PtrType, typename SizeType, typename HeaderType, typename HeaderCallbackType, typename... MoreTypes> void dispatchHeaderStackCallback(PtrType ptr, SizeType size, HeaderType header, HeaderCallbackType onHeader, MoreTypes&&... types) { // call for current dispatchHeaderStackCallback(ptr, size, header, onHeader); // call for next dispatchHeaderStackCallback(ptr, size, types...); } /** * Generic utility for the O2 header stack, extract headers * * The O2 header stack consists of one or more headers. The DataHeader is the * first one and mandatory. Other optional headers can be recursively extracted * from a buffer with one call to this utility function. For each header to be * extracted, a variable can be passed be reference. If a header of corresponding * type is in the stack, its content will be assigned to the variable. * * Usage: * DataHeader dataheader; * TriggerHeader triggerheader * parseHeaderStack(ptr, size, * dataheader, * triggerheader */ template < typename PtrType, typename SizeType, typename HeaderType, typename... MoreTypes> void parseHeaderStack(PtrType ptr, SizeType size, HeaderType& header, MoreTypes&&... types); // template specialization: handler for one type template < typename PtrType, typename SizeType, typename HeaderType> void parseHeaderStack(PtrType ptr, SizeType size, HeaderType& header) { const HeaderType* h = o2::header::get<HeaderType*>(ptr, size); if (h) { header = *h; } } // an empty function in case no StackTypes have been provided to call template <typename PtrType, typename SizeType> void parseHeaderStack(PtrType ptr, SizeType size) { } // generic implementation template < typename PtrType, typename SizeType, typename HeaderType, typename... MoreTypes> void parseHeaderStack(PtrType ptr, SizeType size, HeaderType& header, MoreTypes&&... types) { // call for current parseHeaderStack(ptr, size, header); // call for next parseHeaderStack(ptr, size, types...); } }; // namespace algorithm }; // namespace o2 #endif //ALGORITHM_HEADERSTACK_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. |