KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVClassMonitor.cpp
1//Created by KVClassFactory on Thu Jun 17 14:19:50 2010
2//Author: John Frankland,,,
3
4#include "KVClassMonitor.h"
5#include "TObjectTable.h"
6#include "TROOT.h"
7#include "TClass.h"
8
10
11
14
15
21
23{
24 // Default constructor
25 // fill fClassStats with all current instance counts
26 // Store current class instance statistics as 'initial' values
27 // used for global comparison by CompareToInit()
28
29 fgClassMonitor = this;
31 TIter next(gROOT->GetListOfClasses());
32 TClass* cl;
33 while ((cl = (TClass*) next())) {
34 Int_t n = cl->GetInstanceCount();
35 fClassStats.SetValue(cl->GetName(), n);
36 }
37}
38
39
40
44
46{
47 // Store current class instance statistics as 'initial' values
48 // used for global comparison by CompareToInit()
49
51 TIter next(gROOT->GetListOfClasses());
52 TClass* cl;
53 while ((cl = (TClass*) next())) {
54 Int_t n = cl->GetInstanceCount();
55 fClassStatsInit.SetValue(cl->GetName(), n);
56 }
57}
58
59
60
64
65std::map<std::string, int>& KVClassMonitor::GetListOfChanges() const
66{
67 // Return list of classes whose count changed in last call to Check()
68 // Each parameter (classname) has a value corresponding to the change (+ or -)
69
70 return fChanges;
71}
72
73
74
77
79{
80 // Return pointer to unique instance of class monitor class
82 return fgClassMonitor;
83}
84
85
86
89
91{
92 // Destructor
93 fgClassMonitor = nullptr;
94}
95
96
97
101
103{
104 // update class instance statistics
105 // print warning for every class whose number has increased
106 Info("Check", "Checking class instance statistics");
107 fChanges.clear();
109 TIter next(gROOT->GetListOfClasses());
110 TClass* cl;
111 while ((cl = (TClass*) next())) {
112 Int_t n = cl->GetInstanceCount();
113 Int_t old = fClassStats.GetValue(cl->GetName(), 0);
114 if (n != old) {
115 if (n > old) Warning("Check", "%s +%d (%d --> %d)", cl->GetName(), n - old, old, n);
116 else Warning("Check", "%s -%d (%d --> %d)", cl->GetName(), old - n, old, n);
117 fChanges[cl->GetName()] = (n - old);
118 }
119 fClassStats.SetValue(cl->GetName(), n);
120 }
121}
122
123
124
128
130{
131 // compare class instance statistics to initial values
132 // print warning for every class whose number has increased
133 Info("CompareToInit", "Checking class instance statistics");
135 TIter next(gROOT->GetListOfClasses());
136 TClass* cl;
137 while ((cl = (TClass*) next())) {
138 Int_t n = cl->GetInstanceCount();
139 Int_t old = fClassStatsInit.GetValue(cl->GetName(), 0);
140 if (n != old) {
141 if (n > old) Warning("CompareToInit", "%s +%d (%d --> %d)", cl->GetName(), n - old, old, n);
142 else Warning("CompareToInit", "%s -%d (%d --> %d)", cl->GetName(), old - n, old, n);
143 }
144 }
145}
146
147
int Int_t
bool Bool_t
constexpr Bool_t kFALSE
R__EXTERN TObjectTable * gObjectTable
#define gROOT
Simple tool to track which classes instance count increases over time.
static KVClassMonitor * GetInstance()
Return pointer to unique instance of class monitor class.
std::map< std::string, int > fChanges
list of classes whose number changed in last Check()
std::map< std::string, int > & GetListOfChanges() const
TEnv fClassStats
store class instance statistics
TEnv fClassStatsInit
intitial class instance statistics
static Bool_t fDisableCheck
disable static DoCheck() method
virtual ~KVClassMonitor()
Destructor.
static KVClassMonitor * fgClassMonitor
singleton
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
void UpdateInstCount() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const Int_t n
ClassImp(TPyArg)