Line data Source code
1 : #ifndef ALIHLTCDHWRAPPER_H
2 : #define ALIHLTCDHWRAPPER_H
3 :
4 : #include <assert.h>
5 : #include "AliRawDataHeader.h"
6 : #include "AliRawDataHeaderV3.h"
7 :
8 : #define CHECK_AND_CALL(func, args...) \
9 : ( GetVersion() == 2 ? \
10 : reinterpret_cast<const AliRawDataHeader*>(fCDH)->func(args) : \
11 : reinterpret_cast<const AliRawDataHeaderV3*>(fCDH)->func(args) )
12 :
13 :
14 : class AliHLTCDHWrapper {
15 : public:
16 0 : AliHLTCDHWrapper() : fCDH(NULL) {}
17 : AliHLTCDHWrapper(const AliHLTCDHWrapper& other) : fCDH(other.fCDH) { CheckVersion(); }
18 0 : AliHLTCDHWrapper(const void* cdh) : fCDH(cdh) { CheckVersion(); }
19 :
20 0 : ~AliHLTCDHWrapper() {}
21 :
22 : inline AliHLTCDHWrapper& operator=(const AliHLTCDHWrapper& other) {
23 0 : fCDH = other.fCDH;
24 0 : CheckVersion();
25 0 : return *this;
26 : }
27 :
28 : inline AliHLTCDHWrapper& operator=(const void*& cdh) {
29 : fCDH = cdh;
30 : CheckVersion();
31 : return *this;
32 : }
33 :
34 : inline void CheckVersion() {
35 : #ifdef DEBUG
36 : if(fCDH)
37 : assert(GetVersion() == 2 || GetVersion() == 3);
38 : #endif
39 0 : }
40 :
41 : inline UChar_t GetVersion() const {
42 0 : return (reinterpret_cast<const AliRawDataHeader*>(fCDH))->GetVersion();
43 : }
44 :
45 : inline UInt_t GetHeaderSize() {
46 0 : return (GetVersion() == 2 ?
47 : sizeof(AliRawDataHeader) : sizeof(AliRawDataHeaderV3) );
48 : }
49 :
50 : inline const void* GetHeader() const {
51 0 : return fCDH;
52 : }
53 :
54 : inline UInt_t GetDataSize() const {
55 : //first word, independent of Version
56 0 : return *((UInt_t*)fCDH);
57 : }
58 :
59 : inline UShort_t GetEventID1() const {
60 : return CHECK_AND_CALL(GetEventID1);
61 : }
62 :
63 : inline UInt_t GetEventID2() const {
64 : return CHECK_AND_CALL(GetEventID2);
65 : }
66 :
67 : inline UChar_t GetL1TriggerMessage() const {
68 0 : return CHECK_AND_CALL(GetL1TriggerMessage);
69 : }
70 :
71 : inline UChar_t GetAttributes() const {
72 : return CHECK_AND_CALL(GetAttributes);
73 : }
74 :
75 : inline Bool_t TestAttribute(Int_t index) const {
76 : return CHECK_AND_CALL(TestAttribute, index);
77 : }
78 :
79 : /*
80 : inline void SetAttribute(Int_t index) {
81 : CHECK_AND_CALL(SetAttribute, index);
82 : }
83 : */
84 :
85 : /*
86 : inline void ResetAttribute(Int_t index) {
87 : CHECK_AND_CALL(ResetAttribute, index);
88 : }
89 : */
90 :
91 : inline UInt_t GetSubDetectors() const {
92 : return CHECK_AND_CALL(GetSubDetectors);
93 : }
94 :
95 : inline UInt_t GetStatus() const {
96 0 : return CHECK_AND_CALL(GetStatus);
97 : }
98 :
99 : inline UInt_t GetMiniEventID() const {
100 : return CHECK_AND_CALL(GetMiniEventID);
101 : }
102 :
103 : inline ULong64_t GetTriggerClasses() const {
104 0 : return CHECK_AND_CALL(GetTriggerClasses);
105 : }
106 :
107 : inline ULong64_t GetTriggerClassesNext50() const {
108 0 : return CHECK_AND_CALL(GetTriggerClassesNext50);
109 : }
110 :
111 : inline ULong64_t GetROI() const {
112 : return CHECK_AND_CALL(GetROI);
113 : }
114 :
115 : /*
116 : inline void SetTriggerClass(ULong64_t mask) {
117 : CHECK_AND_CALL(SetTriggerClass, mask);
118 : }
119 : */
120 :
121 : private:
122 : const void* fCDH;
123 :
124 : };
125 :
126 :
127 : #endif
|