Logo ROOT   6.08/07
Reference Guide
TObjectTable.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Fons Rademakers 11/08/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TObjectTable
13 #define ROOT_TObjectTable
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TObjectTable //
19 // //
20 // This class registers all instances of TObject and its derived //
21 // classes in a hash table. The Add() and Remove() members are called //
22 // from the TObject ctor and dtor, repectively. Using the Print() //
23 // member one can see all currently active objects in the system. //
24 // Using the runtime flag: Root.ObjectStat one can toggle this feature //
25 // on or off. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 
30 #ifndef ROOT_TObject
31 #include "TObject.h"
32 #endif
33 
34 class TClass;
35 
36 
37 class TObjectTable : public TObject {
38 
39 private:
43 
45  void Expand(Int_t newsize);
47  void FixCollisions(Int_t index);
48 
49 private:
50  TObjectTable(const TObjectTable&); // not implemented
51  TObjectTable& operator=(const TObjectTable&); // not implemented
52 
53 public:
54  TObjectTable(Int_t tableSize = 100);
55  ~TObjectTable();
56 
57  void Add(TObject *obj);
58  void *CheckPtrAndWarn(const char *msg, void *vp);
59  void Delete(Option_t *opt = "");
60  Int_t GetSize() const { return fSize; }
61  Int_t Instances() const { return fTally; }
62  void InstanceStatistics() const;
63  void Print(Option_t *option="") const;
65  void Remove(TObject *obj);
66  void RemoveQuietly(TObject *obj);
67  void Statistics() { Print(); }
68  void Terminate();
69  void UpdateInstCount() const;
70 
71  static void AddObj(TObject *obj);
72 
73  ClassDef(TObjectTable,0) //Table of active objects
74 };
75 
76 
78  { return (Bool_t) (fTally >= ((3*fSize)/4)); }
79 
81  { return fTable[FindElement(op)] != 0; }
82 
83 
85 
86 #endif
Int_t FindElement(TObject *obj)
Find an object in the object table.
const char Option_t
Definition: RtypesCore.h:62
void Expand(Int_t newsize)
Expand the object table.
void RemoveQuietly(TObject *obj)
Remove an object from the object table.
~TObjectTable()
Delete TObjectTable.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void UpdateInstCount() const
Histogram all objects according to their classes.
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t GetSize() const
Definition: TObjectTable.h:60
void Terminate()
Deletes the object table (this static class function calls the dtor).
Int_t Instances() const
Definition: TObjectTable.h:61
void * CheckPtrAndWarn(const char *msg, void *vp)
Issue a warning in case an object still appears in the table while it should not. ...
TObjectTable(const TObjectTable &)
Bool_t PtrIsValid(TObject *obj)
Definition: TObjectTable.h:80
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
This class registers all instances of TObject and its derived classes in a hash table.
Definition: TObjectTable.h:37
static void AddObj(TObject *obj)
Add an object to the global object table gObjectTable.
R__EXTERN TObjectTable * gObjectTable
Definition: TObjectTable.h:84
Bool_t HighWaterMark()
Definition: TObjectTable.h:77
TObject ** fTable
Definition: TObjectTable.h:40
void Statistics()
Definition: TObjectTable.h:67
void Add(TObject *obj)
Add an object to the object table.
void FixCollisions(Int_t index)
Rehash the object table in case an object has been removed.
void InstanceStatistics() const
Print the object table.
Mother of all ROOT objects.
Definition: TObject.h:37
#define R__EXTERN
Definition: DllImport.h:27
void Delete(Option_t *opt="")
Delete all objects stored in the TObjectTable.
TObjectTable & operator=(const TObjectTable &)
void Print(Option_t *option="") const
Print the object table.
void Remove(TObject *obj)
Remove an object from the object table.