ROOT  6.06/09
Reference Guide
TTableMap.h
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@bnl.gov) 01/03/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * Copyright (C) 2001 [BNL] Brookhaven National Laboratory. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 #ifndef ROOT_TTableMap
14 #define ROOT_TTableMap
15 
16 #include "assert.h"
17 #include <vector>
18 
19 #ifndef ROOT_TTable
20 #include "TTable.h"
21 #endif
22 
23 //////////////////////////////////////////////////////
24 //
25 // Class TTableMap
26 // Iterator of the table with extra index array
27 //
28 //////////////////////////////////////////////////////
29 
30 
31 class TTableMap : public TObject
32 #ifndef __CINT__
33  , public std::vector<Long_t>
34 #endif
35 {
36 private:
37  TTableMap &operator=(const TTableMap &orig); // intentionally not implemented.
38 protected:
39  const TTable *fTable; // pointer to the refered TTable
40 
41 public:
42 
43  TTableMap(const TTable *table=0);
44  TTableMap(const TTableMap &map) : TObject(map)
45 #ifndef __CINT__
46  , std::vector<Long_t>(map)
47 #endif
48  , fTable(map.fTable) {;}
49  virtual ~TTableMap(){;}
50  Bool_t IsValid() const;
51  Bool_t IsFolder() const;
52  void Push_back(Long_t next); // workaround for Cint
53  const TTable *Table(){return fTable;}
54 
56  TTable::iterator Begin() const;
58  TTable::iterator End() const;
59 
60  ClassDef(TTableMap,1) // "Map" array for TTable object
61 };
62 
63 //___________________________________________________________________________________________________________
64 inline Bool_t TTableMap::IsValid() const
65 {
66  // Check whether all "map" values do belong the table
67  TTable::iterator i = Begin();
68  TTable::iterator finish = End();
69  Int_t totalSize = fTable->GetNRows();
70 
71  for (; i != finish; i++) {
72  Long_t th = *i;
73  if ( th == -1 || (0 <= th && th < totalSize) ) continue;
74  return kFALSE;
75  }
76  return kTRUE;
77 }
78 //___________________________________________________________________________________________________________
79 inline TTable::iterator TTableMap::Begin() { std::vector<Long_t>::iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
80 //___________________________________________________________________________________________________________
81 inline TTable::iterator TTableMap::Begin() const { std::vector<Long_t>::const_iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
82 //___________________________________________________________________________________________________________
83 inline TTable::iterator TTableMap::End() { std::vector<Long_t>::iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
84 //___________________________________________________________________________________________________________
85 inline TTable::iterator TTableMap::End() const { std::vector<Long_t>::const_iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
86 //___________________________________________________________________________________________________________
87 inline Bool_t TTableMap::IsFolder() const { return kTRUE;}
88 //___________________________________________________________________________________________________________
89 inline void TTableMap::Push_back(Long_t next){ push_back(next); } // workaround for Cint
90 
91 
92 #endif
TTableMap(const TTable *table=0)
TTable::iterator Begin()
Definition: TTableMap.h:79
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual ~TTableMap()
Definition: TTableMap.h:49
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
STL namespace.
void Push_back(Long_t next)
Definition: TTableMap.h:89
TTable::iterator End()
Definition: TTableMap.h:83
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TTableMap.h:87
Bool_t IsValid() const
Definition: TTableMap.h:64
TTableMap(const TTableMap &map)
Definition: TTableMap.h:44
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1392
long Long_t
Definition: RtypesCore.h:50
Definition: TTable.h:52
const TTable * fTable
Definition: TTableMap.h:39
Mother of all ROOT objects.
Definition: TObject.h:58
const TTable * Table()
Definition: TTableMap.h:53
TTableMap & operator=(const TTableMap &orig)
const Bool_t kTRUE
Definition: Rtypes.h:91