ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
TrigConf::MsgStreamTC Class Reference

MsgStreamTC class to be used in TrigConf equivalent to Gaudi's MsgStream. More...

#include <MsgStream.h>

Inheritance diagram for TrigConf::MsgStreamTC:
Collaboration diagram for TrigConf::MsgStreamTC:

Public Member Functions

 MsgStreamTC (const std::string &name)
 
MSGTC::Level level ()
 Return message level of stream. More...
 
void setLevel (MSGTC::Level lvl)
 Set message level of stream. More...
 
void setWidth (unsigned int width)
 
MsgStreamTCoperator<< (MSGTC::Level lvl)
 Output operator for message levels. More...
 
template<typename T >
MsgStreamTCoperator<< (const T &t)
 Output operator for default types. More...
 
MsgStreamTCoperator<< (std::ios &(*f)(std::ios &))
 Output operator for stream modifiers. More...
 
MsgStreamTCoperator<< (std::ostream &(*f)(std::ostream &))
 Output operator to support endl, etc. More...
 
MsgStreamTCoperator<< (MsgStreamTC &(*f)(MsgStreamTC &))
 Output operator to support endmsg, etc. More...
 
void doOutput ()
 Print the current message buffer. More...
 
bool isActive ()
 Is the stream active? More...
 
void setName (const std::string &name)
 set the name if you want to change the message stream name More...
 

Private Attributes

bool m_active
 stream active? More...
 
MSGTC::Level m_level
 stream level More...
 
MSGTC::Level m_msgLevel
 current message level More...
 
std::string m_name
 stream name More...
 
unsigned int m_width { 30 }
 width for printing owner name More...
 

Detailed Description

MsgStreamTC class to be used in TrigConf equivalent to Gaudi's MsgStream.

The usage and behavior is identical to the default Gaudi message stream. If the code is run within a Gaudi/Athena environment, the MsgStreamTC will try to print its messages via the Gaudi MessageSvc. This is achieved via weak linking. In a non-Gaudi/Athena environment std::cout will be used. The class can be used directly or better via inheriting from TrigConf::TrigConfMessaging, which is the equivalent of AthMessaging.

Main difference to Gaudi MsgStream:

Definition at line 48 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

Constructor & Destructor Documentation

◆ MsgStreamTC()

MsgStreamTC::MsgStreamTC ( const std::string &  name)

Definition at line 42 of file Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx.

42  :
43  m_active(false),
45  m_name(name)
46 {
47  // Initialize our own OutputLevel to the global one from the MessageSvc
49 }

Member Function Documentation

◆ doOutput()

void MsgStreamTC::doOutput ( )

Print the current message buffer.

Definition at line 60 of file Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx.

61 {
62  if (getMessageSvc()) {
64  }
65  else {
66  std::ios::fmtflags f( std::cout.flags() );
67  std::cout << std::setw(m_width) << std::left << m_name << " " << levelNames[m_msgLevel] << " " << str() << std::endl;
68  std::cout.flags(f);
69  }
70  str(""); // Clear our buffer after message has been printed
71 }

◆ isActive()

bool TrigConf::MsgStreamTC::isActive ( )
inline

Is the stream active?

Definition at line 99 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

99 { return m_active; }

◆ level()

MSGTC::Level TrigConf::MsgStreamTC::level ( )
inline

Return message level of stream.

Definition at line 53 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

53 {return m_level;}

◆ operator<<() [1/5]

template<typename T >
MsgStreamTC& TrigConf::MsgStreamTC::operator<< ( const T &  t)
inline

Output operator for default types.

Definition at line 72 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

72  {
73  if (m_active) *static_cast<std::ostringstream*>(this) << t;
74  return *this;
75  }

◆ operator<<() [2/5]

MsgStreamTC& TrigConf::MsgStreamTC::operator<< ( MsgStreamTC &(*)(MsgStreamTC &)  f)
inline

Output operator to support endmsg, etc.

Definition at line 90 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

