00001 // @(#)root/table:$Id: TTableMap.h 27657 2009-02-28 04:51:36Z pcanal $ 00002 // Author: Valery Fine(fine@bnl.gov) 01/03/2001 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. * 00006 * Copyright (C) 2001 [BNL] Brookhaven National Laboratory. * 00007 * All rights reserved. * 00008 * * 00009 * For the licensing terms see $ROOTSYS/LICENSE. * 00010 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00011 *************************************************************************/ 00012 00013 #ifndef ROOT_TTableMap 00014 #define ROOT_TTableMap 00015 00016 #include "assert.h" 00017 #include <vector> 00018 00019 #ifndef ROOT_TTable 00020 #include "TTable.h" 00021 #endif 00022 00023 ////////////////////////////////////////////////////// 00024 // 00025 // Class TTableMap 00026 // Iterator of the table with extra index array 00027 // 00028 ////////////////////////////////////////////////////// 00029 00030 00031 class TTableMap : public TObject 00032 #ifndef __CINT__ 00033 , public std::vector<Long_t> 00034 #endif 00035 { 00036 protected: 00037 const TTable *fTable; // pointer to the refered TTable 00038 00039 public: 00040 00041 TTableMap(const TTable *table=0); 00042 TTableMap(const TTableMap &map) : TObject(map) 00043 #ifndef __CINT__ 00044 , std::vector<Long_t>(map) 00045 #endif 00046 , fTable(map.fTable) {;} 00047 virtual ~TTableMap(){;} 00048 Bool_t IsValid() const; 00049 Bool_t IsFolder() const; 00050 void Push_back(Long_t next); // workaround for Cint 00051 const TTable *Table(){return fTable;} 00052 00053 TTable::iterator Begin(); 00054 TTable::iterator Begin() const; 00055 TTable::iterator End(); 00056 TTable::iterator End() const; 00057 00058 ClassDef(TTableMap,1) // "Map" array for TTable object 00059 }; 00060 00061 //___________________________________________________________________________________________________________ 00062 inline Bool_t TTableMap::IsValid() const 00063 { 00064 // Check whether all "map" values do belong the table 00065 TTable::iterator i = Begin(); 00066 TTable::iterator finish = End(); 00067 Int_t totalSize = fTable->GetNRows(); 00068 00069 for (; i != finish; i++) { 00070 Long_t th = *i; 00071 if ( th == -1 || (0 <= th && th < totalSize) ) continue; 00072 return kFALSE; 00073 } 00074 return kTRUE; 00075 } 00076 //___________________________________________________________________________________________________________ 00077 inline TTable::iterator TTableMap::Begin() { std::vector<Long_t>::iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);} 00078 //___________________________________________________________________________________________________________ 00079 inline TTable::iterator TTableMap::Begin() const { std::vector<Long_t>::const_iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);} 00080 //___________________________________________________________________________________________________________ 00081 inline TTable::iterator TTableMap::End() { std::vector<Long_t>::iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);} 00082 //___________________________________________________________________________________________________________ 00083 inline TTable::iterator TTableMap::End() const { std::vector<Long_t>::const_iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);} 00084 //___________________________________________________________________________________________________________ 00085 inline Bool_t TTableMap::IsFolder() const { return kTRUE;} 00086 //___________________________________________________________________________________________________________ 00087 inline void TTableMap::Push_back(Long_t next){ push_back(next); } // workaround for Cint 00088 00089 00090 #endif