StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TIndexTable.cxx
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 #include "TIndexTable.h"
14 
15 #include "TTableDescriptor.h"
16 
18 // TIndexTable class is helper class to keep the list of the referencs to the
19 // TTable rows and iterate over it.
20 // TIndexTable is a persistent class.
21 // The pointer to the TIndexTable object may be used as an element
22 // of the TTable row and saved with the table all together.
23 //
24 // For example, the track table may contain a member to the "map" of the hits
25 // struct {
26 // float helix;
27 // TIndexTable *hits;
28 // } tracks_t;
29 //
30 // // Create track table:
31 // LArTrackTable *tracks = new LArTrackTable(...);
32 //
33 // // Get pointer to the hit table
34 // LArHitTable *hits = GiveMeHits();
35 // // Loop over all tracks
36 // LArTrackTable::iterator track = tracks->begin();
37 // LArTrackTable::iterator last = tracks->end();
38 // for (;track != last;track++) {
39 // // Find all hits of this track
40 // LArHitTable::iterator hit = hits->begin();
41 // LArHitTable::iterator lastHit = hits->end();
42 // Long_t hitIndx = 0;
43 // // Create an empty list of this track hits
44 // (*track).hits = new TIndexTable(hits);
45 // for(;hit != lastHit;hit++,hitIndx) {
46 // if (IsMyHit(*hit)) { // add this hit index to the current track
47 // (*track).hits->push_back(hitIndx);
48 // }
49 // }
50 // }
51 //___________________________________________________________________
52 
53 // TableClassImpl(TIndexTable,int);
54  TTableDescriptor *TIndexTable::fgColDescriptors = TIndexTable::CreateDescriptor();
55  ClassImp(TIndexTable);
56 
57 #if 0
58 void TIndexTable::Dictionary()
59 {
60  //to be documented
61  TClass *c = CreateClass(_QUOTE_(className), Class_Version(),
62  DeclFileName(), ImplFileName(),
63  DeclFileLine(), ImplFileLine());
64 
65  int nch = strlen(_QUOTE2_(structName,.h))+2;
66  char *structBuf = new char[nch];
67  strlcpy(structBuf,_QUOTE2_(structName,.h),nch);
68  char *s = strstr(structBuf,"_st.h");
69  if (s) { *s = 0; strlcat(structBuf,".h",nch); }
70  TClass *r = CreateClass(_QUOTE_(structName), Class_Version(),
71  structBuf, structBuf, 1, 1 );
72  fgIsA = c;
73  fgColDescriptors = new TTableDescriptor(r);
74 }
75  _TableClassImp_(TIndexTable,int)
76 #endif
77  TableClassStreamerImp(TIndexTable)
78 
79 
82 TIndexTable::TIndexTable(const TTable *table):TTable("Index",-1), fRefTable(table)
83 {
84  if (!fgColDescriptors) CreateDescriptor();
85  fSize = fgColDescriptors->Sizeof();
86  // Add refered table to this index.
87  // yf if (table) Add((TDataSet *)table);
88 }
91 
93 {
94  if (!fgColDescriptors) {
95  // Set an empty descriptor
96  fgColDescriptors= new TTableDescriptor("int");
97  // Create one
98  if (fgColDescriptors) {
99  TTableDescriptor &dsc = *fgColDescriptors;
100  tableDescriptor_st row;
101 
102  memset(&row,0,sizeof(row));
103  strlcpy(row.fColumnName,"index",sizeof(row.fColumnName));
104 
105  row.fType = kInt;
106  row.fTypeSize = sizeof(Int_t);
107  row.fSize = row.fTypeSize;
108  dsc.AddAt(&row);
109  }
110  }
111  return fgColDescriptors;
112 }
113 
116 
118 {
119  return fgColDescriptors;
120 }
121 
124 
126 {
127  fgColDescriptors = list;
128 }
129 
130 //___________________________________________________________________
131 
134 
136 {
137  return fRefTable;
138 }
virtual Int_t AddAt(const void *c)
Append one row pointed by "c" to the descriptor.
const TTable * Table() const
to be documented
virtual void SetDescriptorPointer(TTableDescriptor *list)
set table descriptor
Definition: TTable.h:48
static TTableDescriptor * CreateDescriptor()
to be documented
Definition: TIndexTable.cxx:92
virtual TTableDescriptor * GetDescriptorPointer() const
return column descriptor