Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
32class TObjArray;
33class TProcessID;
34
35class TRefTable : public TObject {
36
37protected:
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;
59
60public:
61
64 };
65
66 TRefTable();
67 TRefTable(TObject *owner, Int_t size);
68 virtual ~TRefTable();
69
70 TRefTable(const TRefTable&) = delete;
71 TRefTable &operator=(const TRefTable&) = delete;
72
73 virtual Int_t Add(Int_t uid, TProcessID* context = nullptr);
74 void Clear(Option_t * /*option*/ ="") override;
75 virtual Int_t Expand(Int_t pid, Int_t newsize);
76 virtual void FillBuffer(TBuffer &b);
77 static TRefTable *GetRefTable();
78 Int_t GetNumPIDs() const {return fNumPIDs;}
80 Int_t GetN(Int_t pid) const {return fN[GetInternalIdxForPID(pid)];}
81 TObject *GetOwner() const {return fOwner;}
82 TObject *GetParent(Int_t uid, TProcessID *context = nullptr) const;
83 TObjArray *GetParents() const {return fParents;}
84 UInt_t GetUID() const {return fUID;}
86 Bool_t Notify() override;
87 virtual void ReadBuffer(TBuffer &b);
88 virtual void Reset(Option_t * /* option */ ="");
89 virtual Int_t SetParent(const TObject* parent, Int_t branchID);
90 static void SetRefTable(TRefTable *table);
91 virtual void SetUID(UInt_t uid, TProcessID *context = nullptr) { fUID = uid; fUIDContext = context; }
92
93 ClassDefOverride(TRefTable,3) //Table of referenced objects during an I/O operation
94};
95
96#endif
#define b(i)
Definition RSha256.hxx:100
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Buffer base class used for serializing objects.
Definition TBuffer.h:43
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition TProcessID.h:74
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition TRefTable.h:35
@ kHaveWarnedReadingOld
Definition TRefTable.h:63
void Clear(Option_t *="") override
Clear all entries in the table.
Int_t * fN
[fNumPIDs] allocated size of array fParentIDs for each ProcessID
Definition TRefTable.h:40
Int_t GetNumPIDs() const
Definition TRefTable.h:78
virtual Int_t SetParent(const TObject *parent, Int_t branchID)
– Set current parent object, typically a branch of a tree.
std::vector< Int_t > fMapPIDtoInternal
Definition TRefTable.h:50
TRefTable()
Default constructor for I/O.
Definition TRefTable.cxx:52
virtual Int_t ExpandForIID(Int_t iid, Int_t newsize)
Expand fParentIDs to newsize for internel ProcessID index iid.
Int_t GetInternalIdxForPID(TProcessID *procid) const
Get the index for fProcessIDs, fAllocSize, etc given a PID.
UInt_t fUID
default size for a new PID array
Definition TRefTable.h:44
Int_t fNumPIDs
Definition TRefTable.h:38
UInt_t GetUID() const
Definition TRefTable.h:84
TObjArray * fParents
Definition TRefTable.h:47
TProcessID * GetUIDContext() const
Definition TRefTable.h:85
virtual void FillBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.
virtual void SetUID(UInt_t uid, TProcessID *context=nullptr)
Definition TRefTable.h:91
Int_t FindPIDGUID(const char *guid) const
Get fProcessGUIDs' index of the TProcessID with GUID guid.
Int_t * fAllocSize
number of known ProcessIDs
Definition TRefTable.h:39
TProcessID * fUIDContext
Current uid (set by TRef::GetObject)
Definition TRefTable.h:45
TObject * GetParent(Int_t uid, TProcessID *context=nullptr) const
Return object corresponding to uid.
Int_t AddInternalIdxForPID(TProcessID *procid)
Add the internal index for fProcessIDs, fAllocSize, etc given a PID.
TObject * GetOwner() const
Definition TRefTable.h:81
static TRefTable * fgRefTable
cache of pid to index in fProcessGUIDs
Definition TRefTable.h:51
static void SetRefTable(TRefTable *table)
Static function setting the current TRefTable.
Int_t fSize
TProcessID the current uid is referring to.
Definition TRefTable.h:46
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.
virtual void Reset(Option_t *="")
Clear all entries in the table.
void ExpandPIDs(Int_t numpids)
Expand the arrays of managed PIDs.
std::vector< std::string > fProcessGUIDs
Definition TRefTable.h:49
virtual Int_t Add(Int_t uid, TProcessID *context=nullptr)
Add a new uid to the table.
Definition TRefTable.cxx:88
virtual Int_t Expand(Int_t pid, Int_t newsize)
Expand fParentIDs to newsize for ProcessID pid.
virtual ~TRefTable()
Destructor.
Definition TRefTable.cxx:71
TRefTable & operator=(const TRefTable &)=delete
TRefTable(const TRefTable &)=delete
Int_t GetSize(Int_t pid) const
Definition TRefTable.h:79
Int_t ** fParentIDs
[fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
Definition TRefTable.h:41
Bool_t Notify() override
This function is called by TRef::Streamer or TStreamerInfo::ReadBuffer when reading a reference.
Int_t GetN(Int_t pid) const
Definition TRefTable.h:80
TObjArray * GetParents() const
Definition TRefTable.h:83
Int_t fParentID
[fNumPIDs][fAllocSize] array of Parent IDs
Definition TRefTable.h:42
TObject * fOwner
Definition TRefTable.h:48
virtual void ReadBuffer(TBuffer &b)
Fill buffer b with the fN elements in fParentdIDs.