Logo ROOT  
Reference Guide
TRefTable.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Rene Brun 17/08/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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_TRefTable
13 #define ROOT_TRefTable
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TRefTable //
19 // //
20 // A TRefTable maintains the association between a referenced object //
21 // and the parent object supporting this referenced object. //
22 // The parent object is typically a branch of a TTree. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 
27 #include "TObject.h"
28 
29 #include <string>
30 #include <vector>
31 
32 class TObjArray;
33 class TProcessID;
34 
35 class TRefTable : public TObject {
36 
37 protected:
38  Int_t fNumPIDs; //!number of known ProcessIDs
39  Int_t *fAllocSize; //![fNumPIDs] allocated size of array fParentIDs for each ProcessID
40  Int_t *fN; //![fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
41  Int_t **fParentIDs; //![fNumPIDs][fAllocSize] array of Parent IDs
42  Int_t fParentID; //!current parent ID in fParents (latest call to SetParent)
43  Int_t fDefaultSize;//!default size for a new PID array
44  UInt_t fUID; //!Current uid (set by TRef::GetObject)
45  TProcessID *fUIDContext; //!TProcessID the current uid is referring to
46  Int_t fSize; //dummy for backward compatibility
47  TObjArray *fParents; //array of Parent objects (eg TTree branch) holding the referenced objects
48  TObject *fOwner; //Object owning this TRefTable
49  std::vector<std::string> fProcessGUIDs; // UUIDs of TProcessIDs used in fParentIDs
50  std::vector<Int_t> fMapPIDtoInternal; //! cache of pid to index in fProcessGUIDs
51  static TRefTable *fgRefTable; //Pointer to current TRefTable
52 
54  virtual Int_t ExpandForIID(Int_t iid, Int_t newsize);
55  void ExpandPIDs(Int_t numpids);
56  Int_t FindPIDGUID(const char* guid) const;
57  Int_t GetInternalIdxForPID(TProcessID* procid) const;
58  Int_t GetInternalIdxForPID(Int_t pid) const;
59 
60 public:
61 
62  enum EStatusBits {
64  };
65 
66  TRefTable();
67  TRefTable(TObject *owner, Int_t size);
68  virtual ~TRefTable();
69  virtual Int_t Add(Int_t uid, TProcessID* context = 0);
70  virtual void Clear(Option_t * /*option*/ ="");
71  virtual Int_t Expand(Int_t pid, Int_t newsize);
72  virtual void FillBuffer(TBuffer &b);
73  static TRefTable *GetRefTable();
74  Int_t GetNumPIDs() const {return fNumPIDs;}
75  Int_t GetSize(Int_t pid) const {return fAllocSize[GetInternalIdxForPID(pid)];}
76  Int_t GetN(Int_t pid) const {return fN[GetInternalIdxForPID(pid)];}
77  TObject *GetOwner() const {return fOwner;}
78  TObject *GetParent(Int_t uid, TProcessID* context = 0) const;
79  TObjArray *GetParents() const {return fParents;}
80  UInt_t GetUID() const {return fUID;}
82  virtual Bool_t Notify();
83  virtual void ReadBuffer(TBuffer &b);
84  virtual void Reset(Option_t * /* option */ ="");
85  virtual Int_t SetParent(const TObject* parent, Int_t branchID);
86  static void SetRefTable(TRefTable *table);
87  virtual void SetUID(UInt_t uid, TProcessID* context = 0) {fUID=uid; fUIDContext = context;}
88 
89  ClassDef(TRefTable,3) //Table of referenced objects during an I/O operation
90 };
91 
92 #endif
TRefTable::TRefTable
TRefTable()
Default constructor for I/O.
Definition: TRefTable.cxx:52
TObjArray
Definition: TObjArray.h:37
TRefTable::Clear
virtual void Clear(Option_t *="")
Clear all entries in the table.
Definition: TRefTable.cxx:145
TRefTable::Reset
virtual void Reset(Option_t *="")
Clear all entries in the table.
Definition: TRefTable.cxx:345
TRefTable::Add
virtual Int_t Add(Int_t uid, TProcessID *context=0)
Add a new uid to the table.
Definition: TRefTable.cxx:88
TRefTable::GetParents
TObjArray * GetParents() const
Definition: TRefTable.h:79
TRefTable::fProcessGUIDs
std::vector< std::string > fProcessGUIDs
Definition: TRefTable.h:49
TProcessID
Definition: TProcessID.h:74
Int_t
int Int_t
Definition: RtypesCore.h:45
TRefTable::fUID
UInt_t fUID
default size for a new PID array
Definition: TRefTable.h:44
TRefTable::fDefaultSize
Int_t fDefaultSize
current parent ID in fParents (latest call to SetParent)
Definition: TRefTable.h:43
TBuffer
Definition: TBuffer.h:43
TRefTable::fParents
TObjArray * fParents
Definition: TRefTable.h:47
TRefTable::fParentIDs
Int_t ** fParentIDs
[fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
Definition: TRefTable.h:41
TRefTable::fSize
Int_t fSize
TProcessID the current uid is referring to.
Definition: TRefTable.h:46
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
b
#define b(i)
Definition: RSha256.hxx:118
TRefTable::fgRefTable
static TRefTable * fgRefTable
cache of pid to index in fProcessGUIDs
Definition: TRefTable.h:51
TRefTable::GetParent
TObject * GetParent(Int_t uid, TProcessID *context=0) const
Return object corresponding to uid.
Definition: TRefTable.cxx:249
TRefTable::GetUIDContext
TProcessID * GetUIDContext() const
Definition: TRefTable.h:81
TRefTable::SetRefTable
static void SetRefTable(TRefTable *table)
Static function setting the current TRefTable.
Definition: TRefTable.cxx:383
TRefTable::GetInternalIdxForPID
Int_t GetInternalIdxForPID(TProcessID *procid) const
Get the index for fProcessIDs, fAllocSize, etc given a PID.
Definition: TRefTable.cxx:269
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TRefTable::ExpandPIDs
void ExpandPIDs(Int_t numpids)
Expand the arrays of managed PIDs.
Definition: TRefTable.cxx:193
TRefTable::SetUID
virtual void SetUID(UInt_t uid, TProcessID *context=0)
Definition: TRefTable.h:87
TRefTable::GetRefTable
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
Definition: TRefTable.cxx:287
TRefTable::Notify
virtual Bool_t Notify()
This function is called by TRef::Streamer or TStreamerInfo::ReadBuffer when reading a reference.
Definition: TRefTable.cxx:299
BIT
#define BIT(n)
Definition: Rtypes.h:85
TRefTable::GetUID
UInt_t GetUID() const
Definition: TRefTable.h:80
TRefTable::fOwner
TObject * fOwner
Definition: TRefTable.h:48
TRefTable::GetNumPIDs
Int_t GetNumPIDs() const
Definition: TRefTable.h:74
TRefTable::ReadBuffer
virtual void ReadBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.
Definition: TRefTable.cxx:308
TRefTable::fMapPIDtoInternal
std::vector< Int_t > fMapPIDtoInternal
Definition: TRefTable.h:50
TRefTable::ExpandForIID
virtual Int_t ExpandForIID(Int_t iid, Int_t newsize)
Expand fParentIDs to newsize for internel ProcessID index iid.
Definition: TRefTable.cxx:167
unsigned int
TRefTable::fAllocSize
Int_t * fAllocSize
number of known ProcessIDs
Definition: TRefTable.h:39
TRefTable
Definition: TRefTable.h:35
TRefTable::GetOwner
TObject * GetOwner() const
Definition: TRefTable.h:77
TRefTable::GetSize
Int_t GetSize(Int_t pid) const
Definition: TRefTable.h:75
TRefTable::GetN
Int_t GetN(Int_t pid) const
Definition: TRefTable.h:76
TObject.h
TRefTable::Expand
virtual Int_t Expand(Int_t pid, Int_t newsize)
Expand fParentIDs to newsize for ProcessID pid.
Definition: TRefTable.cxx:157
TRefTable::SetParent
virtual Int_t SetParent(const TObject *parent, Int_t branchID)
– Set current parent object, typically a branch of a tree.
Definition: TRefTable.cxx:357
TRefTable::kHaveWarnedReadingOld
@ kHaveWarnedReadingOld
Definition: TRefTable.h:63
TRefTable::fUIDContext
TProcessID * fUIDContext
Current uid (set by TRef::GetObject)
Definition: TRefTable.h:45
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TRefTable::FindPIDGUID
Int_t FindPIDGUID(const char *guid) const
Get fProcessGUIDs' index of the TProcessID with GUID guid.
Definition: TRefTable.cxx:238
TRefTable::FillBuffer
virtual void FillBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.
Definition: TRefTable.cxx:225
TRefTable::fNumPIDs
Int_t fNumPIDs
Definition: TRefTable.h:38
TRefTable::AddInternalIdxForPID
Int_t AddInternalIdxForPID(TProcessID *procid)
Add the internal index for fProcessIDs, fAllocSize, etc given a PID.
Definition: TRefTable.cxx:119
TRefTable::~TRefTable
virtual ~TRefTable()
Destructor.
Definition: TRefTable.cxx:71
TObject::EStatusBits
EStatusBits
Definition: TObject.h:57
TRefTable::fParentID
Int_t fParentID
[fNumPIDs][fAllocSize] array of Parent IDs
Definition: TRefTable.h:42
TRefTable::fN
Int_t * fN
[fNumPIDs] allocated size of array fParentIDs for each ProcessID
Definition: TRefTable.h:40
int