ATLAS Offline Software
Loading...
Searching...
No Matches
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
12
13#include <sstream>
14
15class IMessageSvc;
16
17namespace TrigConf {
18
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
const double width
MsgStreamTC class to be used in TrigConf equivalent to Gaudi's MsgStream.
void setLevel(MSGTC::Level lvl)
Set message level of stream.
MsgStreamTC & operator<<(MSGTC::Level lvl)
Output operator for message levels.
void setName(const std::string &name)
set the name if you want to change the message stream name
Messsage levels matching the Gaudi definition.
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
MsgStreamTC & endmsgtc(MsgStreamTC &s)
End of message.