ROOT logo
// @(#)root/table:$Id: TTableMap.cxx 27657 2009-02-28 04:51:36Z pcanal $
// Author: Valery Fine(fine@bnl.gov)   01/03/2001

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * Copyright (C) 2001 [BNL] Brookhaven National Laboratory.              *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TArrayL.h"
#include "TTableMap.h"

//////////////////////////////////////////////////////////////////////////////
// TTableMap class is helper class to keep the list of the referencs to the
// TTable rows and iterate over it.
// TTableMap is a persistent class.
// The pointer to the TTableMap object may be used as an element
// of the TTable row and saved with the table all together.
//
// For example, the track table may contain a member to the "map" of the hits
//  struct {
//    float helix;
//    TTableMap *hits;
//  } tracks_t;
//
//   // Create track table:
//   LArTrackTable *tracks = new LArTrackTable(...);
//
//   // Get pointer to the hit table
//   LArHitTable *hits = GiveMeHits();
//   // Loop over all tracks
//   LArTrackTable::iterator track = tracks->begin();
//   LArTrackTable::iterator last = tracks->end();
//   for (;track != last;track++) {
//     // Find all hits of this track
//      LArHitTable::iterator hit     = hits->begin();
//      LArHitTable::iterator lastHit = hits->end();
//      Long_t hitIndx = 0;
//      // Create an empty list of this track hits
//      (*track).hits = new TTableMap(hits);
//      for(;hit != lastHit;hit++,hitIndx) {
//        if (IsMyHit(*hit)) {  // add this hit index to the current track
//           (*track).hits->push_back(hitIndx);
//        }
//      }
//   }
//___________________________________________________________________

ClassImp(TTableMap)

TTableMap::TTableMap(const TTable *table)
          : fTable(table)
{
   //to be documented
}

//___________________________________________________________________
void TTableMap::Streamer(TBuffer &R__b)
{
   // UInt_t R__s, R__c;
   TArrayL vecIO;
   if (R__b.IsReading()) {
      Version_t v =  R__b.ReadVersion();
      if (v) { }
      // read Table
      R__b >> fTable;
      // Read index array
      vecIO.Streamer(R__b);
      Int_t n = vecIO.GetSize();
      Int_t i = 0;
      reserve(n);
      Long_t *thisArr = vecIO.GetArray();
      for (i=0; i<n; i++,thisArr++) push_back(*thisArr);
   } else {
      // Write TTable
      assert(IsValid());
      R__b.WriteVersion(IsA());
      R__b << fTable;
      //  Write index array
      TTableMap::iterator ptr = begin();
      vecIO.Adopt(size(),&(*ptr));
      vecIO.Streamer(R__b);
      vecIO.fArray=0;  // we should not destroy the real array
   }
}
 TTableMap.cxx:1
 TTableMap.cxx:2
 TTableMap.cxx:3
 TTableMap.cxx:4
 TTableMap.cxx:5
 TTableMap.cxx:6
 TTableMap.cxx:7
 TTableMap.cxx:8
 TTableMap.cxx:9
 TTableMap.cxx:10
 TTableMap.cxx:11
 TTableMap.cxx:12
 TTableMap.cxx:13
 TTableMap.cxx:14
 TTableMap.cxx:15
 TTableMap.cxx:16
 TTableMap.cxx:17
 TTableMap.cxx:18
 TTableMap.cxx:19
 TTableMap.cxx:20
 TTableMap.cxx:21
 TTableMap.cxx:22
 TTableMap.cxx:23
 TTableMap.cxx:24
 TTableMap.cxx:25
 TTableMap.cxx:26
 TTableMap.cxx:27
 TTableMap.cxx:28
 TTableMap.cxx:29
 TTableMap.cxx:30
 TTableMap.cxx:31
 TTableMap.cxx:32
 TTableMap.cxx:33
 TTableMap.cxx:34
 TTableMap.cxx:35
 TTableMap.cxx:36
 TTableMap.cxx:37
 TTableMap.cxx:38
 TTableMap.cxx:39
 TTableMap.cxx:40
 TTableMap.cxx:41
 TTableMap.cxx:42
 TTableMap.cxx:43
 TTableMap.cxx:44
 TTableMap.cxx:45
 TTableMap.cxx:46
 TTableMap.cxx:47
 TTableMap.cxx:48
 TTableMap.cxx:49
 TTableMap.cxx:50
 TTableMap.cxx:51
 TTableMap.cxx:52
 TTableMap.cxx:53
 TTableMap.cxx:54
 TTableMap.cxx:55
 TTableMap.cxx:56
 TTableMap.cxx:57
 TTableMap.cxx:58
 TTableMap.cxx:59
 TTableMap.cxx:60
 TTableMap.cxx:61
 TTableMap.cxx:62
 TTableMap.cxx:63
 TTableMap.cxx:64
 TTableMap.cxx:65
 TTableMap.cxx:66
 TTableMap.cxx:67
 TTableMap.cxx:68
 TTableMap.cxx:69
 TTableMap.cxx:70
 TTableMap.cxx:71
 TTableMap.cxx:72
 TTableMap.cxx:73
 TTableMap.cxx:74
 TTableMap.cxx:75
 TTableMap.cxx:76
 TTableMap.cxx:77
 TTableMap.cxx:78
 TTableMap.cxx:79
 TTableMap.cxx:80
 TTableMap.cxx:81
 TTableMap.cxx:82
 TTableMap.cxx:83
 TTableMap.cxx:84
 TTableMap.cxx:85
 TTableMap.cxx:86
 TTableMap.cxx:87
 TTableMap.cxx:88