StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TTableMap.h
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 #include "TTable.h"
20 
22 //
23 // Class TTableMap
24 // Iterator of the table with extra index array
25 //
27 
28 
29 class TTableMap : public TObject
30 #ifndef __CINT__
31  , public std::vector<Long_t>
32 #endif
33 {
34 private:
35  TTableMap &operator=(const TTableMap &orig); // intentionally not implemented.
36 protected:
37  const TTable *fTable; // pointer to the refered TTable
38 
39 public:
40 
41  TTableMap(const TTable *table=0);
42  TTableMap(const TTableMap &map) : TObject(map)
43 #ifndef __CINT__
44  , std::vector<Long_t>(map)
45 #endif
46  , fTable(map.fTable) {;}
47  virtual ~TTableMap();
48  Bool_t IsValid() const;
49  Bool_t IsFolder() const;
50  void Push_back(Long_t next); // workaround for Cint
51  const TTable *Table(){return fTable;}
52 
53  TTable::iterator Begin();
54  TTable::iterator Begin() const;
55  TTable::iterator End();
56  TTable::iterator End() const;
57 
58  ClassDef(TTableMap,1) // "Map" array for TTable object
59 };
60 
61 //___________________________________________________________________________________________________________
62 inline Bool_t TTableMap::IsValid() const
63 {
64  // Check whether all "map" values do belong the table
65  TTable::iterator i = Begin();
66  TTable::iterator finish = End();
67  Int_t totalSize = fTable->GetNRows();
68 
69  for (; i != finish; i++) {
70  Long_t th = *i;
71  if ( th == -1 || (0 <= th && th < totalSize) ) continue;
72  return kFALSE;
73  }
74  return kTRUE;
75 }
76 //___________________________________________________________________________________________________________
77 inline TTable::iterator TTableMap::Begin() { std::vector<Long_t>::iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
78 //___________________________________________________________________________________________________________
79 inline TTable::iterator TTableMap::Begin() const { std::vector<Long_t>::const_iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
80 //___________________________________________________________________________________________________________
81 inline TTable::iterator TTableMap::End() { std::vector<Long_t>::iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
82 //___________________________________________________________________________________________________________
83 inline TTable::iterator TTableMap::End() const { std::vector<Long_t>::const_iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
84 //___________________________________________________________________________________________________________
85 inline Bool_t TTableMap::IsFolder() const { return kTRUE;}
86 //___________________________________________________________________________________________________________
87 inline void TTableMap::Push_back(Long_t next){ push_back(next); } // workaround for Cint
88 
89 
90 #endif
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
Definition: TTable.h:48