Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files 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 #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 
53  Int_t AddInternalIdxForPID(TProcessID* procid);
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 {
63  kHaveWarnedReadingOld = BIT(14)
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;}
81  TProcessID *GetUIDContext() const {return fUIDContext;}
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