class TTable::iterator


TTable

 Wraps the array of the plain C-structures (one C-structure per element)

class TTable provides the automatic schema evolution for
the derived "table" classes saved with ROOT format.

"Automatic Schema evolution" provides:
-  skipping data-member if it is not present for the current
implementation of the "table" but was present at the time the
table was written;
-  assign a default value ZERO for the brand-new data-members,
those were not in the structure when the object was written but
present now;
-  trace propely any change in the order of the data-members

To enjoy this class one has to derive his/her own custom class:

St_dst_track_Table.h:

#ifndef STAF_St_dst_track_Table
#define STAF_St_dst_track_Table

#include "TTable.h"

 #include "dst_track.h"  the C-structure defintion may be kept
separately
typedef struct dst_track_st {
     float r0;             /* radius at start (cm). See also comments*
     float phi0;           /* azimuthal angle at start (deg)         *
     float z0;             /* z-coord. at start (cm)                 *
     float psi;            /* azimuthal angle of pT vector (deg)     *
     float tanl;           /* tan(dip) =pz/pt at start               *
     float invpt;          /* 1/pt at start (GeV/c)^(-1)             *
     float curvature;      /* Track curvature (1/cm)                 *
     float covar[15];      /* full covariance matrix                 *
     float chisq[2];       /* Chi-square per degree of freedom       *
     float x_first[3];     /* coord. of first measured point (cm)    *
     float x_last[3];      /* coord. of last measured point (cm)     *
     float length;         /* from first to last point (cm)          *
     float impact;         /* primary vertex (cm)                    *
     unsigned long map[2]; /* extrap. info. (see preceeding comments)*
     int id;               /* Primary key (see comments)             *
     int iflag;            /* bitmask quality info. (see comments)   *
     int det_id;           /* Detector id information                *
     int method;           /* Track finding/fitting method, packed   *
     int pid;              /* Geant particle ID for assumed mass     *
     int n_point;          /* SVT, TPC, FTPC component #s are packed *
     int n_max_point;      /* SVT, TPC, FTPC component #s are packed *
     int n_fit_point;      /* SVT, TPC, FTPC component #s are packed *
     int icharge;          /* Particle charge in units of |e|        *
     int id_start_vertex;  /* final fit and primary track candidates *
} DST_TRACK_ST;

class St_dst_track : public TTable
{
public:
ClassDefTable(St_dst_track,dst_track_st)
ClassDef(St_dst_track,2) //C++ wrapper for <dst_track> StAF table
};
#endif


where the CPP macro defines several convinient methods for the
"table" class (see: $ROOTSYS/table/inc/Ttypes.h for details:

  #define ClassDefTable(className,structName)
    protected:
       static TTableDescriptor *fgColDescriptors;
       virtual TTableDescriptor *GetDescriptorPointer() const { return fgColDescriptors;}
       virtual void SetDescriptorPointer(TTableDescriptor *list) const { fgColDescriptors = list;}
    public:
      typedef structName* iterator;
      className() : TTable(_QUOTE_(className),sizeof(structName))    {SetType(_QUOTE_(structName));}
      className(const Text_t *name) : TTable(name,sizeof(structName)) {SetType(_QUOTE_(structName));}
      className(Int_t n) : TTable(_QUOTE_(className),n,sizeof(structName)) {SetType(_QUOTE_(structName));}
      className(const Text_t *name,Int_t n) : TTable(name,n,sizeof(structName)) {SetType(_QUOTE_(structName));}
      structName *GetTable(Int_t i=0) const { return ((structName *)GetArray())+i;}
      structName &operator[](Int_t i){ assert(i>=0 && i < GetNRows()); return *GetTable(i); }
      const structName &operator[](Int_t i) const { assert(i>=0 && i < GetNRows()); return *((const structName *)(GetTable(i))); }
      structName *begin() const  {                      return GetNRows()? GetTable(0):0;}
      structName *end()   const  {Int_t i = GetNRows(); return          i? GetTable(i):0;}

The class implementation file may 2 lines and look as follows:
(for the example above):

St_dst_track_Table.cxx:

#include "St_dst_track_Table.h"
TableClassImpl(St_dst_track, dst_track_st)

LinkDef.h

To provide ROOT I/O for this class TWO CINT dictonary entries
should be defined with your custom LinkDef.h file
1. First entry (as usually) for the class derived from TTable
for example:
#pragma C++ class St_dst_track
2. Second entry for the C-structure wrapped into the class.
Since C-structuire is not derived from TObject it must be
properly defined as "foreign" ROOT class
#pragma C++ class dst_track_st+;

meta-variables i$ and n$ introduced
where "i$" stands for the current row index
"n$" stands for the total number of rows
meta-variable can be used along the normal
table column names in the expressions (see for example
method TTable::Draw


Function Members (Methods)

public:
~iterator()
TTable::iteratoriterator()
TTable::iteratoriterator(const TTable::iterator& iter)
TTable::iteratoriterator(const TTable& table, TTable::iterator::vec_const_iterator& arowPtr)
void*operator void*() const
Bool_toperator!=(const TTable::iterator& t) const
Long_toperator*() const
TTable::iteratoroperator+(Int_t idx)
voidoperator++()
voidoperator++(int)
voidoperator+=(Int_t idx)
TTable::iteratoroperator-(Int_t idx)
Int_toperator-(const TTable::iterator& it) const
voidoperator--()
voidoperator--(int)
voidoperator-=(Int_t idx)
voidoperator=(const TTable::iterator& iter)
Bool_toperator==(const TTable::iterator& t) const
void*rowPtr() const
const Long_t&RowSize() const
const TTable&Table() const

Data Members

private:
TTable::iterator::vec_iteratorfCurrentRow
Long_tfRowSize
const TTable*fThisTable

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TTable & operator=(const TTable::iterator& iter)
iterator(const TTable::iterator& iter)
{;}
iterator(const TTable& table, TTable::iterator::vec_const_iterator& arowPtr)
{;}
iterator(const TTable& table, TTable::iterator::vec_const_iterator& arowPtr)
fCurrentRow(* const_cast<vector<Long_t>::iterator *>(&arowPtr) ) {;}
{;}
void operator++(int )
{ ++fCurrentRow; }
void operator++(int )
{ fCurrentRow++; }
void operator--(int )
{ --fCurrentRow; }
void operator--(int )
{ fCurrentRow--; }
iterator operator+(Int_t idx)
{ std::vector<Long_t>::iterator addition = fCurrentRow+idx; return iterator(*fThisTable,addition); }
iterator operator-(Int_t idx)
{ std::vector<Long_t>::iterator subtraction = fCurrentRow-idx; return iterator(*fThisTable,subtraction); }
void operator+=(Int_t idx)
{ fCurrentRow+=idx; }
void operator-=(Int_t idx)
{ fCurrentRow-=idx; }
void * rowPtr()
{ return (void *)(((const char *)fThisTable->GetArray()) + (*fCurrentRow)*fRowSize ); }
Int_t operator-(const iterator &it)
{ return (*fCurrentRow)-(*(it.fCurrentRow)); }
Bool_t operator==(const TTable::iterator& t) const
{ return ( (fCurrentRow == t.fCurrentRow) && (fThisTable == t.fThisTable) ); }
Bool_t operator!=(const TTable::iterator& t) const
{ return !operator==(t); }
const Long_t & RowSize()
{ return fRowSize;}

Author: Valery Fine(fine@mail.cern.ch) 03/07/98
Last change: root/table:$Id: TTable.h 23631 2008-05-01 10:50:11Z rdm $
Last generated: 2008-06-25 08:54
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.