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