LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTBlockDataCollection.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 69 1.4 %
Date: 2016-06-14 17:26:59 Functions: 1 12 8.3 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the ALICE HLT Project        * 
       5             : //* ALICE Experiment at CERN, All rights reserved.                         *
       6             : //*                                                                        *
       7             : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       8             : //*                  for The ALICE HLT Project.                            *
       9             : //*                                                                        *
      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             : //**************************************************************************
      18             : 
      19             : /** @file   AliHLTBlockDataCollection.cxx
      20             :     @author Matthias Richter
      21             :     @date   
      22             :     @brief  A collection of AliHLTComponentBlockData descriptors providing
      23             :             argument parsing and basic selection.
      24             : */
      25             : 
      26             : #include <cstdlib>
      27             : #include "AliHLTBlockDataCollection.h"
      28             : #include "AliHLTComponent.h"
      29             : #include "TString.h"
      30             : 
      31             : /** ROOT macro for the implementation of ROOT specific class methods */
      32         126 : ClassImp(AliHLTBlockDataCollection)
      33             : 
      34             : AliHLTBlockDataCollection::AliHLTBlockDataCollection()
      35           0 :   : TObject()
      36           0 :   , AliHLTLogging()
      37           0 :   , fFilterRules()
      38           0 : {
      39             :   // see header file for class documentation
      40             :   // or
      41             :   // refer to README to build package
      42             :   // or
      43             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      44           0 : }
      45             : 
      46           0 : AliHLTBlockDataCollection::~AliHLTBlockDataCollection()
      47           0 : {
      48             :   // see header file for class documentation
      49           0 : }
      50             : 
      51             : int AliHLTBlockDataCollection::Add(const AliHLTComponentBlockData& block)
      52             : {
      53             :   // see header file for class documentation
      54           0 :   fFilterRules.push_back(block);
      55           0 :   return fFilterRules.size();
      56             : }
      57             : 
      58             : int AliHLTBlockDataCollection::ScanArgument( int argc, const char** argv )
      59             : {
      60             :   // see header file for class documentation
      61             :   int iResult=0;
      62           0 :   TString argument="";
      63             :   int bMissingParam=0;
      64           0 :   AliHLTComponentBlockData rule;
      65           0 :   AliHLTComponent::FillBlockData(rule);
      66             :   int i=0;
      67           0 :   for (; i<argc && iResult>=0; i++) {
      68           0 :     argument=argv[i];
      69           0 :     if (argument.IsNull()) continue;
      70             : 
      71             :     // -datatype
      72           0 :     if (argument.CompareTo("-datatype")==0) {
      73           0 :       if ((bMissingParam=(i+2>=argc))) break;
      74             : 
      75           0 :       if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
      76             :         // the data type has already been set, add to list
      77             :         // and reset
      78           0 :         fFilterRules.push_back(rule);
      79           0 :         AliHLTComponent::FillBlockData(rule);
      80             :       }
      81             : 
      82           0 :       AliHLTComponent::SetDataType(rule.fDataType, argv[i+1], argv[i+2]);
      83             :       i+=2;
      84             : 
      85             :       // -origin
      86           0 :     } else if (argument.CompareTo("-origin")==0) {
      87           0 :       if ((bMissingParam=(i+1>=argc))) break;
      88             : 
      89           0 :       if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
      90             :         // the data type has already been set, add to list
      91             :         // and reset
      92           0 :         fFilterRules.push_back(rule);
      93           0 :         AliHLTComponent::FillBlockData(rule);
      94             :       }
      95             : 
      96           0 :       AliHLTComponent::SetDataType(rule.fDataType, NULL, argv[i+1]);
      97             :       i+=1;
      98             : 
      99             :       // -typeid
     100           0 :     } else if (argument.CompareTo("-typeid")==0) {
     101           0 :       if ((bMissingParam=(i+1>=argc))) break;
     102             : 
     103           0 :       if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
     104             :         // the data type has already been set, add to list
     105             :         // and reset
     106           0 :         fFilterRules.push_back(rule);
     107           0 :         AliHLTComponent::FillBlockData(rule);
     108             :       }
     109             : 
     110           0 :       AliHLTComponent::SetDataType(rule.fDataType, argv[i+1], NULL);
     111             :       i+=1;
     112             : 
     113             :       // -dataspec
     114           0 :     } else if (argument.CompareTo("-dataspec")==0) {
     115           0 :       if ((bMissingParam=(++i>=argc))) break;
     116             : 
     117           0 :       if (rule.fSpecification!=kAliHLTVoidDataSpec) {
     118             :         // the specification has already been set, add to list
     119             :         // and reset
     120           0 :         fFilterRules.push_back(rule);
     121           0 :         AliHLTComponent::FillBlockData(rule);
     122             :       }
     123             : 
     124           0 :       TString parameter(argv[i]);
     125           0 :       parameter.Remove(TString::kLeading, ' '); // remove all blanks
     126           0 :       char* pRemnant=NULL;
     127           0 :       rule.fSpecification=strtoul(parameter.Data(), &pRemnant, 0);
     128           0 :       if (pRemnant!=NULL && pRemnant[0]!=0) {
     129           0 :         HLTError("invalid parameter/remnant (%s) for argument %s, number expected", pRemnant, argument.Data());
     130             :         iResult=-EINVAL;
     131           0 :       }
     132           0 :     } else {
     133             :       // terminate at the first unknown argument
     134             :       break;
     135             :     }
     136             :   }
     137             : 
     138           0 :   if (bMissingParam) {
     139           0 :     HLTError("missing parameter for argument %s", argument.Data());
     140             :     iResult=-EPROTO;
     141           0 :   }
     142           0 :   if (iResult>=0) {
     143           0 :     if (rule.fSpecification!=kAliHLTVoidDataSpec || !MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
     144             :       // add the pending rule
     145           0 :       fFilterRules.push_back(rule);
     146           0 :       AliHLTComponent::FillBlockData(rule);
     147             :     }
     148             :     iResult=i;
     149           0 :   }
     150             : 
     151             :   return iResult;
     152           0 : }
     153             : 
     154             : int AliHLTBlockDataCollection::IsSelected(const AliHLTComponentBlockData& block)
     155             : {
     156             :   // see header file for class documentation
     157           0 :   AliHLTComponentBlockDataList::iterator desc=fFilterRules.begin();
     158             :   //HLTDebug("check block: %s spec %#x", DataType2Text(block.fDataType, 1).c_str(), block.fSpecification);
     159           0 :   if (desc==fFilterRules.end()) return 1; // no filter rules
     160             :   do {
     161             :     // match if
     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           0 :     if (((*desc).fDataType==block.fDataType) &&
     167           0 :         ((*desc).fSpecification==block.fSpecification || (*desc).fSpecification==kAliHLTVoidDataSpec) &&
     168           0 :         (!MatchExactly((*desc).fDataType,kAliHLTAnyDataType) || (*desc).fSpecification!=kAliHLTVoidDataSpec)) {
     169           0 :       return 1;
     170             :     }
     171           0 :   } while (++desc!=fFilterRules.end());
     172             :   
     173           0 :   return 0;
     174           0 : }
     175             : 
     176             : int AliHLTBlockDataCollection::IsEmpty()
     177             : {
     178             :   // see header file for class documentation
     179           0 :   if (fFilterRules.size()==0) return 1;
     180           0 :   return 0;
     181           0 : }

Generated by: LCOV version 1.11