ROOT logo
// @(#)root/table:$Id: TIndexTable.cxx 21565 2007-12-28 12:28:46Z brun $
// Author: Valery Fine(fine@bnl.gov)   01/03/2001

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * Copyright (C) 2001 [BNL] Brookhaven National Laboratory.              *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TIndexTable.h"

//////////////////////////////////////////////////////////////////////////////
// TIndexTable class is helper class to keep the list of the referencs to the
// TTable rows and iterate over it.
// TIndexTable is a persistent class.
// The pointer to the TIndexTable object may be used as an element
// of the TTable row and saved with the table all together.
//
// For example, the track table may contain a member to the "map" of the hits
//  struct {
//    float helix;
//    TIndexTable *hits;
//  } tracks_t;
//
//   // Create track table:
//   LArTrackTable *tracks = new LArTrackTable(...);
//
//   // Get pointer to the hit table
//   LArHitTable *hits = GiveMeHits();
//   // Loop over all tracks
//   LArTrackTable::iterator track = tracks->begin();
//   LArTrackTable::iterator last = tracks->end();
//   for (;track != last;track++) {
//     // Find all hits of this track
//      LArHitTable::iterator hit     = hits->begin();
//      LArHitTable::iterator lastHit = hits->end();
//      Long_t hitIndx = 0;
//      // Create an empty list of this track hits
//      (*track).hits = new TIndexTable(hits);
//      for(;hit != lastHit;hit++,hitIndx) {
//        if (IsMyHit(*hit)) {  // add this hit index to the current track
//           (*track).hits->push_back(hitIndx);
//        }
//      }
//   }
//___________________________________________________________________

// TableClassImpl(TIndexTable,int);
   TTableDescriptor *TIndexTable::fgColDescriptors = TIndexTable::CreateDescriptor();
   ClassImp(TIndexTable)
     
#if 0
void TIndexTable::Dictionary()
{
   //to be documented
   TClass *c = CreateClass(_QUOTE_(className), Class_Version(),
                           DeclFileName(), ImplFileName(),
                           DeclFileLine(), ImplFileLine());

   char *structBuf = new char[strlen(_QUOTE2_(structName,.h))+2];
   strcpy(structBuf,_QUOTE2_(structName,.h));
   char *s = strstr(structBuf,"_st.h");
   if (s) { *s = 0;  strcat(structBuf,".h"); }
   TClass *r = CreateClass(_QUOTE_(structName), Class_Version(),
                           structBuf, structBuf, 1,  1 );
   fgIsA = c;
   fgColDescriptors = new TTableDescriptor(r);
}
   _TableClassImp_(TIndexTable,int)
#endif
   TableClassStreamerImp(TIndexTable)

//___________________________________________________________________
TIndexTable::TIndexTable(const TTable *table):TTable("Index",-1), fRefTable(table)
{
   //to be documented
   if (!fgColDescriptors)    CreateDescriptor();
   fSize = fgColDescriptors->Sizeof();
   // Add refered table to this index.
   // yf  if (table) Add((TDataSet *)table);
}
//___________________________________________________________________
TTableDescriptor *TIndexTable::CreateDescriptor()
{
   //to be documented
   if (!fgColDescriptors) {
      // Set an empty descriptor
      fgColDescriptors= new TTableDescriptor("int");
      // Create one
      if (fgColDescriptors) {
         TTableDescriptor  &dsc = *fgColDescriptors;
         tableDescriptor_st row;

         memset(&row,0,sizeof(row));
         strncpy(row.fColumnName,"index",sizeof(row.fColumnName));

         row.fType = kInt;
         row.fTypeSize = sizeof(Int_t);
         row.fSize = row.fTypeSize;
         dsc.AddAt(&row);
      }
   }
   return fgColDescriptors;
}

//___________________________________________________________________
TTableDescriptor *TIndexTable::GetDescriptorPointer() const 
{ 
   //return column descriptor
   return fgColDescriptors;
}

//___________________________________________________________________
void TIndexTable::SetDescriptorPointer(TTableDescriptor *list)  
{ 
   //set table descriptor
   fgColDescriptors = list;
}

//___________________________________________________________________

