ROOT  6.06/09
Reference Guide
TTableDescriptor.h
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine 09/08/99 (E-mail: fine@bnl.gov)
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTableDescriptor
13 #define ROOT_TTableDescriptor
14 
15 #include "TTable.h"
16 #include "tableDescriptor.h"
17 
18 class TClass;
19 //______________________________________________________________________________
20 //
21 // TTableDescriptor - run-time descriptor of the TTable object rows.
22 //______________________________________________________________________________
23 
24 
25 class TTableDescriptor : public TTable {
26 private:
27  TTableDescriptor &operator=(const TTableDescriptor &dsc); // Intentionally not implemented.
28 protected:
29  friend class TTable;
30  TClass *fRowClass; // TClass defining
31  // the table row C-structure
32  TTableDescriptor *fSecondDescriptor; // shadow descriptor
33  // to back TTable::Streamer
34  static TString fgCommentsName; // The name of dataset to keep the comments fields
35  virtual void Init(TClass *classPtr);
36  static void SetCommentsSetName(const char *name=".comments");
37 
38 public:
39 
40  TTableDescriptor(const TTable *parentTable);
41  TTableDescriptor(TClass *classPtr);
42  TTableDescriptor(const TTableDescriptor &dsc):TTable(dsc),fRowClass(dsc.fRowClass),fSecondDescriptor(0){}
43  virtual ~TTableDescriptor();
44  virtual Int_t AddAt(const void *c);
45  virtual void AddAt(const void *c, Int_t i);
46  virtual void AddAt(const tableDescriptor_st &element, const char *comment,Int_t indx);
47  virtual void AddAt(TDataSet *dataset,Int_t idx=0);
48  TString CreateLeafList() const;
49  void LearnTable(const TTable *parentTable);
50  void LearnTable(TClass *classPtr);
51  const Char_t *ColumnName(Int_t columnIndex) const;
52  Int_t ColumnByName(const Char_t *columnName=0) const;
53  UInt_t NumberOfColumns() const;
54  const UInt_t *IndexArray(Int_t columnIndex) const;
55  UInt_t Offset(Int_t columnIndex) const;
56  Int_t Offset(const Char_t *columnName=0) const;
57  UInt_t ColumnSize(Int_t columnIndex) const;
58  Int_t ColumnSize(const Char_t *columnName=0) const;
59  UInt_t TypeSize(Int_t columnIndex) const;
60  Int_t TypeSize(const Char_t *columnName=0) const;
61  UInt_t Dimensions(Int_t columnIndex) const;
62  Int_t Dimensions(const Char_t *columnName=0) const;
63  TTable::EColumnType ColumnType(Int_t columnIndex) const;
64  TTable::EColumnType ColumnType(const Char_t *columnName=0) const;
65  TClass *RowClass() const;
66  void SetOffset(UInt_t offset,Int_t column);
67  void SetSize(UInt_t size,Int_t column);
68  void SetTypeSize(UInt_t size,Int_t column);
69  void SetDimensions(UInt_t dim,Int_t column);
70  Int_t Sizeof() const;
72  virtual Int_t UpdateOffsets(const TTableDescriptor *newDesciptor);
73 
74  static TTableDescriptor *MakeDescriptor(const char *structName);
76 
77 // ClassDefTable(TTableDescriptor,tableDescriptor_st)
78 protected:
80  virtual TTableDescriptor *GetDescriptorPointer() const;
81  virtual void SetDescriptorPointer(TTableDescriptor *list);
82 public:
84  TTableDescriptor() : TTable("TTableDescriptor",sizeof(tableDescriptor_st)), fRowClass(0), fSecondDescriptor(0) {SetType("tableDescriptor_st");}
85  TTableDescriptor(const char *name) : TTable(name,sizeof(tableDescriptor_st)), fRowClass(0), fSecondDescriptor(0) {SetType("tableDescriptor_st");}
86  TTableDescriptor(Int_t n) : TTable("TTableDescriptor",n,sizeof(tableDescriptor_st)), fRowClass(0), fSecondDescriptor(0) {SetType("tableDescriptor_st");}
87  TTableDescriptor(const char *name,Int_t n) : TTable(name,n,sizeof(tableDescriptor_st)), fRowClass(0), fSecondDescriptor(0) {SetType("tableDescriptor_st");}
89  tableDescriptor_st &operator[](Int_t i){ assert(i>=0 && i < GetNRows()); return *GetTable(i); }
90  const tableDescriptor_st &operator[](Int_t i) const { assert(i>=0 && i < GetNRows()); return *((const tableDescriptor_st *)(GetTable(i))); }
91  tableDescriptor_st *begin() const { return GetNRows()? GetTable(0):0;}
92  tableDescriptor_st *end() const {Long_t i = GetNRows(); return i? GetTable(i):0;}
93  static const char *TableDictionary();
94  ClassDef(TTableDescriptor,0) // descrpitor defining the internal layout of TTable objects
95 };
96 
97 //______________________________________________________________________________
98 // inline TTableDescriptor(const TTableDescriptor &dsc) : TTable(dsc), fRowClass(dsc.fRowClass),fSecondDescriptor(0){}
99 inline const Char_t *TTableDescriptor::ColumnName(Int_t column)const {return ((tableDescriptor_st *)At(column))->fColumnName;}
100 inline UInt_t TTableDescriptor::Offset(Int_t column) const {return ((tableDescriptor_st *)At(column))->fOffset; }
101 inline const UInt_t *TTableDescriptor::IndexArray(Int_t column)const {return ((tableDescriptor_st *)At(column))->fIndexArray;}
103 inline UInt_t TTableDescriptor::ColumnSize(Int_t column) const {return ((tableDescriptor_st *)At(column))->fSize; }
104 inline UInt_t TTableDescriptor::TypeSize(Int_t column) const {return ((tableDescriptor_st *)At(column))->fTypeSize; }
105 inline UInt_t TTableDescriptor::Dimensions(Int_t column) const {return ((tableDescriptor_st *)At(column))->fDimensions;}
107 inline TClass *TTableDescriptor::RowClass() const { return fRowClass;}
108 inline void TTableDescriptor::SetOffset(UInt_t offset,Int_t column) {((tableDescriptor_st *)At(column))->fOffset = offset;}
109 inline void TTableDescriptor::SetSize(UInt_t size,Int_t column) {((tableDescriptor_st *)At(column))->fSize = size; }
110 inline void TTableDescriptor::SetTypeSize(UInt_t size,Int_t column) {((tableDescriptor_st *)At(column))->fTypeSize = size; }
111 inline void TTableDescriptor::SetDimensions(UInt_t dim,Int_t column) {((tableDescriptor_st *)At(column))->fDimensions = dim; }
113 
114 #endif
tableDescriptor_st * end() const
void * GetArray() const
Definition: TTable.h:284
void LearnTable(const TTable *parentTable)
to be documented
Long_t fSize
Definition: TTable.h:56
void SetTypeSize(UInt_t size, Int_t column)
tableDescriptor_st & operator[](Int_t i)
tableDescriptor_st * GetTable(Int_t i=0) const
static const std::string comment("comment")
const Char_t * ColumnName(Int_t columnIndex) const
#define assert(cond)
Definition: unittest.h:542
UInt_t Offset(Int_t columnIndex) const
Basic string class.
Definition: TString.h:137
TTableDescriptor(const TTableDescriptor &dsc)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
UInt_t ColumnSize(Int_t columnIndex) const
tableDescriptor_st * iterator
virtual Int_t UpdateOffsets(const TTableDescriptor *newDesciptor)
"Schema evolution" Method updates the offsets with a new ones from another descriptor ...
void SetSize(UInt_t size, Int_t column)
static TTableDescriptor * fgColDescriptors
Int_t Sizeof() const
to be documented
static TString fgCommentsName
TTableDescriptor(const char *name)
#define ClassDef(name, id)
Definition: Rtypes.h:254
UInt_t TypeSize(Int_t columnIndex) const
static const char * TableDictionary()
Int_t ColumnByName(const Char_t *columnName=0) const
Find the column index but the column name.
virtual void Init(TClass *classPtr)
Create a descriptor of the C-structure defined by TClass TClass *classPtr must be a valid pointer to ...
TTable::EColumnType ColumnType(Int_t columnIndex) const
EColumnType
Definition: TTable.h:86
virtual TTableDescriptor * GetDescriptorPointer() const
to be documented
tableDescriptor_st * begin() const
virtual Int_t AddAt(const void *c)
Append one row pointed by "c" to the descriptor.
TTableDescriptor * fSecondDescriptor
void SetColumnType(TTable::EColumnType type, Int_t column)
virtual void SetType(const char *const type)
to be documented
Definition: TTable.cxx:1983
TTableDescriptor & operator=(const TTableDescriptor &dsc)
TClass * RowClass() const
TTableDescriptor(const char *name, Int_t n)
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1392
unsigned int UInt_t
Definition: RtypesCore.h:42
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TTableDescriptor(Int_t n)
const tableDescriptor_st & operator[](Int_t i) const
PyObject * fType
long Long_t
Definition: RtypesCore.h:50
int type
Definition: TGX11.cxx:120
void SetDimensions(UInt_t dim, Int_t column)
static void SetCommentsSetName(const char *name=".comments")
set comments name
Definition: TTable.h:52
#define name(a, b)
Definition: linkTestLib0.cpp:5
UInt_t NumberOfColumns() const
void SetOffset(UInt_t offset, Int_t column)
static TTableDescriptor * MakeDescriptor(const char *structName)
MakeDescriptor(const char *structName) - static method structName - the name of the C structure to cr...
char Char_t
Definition: RtypesCore.h:29
virtual void SetDescriptorPointer(TTableDescriptor *list)
to be documented
TString CreateLeafList() const
Create a list of leaf to be useful for TBranch::TBranch ctor.
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
Definition: TTable.cxx:303
UInt_t Dimensions(Int_t columnIndex) const
virtual ~TTableDescriptor()
class destructor
const Bool_t kTRUE
Definition: Rtypes.h:91
const UInt_t * IndexArray(Int_t columnIndex) const
TDataSet * MakeCommentField(Bool_t createFlag=kTRUE)
Instantiate a comment dataset if any.
const Int_t n
Definition: legend1.C:16