00001
00002
00003 #ifndef ASGTOOLS_MSGSTREAM_H
00004 #define ASGTOOLS_MSGSTREAM_H
00005
00006
00007 #include <string>
00008 #include <sstream>
00009
00010
00011 #include "AsgTools/AsgToolsConf.h"
00012 #include "AsgTools/MsgLevel.h"
00013 #include "AsgTools/IAsgTool.h"
00014
00015 #ifdef ASGTOOL_ATHENA
00016 # include "GaudiKernel/MsgStream.h"
00017 #elif defined(ASGTOOL_STANDALONE)
00018
00030 class MsgStream : public std::ostringstream {
00031
00032 public:
00034 MsgStream( const asg::IAsgTool* tool = 0 );
00036 MsgStream( const std::string& name );
00038 MsgStream( void* msgSvc, const std::string& name, int buffer_length = 128 );
00039
00042
00044 MsgStream& operator<< ( MsgStream& ( *_f )( MsgStream& ) );
00046 MsgStream& operator<< ( std::ostream& ( *_f )( std::ostream& ) );
00048 MsgStream& operator<< ( std::ios& ( *_f )( std::ios& ) );
00049
00051 MsgStream& operator<< ( MSG::Level lvl );
00052
00054 template< class T >
00055 MsgStream& operator<< ( const T& arg ) {
00056 ( * ( std::ostringstream* ) this ) << arg;
00057 return *this;
00058 }
00059
00061
00063 MsgStream& doOutput();
00064
00066 static void setSourceWidth( size_t width );
00067
00070
00072 void setLevel( MSG::Level lvl );
00073
00075 bool msgLevel( MSG::Level lvl ) const;
00076
00078 MSG::Level level() const;
00080 MSG::Level& mutable_level();
00081
00083 MSG::Level currentLevel() const;
00084
00086
00088 const std::string& name() const;
00090 void setName( const std::string& name );
00091
00092 private:
00094 const asg::IAsgTool* m_tool;
00096 std::string m_name;
00098 MSG::Level m_lvl;
00100 MSG::Level m_reqlvl;
00102 static size_t s_sourceWidth;
00103
00104 };
00105
00107 inline MsgStream& endmsg( MsgStream& s ) {
00108 return s.doOutput();
00109 }
00111 #define endreq endmsg
00112
00113 #else
00114 # error "What environment are we in?!?"
00115 #endif // Environment selection
00116 #endif // ASGTOOLS_MSGSTREAM_H