Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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&) = delete;
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
bool Bool_t
Definition RtypesCore.h:63
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
R__EXTERN TObjectTable * gObjectTable
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
This class registers all instances of TObject and its derived classes in a hash table.
void Statistics()
void InstanceStatistics() const
Print the object table.
TObject ** fTable
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 & operator=(const TObjectTable &)=delete
~TObjectTable()
Delete TObjectTable.
Int_t GetSize() const
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.
TObjectTable(const TObjectTable &)=delete
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.
Bool_t PtrIsValid(TObject *obj)
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()
Int_t Instances() const
Mother of all ROOT objects.
Definition TObject.h:41