|
Sierra Toolkit
Version of the Day
|
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>
743 dout <<
"(pointer " << (
void *) c.
m_t <<
"), ";
748 dout <<
"<not created>";
767 template <
class T,
typename R>
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 & setFlags(int flags)
Member function setFlags sets the flags bitmask which describes the output line prefix content.
Writer & pop(Writer &dout)
Member function pop calls the Writer::pop manipulator.
bool shouldPrint()
Member function shouldPrint returns true if the line should print.
Class c_ptr_ simply stores a pointer to an object of type T. This allows pointers which want to be de...
Class _setlinemask is the line mask manipulator.
Writer & dflush(Writer &dout)
Writer function dflush calls the Writer::dflush manipulator.
c_ptr_func_(const T *t, R(T::*pmf)() const)
c_ptr_< T > c_ptr(const T *t)
Writer & operator<<(Writer &(*f)(Writer &))
Member function operator<< is the manipulator instantiation function.
const T * m_t
Pointer to object.
bool isTracing()
Member function isTracing returns true of the trace depth is greater than zero. The value of -1 is in...
int getFlags()
Member function getFlags returns the flags bitmask.
int decTraceDepth()
Member function decTraceDepth decrements the tracing count.
Writer & dflush()
Member function dflush flushes the output stream.
Writer & m(PrintMask line_mask)
Member function m sets the line mask of this line.
Writer & setPrintMask(PrintMask mask=0)
Member function setPrintMask sets the print output mask.
const T * m_t
Pointer to object.
Class c_ptr_func_ simply stores a pointer to an object of type T. This allows pointers which want to ...
Writer & resetLineMask()
Member function pop is a manipulator which decreases the line mask depth by one, but not less than ze...
Writer & w(bool on, PrintMask line_mask)
Member function m sets the line mask of this line.
bool isEnabled()
Member function isEnabled returns true if the ENABLED bit is set in the flags bitmask.
~Writer()
Destroys a Writer instance.
Writer & push()
Member function push is a manipulator which increases the line mask depth by one.
Writer & pop()
Member function pop is a manipulator which decreases the line mask depth by one, but not less than ze...
Writer & dendl()
Member function dendl is a manipulator which sets the output stream to a new line.
R(T::* m_pmf)() const
Function to call for dump.
Writer & dendl(Writer &dout)
Writer function dendl calls the Writer::dendl manipulator.
Writer & setLineMask(PrintMask line_mask)
Member function setPrintMask sets the print output mask.
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.
int incTraceDepth()
Member function incTraceDepth increments the tracing count.
Class Writer implements a runtime selectable diagnostic output writer to aid in the development and d...
PrintMask getPrintMask()
Member function getLineMask returns the current line mask.
bool isTraceable()
Member function isTraceable returns true if currently tracing or tracing is enabled.
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.
_setlinemask(PrintMask line_mask)
Creates a new setlinemask instance.
Writer & resetlinemask(Writer &dout)
Function resetlinemask calls the Writer::resetLineMask manipulator.
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....
Writer & push(Writer &dout)
Function push calls the Writer::push manipulator.
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(PrintMask line_mask)
Member function shouldPrint returns true if the line should print.
std::ostream & getStream()
Member function getStream returns the output stream.
_setlinemask setlinemask(PrintMask line_mask)
Function setlinemask sets the active line mask bits as a manipulator.