Logo ROOT   6.10/09
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 {
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
Int_t fParentID
[fNumPIDs][fAllocSize] array of Parent IDs
Definition: TRefTable.h:42
TObject * fOwner
Definition: TRefTable.h:48
Int_t GetNumPIDs() const
Definition: TRefTable.h:74
An array of TObjects.
Definition: TObjArray.h:37
const char Option_t
Definition: RtypesCore.h:62
Int_t GetSize(Int_t pid) const
Definition: TRefTable.h:75
TObjArray * GetParents() const
Definition: TRefTable.h:79
#define BIT(n)
Definition: Rtypes.h:75
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
UInt_t GetUID() const
Definition: TRefTable.h:80
virtual Int_t Add(Int_t uid, TProcessID *context=0)
Add a new uid to the table.
Definition: TRefTable.cxx:88
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Clear(Option_t *="")
Clear all entries in the table.
Definition: TRefTable.cxx:145
static void SetRefTable(TRefTable *table)
Static function setting the current TRefTable.
Definition: TRefTable.cxx:383
Int_t GetInternalIdxForPID(TProcessID *procid) const
Get the index for fProcessIDs, fAllocSize, etc given a PID.
Definition: TRefTable.cxx:269
void ExpandPIDs(Int_t numpids)
Expand the arrays of managed PIDs.
Definition: TRefTable.cxx:193
TObjArray * fParents
Definition: TRefTable.h:47
#define ClassDef(name, id)
Definition: Rtypes.h:297
Int_t fSize
TProcessID the current uid is referring to.
Definition: TRefTable.h:46
Int_t * fN
[fNumPIDs] allocated size of array fParentIDs for each ProcessID
Definition: TRefTable.h:40
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
Int_t fNumPIDs
Definition: TRefTable.h:38
Int_t AddInternalIdxForPID(TProcessID *procid)
Add the internal index for fProcessIDs, fAllocSize, etc given a PID.
Definition: TRefTable.cxx:119
static TRefTable * fgRefTable
cache of pid to index in fProcessGUIDs
Definition: TRefTable.h:51
virtual ~TRefTable()
Destructor.
Definition: TRefTable.cxx:71
virtual void Reset(Option_t *="")
Clear all entries in the table.
Definition: TRefTable.cxx:345
virtual void ReadBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.
Definition: TRefTable.cxx:308
Int_t GetN(Int_t pid) const
Definition: TRefTable.h:76
std::vector< Int_t > fMapPIDtoInternal
Definition: TRefTable.h:50
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Int_t ExpandForIID(Int_t iid, Int_t newsize)
Expand fParentIDs to newsize for internel ProcessID index iid.
Definition: TRefTable.cxx:167
std::vector< std::string > fProcessGUIDs
Definition: TRefTable.h:49
Int_t * fAllocSize
number of known ProcessIDs
Definition: TRefTable.h:39
TObject * GetOwner() const
Definition: TRefTable.h:77
UInt_t fUID
default size for a new PID array
Definition: TRefTable.h:44
Int_t fDefaultSize
current parent ID in fParents (latest call to SetParent)
Definition: TRefTable.h:43
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
Definition: TRefTable.cxx:287
virtual Int_t Expand(Int_t pid, Int_t newsize)
Expand fParentIDs to newsize for ProcessID pid.
Definition: TRefTable.cxx:157
virtual Int_t SetParent(const TObject *parent, Int_t branchID)
– Set current parent object, typically a branch of a tree.
Definition: TRefTable.cxx:357
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition: TRefTable.h:35
virtual void FillBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.
Definition: TRefTable.cxx:225
TProcessID * GetUIDContext() const
Definition: TRefTable.h:81
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Int_t ** fParentIDs
[fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
Definition: TRefTable.h:41
TProcessID * fUIDContext
Current uid (set by TRef::GetObject)
Definition: TRefTable.h:45
Int_t FindPIDGUID(const char *guid) const
Get fProcessGUIDs&#39; index of the TProcessID with GUID guid.
Definition: TRefTable.cxx:238
virtual void SetUID(UInt_t uid, TProcessID *context=0)
Definition: TRefTable.h:87
TRefTable()
Default constructor for I/O.
Definition: TRefTable.cxx:52
virtual Bool_t Notify()
This function is called by TRef::Streamer or TStreamerInfo::ReadBuffer when reading a reference...
Definition: TRefTable.cxx:299
TObject * GetParent(Int_t uid, TProcessID *context=0) const
Return object corresponding to uid.
Definition: TRefTable.cxx:249