ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TObject
28 #include "TObject.h"
29 #endif
30 
31 #include <string>
32 #include <vector>
33 
34 class TObjArray;
35 class TProcessID;
36 
37 class TRefTable : public TObject {
38 
39 protected:
40  Int_t fNumPIDs; //!number of known ProcessIDs
41  Int_t *fAllocSize; //![fNumPIDs] allocated size of array fParentIDs for each ProcessID
42  Int_t *fN; //![fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
43  Int_t **fParentIDs; //![fNumPIDs][fAllocSize] array of Parent IDs
44  Int_t fParentID; //!current parent ID in fParents (latest call to SetParent)
45  Int_t fDefaultSize;//!default size for a new PID array
46  UInt_t fUID; //!Current uid (set by TRef::GetObject)
47  TProcessID *fUIDContext; //!TProcessID the current uid is referring to
48  Int_t fSize; //dummy for backward compatibility
49  TObjArray *fParents; //array of Parent objects (eg TTree branch) holding the referenced objects
50  TObject *fOwner; //Object owning this TRefTable
51  std::vector<std::string> fProcessGUIDs; // UUIDs of TProcessIDs used in fParentIDs
52  std::vector<Int_t> fMapPIDtoInternal; //! cache of pid to index in fProcessGUIDs
53  static TRefTable *fgRefTable; //Pointer to current TRefTable
54 
56  virtual Int_t ExpandForIID(Int_t iid, Int_t newsize);
57  void ExpandPIDs(Int_t numpids);
58  Int_t FindPIDGUID(const char* guid) const;
59  Int_t GetInternalIdxForPID(TProcessID* procid) const;
60  Int_t GetInternalIdxForPID(Int_t pid) const;
61 
62 public:
63 
64  enum {
66  };
67 
68  TRefTable();
69  TRefTable(TObject *owner, Int_t size);
70  virtual ~TRefTable();
71  virtual Int_t Add(Int_t uid, TProcessID* context = 0);
72  virtual void Clear(Option_t * /*option*/ ="");
73  virtual Int_t Expand(Int_t pid, Int_t newsize);
74  virtual void FillBuffer(TBuffer &b);
75  static TRefTable *GetRefTable();
76  Int_t GetNumPIDs() const {return fNumPIDs;}
77  Int_t GetSize(Int_t pid) const {return fAllocSize[GetInternalIdxForPID(pid)];}
78  Int_t GetN(Int_t pid) const {return fN[GetInternalIdxForPID(pid)];}
79  TObject *GetOwner() const {return fOwner;}
80  TObject *GetParent(Int_t uid, TProcessID* context = 0) const;
81  TObjArray *GetParents() const {return fParents;}
82  UInt_t GetUID() const {return fUID;}
84  virtual Bool_t Notify();
85  virtual void ReadBuffer(TBuffer &b);
86  virtual void Reset(Option_t * /* option */ ="");
87  virtual Int_t SetParent(const TObject* parent, Int_t branchID);
88  static void SetRefTable(TRefTable *table);
89  virtual void SetUID(UInt_t uid, TProcessID* context = 0) {fUID=uid; fUIDContext = context;}
90 
91  ClassDef(TRefTable,3) //Table of referenced objects during an I/O operation
92 };
93 
94 #endif
Int_t fParentID
[fNumPIDs][fAllocSize] array of Parent IDs
Definition: TRefTable.h:44
TObject * fOwner
Definition: TRefTable.h:50
An array of TObjects.
Definition: TObjArray.h:39
Int_t GetSize(Int_t pid) const
Definition: TRefTable.h:77
const char Option_t
Definition: RtypesCore.h:62
TObject * GetParent(Int_t uid, TProcessID *context=0) const
Return object corresponding to uid.
Definition: TRefTable.cxx:249
TProcessID * GetUIDContext() const
Definition: TRefTable.h:83
#define BIT(n)
Definition: Rtypes.h:120
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
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
void ExpandPIDs(Int_t numpids)
Expand the arrays of managed PIDs.
Definition: TRefTable.cxx:193
TObjArray * fParents
Definition: TRefTable.h:49
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t fSize
TProcessID the current uid is referring to.
Definition: TRefTable.h:48
TObject * GetOwner() const
Definition: TRefTable.h:79
Int_t * fN
[fNumPIDs] allocated size of array fParentIDs for each ProcessID
Definition: TRefTable.h:42
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:34
Int_t fNumPIDs
Definition: TRefTable.h:40
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:53
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
std::vector< Int_t > fMapPIDtoInternal
Definition: TRefTable.h:52
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:51
Int_t GetNumPIDs() const
Definition: TRefTable.h:76
TObjArray * GetParents() const
Definition: TRefTable.h:81
Int_t * fAllocSize
number of known ProcessIDs
Definition: TRefTable.h:41
UInt_t fUID
default size for a new PID array
Definition: TRefTable.h:46
Int_t fDefaultSize
current parent ID in fParents (latest call to SetParent)
Definition: TRefTable.h:45
Int_t GetN(Int_t pid) const
Definition: TRefTable.h:78
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:37
Int_t FindPIDGUID(const char *guid) const
Get fProcessGUIDs' index of the TProcessID with GUID guid.
Definition: TRefTable.cxx:238
virtual void FillBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.
Definition: TRefTable.cxx:225
Mother of all ROOT objects.
Definition: TObject.h:58
UInt_t GetUID() const
Definition: TRefTable.h:82
Int_t ** fParentIDs
[fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
Definition: TRefTable.h:43
TProcessID * fUIDContext
Current uid (set by TRef::GetObject)
Definition: TRefTable.h:47
virtual void SetUID(UInt_t uid, TProcessID *context=0)
Definition: TRefTable.h:89
Int_t GetInternalIdxForPID(TProcessID *procid) const
Get the index for fProcessIDs, fAllocSize, etc given a PID.
Definition: TRefTable.cxx:269
virtual Bool_t Notify()
This function is called by TRef::Streamer or TStreamerInfo::ReadBuffer when reading a reference...
Definition: TRefTable.cxx:299