00001 // @(#)root/cont:$Id: TRefTable.h 37274 2010-12-04 21:31:29Z pcanal $ 00002 // Author: Rene Brun 17/08/2004 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef ROOT_TRefTable 00013 #define ROOT_TRefTable 00014 00015 00016 ////////////////////////////////////////////////////////////////////////// 00017 // // 00018 // TRefTable // 00019 // // 00020 // A TRefTable maintains the association between a referenced object // 00021 // and the parent object supporting this referenced object. // 00022 // The parent object is typically a branch of a TTree. // 00023 // // 00024 ////////////////////////////////////////////////////////////////////////// 00025 00026 00027 #ifndef ROOT_TObject 00028 #include "TObject.h" 00029 #endif 00030 00031 #include <string> 00032 #include <vector> 00033 00034 class TObjArray; 00035 class TProcessID; 00036 00037 class TRefTable : public TObject { 00038 00039 protected: 00040 Int_t fNumPIDs; //!number of known ProcessIDs 00041 Int_t *fAllocSize; //![fNumPIDs] allocated size of array fParentIDs for each ProcessID 00042 Int_t *fN; //![fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID 00043 Int_t **fParentIDs; //![fNumPIDs][fAllocSize] array of Parent IDs 00044 Int_t fParentID; //!current parent ID in fParents (latest call to SetParent) 00045 Int_t fDefaultSize;//!default size for a new PID array 00046 UInt_t fUID; //!Current uid (set by TRef::GetObject) 00047 TProcessID *fUIDContext; //!TProcessID the current uid is referring to 00048 Int_t fSize; //dummy for backward compatibility 00049 TObjArray *fParents; //array of Parent objects (eg TTree branch) holding the referenced objects 00050 TObject *fOwner; //Object owning this TRefTable 00051 std::vector<std::string> fProcessGUIDs; // UUIDs of TProcessIDs used in fParentIDs 00052 std::vector<Int_t> fMapPIDtoInternal; //! cache of pid to index in fProcessGUIDs 00053 static TRefTable *fgRefTable; //Pointer to current TRefTable 00054 00055 Int_t AddInternalIdxForPID(TProcessID* procid); 00056 virtual Int_t ExpandForIID(Int_t iid, Int_t newsize); 00057 void ExpandPIDs(Int_t numpids); 00058 Int_t FindPIDGUID(const char* guid) const; 00059 Int_t GetInternalIdxForPID(TProcessID* procid) const; 00060 Int_t GetInternalIdxForPID(Int_t pid) const; 00061 00062 public: 00063 00064 enum { 00065 kHaveWarnedReadingOld = BIT(14) 00066 }; 00067 00068 TRefTable(); 00069 TRefTable(TObject *owner, Int_t size); 00070 virtual ~TRefTable(); 00071 virtual Int_t Add(Int_t uid, TProcessID* context = 0); 00072 virtual void Clear(Option_t * /*option*/ =""); 00073 virtual Int_t Expand(Int_t pid, Int_t newsize); 00074 virtual void FillBuffer(TBuffer &b); 00075 static TRefTable *GetRefTable(); 00076 Int_t GetNumPIDs() const {return fNumPIDs;} 00077 Int_t GetSize(Int_t pid) const {return fAllocSize[GetInternalIdxForPID(pid)];} 00078 Int_t GetN(Int_t pid) const {return fN[GetInternalIdxForPID(pid)];} 00079 TObject *GetOwner() const {return fOwner;} 00080 TObject *GetParent(Int_t uid, TProcessID* context = 0) const; 00081 TObjArray *GetParents() const {return fParents;} 00082 UInt_t GetUID() const {return fUID;} 00083 TProcessID *GetUIDContext() const {return fUIDContext;} 00084 virtual Bool_t Notify(); 00085 virtual void ReadBuffer(TBuffer &b); 00086 virtual void Reset(Option_t * /* option */ =""); 00087 virtual Int_t SetParent(const TObject* parent, Int_t branchID); 00088 static void SetRefTable(TRefTable *table); 00089 virtual void SetUID(UInt_t uid, TProcessID* context = 0) {fUID=uid; fUIDContext = context;} 00090 00091 ClassDef(TRefTable,3) //Table of referenced objects during an I/O operation 00092 }; 00093 00094 #endif