Logo ROOT   6.16/01
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#include "TObject.h"
31
32class TClass;
33
34
35class TObjectTable : public TObject {
36
37private:
41
43 void Expand(Int_t newsize);
45 void FixCollisions(Int_t index);
46
47private:
48 TObjectTable(const TObjectTable&); // not implemented
49 TObjectTable& operator=(const TObjectTable&); // not implemented
50
51public:
52 TObjectTable(Int_t tableSize = 100);
54
55 void Add(TObject *obj);
56 void *CheckPtrAndWarn(const char *msg, void *vp);
57 void Delete(Option_t *opt = "");
58 Int_t GetSize() const { return fSize; }
59 Int_t Instances() const { return fTally; }
60 void InstanceStatistics() const;
61 void Print(Option_t *option="") const;
63 void Remove(TObject *obj);
64 void RemoveQuietly(TObject *obj);
65 void Statistics() { Print(); }
66 void Terminate();
67 void UpdateInstCount() const;
68
69 static void AddObj(TObject *obj);
70
71 ClassDef(TObjectTable,0) //Table of active objects
72};
73
74
76 { return (Bool_t) (fTally >= ((3*fSize)/4)); }
77
79 { return fTable[FindElement(op)] != 0; }
80
81
83
84#endif
#define R__EXTERN
Definition: DllImport.h:27
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
R__EXTERN TObjectTable * gObjectTable
Definition: TObjectTable.h:82
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
This class registers all instances of TObject and its derived classes in a hash table.
Definition: TObjectTable.h:35
void Statistics()
Definition: TObjectTable.h:65
void InstanceStatistics() const
Print the object table.
TObject ** fTable
Definition: TObjectTable.h:38
void Delete(Option_t *opt="")
Delete all objects stored in the TObjectTable.
Int_t FindElement(TObject *obj)
Find an object in the object table.
void Print(Option_t *option="") const
Print the object table.
void Terminate()
Deletes the object table (this static class function calls the dtor).
~TObjectTable()
Delete TObjectTable.
Int_t GetSize() const
Definition: TObjectTable.h:58
void Remove(TObject *obj)
Remove an object from the object table.
void * CheckPtrAndWarn(const char *msg, void *vp)
Issue a warning in case an object still appears in the table while it should not.
void UpdateInstCount() const
Histogram all objects according to their classes.
void FixCollisions(Int_t index)
Rehash the object table in case an object has been removed.
void Add(TObject *obj)
Add an object to the object table.
TObjectTable(const TObjectTable &)
TObjectTable & operator=(const TObjectTable &)
Bool_t PtrIsValid(TObject *obj)
Definition: TObjectTable.h:78
static void AddObj(TObject *obj)
Add an object to the global object table gObjectTable.
void Expand(Int_t newsize)
Expand the object table.
void RemoveQuietly(TObject *obj)
Remove an object from the object table.
Bool_t HighWaterMark()
Definition: TObjectTable.h:75
Int_t Instances() const
Definition: TObjectTable.h:59
Mother of all ROOT objects.
Definition: TObject.h:37