TObjectTable.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Id: TObjectTable.h 20882 2007-11-19 11:31:26Z rdm $
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 
00016 //////////////////////////////////////////////////////////////////////////
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 //                                                                      //
00027 //////////////////////////////////////////////////////////////////////////
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 private:
00050    TObjectTable(const TObjectTable&);             // not implemented
00051    TObjectTable& operator=(const TObjectTable&);  // not implemented
00052 
00053 public:
00054    TObjectTable(Int_t tableSize = 100);
00055    ~TObjectTable();
00056 
00057    void      Add(TObject *obj);
00058    void     *CheckPtrAndWarn(const char *msg, void *vp);
00059    void      Delete(Option_t *opt = "");
00060    Int_t     GetSize() const { return fSize; }
00061    Int_t     Instances() const { return fTally; }
00062    void      InstanceStatistics() const;
00063    void      Print(Option_t *option="") const;
00064    Bool_t    PtrIsValid(TObject *obj);
00065    void      Remove(TObject *obj);
00066    void      RemoveQuietly(TObject *obj);
00067    void      Statistics() { Print(); }
00068    void      Terminate();
00069    void      UpdateInstCount() const;
00070 
00071    static void AddObj(TObject *obj);
00072 
00073    ClassDef(TObjectTable,0)  //Table of active objects
00074 };
00075 
00076 
00077 inline Bool_t TObjectTable::HighWaterMark()
00078    { return (Bool_t) (fTally >= ((3*fSize)/4)); }
00079 
00080 inline Bool_t TObjectTable::PtrIsValid(TObject *op)
00081    { return fTable[FindElement(op)] != 0; }
00082 
00083 
00084 R__EXTERN TObjectTable *gObjectTable;
00085 
00086 #endif

Generated on Tue Jul 5 14:11:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1