90  {
91  if (m_active) f(*this);
92  return *this;
93  }

◆ operator<<() [3/5]

MsgStreamTC& TrigConf::MsgStreamTC::operator<< ( MSGTC::Level  lvl)
inline

Output operator for message levels.

Definition at line 64 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

64  {
65  lvl = (lvl >= MSGTC::NUM_LEVELS) ? MSGTC::ALWAYS : (lvl<MSGTC::NIL) ? MSGTC::NIL : lvl;
66  m_active = ((m_msgLevel=lvl) >= m_level); // active if message level >= stream level
67  return *this;
68  }

◆ operator<<() [4/5]

MsgStreamTC& TrigConf::MsgStreamTC::operator<< ( std::ios &(*)(std::ios &)  f)
inline

Output operator for stream modifiers.

Definition at line 78 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

78  {
79  if (m_active) f(*this);
80  return *this;
81  }

◆ operator<<() [5/5]

MsgStreamTC& TrigConf::MsgStreamTC::operator<< ( std::ostream &(*)(std::ostream &)  f)
inline

Output operator to support endl, etc.

Definition at line 84 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

84  {
85  if (m_active) f(*this);
86  return *this;
87  }

◆ setLevel()

void MsgStreamTC::setLevel ( MSGTC::Level  lvl)

Set message level of stream.

Definition at line 52 of file Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx.

52  {
53  lvl = (lvl >= MSGTC::NUM_LEVELS) ? MSGTC::ALWAYS : (lvl<MSGTC::NIL) ? MSGTC::NIL : lvl;
54  m_level = lvl;
55  if (getMessageSvc()) {
57  }
58 }

◆ setName()

void TrigConf::MsgStreamTC::setName ( const std::string &  name)
inline

set the name if you want to change the message stream name

Definition at line 102 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

102 { m_name = name; }

◆ setWidth()

void TrigConf::MsgStreamTC::setWidth ( unsigned int  width)
inline

Definition at line 59 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

59  {
60  m_width = width;
61  }

Member Data Documentation

◆ m_active

bool TrigConf::MsgStreamTC::m_active
private

stream active?

Definition at line 105 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

◆ m_level

MSGTC::Level TrigConf::MsgStreamTC::m_level
private

stream level

Definition at line 106 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

◆ m_msgLevel

MSGTC::Level TrigConf::MsgStreamTC::m_msgLevel
private

current message level

Definition at line 107 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.

◆ m_name

std::string TrigConf::MsgStreamTC::m_name
private

◆ m_width

unsigned int TrigConf::MsgStreamTC::m_width { 30 }
private

width for printing owner name

Definition at line 109 of file Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h.


The documentation for this class was generated from the following files:
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
TrigConf::MsgStreamTC::m_active
bool m_active
stream active?
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:105
Athena::outputLevel
int outputLevel(const IMessageSvc *ims, const std::string &source)
Definition: getMessageSvc.cxx:47
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TrigConf::MsgStreamTC::m_name
std::string m_name
stream name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:108
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
TrigConf::MSGTC::INFO
@ INFO
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:25
TrigConf::MsgStreamTC::m_width
unsigned int m_width
width for printing owner name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:109
Athena::setOutputLevel
void setOutputLevel(IMessageSvc *ims, const std::string &source, int level)
Definition: getMessageSvc.cxx:52
TrigConf::name
Definition: HLTChainList.h:35
TrigConf::MSGTC::NUM_LEVELS
@ NUM_LEVELS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TrigConf::MsgStreamTC::m_msgLevel
MSGTC::Level m_msgLevel
current message level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:107
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
TrigConf::MsgStreamTC::m_level
MSGTC::Level m_level
stream level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:106
Athena::reportMessage
void reportMessage(IMessageSvc *ims, const std::string &source, int type, const std::string &message)
Wrappers for some of the IMessageSvc methods These can be used from libraries without explicit Gaudi ...
Definition: getMessageSvc.cxx:43