2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
6 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
7 * for The ALICE HLT Project. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /// @file AliHLTDomainEntry.cxx
19 /// @author Artur Szostak <artursz@iafrica.com>
21 /// @brief Implementation of the AliHLTDomainEntry class.
23 /// The AliHLTDomainEntry class is used to store information identifying a particular
24 /// HLT internal data block, or set of data blocks using wild card values. This
25 /// class is used by AliHLTTriggerDomain to store a list of data block classes
26 /// that should be readout by the HLT. The information identifying a data block is
28 /// - the data block type
29 /// - the data block's origin (detector name)
30 /// - the data block's specification (detector specific bits)
31 /// Several useful operators and methods are defined to help manipulate this
32 /// information in the AliHLTTriggerDomain class.
34 #include "AliHLTDomainEntry.h"
35 #include "Riostream.h"
40 ClassImp(AliHLTDomainEntry)
43 AliHLTDomainEntry::AliHLTDomainEntry() :
47 fType(kAliHLTVoidDataType),
48 fSpecification(kAliHLTVoidDataSpec)
50 // Default constructor.
53 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTDomainEntry& domain) :
55 fExclude(domain.fExclude),
56 fUseSpec(domain.fUseSpec),
58 fSpecification(domain.fSpecification)
60 // Copy constructor performs a deep copy.
64 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type) :
69 fSpecification(kAliHLTVoidDataSpec)
71 // Constructs a domain entry with a particular data type and any specification.
72 // See header file for more information.
76 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin) :
81 fSpecification(kAliHLTVoidDataSpec)
83 // Constructs a domain entry with a particular data type and any specification.
84 // See header file for more information.
86 char id[kAliHLTComponentDataTypefIDsize];
87 memset(&id, 0x0, sizeof(id));
88 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
92 fType = AliHLTComponentDataTypeInitializer(id, origin);
96 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type, UInt_t spec) :
103 // Constructs a domain entry with a particular data type and specification.
104 // See header file for more information.
108 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin, UInt_t spec) :
115 // Constructs a domain entry with a particular data type and specification.
116 // See header file for more information.
118 char id[kAliHLTComponentDataTypefIDsize];
119 memset(&id, 0x0, sizeof(id));
120 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
122 id[i] = blocktype[i];
124 fType = AliHLTComponentDataTypeInitializer(id, origin);
128 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTDomainEntry& domain) :
131 fUseSpec(domain.fUseSpec),
133 fSpecification(domain.fSpecification)
135 // Constructs a domain entry from an existing one but with the exclude flag set.
136 // See header file for more information.
140 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type) :
145 fSpecification(kAliHLTVoidDataSpec)
147 // Constructs a domain entry with the given data type, any specification
148 // and the exclude flag set.
149 // See header file for more information.
153 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin) :
158 fSpecification(kAliHLTVoidDataSpec)
160 // Constructs a domain entry with a particular data type, any specification
161 // and the exclude flag set.
162 // See header file for more information.
164 char id[kAliHLTComponentDataTypefIDsize];
165 memset(&id, 0x0, sizeof(id));
166 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
168 id[i] = blocktype[i];
170 fType = AliHLTComponentDataTypeInitializer(id, origin);
174 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type, UInt_t spec) :
181 // Constructs a domain entry with a particular data type and specification,
182 // and the exclude flag is set.
183 // See header file for more information.
187 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin, UInt_t spec) :
194 // Constructs a domain entry with a particular data type and specification,
195 // and the exclude flag is set.
196 // See header file for more information.
198 char id[kAliHLTComponentDataTypefIDsize];
199 memset(&id, 0x0, sizeof(id));
200 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
202 id[i] = blocktype[i];
204 fType = AliHLTComponentDataTypeInitializer(id, origin);
208 AliHLTDomainEntry::~AliHLTDomainEntry()
210 // Default destructor.
214 AliHLTDomainEntry& AliHLTDomainEntry::operator = (const AliHLTDomainEntry& domain)
216 // The copy operator performs a deep copy.
218 if (this==&domain) return *this;
219 TObject::operator = (domain);
220 fType = domain.fType;
221 fUseSpec = domain.fUseSpec;
222 fSpecification = domain.fSpecification;
227 bool AliHLTDomainEntry::IdenticalTo(const AliHLTDomainEntry& rhs) const
229 // Checks if this domain entry is identical to 'rhs' and do not just have a
231 // See header file for more information.
233 if (not MatchExactly(fType, rhs.fType)) return false;
234 return (fUseSpec == rhs.fUseSpec) and (fSpecification == rhs.fSpecification);
238 bool AliHLTDomainEntry::SubsetOf(const AliHLTDomainEntry& rhs) const
240 // Checks if this domain entry is a subset of 'rhs'.
241 // See header file for more information.
243 if (*this != rhs) return false;
244 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
245 bool rhsTypeIsAny = strncmp(&rhs.fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
246 if (thisTypeIsAny and not rhsTypeIsAny) return false;
247 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
248 bool rhsOriginIsAny = strncmp(&rhs.fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
249 if (thisOriginIsAny and not rhsOriginIsAny) return false;
250 bool thisSpecIsAny = not fUseSpec;
251 bool rhsSpecIsAny = not rhs.fUseSpec;
252 if (thisSpecIsAny and not rhsSpecIsAny) return false;
257 bool AliHLTDomainEntry::IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const
259 // Finds the set intersection between this domain entry and 'rhs'.
260 // See header file for more information.
262 if (*this != rhs) return false;
263 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
264 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
265 bool thisSpecIsAny = not fUseSpec;
266 const AliHLTComponentDataType& type = (not thisTypeIsAny) ? fType : rhs.fType;
267 const AliHLTComponentDataType& origin = (not thisOriginIsAny) ? fType : rhs.fType;
270 if (not thisSpecIsAny)
273 spec = fSpecification;
277 useSpec = rhs.fUseSpec;
278 spec = rhs.fSpecification;
282 result = AliHLTDomainEntry(type | origin.fOrigin, spec);
286 result = AliHLTDomainEntry(type | origin.fOrigin);
292 void AliHLTDomainEntry::Print(Option_t* option) const
294 // Inherited from TObject. Prints the domain entry contents.
295 // See header file for more information.
297 cout << AsString().Data();
299 if (opt.Contains("noendl")) return;
304 TString AliHLTDomainEntry::AsString() const
306 // Returns a string representation of the domain entry.
307 // See header file for more information.
310 if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0)
312 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*";
316 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++)
318 if (fType.fID[i] != '\0')
325 if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0)
327 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*";
331 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++)
333 if (fType.fOrigin[i] != '\0')
334 str += fType.fOrigin[i];
343 sprintf(num, "0x%8.8X", fSpecification);
353 int AliHLTDomainEntry::AsBinary(AliHLTUInt32_t buffer[4]) const
355 // convert the data type and specification to a 32 byte buffer
356 if (!buffer) return -EINVAL;
358 AliHLTUInt32_t* tgt=buffer;
361 // lower part of the data type id
363 for ( ii=0; ii<4; ii++ ) {
364 *tgt |= ((AliHLTUInt32_t)(fType.fID[8-1-ii])) << (ii*8);
368 // upper part of the data type id
370 for ( ii=0; ii<4; ii++ ) {
371 *tgt |= ((AliHLTUInt32_t)(fType.fID[8-5-ii])) << (ii*8);
377 for ( ii=0; ii<4; ii++ ) {
378 *tgt |= ((AliHLTUInt32_t)(fType.fOrigin[4-1-ii])) << (ii*8);
384 *tgt = fSpecification;
386 *tgt = kAliHLTVoidDataSpec;