Small fix for case of no time structure
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTDomainEntry.h
CommitLineData
dce3e5ce 1#ifndef ALIHLTDOMAINENTRY_H
2#define ALIHLTDOMAINENTRY_H
3/* This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/// @file AliHLTDomainEntry.h
8/// @author Artur Szostak <artursz@iafrica.com>
9/// @date 20 Nov 2008
10/// @brief Declaration of the AliHLTDomainEntry class used to store identifying information about HLT data blocks.
11
12#include "TObject.h"
13#include "AliHLTDataTypes.h"
14
1b9a175e 15/**
16 * \class AliHLTDomainEntry
17 * The AliHLTDomainEntry class is used to store information identifying a particular
18 * HLT internal data block, or set of data blocks using wild card values. This
19 * class is used by AliHLTTriggerDomain to store a list of data block classes
20 * that should be readout by the HLT. The information identifying a data block is
21 * the following:
22 * - the data block type
23 * - the data block's origin (detector name)
24 * - the data block's specification (detector specific bits)
25 * Several useful operators and methods are defined to help manipulate this
26 * information in the AliHLTTriggerDomain class.
27 */
dce3e5ce 28class AliHLTDomainEntry : public TObject
29{
30 public:
31
32 /**
33 * Default constructor.
34 */
35 AliHLTDomainEntry();
36
37 /**
38 * Copy constructor performs a deep copy.
39 * \param domain The domain entry to copy from.
40 */
41 AliHLTDomainEntry(const AliHLTDomainEntry& domain);
42
43 /**
44 * This constructs a domain entry with a particular data type and an 'any' wild
45 * card value for specification indicating any specification will match.
46 * \param type The data block type and origin to use.
47 */
48 AliHLTDomainEntry(const AliHLTComponentDataType& type);
49
50 /**
51 * This constructs a domain entry with a particular data type and origin. The
52 * specification is marked as an 'any' wild card value, indicating any data
53 * block specification will match.
54 * \param blocktype The data block type string of the data block. The value
55 * kAliHLTAnyDataTypeID can be used to specify the any type wild card value.
56 * \param origin The origin of the data block, such as the detector name.
57 * The value kAliHLTDataOriginAny can be used to specify the any origin
58 * wild card value.
59 */
60 AliHLTDomainEntry(const char* blocktype, const char* origin);
61
62 /**
63 * This constructs a domain entry with a particular data type, origin and
64 * specification.
65 * \param type The data block type and origin to use.
66 * \param spec The data block specification to use.
67 */
68 AliHLTDomainEntry(const AliHLTComponentDataType& type, UInt_t spec);
69
70 /**
71 * This constructs a domain entry with a particular data type, origin and
72 * specification.
73 * \param blocktype The data block type string of the data block. The value
74 * kAliHLTAnyDataTypeID can be used to specify the any type wild card value.
75 * \param origin The origin of the data block, such as the detector name.
76 * The value kAliHLTDataOriginAny can be used to specify the any origin
77 * wild card value.
78 * \param spec The data block specification to use.
79 */
80 AliHLTDomainEntry(const char* blocktype, const char* origin, UInt_t spec);
81
82 /**
83 * The constructor deep copies the domain entry but overrides the exclude flag.
84 * \param exclude The new exclude flag value to use. If 'true' then the entry
85 * forms part of a trigger domain exclusion rule.
86 * \param domain The domain entry to copy from.
87 */
88 AliHLTDomainEntry(Bool_t exclude, const AliHLTDomainEntry& domain);
89
90 /**
91 * This constructs a domain entry with a particular data type and exclude flag
92 * value, but an 'any' wild card value is used for the data block specification.
93 * \param exclude The exclude flag value to use. If 'true' then the entry forms
94 * part of a trigger domain exclusion rule.
95 * \param type The data block type and origin to use.
96 */
97 AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type);
98
99 /**
100 * This constructs a domain entry with a particular data type, origin and exclusion
101 * value. The specification is marked as an 'any' wild card value, indicating any
102 * data block specification will match.
103 * \param exclude The exclude flag value to use. If 'true' then the entry forms
104 * part of a trigger domain exclusion rule.
105 * \param blocktype The data block type string of the data block. The value
106 * kAliHLTAnyDataTypeID can be used to specify the any type wild card value.
107 * \param origin The origin of the data block, such as the detector name.
108 * The value kAliHLTDataOriginAny can be used to specify the any origin
109 * wild card value.
110 */
111 AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin);
112
113 /**
114 * This constructs a domain entry with a particular exclude flag value, data type,
115 * origin and specification.
116 * \param exclude The exclude flag value to use. If 'true' then the entry forms
117 * part of a trigger domain exclusion rule.
118 * \param type The data block type and origin to use.
119 * \param spec The data block specification to use.
120 */
121 AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type, UInt_t spec);
122
123 /**
124 * This constructs a domain entry with a particular exclude flag value, data type,
125 * origin and specification.
126 * \param exclude The exclude flag value to use. If 'true' then the entry forms
127 * part of a trigger domain exclusion rule.
128 * \param blocktype The data block type string of the data block. The value
129 * kAliHLTAnyDataTypeID can be used to specify the any type wild card value.
130 * \param origin The origin of the data block, such as the detector name.
131 * The value kAliHLTDataOriginAny can be used to specify the any origin
132 * wild card value.
133 * \param spec The data block specification to use.
134 */
135 AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin, UInt_t spec);
136
137 /**
138 * Default destructor.
139 */
140 virtual ~AliHLTDomainEntry();
141
142 /**
143 * Returns the value of the exclude flag.
144 * \return true if the domain entry is an exclusion and the matching data blocks
145 * should not form part of the trigger domain for readout.
146 */
147 Bool_t Exclusive() const { return fExclude; }
148
149 /**
150 * Sets the value of the exclude flag.
151 * \param value The value to set the flag to. If 'true' then the domain entry
152 * is an exclusion and the matching data blocks should not form part of the
153 * trigger domain for readout. If 'false' then the matching data blocks should
154 * form part of the readout.
155 */
156 void Exclusive(Bool_t value) { fExclude = value; }
157
158 /**
159 * Indicates if the domain entry is an inclusive rule.
160 * \return true if the domain entry is an inclusion and the matching data blocks
161 * should form part of the trigger domain for readout.
162 */
163 Bool_t Inclusive() const { return ! fExclude; }
164
165 /**
166 * Used to set if the domain entry should be an inclusion or exclusion.
167 * \param value The value to set. If 'true' then the domain entry is an inclusion
168 * and the matching data blocks should form part of the trigger domain for readout.
169 * If 'false' then the matching data blocks should not form part of the readout.
170 */
171 void Inclusive(Bool_t value) { fExclude = ! value; }
172
173 /**
174 * Returns the data type of the domain entry.
175 * \return The data type that data blocks are compared to.
176 */
177 const AliHLTComponentDataType& DataType() const { return fType; }
178
179 /**
180 * Indicates if the specification is used.
181 * \return true if the specification is used when matching data blocks, otherwise
182 * false, indicating that the specification is treated as a wild card value.
183 */
184 Bool_t IsValidSpecification() const { return fUseSpec; }
185
186 /**
187 * Returns the data block specification of the domain entry.
188 * \return The data block specification that data blocks are compared to.
189 */
190 UInt_t Specification() const { return fSpecification; }
191
192 /**
193 * The copy operator performs a deep copy.
194 * \param domain The domain entry to copy from.
195 */
196 AliHLTDomainEntry& operator = (const AliHLTDomainEntry& domain);
197
198 /**
199 * The comparison operator checks to see if two domain entries match.
200 * \param rhs The right hand side domain entry to compare to.
201 * \return true if the domain entries are identical or if they overlap (match)
202 * due to wild card values. False is returned if there is absolutely no
203 * overlap between this and the right hand side domain entries.
204 */
205 bool operator == (const AliHLTDomainEntry& rhs) const
206 {
207 return (fType == rhs.fType) && (fUseSpec && rhs.fUseSpec ? fSpecification == rhs.fSpecification : true);
208 }
209
210 /**
211 * The comparison operator checks to see if two domain entries do not match.
212 * \param rhs The right hand side domain entry to compare to.
213 * \return true if the domain entries do not overlap (match) in any way, also
214 * after considering any wild card values. False is returned if the entries
215 * are identical or if they overlap due to wild card values.
216 */
217 bool operator != (const AliHLTDomainEntry& rhs) const
218 {
219 return ! this->operator == (rhs);
220 }
221
222 /**
223 * The comparison operator checks to see if the data block matches the domain entry.
224 * \note The data block's specification is treated as exact and never as a wild card
225 * 'any' value. To be able to treat the specification as 'any', create a new
226 * AliHLTDomainEntry object with the
227 * \code AliHLTDomainEntry(const AliHLTComponentDataType& type) \endcode
228 * constructor, using the data blocks type for the <i>type</i> parameter.
229 * With the new AliHLTDomainEntry object one can make the required wild card comparison.
230 * \param block The data block to compare to.
231 * \return true if the data block matches the domain entry and false otherwise.
232 */
233 bool operator == (const AliHLTComponentBlockData* block) const
234 {
235 return (fType == block->fDataType) && (fUseSpec ? fSpecification == block->fSpecification : true);
236 }
237
238 /**
239 * The comparison operator checks to see if the data block does not match the domain entry.
240 * \note The data block's specification is treated as exact and never as a wild card
241 * 'any' value. To be able to make the required comparison treating the specification
242 * as 'any' try the following code:
243 * \code
244 * AliHLTComponentBlockData* block; // assumed initialised.
245 * AliHLTDomainEntry entryToCompareTo; // assumed initialised.
246 * AliHLTDomainEntry newEntryForBlock(block->fDataType);
247 * bool comparisonResult = (entryToCompareTo == newEntryForBlock);
248 * \endcode
249 * \param block The data block to compare to.
250 * \return true if the data block matches the domain entry and false otherwise.
251 */
252 bool operator != (const AliHLTComponentBlockData* block) const
253 {
254 return ! this->operator == (block);
255 }
256
257 /**
258 * This typecast operator returns the data type of the domain entry.
259 * \return Copy of the data block type structure.
260 */
261 operator AliHLTComponentDataType () const { return fType; }
262
263 /**
264 * Compares this domain entry to another to see if they are identical.
265 * \param rhs The domain entry to compare to.
266 * \return True if the two domain entries have the same data types, origins and
267 * specifications, character for character, ignoring wild card symantics.
268 * False is returned otherwise.
269 * \note No comparison is done for the exclude flag.
270 */
271 bool IdenticalTo(const AliHLTDomainEntry& rhs) const;
272
273 /**
274 * Compares this domain entry is a subset of the given entry.
275 * If we consider the possibility of wild card characters, then the domain entry
276 * can be thought of as a set of possible data block entries. This operator
277 * therefore effectively implements set logic.
278 * \param rhs The domain entry to compare to.
279 * \return True if the this domain entry is either identical to <i>rhs</i>, i.e.
280 * IdenticalTo(rhs) returns true, or if <i>rhs</i> can match to all data blocks
281 * that this domain entry can match to, but also <i>rhs</i> can match to other
282 * data blocks that this entry cannot match to.
283 * \note No comparison is done for the exclude flag.
284 */
285 bool SubsetOf(const AliHLTDomainEntry& rhs) const;
286
287 /**
288 * Finds the set intersection between this domain entry and 'rhs', and puts the
289 * intersection value into 'result'.
290 * If we consider the possibility of wild card characters, then the domain entry
291 * can be thought of as a set of possible data block entries. This operator
292 * therefore effectively implements the set intersection.
293 * \param rhs <i>[in]</i> The domain entry to compare to.
294 * \param result <i>[out]</i> The resulting intersect is written into this
295 * variable if this method returns true. The contents is not modified if
296 * there is no intersect and this method returns false.
297 * \return true is returned if there is a intersect between the domain entries
298 * and false otherwise.
299 */
300 bool IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const;
301
302 /**
303 * Inherited from TObject. Prints the domain entry in the following format:<br>
304 * \<type\>:\<origin\>:\<specification\><br>
305 * where<br>
306 * \<type\> is the 8 character data block type.<br>
307 * \<origin\> is the 4 character data block origin.<br>
308 * \<specification\> is the data block specification printed in hexadecimal format.<br>
309 * The "\0" string is printed for NULL characters in the type and origin strings.
310 * While "********" is printed for the 'any' data type wild card value, "****"
311 * is printed for the 'any' origin wild card value and "**********" is printed
312 * for the 'any' specification wild card.
313 * \param option If set to "noendl" then no end of line is printed.
314 */
315 virtual void Print(Option_t* option = "") const;
316
317 private:
318
319 Bool_t fExclude; /// Indicates if the domain entry is exclusive, indicating data blocks that should not be readout.
320 Bool_t fUseSpec; /// Indicates if the fSpecification field should be used. If not set then the specification is treated as an 'any' wild card value.
321 AliHLTComponentDataType fType; /// The HLT data block type.
322 UInt_t fSpecification; /// The data block specification to match.
323
324 ClassDef(AliHLTDomainEntry, 1) // A data block type and possible specification entry, which forms part of a trigger domain.
325};
326
327#endif // ALIHLTDOMAINENTRY_H
328