ROOT  6.06/09
Reference Guide
TIndexTable.cxx
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 #include "TIndexTable.h"
14 
15 //////////////////////////////////////////////////////////////////////////////
16 // TIndexTable class is helper class to keep the list of the referencs to the
17 // TTable rows and iterate over it.
18 // TIndexTable is a persistent class.
19 // The pointer to the TIndexTable object may be used as an element
20 // of the TTable row and saved with the table all together.
21 //
22 // For example, the track table may contain a member to the "map" of the hits
23 // struct {
24 // float helix;
25 // TIndexTable *hits;
26 // } tracks_t;
27 //
28 // // Create track table:
29 // LArTrackTable *tracks = new LArTrackTable(...);
30 //
31 // // Get pointer to the hit table
32 // LArHitTable *hits = GiveMeHits();
33 // // Loop over all tracks
34 // LArTrackTable::iterator track = tracks->begin();
35 // LArTrackTable::iterator last = tracks->end();
36 // for (;track != last;track++) {
37 // // Find all hits of this track
38 // LArHitTable::iterator hit = hits->begin();
39 // LArHitTable::iterator lastHit = hits->end();
40 // Long_t hitIndx = 0;
41 // // Create an empty list of this track hits
42 // (*track).hits = new TIndexTable(hits);
43 // for(;hit != lastHit;hit++,hitIndx) {
44 // if (IsMyHit(*hit)) { // add this hit index to the current track
45 // (*track).hits->push_back(hitIndx);
46 // }
47 // }
48 // }
49 //___________________________________________________________________
50 
51 // TableClassImpl(TIndexTable,int);
52  TTableDescriptor *TIndexTable::fgColDescriptors = TIndexTable::CreateDescriptor();
54 
55 #if 0
56 void TIndexTable::Dictionary()
57 {
58  //to be documented
59  TClass *c = CreateClass(_QUOTE_(className), Class_Version(),
60  DeclFileName(), ImplFileName(),
61  DeclFileLine(), ImplFileLine());
62 
63  int nch = strlen(_QUOTE2_(structName,.h))+2;
64  char *structBuf = new char[nch];
65  strlcpy(structBuf,_QUOTE2_(structName,.h),nch);
66  char *s = strstr(structBuf,"_st.h");
67  if (s) { *s = 0; strlcat(structBuf,".h",nch); }
68  TClass *r = CreateClass(_QUOTE_(structName), Class_Version(),
69  structBuf, structBuf, 1, 1 );
70  fgIsA = c;
72 }
74 #endif
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 ///to be documented
79 
80 TIndexTable::TIndexTable(const TTable *table):TTable("Index",-1), fRefTable(table)
81 {
82  if (!fgColDescriptors) CreateDescriptor();
83  fSize = fgColDescriptors->Sizeof();
84  // Add refered table to this index.
85  // yf if (table) Add((TDataSet *)table);
86 }
87 ////////////////////////////////////////////////////////////////////////////////
88 ///to be documented
89 
91 {
92  if (!fgColDescriptors) {
93  // Set an empty descriptor
95  // Create one
96  if (fgColDescriptors) {
99 
100  memset(&row,0,sizeof(row));
101  strlcpy(row.fColumnName,"index",sizeof(row.fColumnName));
102 
103  row.fType = kInt;
104  row.fTypeSize = sizeof(Int_t);
105  row.fSize = row.fTypeSize;
106  dsc.AddAt(&row);
107  }
108  }
109  return fgColDescriptors;
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 ///return column descriptor
114 
116 {
117  return fgColDescriptors;
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 ///set table descriptor
122 
124 {
125  fgColDescriptors = list;
126 }
127 
128 //___________________________________________________________________
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 ///to be documented
132 
134 {
135  return fRefTable;
136 }
#define TableClassStreamerImp(className)
Definition: Ttypes.h:42
#define _QUOTE2_(name1, name2)
Definition: Ttypes.h:32
TH1 * h
Definition: legend2.C:5
int Int_t
Definition: RtypesCore.h:41
ClassImp(TIndexTable) TableClassStreamerImp(TIndexTable) TIndexTable
to be documented
Definition: TIndexTable.cxx:53
ClassImp(TTable) TTableDescriptor *TTable return new TTableDescriptor(this)
protected: create a new TTableDescriptor descriptor for this table
static TTableDescriptor * fgColDescriptors
Definition: TIndexTable.h:71
#define _QUOTE_(name)
Definition: RConfig.h:412
const TTable * fRefTable
Definition: TIndexTable.h:30
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
TClass * CreateClass(const char *cname, Version_t id, const type_info &info, TVirtualIsAProxy *isa, const char *dfil, const char *ifil, Int_t dl, Int_t il)
Global function called by a class' static Dictionary() method (see the ClassDef macro).
Definition: TClass.cxx:5483
ROOT::R::TRInterface & r
Definition: Object.C:4
unsigned int fSize
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
#define _TableClassImp_(className, structName)
Definition: Ttypes.h:39
unsigned int fTypeSize
Definition: TTable.h:52
static TTableDescriptor * CreateDescriptor()
to be documented
Definition: TIndexTable.cxx:90
virtual TTableDescriptor * GetDescriptorPointer() const
return column descriptor