ROOT logo
// @(#)root/cont:$Id$
// Author: Rene Brun   17/08/2004

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

#ifndef ROOT_TRefTable
#define ROOT_TRefTable


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TRefTable                                                            //
//                                                                      //
// A TRefTable maintains the association between a referenced object    //
// and the parent object supporting this referenced object.             //
// The parent object is typically a branch of a TTree.                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


#ifndef ROOT_TObject
#include "TObject.h"
#endif

#include <string>
#include <vector>

class TObjArray;
class TProcessID;

class TRefTable : public TObject {

protected:
   Int_t             fNumPIDs;    //!number of known ProcessIDs
   Int_t            *fAllocSize;  //![fNumPIDs] allocated size of array fParentIDs for each ProcessID
   Int_t            *fN;          //![fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
   Int_t           **fParentIDs;  //![fNumPIDs][fAllocSize] array of Parent IDs
   Int_t             fParentID;   //!current parent ID in fParents (latest call to SetParent)
   Int_t             fDefaultSize;//!default size for a new PID array
   UInt_t            fUID;        //!Current uid (set by TRef::GetObject)
   TProcessID       *fUIDContext; //!TProcessID the current uid is referring to
   Int_t             fSize;       //dummy for backward compatibility
   TObjArray        *fParents;    //array of Parent objects  (eg TTree branch) holding the referenced objects
   TObject          *fOwner;      //Object owning this TRefTable
   std::vector<std::string> fProcessGUIDs; // UUIDs of TProcessIDs used in fParentIDs
   std::vector<Int_t> fMapPIDtoInternal;   //! cache of pid to index in fProcessGUIDs
   static TRefTable *fgRefTable;  //Pointer to current TRefTable

   Int_t              AddInternalIdxForPID(TProcessID* procid);
   virtual Int_t      ExpandForIID(Int_t iid, Int_t newsize);
   void               ExpandPIDs(Int_t numpids);
   Int_t              FindPIDGUID(const char* guid) const;
   Int_t              GetInternalIdxForPID(TProcessID* procid) const;
   Int_t              GetInternalIdxForPID(Int_t pid) const;

public:

   enum {
      kHaveWarnedReadingOld = BIT(14)
   };

   TRefTable();
   TRefTable(TObject *owner, Int_t size);
   virtual ~TRefTable();
   virtual Int_t      Add(Int_t uid, TProcessID* context = 0);
   virtual void       Clear(Option_t * /*option*/ ="");
   virtual Int_t      Expand(Int_t pid, Int_t newsize);
   virtual void       FillBuffer(TBuffer &b);
   static TRefTable  *GetRefTable();
   Int_t              GetNumPIDs() const {return fNumPIDs;}
   Int_t              GetSize(Int_t pid) const {return fAllocSize[GetInternalIdxForPID(pid)];}
   Int_t              GetN(Int_t pid) const {return fN[GetInternalIdxForPID(pid)];}
   TObject           *GetOwner() const {return fOwner;}
   TObject           *GetParent(Int_t uid, TProcessID* context = 0) const;
   TObjArray         *GetParents() const {return fParents;}
   UInt_t             GetUID() const {return fUID;}
   TProcessID        *GetUIDContext() const {return fUIDContext;}
   virtual Bool_t     Notify();
   virtual void       ReadBuffer(TBuffer &b);
   virtual void       Reset(Option_t * /* option */ ="");
   virtual Int_t      SetParent(const TObject* parent, Int_t branchID);
   static  void       SetRefTable(TRefTable *table);
   virtual void       SetUID(UInt_t uid, TProcessID* context = 0) {fUID=uid; fUIDContext = context;}

   ClassDef(TRefTable,3)  //Table of referenced objects during an I/O operation
};

#endif
 TRefTable.h:1
 TRefTable.h:2
 TRefTable.h:3
 TRefTable.h:4
 TRefTable.h:5
 TRefTable.h:6
 TRefTable.h:7
 TRefTable.h:8
 TRefTable.h:9
 TRefTable.h:10
 TRefTable.h:11
 TRefTable.h:12
 TRefTable.h:13
 TRefTable.h:14
 TRefTable.h:15
 TRefTable.h:16
 TRefTable.h:17
 TRefTable.h:18
 TRefTable.h:19
 TRefTable.h:20
 TRefTable.h:21
 TRefTable.h:22
 TRefTable.h:23
 TRefTable.h:24
 TRefTable.h:25
 TRefTable.h:26
 TRefTable.h:27
 TRefTable.h:28
 TRefTable.h:29
 TRefTable.h:30
 TRefTable.h:31
 TRefTable.h:32
 TRefTable.h:33
 TRefTable.h:34
 TRefTable.h:35
 TRefTable.h:36
 TRefTable.h:37
 TRefTable.h:38
 TRefTable.h:39
 TRefTable.h:40
 TRefTable.h:41
 TRefTable.h:42
 TRefTable.h:43
 TRefTable.h:44
 TRefTable.h:45
 TRefTable.h:46
 TRefTable.h:47
 TRefTable.h:48
 TRefTable.h:49
 TRefTable.h:50
 TRefTable.h:51
 TRefTable.h:52
 TRefTable.h:53
 TRefTable.h:54
 TRefTable.h:55
 TRefTable.h:56
 TRefTable.h:57
 TRefTable.h:58
 TRefTable.h:59
 TRefTable.h:60
 TRefTable.h:61
 TRefTable.h:62
 TRefTable.h:63
 TRefTable.h:64
 TRefTable.h:65
 TRefTable.h:66
 TRefTable.h:67
 TRefTable.h:68
 TRefTable.h:69
 TRefTable.h:70
 TRefTable.h:71
 TRefTable.h:72
 TRefTable.h:73
 TRefTable.h:74
 TRefTable.h:75
 TRefTable.h:76
 TRefTable.h:77
 TRefTable.h:78
 TRefTable.h:79
 TRefTable.h:80
 TRefTable.h:81
 TRefTable.h:82
 TRefTable.h:83
 TRefTable.h:84
 TRefTable.h:85
 TRefTable.h:86
 TRefTable.h:87
 TRefTable.h:88
 TRefTable.h:89
 TRefTable.h:90
 TRefTable.h:91
 TRefTable.h:92
 TRefTable.h:93
 TRefTable.h:94