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"
39 ClassImp(AliHLTDomainEntry)
42 AliHLTDomainEntry::AliHLTDomainEntry() :
46 fType(kAliHLTVoidDataType),
49 // Default constructor.
52 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTDomainEntry& domain) :
54 fExclude(domain.fExclude),
55 fUseSpec(domain.fUseSpec),
57 fSpecification(domain.fSpecification)
59 // Copy constructor performs a deep copy.
63 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type) :
70 // Constructs a domain entry with a particular data type and any specification.
71 // See header file for more information.
75 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin) :
82 // Constructs a domain entry with a particular data type and any specification.
83 // See header file for more information.
85 char id[kAliHLTComponentDataTypefIDsize];
86 memset(&id, 0x0, sizeof(id));
87 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
91 fType = AliHLTComponentDataTypeInitializer(id, origin);
95 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type, UInt_t spec) :
102 // Constructs a domain entry with a particular data type and specification.
103 // See header file for more information.
107 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin, UInt_t spec) :
114 // Constructs a domain entry with a particular data type and specification.
115 // See header file for more information.
117 char id[kAliHLTComponentDataTypefIDsize];
118 memset(&id, 0x0, sizeof(id));
119 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
121 id[i] = blocktype[i];
123 fType = AliHLTComponentDataTypeInitializer(id, origin);
127 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTDomainEntry& domain) :
130 fUseSpec(domain.fUseSpec),
132 fSpecification(domain.fSpecification)
134 // Constructs a domain entry from an existing one but with the exclude flag set.
135 // See header file for more information.
139 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type) :
146 // Constructs a domain entry with the given data type, any specification
147 // and the exclude flag set.
148 // See header file for more information.
152 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin) :
159 // Constructs a domain entry with a particular data type, any specification
160 // and the exclude flag set.
161 // See header file for more information.
163 char id[kAliHLTComponentDataTypefIDsize];
164 memset(&id, 0x0, sizeof(id));
165 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
167 id[i] = blocktype[i];
169 fType = AliHLTComponentDataTypeInitializer(id, origin);
173 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type, UInt_t spec) :
180 // Constructs a domain entry with a particular data type and specification,
181 // and the exclude flag is set.
182 // See header file for more information.
186 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin, UInt_t spec) :
193 // Constructs a domain entry with a particular data type and specification,
194 // and the exclude flag is set.
195 // See header file for more information.
197 char id[kAliHLTComponentDataTypefIDsize];
198 memset(&id, 0x0, sizeof(id));
199 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
201 id[i] = blocktype[i];
203 fType = AliHLTComponentDataTypeInitializer(id, origin);
207 AliHLTDomainEntry::~AliHLTDomainEntry()
209 // Default destructor.
213 AliHLTDomainEntry& AliHLTDomainEntry::operator = (const AliHLTDomainEntry& domain)
215 // The copy operator performs a deep copy.
217 TObject::operator = (domain);
218 fType = domain.fType;
219 fUseSpec = domain.fUseSpec;
220 fSpecification = domain.fSpecification;
225 bool AliHLTDomainEntry::IdenticalTo(const AliHLTDomainEntry& rhs) const
227 // Checks if this domain entry is identical to 'rhs' and do not just have a
229 // See header file for more information.
231 if (not MatchExactly(fType, rhs.fType)) return false;
232 return (fUseSpec == rhs.fUseSpec) and (fSpecification == rhs.fSpecification);
236 bool AliHLTDomainEntry::SubsetOf(const AliHLTDomainEntry& rhs) const
238 // Checks if this domain entry is a subset of 'rhs'.
239 // See header file for more information.
241 if (*this != rhs) return false;
242 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
243 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
244 bool thisSpecIsAny = not fUseSpec;
245 bool rhsTypeIsAny = strncmp(&rhs.fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
246 bool rhsOriginIsAny = strncmp(&rhs.fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
247 bool rhsSpecIsAny = not rhs.fUseSpec;
248 if (thisTypeIsAny and not rhsTypeIsAny) return false;
249 if (thisOriginIsAny and not rhsOriginIsAny) return false;
250 if (thisSpecIsAny and not rhsSpecIsAny) return false;
255 bool AliHLTDomainEntry::IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const
257 // Finds the set intersection between this domain entry and 'rhs'.
258 // See header file for more information.
260 if (*this != rhs) return false;
261 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
262 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
263 bool thisSpecIsAny = not fUseSpec;
264 const AliHLTComponentDataType& type = (not thisTypeIsAny) ? fType : rhs.fType;
265 const AliHLTComponentDataType& origin = (not thisOriginIsAny) ? fType : rhs.fType;
268 if (not thisSpecIsAny)
271 spec = fSpecification;
275 useSpec = rhs.fUseSpec;
276 spec = rhs.fSpecification;
280 result = AliHLTDomainEntry(type | origin.fOrigin, spec);
284 result = AliHLTDomainEntry(type | origin.fOrigin);
290 void AliHLTDomainEntry::Print(Option_t* option) const
292 // Inherited from TObject. Prints the domain entry contents.
293 // See header file for more information.
295 cout << AsString().Data();
297 if (opt.Contains("noendl")) return;
302 TString AliHLTDomainEntry::AsString() const
304 // Returns a string representation of the domain entry.
305 // See header file for more information.
308 if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0)
310 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*";
314 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++)
316 if (fType.fID[i] != '\0')
323 if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0)
325 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*";
329 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++)
331 if (fType.fOrigin[i] != '\0')
332 str += fType.fOrigin[i];
341 sprintf(num, "0x%8.8X", fSpecification);