ATLAS Offline Software
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGCONFBASE_MSGSTREAM_H
6 #define TRIGCONFBASE_MSGSTREAM_H 1
7 
13 #include <sstream>
14 
15 class IMessageSvc;
16 
17 namespace TrigConf {
18 
20  namespace MSGTC {
21  enum Level {
22  NIL = 0,
31  };
32  }
33 
48  class MsgStreamTC : public std::ostringstream {
49  public:
50  MsgStreamTC(const std::string& name);
51 
54 
56  void setLevel(MSGTC::Level lvl);
57 
58  // set width for printing the name
59  void setWidth(unsigned int width) {
60  m_width = width;
61  }
62 
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  }
69 
71  template<typename T>
72  MsgStreamTC& operator<< (const T& t) {
73  if (m_active) *static_cast<std::ostringstream*>(this) << t;
74  return *this;
75  }
76 
78  MsgStreamTC& operator<< (std::ios& (*f)(std::ios&)) {
79  if (m_active) f(*this);
80  return *this;
81  }
82 
84  MsgStreamTC& operator<< ( std::ostream& (*f)(std::ostream&)) {
85  if (m_active) f(*this);
86  return *this;
87  }
88 
91  if (m_active) f(*this);
92  return *this;
93  }
94 
96  void doOutput();
97 
99  bool isActive() { return m_active; }
100 
102  void setName(const std::string & name) { m_name = name; }
103 
104  private:
105  bool m_active;
108  std::string m_name;
109  unsigned int m_width { 30 };
110  };
111 
114  if (s.isActive()) s.doOutput();
115  return s;
116  }
117 
118 } // namespace TrigConf
119 
120 #endif
TrigConf::MsgStreamTC::setWidth
void setWidth(unsigned int width)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:59
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:128
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TrigConf::MsgStreamTC::doOutput
void doOutput()
Print the current message buffer.
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:60
TrigConf::MSGTC::DEBUG
@ DEBUG
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:24
TrigConf::MsgStreamTC::m_active
bool m_active
stream active?
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:105
TrigConf::MSGTC::ERROR
@ ERROR
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:27
TrigConf::MSGTC::FATAL
@ FATAL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:28
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
TrigConf::MsgStreamTC::isActive
bool isActive()
Is the stream active?
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:99
TrigConf::MsgStreamTC::m_name
std::string m_name
stream name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:108
TrigConf::endmsgtc
MsgStreamTC & endmsgtc(MsgStreamTC &s)
End of message.
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:113
TrigConf::MsgStreamTC::operator<<
MsgStreamTC & operator<<(MSGTC::Level lvl)
Output operator for message levels.
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:64
TrigConf::MsgStreamTC
MsgStreamTC class to be used in TrigConf equivalent to Gaudi's MsgStream.
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:48
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::VERBOSE
@ VERBOSE
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:23
TrigConf::MSGTC::INFO
@ INFO
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:25
TrigConf::MsgStreamTC::level
MSGTC::Level level()
Return message level of stream.
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:53
TrigConf::MsgStreamTC::m_width
unsigned int m_width
width for printing owner name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:109
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:221
TrigConf::MsgStreamTC::MsgStreamTC
MsgStreamTC(const std::string &name)
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:42
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
TrigConf::MsgStreamTC::setName
void setName(const std::string &name)
set the name if you want to change the message stream name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:102
TrigConf::MsgStreamTC::setLevel
void setLevel(MSGTC::Level lvl)
Set message level of stream.
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:52
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
TrigConf::MSGTC::WARNING
@ WARNING
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:26