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),
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) :
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) :
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) :
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) :
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 TObject::operator = (domain);
219 fType = domain.fType;
220 fUseSpec = domain.fUseSpec;
221 fSpecification = domain.fSpecification;
226 bool AliHLTDomainEntry::IdenticalTo(const AliHLTDomainEntry& rhs) const
228 // Checks if this domain entry is identical to 'rhs' and do not just have a
230 // See header file for more information.
232 if (not MatchExactly(fType, rhs.fType)) return false;
233 return (fUseSpec == rhs.fUseSpec) and (fSpecification == rhs.fSpecification);
237 bool AliHLTDomainEntry::SubsetOf(const AliHLTDomainEntry& rhs) const
239 // Checks if this domain entry is a subset of 'rhs'.
240 // See header file for more information.
242 if (*this != rhs) return false;
243 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
244 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
245 bool thisSpecIsAny = not fUseSpec;
246 bool rhsTypeIsAny = strncmp(&rhs.fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
247 bool rhsOriginIsAny = strncmp(&rhs.fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
248 bool rhsSpecIsAny = not rhs.fUseSpec;
249 if (thisTypeIsAny and not rhsTypeIsAny) return false;
250 if (thisOriginIsAny and not rhsOriginIsAny) return false;
251 if (thisSpecIsAny and not rhsSpecIsAny) return false;
256 bool AliHLTDomainEntry::IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const
258 // Finds the set intersection between this domain entry and 'rhs'.
259 // See header file for more information.
261 if (*this != rhs) return false;
262 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
263 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
264 bool thisSpecIsAny = not fUseSpec;
265 const AliHLTComponentDataType& type = (not thisTypeIsAny) ? fType : rhs.fType;
266 const AliHLTComponentDataType& origin = (not thisOriginIsAny) ? fType : rhs.fType;
269 if (not thisSpecIsAny)
272 spec = fSpecification;
276 useSpec = rhs.fUseSpec;
277 spec = rhs.fSpecification;
281 result = AliHLTDomainEntry(type | origin.fOrigin, spec);
285 result = AliHLTDomainEntry(type | origin.fOrigin);
291 void AliHLTDomainEntry::Print(Option_t* option) const
293 // Inherited from TObject. Prints the domain entry contents.
294 // See header file for more information.
296 cout << AsString().Data();
298 if (opt.Contains("noendl")) return;
303 TString AliHLTDomainEntry::AsString() const
305 // Returns a string representation of the domain entry.
306 // See header file for more information.
309 if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0)
311 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*";
315 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++)
317 if (fType.fID[i] != '\0')
324 if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0)
326 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*";
330 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++)
332 if (fType.fOrigin[i] != '\0')
333 str += fType.fOrigin[i];
342 sprintf(num, "0x%8.8X", fSpecification);
352 int AliHLTDomainEntry::AsBinary(AliHLTUInt32_t buffer[4]) const
354 // convert the data type and specification to a 32 byte buffer
355 if (!buffer) return -EINVAL;
357 AliHLTUInt32_t* tgt=buffer;
360 // lower part of the data type id
362 for ( ii=0; ii<4; ii++ ) {
363 *tgt |= ((AliHLTUInt32_t)(fType.fID[8-1-ii])) << (ii*8);
367 // upper part of the data type id
369 for ( ii=0; ii<4; ii++ ) {
370 *tgt |= ((AliHLTUInt32_t)(fType.fID[8-5-ii])) << (ii*8);
376 for ( ii=0; ii<4; ii++ ) {
377 *tgt |= ((AliHLTUInt32_t)(fType.fOrigin[4-1-ii])) << (ii*8);
382 *tgt = fSpecification;