ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaBaseComps
AthenaBaseComps
AthMessaging.h
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// AthMessaging.h
8
// Header file for class AthMessaging
9
// Author: S.Binet<binet@cern.ch>, Frank Winklmeier
11
#ifndef ATHENABASECOMPS_ATHMESSAGING_H
12
#define ATHENABASECOMPS_ATHMESSAGING_H 1
13
14
// STL includes
15
#include <iosfwd>
16
#include <string>
17
#include <atomic>
18
19
// framework includes
20
#include "GaudiKernel/IMessageSvc.h"
21
#include "GaudiKernel/MsgStream.h"
22
#include "Gaudi/Property.h"
23
#include "
AthenaBaseComps/AthMsgStreamMacros.h
"
24
#include "
CxxUtils/checker_macros.h
"
25
26
#include <boost/thread/tss.hpp>
27
28
54
class
AthMessaging
55
{
56
58
// Public methods:
60
public
:
61
66
AthMessaging
(IMessageSvc* msgSvc,
const
std::string& name);
67
71
AthMessaging
(
const
std::string& name);
72
74
virtual
~AthMessaging
();
75
77
// Const methods:
79
85
bool
86
msgLvl
(
const
MSG::Level lvl)
const
;
87
92
MsgStream&
msg
()
const
;
93
98
MsgStream&
99
msg
(
const
MSG::Level lvl)
const
;
100
102
// Non-const methods:
104
108
void
setLevel
(MSG::Level lvl);
109
111
// Private methods:
113
private
:
114
116
AthMessaging
();
//> not implemented
117
AthMessaging
(
const
AthMessaging
& rhs );
//> not implemented
118
AthMessaging
&
operator=
(
const
AthMessaging
& rhs );
//> not implemented
119
121
void
initMessaging
()
const
;
122
124
// Private data:
126
private
:
127
129
std::string
m_nm
;
130
132
mutable
boost::thread_specific_ptr<MsgStream>
m_msg_tls
;
133
135
mutable
std::atomic<IMessageSvc*>
m_imsg
{
nullptr
};
136
138
mutable
std::atomic<MSG::Level>
m_lvl
{ MSG::NIL };
139
141
mutable
std::atomic_flag m_initialized
ATLAS_THREAD_SAFE
= ATOMIC_FLAG_INIT;
142
143
};
144
146
// Inline methods:
148
149
inline
150
bool
151
AthMessaging::msgLvl
(
const
MSG::Level lvl)
const
152
{
153
// If user did not set explicit message level we have to initialize
154
// the messaging and retrieve the default via the MessageSvc.
155
if
(
m_lvl
==MSG::NIL && !m_initialized.test_and_set())
initMessaging
();
156
157
if
(
m_lvl
<= lvl) {
158
msg
() << lvl;
159
return
true
;
160
}
else
{
161
return
false
;
162
}
163
}
164
165
inline
166
MsgStream&
167
AthMessaging::msg
()
const
168
{
169
MsgStream* ms =
m_msg_tls
.get();
170
if
(!ms) {
171
if
(!m_initialized.test_and_set())
initMessaging
();
172
ms =
new
MsgStream(
m_imsg
,
m_nm
);
173
m_msg_tls
.reset( ms );
174
}
175
176
ms->setLevel (
m_lvl
);
177
return
*ms;
178
}
179
180
inline
181
MsgStream&
182
AthMessaging::msg
(
const
MSG::Level lvl)
const
183
{
return
msg
() << lvl; }
184
185
186
#endif
//> !ATHENABASECOMPS_ATHMESSAGING_H
AthMsgStreamMacros.h
checker_macros.h
Define macros for attributes used to control the static checker.
AthMessaging::operator=
AthMessaging & operator=(const AthMessaging &rhs)
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
Definition
AthMessaging.h:132
AthMessaging::ATLAS_THREAD_SAFE
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging).
Definition
AthMessaging.h:141
AthMessaging::setLevel
void setLevel(MSG::Level lvl)
Change the current logging level.
Definition
AthMessaging.cxx:28
AthMessaging::AthMessaging
AthMessaging(const AthMessaging &rhs)
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition
AthMessaging.h:129
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition
AthMessaging.h:135
AthMessaging::~AthMessaging
virtual ~AthMessaging()
Destructor:
Definition
AthMessaging.cxx:24
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition
AthMessaging.h:167
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition
AthMessaging.h:138
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition
AthMessaging.h:151
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition
AthMessaging.cxx:39
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
Generated on
for ATLAS Offline Software by
1.17.0