ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Base
src
VP1HelperClassBase.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Implementation of class VP1HelperClassBase //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: February 2008 //
12
// //
14
15
#include "
VP1Base/VP1HelperClassBase.h
"
16
#include "
VP1Base/IVP1System.h
"
17
#include "
VP1Base/VP1QtUtils.h
"
18
#include "
VP1Base/VP1Msg.h
"
19
#include <iostream>
20
#include <map>
21
22
const
bool
VP1HelperClassBase::s_vp1verbose
=
VP1QtUtils::environmentVariableIsOn
(
"VP1_VERBOSE_OUTPUT"
);
23
24
//only filled in verbose mode:
25
static
std::map<VP1HelperClassBase*,QString>
vp1helperclassbase_instanceMap
;
//instance -> systemname
26
27
//____________________________________________________________________
28
VP1HelperClassBase::VP1HelperClassBase
(
IVP1System
* sys, QString helpername)
29
:
m_helpername
(helpername),
m_system
(sys)
30
{
31
if
(
VP1Msg::verbose
()){
32
messageVerbose
(
"base constructor ("
+
str
(
this
)+
")"
+(
m_system
?
" system = "
+
m_system
->name():QString(
""
)));
33
vp1helperclassbase_instanceMap
[
this
] = (
m_system
?
m_system
->name():QString(
""
));
34
}
35
}
36
37
//____________________________________________________________________
38
VP1HelperClassBase::~VP1HelperClassBase
()
39
{
40
if
(
VP1Msg::verbose
()){
41
messageVerbose
(
"base destructor ("
+
str
(
this
)+
")"
+(
m_system
?
" system = "
+
m_system
->name():QString(
""
)));
42
std::map<VP1HelperClassBase*,QString>::iterator it =
vp1helperclassbase_instanceMap
.find(
this
);
43
if
(it!=
vp1helperclassbase_instanceMap
.end())
44
vp1helperclassbase_instanceMap
.erase(it);
45
}
46
}
47
48
//____________________________________________________________________
49
void
VP1HelperClassBase::message
(
const
QString&
str
)
const
50
{
51
if
(
m_helpername
.isEmpty()) {
52
if
(
m_system
)
53
m_system
->message(
str
);
54
else
55
std::cout<<
VP1Msg::prefix_msg
()<<
" [nameless helper class]: "
<<
str
.toStdString()<<std::endl;
56
}
else
{
57
if
(
m_system
)
58
m_system
->
message
(
"["
+
m_helpername
+
"] "
+
str
);
59
else
60
std::cout<<
VP1Msg::prefix_msg
()<<
" ["
<<
m_helpername
.toStdString()<<
"]: "
<<
str
.toStdString()<<std::endl;
61
}
62
}
63
64
//____________________________________________________________________
65
void
VP1HelperClassBase::messageDebug
(
const
QString&
str
)
const
66
{
67
if
(!
VP1Msg::debug
())
68
return
;
69
std::string sysstring(
m_system
?
" in "
+
m_system
->name().toStdString() : std::string(
""
));
70
if
(
m_helpername
.isEmpty()) {
71
std::cout<<
VP1Msg::prefix_debug
()<<
" [helper"
<<sysstring<<
"]: "
<<
str
.toStdString()<<std::endl;
72
}
else
{
73
std::cout<<
VP1Msg::prefix_debug
()<<
" ["
<<
m_helpername
.toStdString()<<sysstring<<
"]: "
<<
str
.toStdString()<<std::endl;
74
}
75
}
76
77
//____________________________________________________________________
78
void
VP1HelperClassBase::messageVerbose
(
const
QString&
str
)
const
79
{
80
if
(!
VP1Msg::verbose
())
81
return
;
82
std::string sysstring(
m_system
?
" in "
+
m_system
->name().toStdString() : std::string(
""
));
83
if
(
m_helpername
.isEmpty()) {
84
std::cout<<
VP1Msg::prefix_verbose
()<<
" [helper"
<<sysstring<<
"]: "
<<
str
.toStdString()<<std::endl;
85
}
else
{
86
std::cout<<
VP1Msg::prefix_verbose
()<<
" ["
<<
m_helpername
.toStdString()<<sysstring<<
"]: "
<<
str
.toStdString()<<std::endl;
87
}
88
}
89
90
//____________________________________________________________________
91
void
VP1HelperClassBase::message
(
const
QStringList& l,
const
QString& addtoend )
const
92
{
93
if
(addtoend.isEmpty()) {
94
for
(
const
QString& s : l)
95
message
(s);
96
}
else
{
97
for
(
const
QString& s : l)
98
message
(s+addtoend);
99
}
100
}
101
102
//____________________________________________________________________
103
void
VP1HelperClassBase::messageDebug
(
const
QStringList& l,
const
QString& addtoend )
const
104
{
105
if
(!
VP1Msg::debug
())
106
return
;
107
if
(addtoend.isEmpty()) {
108
for
(
const
QString& s : l)
109
messageDebug
(s);
110
}
else
{
111
for
(
const
QString& s : l)
112
messageDebug
(s+addtoend);
113
}
114
}
115
116
//____________________________________________________________________
117
void
VP1HelperClassBase::messageVerbose
(
const
QStringList& l,
const
QString& addtoend )
const
118
{
119
if
(!
VP1Msg::verbose
())
120
return
;
121
if
(addtoend.isEmpty()) {
122
for
(
const
QString& s : l)
123
messageVerbose
(s);
124
}
else
{
125
for
(
const
QString& s : l)
126
messageVerbose
(s+addtoend);
127
}
128
}
129
130
//____________________________________________________________________
131
void
VP1HelperClassBase::message
(
const
QString& addtostart,
const
QStringList& l,
const
QString& addtoend )
const
132
{
133
if
(addtostart.isEmpty()) {
134
message
(l,addtoend);
135
return
;
136
}
137
if
(addtoend.isEmpty()) {
138
for
(
const
QString& s : l)
139
message
(addtostart+s);
140
}
else
{
141
for
(
const
QString& s : l)
142
message
(addtostart+s+addtoend);
143
}
144
}
145
146
//____________________________________________________________________
147
void
VP1HelperClassBase::messageDebug
(
const
QString& addtostart,
const
QStringList& l,
const
QString& addtoend )
const
148
{
149
if
(!
VP1Msg::debug
())
150
return
;
151
if
(addtostart.isEmpty()) {
152
messageDebug
(l,addtoend);
153
return
;
154
}
155
if
(addtoend.isEmpty()) {
156
for
(
const
QString& s : l)
157
messageDebug
(addtostart+s);
158
}
else
{
159
for
(
const
QString& s : l)
160
messageDebug
(addtostart+s+addtoend);
161
}
162
}
163
164
//____________________________________________________________________
165
void
VP1HelperClassBase::messageVerbose
(
const
QString& addtostart,
const
QStringList& l,
const
QString& addtoend )
const
166
{
167
if
(!
VP1Msg::verbose
())
168
return
;
169
if
(addtostart.isEmpty()) {
170
messageVerbose
(l,addtoend);
171
return
;
172
}
173
if
(addtoend.isEmpty()) {
174
for
(
const
QString& s : l)
175
messageVerbose
(addtostart+s);
176
}
else
{
177
for
(
const
QString& s : l)
178
messageVerbose
(addtostart+s+addtoend);
179
}
180
}
181
182
//____________________________________________________________________
183
void
VP1HelperClassBase::warnUndeletedInstances
()
184
{
185
if
(
vp1helperclassbase_instanceMap
.empty())
186
return
;
187
std::cout <<
"WARNING: Detected "
<<
vp1helperclassbase_instanceMap
.size()<<
" undeleted helper class instances:"
<<std::endl;
188
189
std::map<VP1HelperClassBase*,QString>::iterator it,itE(
vp1helperclassbase_instanceMap
.end());
190
for
(it =
vp1helperclassbase_instanceMap
.begin();it!=itE;++it) {
191
std::cout <<
" ==> "
<<it->first<<
": "
<<it->first->m_helpername.toStdString()
192
<< (it->second.isEmpty()?QString(
""
):
" (in system "
+it->second+
")"
).toStdString()<<std::endl;
193
}
194
}
195
196
//____________________________________________________________________
197
void
VP1HelperClassBase::setSystemBasePointer
(
IVP1System
*sys)
198
{
199
m_system
= sys;
200
if
(
VP1Msg::verbose
()){
201
vp1helperclassbase_instanceMap
[
this
] = (
m_system
?
m_system
->name():QString(
""
));
202
}
203
}
IVP1System.h
vp1helperclassbase_instanceMap
static std::map< VP1HelperClassBase *, QString > vp1helperclassbase_instanceMap
Definition
VP1HelperClassBase.cxx:25
VP1HelperClassBase.h
VP1Msg.h
VP1QtUtils.h
IVP1System
Definition
IVP1System.h:36
IVP1System::message
void message(const QString &) const
Definition
IVP1System.cxx:336
VP1HelperClassBase::m_helpername
QString m_helpername
Definition
VP1HelperClassBase.h:67
VP1HelperClassBase::~VP1HelperClassBase
virtual ~VP1HelperClassBase()
Definition
VP1HelperClassBase.cxx:38
VP1HelperClassBase::s_vp1verbose
static const bool s_vp1verbose
Definition
VP1HelperClassBase.h:69
VP1HelperClassBase::VP1HelperClassBase
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
Definition
VP1HelperClassBase.cxx:28
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition
VP1HelperClassBase.cxx:78
VP1HelperClassBase::warnUndeletedInstances
static void warnUndeletedInstances()
Definition
VP1HelperClassBase.cxx:183
VP1HelperClassBase::message
void message(const QString &) const
Definition
VP1HelperClassBase.cxx:49
VP1HelperClassBase::m_system
IVP1System * m_system
Definition
VP1HelperClassBase.h:68
VP1HelperClassBase::setSystemBasePointer
void setSystemBasePointer(IVP1System *sys)
Definition
VP1HelperClassBase.cxx:197
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition
VP1HelperClassBase.cxx:65
VP1Msg::debug
static bool debug()
Definition
VP1Msg.h:32
VP1Msg::verbose
static bool verbose()
Definition
VP1Msg.h:31
VP1Msg::prefix_msg
static const char * prefix_msg()
Definition
VP1Msg.h:56
VP1Msg::prefix_debug
static const char * prefix_debug()
Definition
VP1Msg.h:57
VP1Msg::prefix_verbose
static const char * prefix_verbose()
Definition
VP1Msg.h:59
VP1QtUtils::environmentVariableIsOn
static bool environmentVariableIsOn(const QString &name)
Definition
VP1QtUtils.cxx:127
str
Definition
BTagTrackIpAccessor.cxx:11
Generated on
for ATLAS Offline Software by
1.17.0