]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDomainEntry.cxx
Bugfix: lowercase b should be upper case B for component id: TPCClusterFinder32Bit
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDomainEntry.cxx
1 // $Id:$
2 /**************************************************************************
3  * This file is property of and copyright by the ALICE HLT Project        *
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  *                                                                        *
6  * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
7  *                  for The ALICE HLT Project.                            *
8  *                                                                        *
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  **************************************************************************/
17
18 /// @file   AliHLTDomainEntry.cxx
19 /// @author Artur Szostak <artursz@iafrica.com>
20 /// @date   20 Nov 2008
21 /// @brief  Implementation of the AliHLTDomainEntry class.
22 ///
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
27 /// the following:
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.
33
34 #include "AliHLTDomainEntry.h"
35 #include "Riostream.h"
36 #include "TString.h"
37 #include <cstring>
38
39 ClassImp(AliHLTDomainEntry)
40
41
42 AliHLTDomainEntry::AliHLTDomainEntry() :
43   TObject(),
44   fExclude(kFALSE),
45   fUseSpec(kFALSE),
46   fType(kAliHLTVoidDataType),
47   fSpecification(0x0)
48 {
49   // Default constructor.
50 }
51
52 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTDomainEntry& domain) :
53   TObject(domain),
54   fExclude(domain.fExclude),
55   fUseSpec(domain.fUseSpec),
56   fType(domain.fType),
57   fSpecification(domain.fSpecification)
58 {
59   // Copy constructor performs a deep copy.
60 }
61
62
63 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type) :
64   TObject(),
65   fExclude(kFALSE),
66   fUseSpec(kFALSE),
67   fType(type),
68   fSpecification(0x0)
69 {
70   // Constructs a domain entry with a particular data type and any specification.
71   // See header file for more information.
72 }
73
74
75 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin) :
76   TObject(),
77   fExclude(kFALSE),
78   fUseSpec(kFALSE),
79   fType(),
80   fSpecification(0x0)
81 {
82   // Constructs a domain entry with a particular data type and any specification.
83   // See header file for more information.
84   
85   char id[kAliHLTComponentDataTypefIDsize];
86   memset(&id, 0x0, sizeof(id));
87   for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
88   {
89     id[i] = blocktype[i];
90   }
91   fType = AliHLTComponentDataTypeInitializer(id, origin);
92 }
93
94
95 AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type, UInt_t spec) :
96   TObject(),
97   fExclude(kFALSE),
98   fUseSpec(kTRUE),
99   fType(type),
100   fSpecification(spec)
101 {
102   // Constructs a domain entry with a particular data type and specification.
103   // See header file for more information.
104 }
105
106
107 AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin, UInt_t spec) :
108   TObject(),
109   fExclude(kFALSE),
110   fUseSpec(kTRUE),
111   fType(),
112   fSpecification(spec)
113 {
114   // Constructs a domain entry with a particular data type and specification.
115   // See header file for more information.
116   
117   char id[kAliHLTComponentDataTypefIDsize];
118   memset(&id, 0x0, sizeof(id));
119   for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
120   {
121     id[i] = blocktype[i];
122   }
123   fType = AliHLTComponentDataTypeInitializer(id, origin);
124 }
125
126
127 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTDomainEntry& domain) :
128   TObject(domain),
129   fExclude(exclude),
130   fUseSpec(domain.fUseSpec),
131   fType(domain.fType),
132   fSpecification(domain.fSpecification)
133 {
134   // Constructs a domain entry from an existing one but with the exclude flag set.
135   // See header file for more information.
136 }
137
138
139 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type) :
140   TObject(),
141   fExclude(exclude),
142   fUseSpec(kFALSE),
143   fType(type),
144   fSpecification(0x0)
145 {
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.
149 }
150
151
152 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin) :
153   TObject(),
154   fExclude(exclude),
155   fUseSpec(kFALSE),
156   fType(),
157   fSpecification(0x0)
158 {
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.
162   
163   char id[kAliHLTComponentDataTypefIDsize];
164   memset(&id, 0x0, sizeof(id));
165   for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
166   {
167     id[i] = blocktype[i];
168   }
169   fType = AliHLTComponentDataTypeInitializer(id, origin);
170 }
171
172
173 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type, UInt_t spec) :
174   TObject(),
175   fExclude(exclude),
176   fUseSpec(kTRUE),
177   fType(type),
178   fSpecification(spec)
179 {
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.
183 }
184
185
186 AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin, UInt_t spec) :
187   TObject(),
188   fExclude(exclude),
189   fUseSpec(kTRUE),
190   fType(),
191   fSpecification(spec)
192 {
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.
196   
197   char id[kAliHLTComponentDataTypefIDsize];
198   memset(&id, 0x0, sizeof(id));
199   for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
200   {
201     id[i] = blocktype[i];
202   }
203   fType = AliHLTComponentDataTypeInitializer(id, origin);
204 }
205
206
207 AliHLTDomainEntry::~AliHLTDomainEntry()
208 {
209   // Default destructor.
210 }
211
212
213 AliHLTDomainEntry& AliHLTDomainEntry::operator = (const AliHLTDomainEntry& domain)
214 {
215   // The copy operator performs a deep copy.
216
217   TObject::operator = (domain);
218   fType = domain.fType;
219   fUseSpec = domain.fUseSpec;
220   fSpecification = domain.fSpecification;
221   return *this;
222 }
223
224
225 bool AliHLTDomainEntry::IdenticalTo(const AliHLTDomainEntry& rhs) const
226 {
227   // Checks if this domain entry is identical to 'rhs' and do not just have a
228   // set intersection.
229   // See header file for more information.
230   
231   if (not MatchExactly(fType, rhs.fType)) return false;
232   return (fUseSpec == rhs.fUseSpec) and (fSpecification == rhs.fSpecification);
233 }
234
235
236 bool AliHLTDomainEntry::SubsetOf(const AliHLTDomainEntry& rhs) const
237 {
238   // Checks if this domain entry is a subset of 'rhs'.
239   // See header file for more information.
240
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;
251   return true;
252 }
253
254
255 bool AliHLTDomainEntry::IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const
256 {
257   // Finds the set intersection between this domain entry and 'rhs'.
258   // See header file for more information.
259
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;
266   Bool_t useSpec;
267   UInt_t spec;
268   if (not thisSpecIsAny)
269   {
270     useSpec = fUseSpec;
271     spec = fSpecification;
272   }
273   else
274   {
275     useSpec = rhs.fUseSpec;
276     spec = rhs.fSpecification;
277   }
278   if (useSpec)
279   {
280     result = AliHLTDomainEntry(type | origin.fOrigin, spec);
281   }
282   else
283   {
284     result = AliHLTDomainEntry(type | origin.fOrigin);
285   }
286   return true;
287 }
288
289
290 void AliHLTDomainEntry::Print(Option_t* option) const
291 {
292   // Inherited from TObject. Prints the domain entry contents.
293   // See header file for more information.
294   
295   cout << AsString().Data();
296   TString opt(option);
297   if (opt.Contains("noendl")) return;
298   cout << endl;
299 }
300
301
302 TString AliHLTDomainEntry::AsString() const
303 {
304   // Returns a string representation of the domain entry.
305   // See header file for more information.
306   
307   TString str;
308   if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0)
309   {
310     for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*";
311   }
312   else
313   {
314     for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++)
315     {
316       if (fType.fID[i] != '\0')
317         str += fType.fID[i];
318       else
319         str += "\\0";
320     }
321   }
322   str += ":";
323   if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0)
324   {
325     for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*";
326   }
327   else
328   {
329     for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++)
330     {
331       if (fType.fOrigin[i] != '\0')
332         str += fType.fOrigin[i];
333       else
334         str += "\\0";
335     }
336   }
337   str += ":";
338   if (fUseSpec)
339   {
340     char num[16];
341     sprintf(num, "0x%8.8X", fSpecification);
342     str += num;
343   }
344   else
345   {
346     str += "**********";
347   }
348   return str;
349 }
350