Logo ROOT   6.16/01
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
29class TTableMap : public TObject
30#ifndef __CINT__
31 , public std::vector<Long_t>
32#endif
33{
34private:
35 TTableMap &operator=(const TTableMap &orig); // intentionally not implemented.
36protected:
37 const TTable *fTable; // pointer to the refered TTable
38
39public:
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//___________________________________________________________________________________________________________
63{
64 // Check whether all "map" values do belong the table
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//___________________________________________________________________________________________________________
77inline TTable::iterator TTableMap::Begin() { std::vector<Long_t>::iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
78//___________________________________________________________________________________________________________
79inline TTable::iterator TTableMap::Begin() const { std::vector<Long_t>::const_iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
80//___________________________________________________________________________________________________________
81inline TTable::iterator TTableMap::End() { std::vector<Long_t>::iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
82//___________________________________________________________________________________________________________
83inline TTable::iterator TTableMap::End() const { std::vector<Long_t>::const_iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
84//___________________________________________________________________________________________________________
85inline Bool_t TTableMap::IsFolder() const { return kTRUE;}
86//___________________________________________________________________________________________________________
87inline void TTableMap::Push_back(Long_t next){ push_back(next); } // workaround for Cint
88
89
90#endif
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:324
Mother of all ROOT objects.
Definition: TObject.h:37
TTableMap(const TTableMap &map)
Definition: TTableMap.h:42
TTable::iterator Begin()
Definition: TTableMap.h:77
const TTable * fTable
Definition: TTableMap.h:37
TTable::iterator End()
Definition: TTableMap.h:81
void Push_back(Long_t next)
Definition: TTableMap.h:87
TTableMap & operator=(const TTableMap &orig)
const TTable * Table()
Definition: TTableMap.h:51
virtual ~TTableMap()
Definition: TTableMap.cxx:57
TTableMap(const TTable *table=0)
Definition: TTableMap.cxx:58
Bool_t IsValid() const
Definition: TTableMap.h:62
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: TTableMap.h:85
Definition: TTable.h:48
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1387
STL namespace.
void table()
Definition: table.C:85