ROOT  6.06/09
Reference Guide
TSelectorScalar.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Maarten Ballintijn 13/02/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TSelectorScalar
13 Named scalar type, based on Long64_t, streamable, storable and
14 mergable. Ideally to be used in tree selectors in the PROOF
15 environment due to its merge functionality which allows a single
16 merged value to be returned to the user.
17 */
18 
19 #include "TSelectorScalar.h"
20 #include "TCollection.h"
21 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Increment scalar value by n.
26 
28 {
29  SetVal(GetVal() + n);
30 }
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Merge scalars with scalars in the list. The scalar values are added.
34 /// Returns the number of scalars that were in the list.
35 
37 {
38  TIter next(list);
39  Int_t n = 0;
40 
41  while (TObject *obj = next()) {
42  TSelectorScalar *c = dynamic_cast<TSelectorScalar*>(obj);
43  if (c) {
44  Inc(c->GetVal());
45  n++;
46  }
47  }
48 
49  return n;
50 }
Int_t Merge(TCollection *list)
Merge scalars with scalars in the list.
void Inc(Long_t n=1)
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
int Int_t
Definition: RtypesCore.h:41
Named scalar type, based on Long64_t, streamable, storable and mergable.
Collection abstract base class.
Definition: TCollection.h:48
ClassImp(TSelectorScalar) void TSelectorScalar
Increment scalar value by n.
long Long_t
Definition: RtypesCore.h:50
Mother of all ROOT objects.
Definition: TObject.h:58
typedef void((*Func_t)())
const AParamType & GetVal() const
Definition: TParameter.h:77
TObject * obj
const Int_t n
Definition: legend1.C:16