9 #ifndef STK_UTIL_DIAG_WRITER_HPP 10 #define STK_UTIL_DIAG_WRITER_HPP 18 #include <stk_util/diag/Writer_fwd.hpp> 31 explicit WriterThrowSafe(Writer &writer);
39 WriterThrowSafe(
const WriterThrowSafe &);
40 void operator = (
const WriterThrowSafe &);
81 struct LineMaskStack :
public std::vector<std::pair<int, PrintMask> >
89 push_back(std::pair<int, PrintMask>(0, LOG_ALWAYS));
98 LineMaskStack &pushDepth() {
99 push_back(std::make_pair(back().first + 1, back().second));
111 LineMaskStack &
push(PrintMask line_mask) {
112 push_back(std::make_pair(back().first, line_mask));
122 LineMaskStack &
pop() {
134 LineMaskStack &popLineMask() {
135 if (size() > 1 && getNextDepth() == getDepth())
146 int getDepth()
const {
157 int getLineMask()
const {
158 return back().second;
168 int getNextDepth()
const {
169 return (end() - 2)->first;
178 LineMaskStack &resetDepth() {
179 while (size() > 1 && getNextDepth() == getDepth())
196 explicit Writer(std::streambuf *streambuf, PrintMask print_mask = static_cast<PrintMask>(LOG_MEMBERS),
Flags flags = static_cast<Flags>(ENABLED));
211 return m_writerStream;
223 m_flags = (
Flags) flags;
236 int getDepth()
const {
237 return m_lineMaskStack.getDepth();
240 Writer &restoreDepth(
int depth) {
241 while (m_lineMaskStack.getDepth() > depth)
281 m_lineMaskStack.push(line_mask);
346 return (m_flags & ENABLED) != 0;
357 return line_mask == 0
358 || ((line_mask & m_printMask & stk_classic::LOG_TRACE)
361 : (line_mask & m_printMask) == line_mask);
393 return line_mask == 0
394 || (line_mask & m_printMask) != 0;
469 return ++m_traceDepth;
478 return --m_traceDepth;
490 return m_traceDepth <= 0 ? false
491 : (m_traceDepth == 1 || (m_traceDepth > 1 && (m_printMask & stk_classic::LOG_TRACE_SUB_CALLS)));
502 return isTracing() || (m_printMask & stk_classic::LOG_TRACE) != 0;
507 PrintMask m_printMask;
508 LineMaskStack m_lineMaskStack;
510 std::ostream m_writerStream;
533 return dout.dflush();
573 : m_lineMask(line_mask)
576 PrintMask m_lineMask;
601 return dout.setLineMask(set_line_mask.m_lineMask);
614 return dout.resetLineMask();
629 Writer &operator<<(Writer &dout,
const char *c_str);
630 Writer &operator<<(Writer &dout,
const std::string &str);
631 Writer &operator<<(Writer &dout,
const void *ptr);
632 Writer &operator<<(Writer &dout,
const float &x);
633 Writer &operator<<(Writer &dout,
const double &x);
634 Writer &operator<<(Writer &dout,
const long double &x);
635 Writer &operator<<(Writer &dout,
const int &x);
636 Writer &operator<<(Writer &dout,
const unsigned int &x);
637 Writer &operator<<(Writer &dout,
const long &x);
638 Writer &operator<<(Writer &dout,
const unsigned long &x);
639 Writer &operator<<(Writer &dout,
const short &x);
640 Writer &operator<<(Writer &dout,
const unsigned short &x);
641 Writer &operator<<(Writer &dout,
const long long &x);
642 Writer &operator<<(Writer &dout,
const unsigned long long &x);
685 template <
class T,
typename R>
723 template <
class T,
typename R>
742 Writer &operator<<(Writer &dout, const c_ptr_<T> &c) {
743 dout <<
"(pointer " << (
void *) c.m_t <<
"), ";
748 dout <<
"<not created>";
767 template <
class T,
typename R>
768 Writer &operator<<(Writer &dout, const c_ptr_func_<T, R> &c) {
770 dout <<
"(pointer), " << (c.m_t->*c.m_pmf)();
772 dout <<
"(pointer), <not created>";
785 #include <stk_util/diag/WriterManip.hpp> 811 #include <stk_util/diag/WriterExt.hpp> 813 #endif // STK_UTIL_DIAG_WRITER_HPP Writer & resetLineMask()
Member function pop is a manipulator which decreases the line mask depth by one, but not less than ze...
const T * m_t
Pointer to object.
_setlinemask(PrintMask line_mask)
Creates a new setlinemask instance.
Writer & dflush()
Member function dflush flushes the output stream.
Writer & operator<<(Writer &(*f)(Writer &))
Member function operator<< is the manipulator instantiation function.
R(T::* m_pmf)() const
Function to call for dump.
int incTraceDepth()
Member function incTraceDepth increments the tracing count.
Writer & pop(Writer &dout)
Member function pop calls the Writer::pop manipulator.
Writer & setFlags(int flags)
Member function setFlags sets the flags bitmask which describes the output line prefix content...
Writer & setLineMask(PrintMask line_mask)
Member function setPrintMask sets the print output mask.
PrintMask getPrintMask()
Member function getLineMask returns the current line mask.
Writer & dendl()
Member function dendl is a manipulator which sets the output stream to a new line.
bool isTraceable()
Member function isTraceable returns true if currently tracing or tracing is enabled.
Writer & dflush(Writer &dout)
Writer function dflush calls the Writer::dflush manipulator.
const T * m_t
Pointer to object.
bool isEnabled()
Member function isEnabled returns true if the ENABLED bit is set in the flags bitmask.
Writer & push()
Member function push is a manipulator which increases the line mask depth by one. ...
c_ptr_< T > c_ptr(const T *t)
Writer(std::streambuf *streambuf, PrintMask print_mask=static_cast< PrintMask >(LOG_MEMBERS), Flags flags=static_cast< Flags >(ENABLED))
Creates a new Writer instance with the specified print mask and output flags.
Class c_ptr_func_ simply stores a pointer to an object of type T. This allows pointers which want to ...
~Writer()
Destroys a Writer instance.
std::ostream & getStream()
Member function getStream returns the output stream.
bool isLoggable(PrintMask line_mask)
Member function isLoggable returns true if any corresponding bit in the line mask matches a bit in th...
bool shouldPrint()
Member function shouldPrint returns true if the line should print.
Writer & t(PrintMask line_mask=0)
Member function t sets the line mask of this line to line_make bitwise or'ed with LOG_TRACE...
Writer & dendl(Writer &dout)
Writer function dendl calls the Writer::dendl manipulator.
c_ptr_func_(const T *t, R(T::*pmf)() const)
Class c_ptr_ simply stores a pointer to an object of type T. This allows pointers which want to be de...
Writer & setPrintMask(PrintMask mask=0)
Member function setPrintMask sets the print output mask.
Class Writer implements a runtime selectable diagnostic output writer to aid in the development and d...
int getFlags()
Member function getFlags returns the flags bitmask.
Writer & m(PrintMask line_mask)
Member function m sets the line mask of this line.
int decTraceDepth()
Member function decTraceDepth decrements the tracing count.
bool shouldPrint(PrintMask line_mask)
Member function shouldPrint returns true if the line should print.
Writer & resetlinemask(Writer &dout)
Function resetlinemask calls the Writer::resetLineMask manipulator.
bool isTracing()
Member function isTracing returns true of the trace depth is greater than zero. The value of -1 is in...
bool shouldTrace(int line_mask)
Member function shouldTrace returns true if any corresponding bit in the line mask matches a bit in t...
c_ptr_func_< T, R > c_ptr_func(const T *t, R(T::*pmf)() const)
Template function c_ptr creates a c_ptr_func_ object of type T ala std::make_pair. This T must implement a member function which takes no arguments and returns a value of type R.
_setlinemask setlinemask(PrintMask line_mask)
Function setlinemask sets the active line mask bits as a manipulator.
Class _setlinemask is the line mask manipulator.
Writer & pop()
Member function pop is a manipulator which decreases the line mask depth by one, but not less than ze...
Writer & push(Writer &dout)
Function push calls the Writer::push manipulator.
Writer & w(bool on, PrintMask line_mask)
Member function m sets the line mask of this line.