Project
Loading...
Searching...
No Matches
RDHAny.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// @brief placeholder class for arbitraty-version 64B-lonh RDH
13// @author ruben.shahoyan@cern.ch
14
15#ifndef ALICEO2_HEADER_RDHANY_H
16#define ALICEO2_HEADER_RDHANY_H
17#include "GPUCommonDef.h"
19#ifndef GPUCA_GPUCODE_DEVICE
20#include <type_traits>
21#include <stdexcept>
22#endif
23
24namespace o2
25{
26namespace header
27{
28
29struct RDHAny {
30 uint64_t word0 = 0x0;
31 uint64_t word1 = 0x0;
32 uint64_t word2 = 0x0;
33 uint64_t word3 = 0x0;
34 uint64_t word4 = 0x0;
35 uint64_t word5 = 0x0;
36 uint64_t word6 = 0x0;
37 uint64_t word7 = 0x0;
38
39 RDHAny(int v = 0); // 0 for default version
40
41 template <typename H>
42 RDHAny(const H& rdh);
43
44 template <typename H>
45 RDHAny& operator=(const H& rdh);
46
47 //------------------ service methods
51 using RDHv7 = o2::header::RAWDataHeaderV7; // update this for every new version
52
54 template <typename RDH>
55 GPUhdi() static constexpr void sanityCheckStrict()
56 {
57#ifndef GPUCA_GPUCODE_DEVICE
58 static_assert(std::is_same<RDH, RDHv4>::value || std::is_same<RDH, RDHv5>::value ||
59 std::is_same<RDH, RDHv6>::value || std::is_same<RDH, RDHv7>::value,
60 "not an RDH");
61#endif
62 }
63
65 template <typename RDH>
66 GPUhdi() static constexpr void sanityCheckLoose()
67 {
68#ifndef GPUCA_GPUCODE_DEVICE
69 static_assert(std::is_same<RDH, RDHv4>::value || std::is_same<RDH, RDHv5>::value ||
70 std::is_same<RDH, RDHv6>::value || std::is_same<RDH, RDHv7>::value || std::is_same<RDHAny, RDH>::value,
71 "not an RDH or RDHAny");
72#endif
73 }
74
75 template <typename H>
76 GPUhdi() static const void* voidify(const H& rdh)
77 {
78 sanityCheckLoose<H>();
79 return reinterpret_cast<const void*>(&rdh);
80 }
81
82 template <typename H>
83 GPUhdi() static void* voidify(H& rdh)
84 {
85 sanityCheckLoose<H>();
86 return reinterpret_cast<void*>(&rdh);
87 }
88
89 GPUhdi() const void* voidify() const { return voidify(*this); }
90 GPUhdi() void* voidify() { return voidify(*this); }
91
92 template <typename H>
93 GPUhdi() H* as_ptr()
94 {
95 sanityCheckLoose<H>();
96 return reinterpret_cast<H*>(this);
97 }
98
99 template <typename H>
100 GPUhdi() H& as_ref()
101 {
102 sanityCheckLoose<H>();
103 return reinterpret_cast<H&>(this);
104 }
105
106 protected:
107 void copyFrom(const void* rdh);
108};
109
112template <typename H>
113inline RDHAny::RDHAny(const H& rdh)
114{
115 sanityCheckLoose<H>();
116 copyFrom(&rdh);
117}
118
121template <typename H>
122inline RDHAny& RDHAny::operator=(const H& rdh)
123{
124 sanityCheckLoose<H>();
125 if (this != voidify(rdh)) {
126 copyFrom(&rdh);
127 }
128 return *this;
129}
130
131} // namespace header
132} // namespace o2
133
134#endif
Definition of the RAW Data Header.
const GLdouble * v
Definition glcorearb.h:832
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
RDHAny & operator=(const H &rdh)
Definition RDHAny.h:122
void copyFrom(const void *rdh)
Definition RDHAny.cxx:39
uint64_t word7
Definition RDHAny.h:37
GPUhdi() H &as_ref()
Definition RDHAny.h:100
GPUhdi() H *as_ptr()
Definition RDHAny.h:93
GPUhdi() void *voidify()
Definition RDHAny.h:90
RDHAny(int v=0)
placeholder copied from specific version
Definition RDHAny.cxx:23
GPUhdi() static void *voidify(H &rdh)
Definition RDHAny.h:83
uint64_t word6
Definition RDHAny.h:36
GPUhdi() static const expr void sanityCheckLoose()
make sure we RDH is a legitimate RAWDataHeader or generic RDHAny placeholder
Definition RDHAny.h:66
uint64_t word0
Definition RDHAny.h:30
GPUhdi() static const void *voidify(const H &rdh)
Definition RDHAny.h:76
uint64_t word1
Definition RDHAny.h:31
GPUhdi() const void *voidify() const
Definition RDHAny.h:89
uint64_t word3
Definition RDHAny.h:33
uint64_t word2
Definition RDHAny.h:32
GPUhdi() static const expr void sanityCheckStrict()
make sure we RDH is a legitimate RAWDataHeader
Definition RDHAny.h:55
uint64_t word4
Definition RDHAny.h:34
uint64_t word5
Definition RDHAny.h:35