Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

stdio-errorhandler.cpp

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  ***************************************************************************/
00010 
00011 
00012 #include <iostream>
00013 
00014 #include "stdio-errorhandler.h"
00015 #include "messaginghub.h"
00016 
00017 void StdIoErrorHandler::printStdout( const ASCString& msg )
00018 {
00019    std::cout << msg << "\n";
00020 }
00021 void StdIoErrorHandler::printStderr( const ASCString& msg )
00022 {
00023    std::cerr << msg << "\n";
00024 }
00025 
00026 void StdIoErrorHandler::messageLogger( const ASCString& msg, int level )
00027 {
00028    // std::cout << "L" << level << ": " << msg << "\n";
00029    std::cout << msg << std::flush;
00030 }
00031 
00032 StdIoErrorHandler::StdIoErrorHandler( bool quitOnFatalError )
00033 {
00034    MessagingHub::Instance().warning.connect( SigC::slot( *this, &StdIoErrorHandler::printStderr ));
00035    MessagingHub::Instance().error.connect( SigC::slot( *this, &StdIoErrorHandler::printStderr ));
00036    MessagingHub::Instance().fatalError.connect( SigC::slot( *this, &StdIoErrorHandler::printStderr ));
00037    MessagingHub::Instance().infoMessage.connect( SigC::slot( *this, &StdIoErrorHandler::printStdout ));
00038    MessagingHub::Instance().logMessage.connect( SigC::slot( *this, &StdIoErrorHandler::messageLogger ));
00039 
00040    if ( quitOnFatalError )
00041       MessagingHub::Instance().exitHandler.connect( SigC::bind( SigC::slot( exit ), -1 ));
00042 
00043 }
00044 
00045 

Generated on Tue Jun 24 01:27:52 2008 for Advanced Strategic Command by  doxygen 1.4.2