]>
Commit | Line | Data |
---|---|---|
d98142ea | 1 | #ifndef ALIFLATESDTRIGGER_H |
2 | #define ALIFLATESDTRIGGER_H | |
3 | ||
4 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice * | |
6 | * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli */ | |
7 | ||
8 | /* | |
9 | * See implementation file for documentation | |
10 | */ | |
11 | ||
12 | /* | |
13 | */ | |
14 | ||
15 | #include "Rtypes.h" | |
1f516476 | 16 | #include "AliVMisc.h" |
d98142ea | 17 | #include <string> |
18 | ||
19 | class AliFlatESDTrigger{ | |
20 | ||
21 | public: | |
22 | ||
23 | // -------------------------------------------------------------------------------- | |
24 | // -- Constructor / Destructors | |
25 | AliFlatESDTrigger(); | |
26 | ~AliFlatESDTrigger(); | |
27 | ||
c2ea967e | 28 | // constructor and method for reinitialisation of virtual table |
1f516476 | 29 | AliFlatESDTrigger( AliVConstructorReinitialisationFlag ); |
c2ea967e | 30 | void Reinitialize() const {} // no virtual table - do nothing |
31 | ||
d98142ea | 32 | // -------------------------------------------------------------------------------- |
33 | // -- Fill / Set methods | |
34 | ||
35 | Int_t SetTriggerClass( const char *TriggerClassName, Int_t TriggerIndex, ULong64_t MaxSize ); | |
36 | ||
37 | // -------------------------------------------------------------------------------- | |
38 | // -- Getter methods | |
39 | ||
40 | Int_t GetTriggerIndex() const { return fTriggerIndex; } | |
888585e5 | 41 | |
d98142ea | 42 | const Char_t *GetTriggerClassName() const { return reinterpret_cast<const Char_t*>( fContent ); } |
43 | ||
44 | // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
45 | ||
888585e5 | 46 | const AliFlatESDTrigger *GetNextTrigger() const { return reinterpret_cast<const AliFlatESDTrigger*>(fContent+fContentSize); } |
47 | ||
48 | AliFlatESDTrigger *GetNextTriggerNonConst() { return reinterpret_cast<AliFlatESDTrigger*>(fContent+fContentSize); } | |
49 | ||
d98142ea | 50 | // -------------------------------------------------------------------------------- |
51 | // -- Size methods | |
52 | ||
53 | ULong64_t GetSize() {return fContent + fContentSize - reinterpret_cast<Byte_t*>(this) ;} | |
54 | ||
55 | private: | |
56 | ||
57 | AliFlatESDTrigger(const AliFlatESDTrigger&); | |
58 | AliFlatESDTrigger& operator=(const AliFlatESDTrigger&); | |
59 | ||
60 | // -------------------------------------------------------------------------------- | |
61 | // -- Fixed size member objects | |
62 | ||
63 | UInt_t fContentSize; // Size of this object | |
64 | Int_t fTriggerIndex; // trigger index | |
65 | ||
66 | // -------------------------------------------------------------------------------- | |
67 | // -- Variable Size Object | |
68 | ||
69 | Byte_t fContent[1]; // Variale size object, which contains all data | |
70 | ||
71 | }; | |
72 | ||
73 | ||
74 | // _______________________________________________________________________________________________________ | |
75 | // inline implementation of some methods | |
76 | ||
77 | inline AliFlatESDTrigger::AliFlatESDTrigger(): | |
78 | fContentSize(1), | |
79 | fTriggerIndex(0) | |
80 | { | |
81 | // Default constructor | |
82 | fContent[0] = '\0'; | |
83 | } | |
84 | ||
85 | inline AliFlatESDTrigger::~AliFlatESDTrigger() | |
86 | { | |
87 | // Destructor | |
88 | } | |
89 | ||
bbddf50f | 90 | #pragma GCC diagnostic ignored "-Weffc++" |
91 | inline AliFlatESDTrigger::AliFlatESDTrigger( AliVConstructorReinitialisationFlag ) {} // do nothing | |
92 | #pragma GCC diagnostic warning "-Weffc++" | |
93 | ||
d98142ea | 94 | inline Int_t AliFlatESDTrigger::SetTriggerClass( const char *TriggerClassName, Int_t TriggerIndex, ULong64_t MaxSize ) |
95 | { | |
96 | // Set trigger class, returns non-zero when the memory needed exeeeds MaxSize | |
3f8b5934 | 97 | |
98 | ||
99 | size_t len = strlen( TriggerClassName ) ; | |
100 | ||
101 | // strlen does not count the terminating \0 character, but this has to be safed too | |
102 | len ++; | |
103 | ||
d98142ea | 104 | if( ( fContent + len ) > reinterpret_cast<Byte_t*>(this) + MaxSize ) return -1; |
105 | ||
106 | fTriggerIndex = TriggerIndex; | |
3f8b5934 | 107 | fContentSize =len; |
d98142ea | 108 | strcpy( reinterpret_cast<char*>(fContent), TriggerClassName ); |
109 | return 0; | |
110 | } | |
111 | ||
112 | #endif |