3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliHLTBlockDataCollection.cxx
20 @author Matthias Richter
22 @brief A collection of AliHLTComponentBlockData descriptors providing
23 argument parsing and basic selection.
27 #include "AliHLTBlockDataCollection.h"
28 #include "AliHLTComponent.h"
31 /** ROOT macro for the implementation of ROOT specific class methods */
32 ClassImp(AliHLTBlockDataCollection)
34 AliHLTBlockDataCollection::AliHLTBlockDataCollection()
39 // see header file for class documentation
41 // refer to README to build package
43 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 AliHLTBlockDataCollection::~AliHLTBlockDataCollection()
48 // see header file for class documentation
51 int AliHLTBlockDataCollection::Add(const AliHLTComponentBlockData& block)
53 // see header file for class documentation
54 fFilterRules.push_back(block);
55 return fFilterRules.size();
58 int AliHLTBlockDataCollection::ScanArgument( int argc, const char** argv )
60 // see header file for class documentation
64 AliHLTComponentBlockData rule;
65 AliHLTComponent::FillBlockData(rule);
67 for (; i<argc && iResult>=0; i++) {
69 if (argument.IsNull()) continue;
72 if (argument.CompareTo("-datatype")==0) {
73 if ((bMissingParam=(i+2>=argc))) break;
75 if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
76 // the data type has already been set, add to list
78 fFilterRules.push_back(rule);
79 AliHLTComponent::FillBlockData(rule);
82 AliHLTComponent::SetDataType(rule.fDataType, argv[i+1], argv[i+2]);
86 } else if (argument.CompareTo("-origin")==0) {
87 if ((bMissingParam=(i+1>=argc))) break;
89 if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
90 // the data type has already been set, add to list
92 fFilterRules.push_back(rule);
93 AliHLTComponent::FillBlockData(rule);
96 AliHLTComponent::SetDataType(rule.fDataType, NULL, argv[i+1]);
100 } else if (argument.CompareTo("-typeid")==0) {
101 if ((bMissingParam=(i+1>=argc))) break;
103 if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
104 // the data type has already been set, add to list
106 fFilterRules.push_back(rule);
107 AliHLTComponent::FillBlockData(rule);
110 AliHLTComponent::SetDataType(rule.fDataType, argv[i+1], NULL);
114 } else if (argument.CompareTo("-dataspec")==0) {
115 if ((bMissingParam=(++i>=argc))) break;
117 if (rule.fSpecification!=kAliHLTVoidDataSpec) {
118 // the specification has already been set, add to list
120 fFilterRules.push_back(rule);
121 AliHLTComponent::FillBlockData(rule);
124 TString parameter(argv[i]);
125 parameter.Remove(TString::kLeading, ' '); // remove all blanks
127 rule.fSpecification=strtoul(parameter.Data(), &pRemnant, 0);
128 if (pRemnant!=NULL && pRemnant[0]!=0) {
129 HLTError("invalid parameter/remnant (%s) for argument %s, number expected", pRemnant, argument.Data());
133 // terminate at the first unknown argument
139 HLTError("missing parameter for argument %s", argument.Data());
143 if (rule.fSpecification!=kAliHLTVoidDataSpec || !MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
144 // add the pending rule
145 fFilterRules.push_back(rule);
146 AliHLTComponent::FillBlockData(rule);
154 int AliHLTBlockDataCollection::IsSelected(const AliHLTComponentBlockData& block)
156 // see header file for class documentation
157 AliHLTComponentBlockDataList::iterator desc=fFilterRules.begin();
158 //HLTDebug("check block: %s spec %#x", DataType2Text(block.fDataType, 1).c_str(), block.fSpecification);
159 if (desc==fFilterRules.end()) return 1; // no filter rules
162 // 1. data types match or filter data type not set
163 // 2. data spec match or filter data wpec not set
164 // 3. either filter data type or spec is set
165 //HLTDebug("check rule : %s spec %#x", DataType2Text((*desc).fDataType, 2).c_str(), block.fSpecification);
166 if (((*desc).fDataType==block.fDataType) &&
167 ((*desc).fSpecification==block.fSpecification || (*desc).fSpecification==kAliHLTVoidDataSpec) &&
168 (!MatchExactly((*desc).fDataType,kAliHLTAnyDataType) || (*desc).fSpecification!=kAliHLTVoidDataSpec)) {
171 } while (++desc!=fFilterRules.end());
176 int AliHLTBlockDataCollection::IsEmpty()
178 // see header file for class documentation
179 if (fFilterRules.size()==0) return 1;