Logo ROOT   6.14/05
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 #include "TTable.h"
20 
21 //////////////////////////////////////////////////////
22 //
23 // Class TTableMap
24 // Iterator of the table with extra index array
25 //
26 //////////////////////////////////////////////////////
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 
54  TTable::iterator Begin() const;
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
TTableMap(const TTable *table=0)
Definition: TTableMap.cxx:56
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TTableMap.h:85
TTable::iterator Begin()
Definition: TTableMap.h:77
virtual ~TTableMap()
Definition: TTableMap.h:47
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
STL namespace.
void Push_back(Long_t next)
Definition: TTableMap.h:87
TTable::iterator End()
Definition: TTableMap.h:81
#define ClassDef(name, id)
Definition: Rtypes.h:320
TTableMap(const TTableMap &map)
Definition: TTableMap.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
Definition: TTable.h:48
const TTable * fTable
Definition: TTableMap.h:37
Mother of all ROOT objects.
Definition: TObject.h:37
const TTable * Table()
Definition: TTableMap.h:51
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1387
TTableMap & operator=(const TTableMap &orig)
Bool_t IsValid() const
Definition: TTableMap.h:62
const Bool_t kTRUE
Definition: RtypesCore.h:87