ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "TTableDescriptor.h"
16 
17 //////////////////////////////////////////////////////////////////////////////
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();
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;
74 }
76 #endif
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 ///to be documented
81 
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 }
89 ////////////////////////////////////////////////////////////////////////////////
90 ///to be documented
91 
93 {
94  if (!fgColDescriptors) {
95  // Set an empty descriptor
97  // Create one
98  if (fgColDescriptors) {
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 
114 ////////////////////////////////////////////////////////////////////////////////
115 ///return column descriptor
116 
118 {
119  return fgColDescriptors;
120 }
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 ///set table descriptor
124 
126 {
127  fgColDescriptors = list;
128 }
129 
130 //___________________________________________________________________
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 ///to be documented
134 
136 {
137  return fRefTable;
138 }
tuple row
Definition: mrt.py:26
#define TableClassStreamerImp(className)
Definition: Ttypes.h:42
#define _QUOTE2_(name1, name2)
Definition: Ttypes.h:32
return c
TH1 * h
Definition: legend2.C:5
int Int_t
Definition: RtypesCore.h:41
ClassImp(TIndexTable) TableClassStreamerImp(TIndexTable) TIndexTable
to be documented
Definition: TIndexTable.cxx:55
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:5393
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:92
virtual TTableDescriptor * GetDescriptorPointer() const
return column descriptor