00001
00002 #ifndef SCT_MULTIMESSAGEDEBUGSTREAM_H
00003 #define SCT_MULTIMESSAGEDEBUGSTREAM_H
00004
00005 #include <sstream>
00006 #include <iostream>
00007
00008 namespace Sct {
00009
00010 class MultiMessageDebugStream {
00011 private:
00012 const bool m_out;
00013 const bool m_err;
00014 const bool m_mrs;
00015 unsigned int m_severity;
00016 std::ostringstream * m_oss;
00018 bool renew();
00019 void announce(const std::string & s);
00020 public:
00021 MultiMessageDebugStream(const bool out=true,
00022 const bool err=true,
00023 const bool mrs=true);
00024 ~MultiMessageDebugStream();
00025 void flush();
00026 void severity(unsigned int i);
00027 template <class T> MultiMessageDebugStream & operator<<(const T & t) {
00028 if (m_oss) {
00029
00030 (*m_oss) << t;
00031 } else {
00032
00033 if (this->renew()) {
00034
00035 (*m_oss) << t;
00036 } else {
00037
00038
00039
00040 if (m_out) {
00041 std::cout << "MultiMessageDubugStreamEmergencyChunk[" << t << "]"
00042 << std::flush;
00043 };
00044 if (m_err) {
00045 std::cerr << "MultiMessageDubugStreamEmergencyChunk[" << t << "]"
00046 << std::flush;
00047 };
00048 };
00049 };
00050
00051 return *this;
00052 };
00053 };
00054
00055 };
00056
00057 #endif