1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
6 * for The ALICE HLT Project. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 /// @file AliHLTDomainEntry.cxx
18 /// @author Artur Szostak <artursz@iafrica.com>
20 /// @brief Implementation of the AliHLTDomainEntry class.
22 /// The AliHLTDomainEntry class is used to store information identifying a particular
23 /// HLT internal data block, or set of data blocks using wild card values. This
24 /// class is used by AliHLTTriggerDomain to store a list of data block classes
25 /// that should be readout by the HLT. The information identifying a data block is
27 /// - the data block type
28 /// - the data block's origin (detector name)
29 /// - the data block's specification (detector specific bits)
30 /// Several useful operators and methods are defined to help manipulate this
31 /// information in the AliHLTTriggerDomain class.
33 #include "AliHLTDomainEntry.h"
34 #include "Riostream.h"
38 ClassImp(AliHLTDomainEntry)
41 AliHLTDomainEntry::AliHLTDomainEntry() :
45 fType(kAliHLTVoidDataType),
48 // Default constructor.
51 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTDomainEntry& domain) :
53 fExclude(domain.fExclude),
54 fUseSpec(domain.fUseSpec),
56 fSpecification(domain.fSpecification)
58 // Copy constructor performs a deep copy.
62 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type) :
69 // Constructs a domain entry with a particular data type and any specification.
70 // See header file for more information.
74 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin) :
81 // Constructs a domain entry with a particular data type and any specification.
82 // See header file for more information.
84 char id[kAliHLTComponentDataTypefIDsize];
85 memset(&id, 0x0, sizeof(id));
86 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
90 fType = AliHLTComponentDataTypeInitializer(id, origin);
94 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type, UInt_t spec) :
101 // Constructs a domain entry with a particular data type and specification.
102 // See header file for more information.
106 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin, UInt_t spec) :
113 // Constructs a domain entry with a particular data type and specification.
114 // See header file for more information.
116 char id[kAliHLTComponentDataTypefIDsize];
117 memset(&id, 0x0, sizeof(id));
118 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
120 id[i] = blocktype[i];
122 fType = AliHLTComponentDataTypeInitializer(id, origin);
126 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTDomainEntry& domain) :
129 fUseSpec(domain.fUseSpec),
131 fSpecification(domain.fSpecification)
133 // Constructs a domain entry from an existing one but with the exclude flag set.
134 // See header file for more information.
138 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type) :
145 // Constructs a domain entry with the given data type, any specification
146 // and the exclude flag set.
147 // See header file for more information.
151 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin) :
158 // Constructs a domain entry with a particular data type, any specification
159 // and the exclude flag set.
160 // See header file for more information.
162 char id[kAliHLTComponentDataTypefIDsize];
163 memset(&id, 0x0, sizeof(id));
164 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
166 id[i] = blocktype[i];
168 fType = AliHLTComponentDataTypeInitializer(id, origin);
172 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type, UInt_t spec) :
179 // Constructs a domain entry with a particular data type and specification,
180 // and the exclude flag is set.
181 // See header file for more information.
185 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin, UInt_t spec) :
192 // Constructs a domain entry with a particular data type and specification,
193 // and the exclude flag is set.
194 // See header file for more information.
196 char id[kAliHLTComponentDataTypefIDsize];
197 memset(&id, 0x0, sizeof(id));
198 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
200 id[i] = blocktype[i];
202 fType = AliHLTComponentDataTypeInitializer(id, origin);
206 AliHLTDomainEntry::~AliHLTDomainEntry()
208 // Default destructor.
212 AliHLTDomainEntry& AliHLTDomainEntry::operator = (const AliHLTDomainEntry& domain)
214 // The copy operator performs a deep copy.
216 TObject::operator = (domain);
217 fType = domain.fType;
218 fUseSpec = domain.fUseSpec;
219 fSpecification = domain.fSpecification;
224 bool AliHLTDomainEntry::IdenticalTo(const AliHLTDomainEntry& rhs) const
226 // Checks if this domain entry is identical to 'rhs' and do not just have a
228 // See header file for more information.
230 if (not MatchExactly(fType, rhs.fType)) return false;
231 return (fUseSpec == rhs.fUseSpec) and (fSpecification == rhs.fSpecification);
235 bool AliHLTDomainEntry::SubsetOf(const AliHLTDomainEntry& rhs) const
237 // Checks if this domain entry is a subset of 'rhs'.
238 // See header file for more information.
240 if (*this != rhs) return false;
241 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
242 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
243 bool thisSpecIsAny = not fUseSpec;
244 bool rhsTypeIsAny = strncmp(&rhs.fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
245 bool rhsOriginIsAny = strncmp(&rhs.fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
246 bool rhsSpecIsAny = not rhs.fUseSpec;
247 if (thisTypeIsAny and not rhsTypeIsAny) return false;
248 if (thisOriginIsAny and not rhsOriginIsAny) return false;
249 if (thisSpecIsAny and not rhsSpecIsAny) return false;
254 bool AliHLTDomainEntry::IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const
256 // Finds the set intersection between this domain entry and 'rhs'.
257 // See header file for more information.
259 if (*this != rhs) return false;
260 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
261 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
262 bool thisSpecIsAny = not fUseSpec;
263 const AliHLTComponentDataType& type = (not thisTypeIsAny) ? fType : rhs.fType;
264 const AliHLTComponentDataType& origin = (not thisOriginIsAny) ? fType : rhs.fType;
267 if (not thisSpecIsAny)
270 spec = fSpecification;
274 useSpec = rhs.fUseSpec;
275 spec = rhs.fSpecification;
279 result = AliHLTDomainEntry(type | origin.fOrigin, spec);
283 result = AliHLTDomainEntry(type | origin.fOrigin);
289 void AliHLTDomainEntry::Print(Option_t* option) const
291 // Inherited from TObject. Prints the domain entry contents.
292 // See header file for more information.
294 cout << AsString().Data();
296 if (opt.Contains("noendl")) return;
301 TString AliHLTDomainEntry::AsString() const
303 // Returns a string representation of the domain entry.
304 // See header file for more information.
307 if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0)
309 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*";
313 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++)
315 if (fType.fID[i] != '\0')
322 if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0)
324 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*";
328 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++)
330 if (fType.fOrigin[i] != '\0')
331 str += fType.fOrigin[i];
340 sprintf(num, "0x%8.8X", fSpecification);