Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

TObjectTable.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Name:  $:$Id: TObjectTable.h,v 1.2 2000/12/13 15:56:17 brun Exp $
00002 // Author: Fons Rademakers   11/08/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, 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_TObjectTable
00013 #define ROOT_TObjectTable
00014 
00015 
00017 //                                                                      //
00018 // TObjectTable                                                         //
00019 //                                                                      //
00020 // This class registers all instances of TObject and its derived        //
00021 // classes in a hash table. The Add() and Remove() members are called   //
00022 // from the TObject ctor and dtor, repectively. Using the Print()       //
00023 // member one can see all currently active objects in the system.       //
00024 // Using the runtime flag: Root.ObjectStat one can toggle this feature  //
00025 // on or off.                                                           //
00026 //                                                                      //
00028 
00029 
00030 #ifndef ROOT_TObject
00031 #include "TObject.h"
00032 #endif
00033 
00034 class TClass;
00035 
00036 
00037 class TObjectTable : public TObject {
00038 
00039 private:
00040    TObject  **fTable;
00041    Int_t      fSize;
00042    Int_t      fTally;
00043 
00044    Bool_t     HighWaterMark();
00045    void       Expand(Int_t newsize);
00046    Int_t      FindElement(TObject *obj);
00047    void       FixCollisions(Int_t index);
00048 
00049 public:
00050    TObjectTable(Int_t tableSize = 100);
00051    ~TObjectTable();
00052 
00053    void      Add(TObject *obj);
00054    void     *CheckPtrAndWarn(const char *msg, void *vp);
00055    void      Delete(Option_t *opt = "");
00056    Int_t     GetSize() const { return fSize; }
00057    Int_t     Instances() const { return fTally; }
00058    void      InstanceStatistics() const;
00059    void      Print(Option_t *option="") const;
00060    Bool_t    PtrIsValid(TObject *obj);
00061    void      Remove(TObject *obj);
00062    void      RemoveQuietly(TObject *obj);
00063    void      Statistics() { Print(); }
00064    void      Terminate();
00065    void      UpdateInstCount() const;
00066 
00067    static void AddObj(TObject *obj);
00068 
00069    ClassDef(TObjectTable,0)  //Table of active objects
00070 };
00071 
00072 
00073 inline Bool_t TObjectTable::HighWaterMark()
00074    { return (Bool_t) (fTally >= ((3*fSize)/4)); }
00075 
00076 inline Bool_t TObjectTable::PtrIsValid(TObject *op)
00077    { return fTable[FindElement(op)] != 0; }
00078 
00079 
00080 R__EXTERN TObjectTable *gObjectTable;
00081 
00082 #endif

Generated on Thu Dec 18 14:52:22 2003 for ROOT by doxygen1.2.16