00001
00002 #include "MultiMessageDebugStream.h"
00003
00004 #include "mrs/message.h"
00005 #include "SctNames.h"
00006
00007 namespace Sct {
00008
00009 bool MultiMessageDebugStream::renew() {
00010 return (m_oss = new std::ostringstream);
00011 };
00012
00013 MultiMessageDebugStream::MultiMessageDebugStream(const bool out,
00014 const bool err,
00015 const bool mrs) :
00016 m_out(out),
00017 m_err(err),
00018 m_mrs(mrs),
00019 m_oss(0) {
00020 };
00021
00022 MultiMessageDebugStream::~MultiMessageDebugStream() {
00023 this->flush();
00024 delete m_oss;
00025 m_oss=0;
00026 };
00027
00028 void MultiMessageDebugStream::flush() {
00029 if (m_oss) {
00030 const std::string s = m_oss->str();
00031 delete m_oss;
00032 m_oss=0;
00033 this->announce(s);
00034 };
00035 };
00036
00037 void MultiMessageDebugStream::announce(const std::string & s) {
00038 if (m_out) {
00039 std::cout << s << std::endl;
00040 };
00041 if (m_err) {
00042 std::cerr << s << std::endl;
00043 };
00044 if (m_mrs) {
00045 IPCPartition p(SctNames::getPartitionName());
00046 if(p.isValid()) {
00047 MRSStream mrs(p);
00048 mrs << MRS_INFORMATION << "MultiMessageDebugStream" << MRS_TEXT(s) << ENDM;
00049 };
00050 };
00051 };
00052
00053
00054 };