//___________________________________________________________________
const TTable *TIndexTable::Table() const
{
   //to be documented
   return fRefTable;
}
 TIndexTable.cxx:1
 TIndexTable.cxx:2
 TIndexTable.cxx:3
 TIndexTable.cxx:4
 TIndexTable.cxx:5
 TIndexTable.cxx:6
 TIndexTable.cxx:7
 TIndexTable.cxx:8
 TIndexTable.cxx:9
 TIndexTable.cxx:10
 TIndexTable.cxx:11
 TIndexTable.cxx:12
 TIndexTable.cxx:13
 TIndexTable.cxx:14
 TIndexTable.cxx:15
 TIndexTable.cxx:16
 TIndexTable.cxx:17
 TIndexTable.cxx:18
 TIndexTable.cxx:19
 TIndexTable.cxx:20
 TIndexTable.cxx:21
 TIndexTable.cxx:22
 TIndexTable.cxx:23
 TIndexTable.cxx:24
 TIndexTable.cxx:25
 TIndexTable.cxx:26
 TIndexTable.cxx:27
 TIndexTable.cxx:28
 TIndexTable.cxx:29
 TIndexTable.cxx:30
 TIndexTable.cxx:31
 TIndexTable.cxx:32
 TIndexTable.cxx:33
 TIndexTable.cxx:34
 TIndexTable.cxx:35
 TIndexTable.cxx:36
 TIndexTable.cxx:37
 TIndexTable.cxx:38
 TIndexTable.cxx:39
 TIndexTable.cxx:40
 TIndexTable.cxx:41
 TIndexTable.cxx:42
 TIndexTable.cxx:43
 TIndexTable.cxx:44
 TIndexTable.cxx:45
 TIndexTable.cxx:46
 TIndexTable.cxx:47
 TIndexTable.cxx:48
 TIndexTable.cxx:49
 TIndexTable.cxx:50
 TIndexTable.cxx:51
 TIndexTable.cxx:52
 TIndexTable.cxx:53
 TIndexTable.cxx:54
 TIndexTable.cxx:55
 TIndexTable.cxx:56
 TIndexTable.cxx:57
 TIndexTable.cxx:58
 TIndexTable.cxx:59
 TIndexTable.cxx:60
 TIndexTable.cxx:61
 TIndexTable.cxx:62
 TIndexTable.cxx:63
 TIndexTable.cxx:64
 TIndexTable.cxx:65
 TIndexTable.cxx:66
 TIndexTable.cxx:67
 TIndexTable.cxx:68
 TIndexTable.cxx:69
 TIndexTable.cxx:70
 TIndexTable.cxx:71
 TIndexTable.cxx:72
 TIndexTable.cxx:73
 TIndexTable.cxx:74
 TIndexTable.cxx:75
 TIndexTable.cxx:76
 TIndexTable.cxx:77
 TIndexTable.cxx:78
 TIndexTable.cxx:79
 TIndexTable.cxx:80
 TIndexTable.cxx:81
 TIndexTable.cxx:82
 TIndexTable.cxx:83
 TIndexTable.cxx:84
 TIndexTable.cxx:85
 TIndexTable.cxx:86
 TIndexTable.cxx:87
 TIndexTable.cxx:88
 TIndexTable.cxx:89
 TIndexTable.cxx:90
 TIndexTable.cxx:91
 TIndexTable.cxx:92
 TIndexTable.cxx:93
 TIndexTable.cxx:94
 TIndexTable.cxx:95
 TIndexTable.cxx:96
 TIndexTable.cxx:97
 TIndexTable.cxx:98
 TIndexTable.cxx:99
 TIndexTable.cxx:100
 TIndexTable.cxx:101
 TIndexTable.cxx:102
 TIndexTable.cxx:103
 TIndexTable.cxx:104
 TIndexTable.cxx:105
 TIndexTable.cxx:106
 TIndexTable.cxx:107
 TIndexTable.cxx:108
 TIndexTable.cxx:109
 TIndexTable.cxx:110
 TIndexTable.cxx:111
 TIndexTable.cxx:112
 TIndexTable.cxx:113
 TIndexTable.cxx:114
 TIndexTable.cxx:115
 TIndexTable.cxx:116
 TIndexTable.cxx:117
 TIndexTable.cxx:118
 TIndexTable.cxx:119
 TIndexTable.cxx:120
 TIndexTable.cxx:121
 TIndexTable.cxx:122
 TIndexTable.cxx:123
 TIndexTable.cxx:124
 TIndexTable.cxx:125
 TIndexTable.cxx:126
 TIndexTable.cxx:127
 TIndexTable.cxx:128
 TIndexTable.cxx:129
 TIndexTable.cxx:130