#ifndef _DebugStream_h #define _DebugStream_h #include #include #include #include #include "Timer.h" /* CLASS DebugStream Defines a class for printing logs and debug information. User may determine the extent of the debugging information actually printed by setting the debug level. KEYWORDS debug AUTHORS Meir Fuchs. (meirfux@math.tau.ac.il) Copyright: SAMBA group, Tel-Aviv Univ. Israel, 1997. CHANGES LOG
  • Defining a streamer operator that supports printing endl 16/02/04 Oranit Dror
  • Using unitbuf flag of Stream for autoflash instead of keeping our own flag 15/02/04 Dina Duhovny and Oranit Dror
  • Added two functions that allows the usage of percision both regular and in fixed floating point output 30/8/99 Zipi Fligelman
  • Added the mode of the DebugStream owning it's ostream. This enables the user to construct the DebugStream with a file name and open/close the file with the DebugStream object liveness. 5/9/99 Ram Nathaniel
  • Added the possibility to autoFlush - to make sure that debug messages are not stuck in the buffers when the program crushes. 5/9/99 Ram Nathaniel
DebugStream& operator<<(T& data); template DebugStream& operator<<(const T& data); // Zipi added to previos version since having problems //template //DebugStream& operator<<(const T*& data); // Special overload to const char * const DebugStream& operator<<(const char* const data); DebugStream& operator<<(std::ostream& (*__pf)(std::ostream&)); private: // can't be a reference since it can be an ofstream or an ostream //according to the constructor used. std::ostream *out; unsigned int dbgLevel; bool withTimer; bool withNewLine; bool withLevel; bool withIndent; Timer timer; bool active; bool ownStream; //for use if constructed with a file name. }; /************************************** * Inline Function Implementation * **************************************/ unsigned DebugStream::getDebugLevel() const { return dbgLevel; } void DebugStream::flush() { out->flush(); } /************************************** * Template Function Implementation * **************************************/ template DebugStream& DebugStream::operator<<(T& data) { if (active) *out << data; return *this; } template DebugStream& DebugStream::operator<<(const T& data) { if (active) *out << data; return *this; } #endif