wxutils.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00007 /*  This is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2 of the License, or (at your option) any later version.
00011  *
00012  *  This software is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Lesser General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public
00018  *  License along with this software. If not, see
00019  *  <http://www.gnu.org/licenses/>.
00020  *
00021  */
00022 
00023 #ifndef _BASE_WX_WXUTILS_H
00024 #define _BASE_WX_WXUTILS_H
00025 
00026 #include <hugin_utils/utils.h>
00027 
00028 // use trace function under windows, because usually there is
00029 // no stdout under windows
00030 #ifdef __WXMSW__
00031     #include <wx/string.h>
00032     #include <wx/log.h>
00033 
00034     #ifdef DEBUG
00035         #undef DEBUG_TRACE
00036         #undef DEBUG_DEBUG
00037         #undef DEBUG_INFO
00038         #undef DEBUG_NOTICE
00039 
00040         // debug trace
00041 //      #define DEBUG_TRACE(msg) { std::stringstream o; o << "TRACE " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str());}
00042         #define DEBUG_TRACE(msg) { std::cerr << "TRACE " << DEBUG_HEADER << msg << std::endl; }
00043         // low level debug info
00044 //      #define DEBUG_DEBUG(msg) { std::stringstream o; o << "DEBUG " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str()); }
00045         #define DEBUG_DEBUG(msg) { std::cerr << "DEBUG " << DEBUG_HEADER << msg << std::endl; }
00046         // informational debug message,
00047 //      #define DEBUG_INFO(msg) { std::stringstream o; o << "INFO " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str()); }
00048         #define DEBUG_INFO(msg) { std::cerr << "INFO " << DEBUG_HEADER << msg << std::endl; }
00049         // major change/operation should use this
00050 //      #define DEBUG_NOTICE(msg) { std::stringstream o; o << "NOTICE " << DEBUG_HEADER << msg; wxLogMessage(o.str().c_str()); }
00051         #define DEBUG_NOTICE(msg) { std::cerr << "NOTICE " << DEBUG_HEADER << msg << std::endl; }
00052     #endif
00053     
00054     #undef DEBUG_WARN
00055     #undef DEBUG_ERROR
00056     #undef DEBUG_FATAL
00057     #undef DEBUG_ASSERT
00058 
00059     // when an error occurred, but can be handled by the same function
00060     #define DEBUG_WARN(msg) { std::stringstream o; o << "WARN: " << DEBUG_HEADER << msg; wxLogWarning(wxString(o.str().c_str(), wxConvISO8859_1));}
00061     // an error occurred, might be handled by a calling function
00062     #define DEBUG_ERROR(msg) { std::stringstream o; o << "ERROR: " << DEBUG_HEADER << msg; wxLogError(wxString(o.str().c_str(),wxConvISO8859_1));}
00063     // a fatal error occurred. further program execution is unlikely
00064     #define DEBUG_FATAL(msg) { std::stringstream o; o << "FATAL: " << DEBUG_HEADER << "(): " << msg; wxLogError(wxString(o.str().c_str(),wxConvISO8859_1)); }
00065     // assertion
00066     #define DEBUG_ASSERT(cond) \
00067         do { \
00068             if (!(cond)) { \
00069                 std::stringstream o; o << "ASSERTATION: " << DEBUG_HEADER << "(): " << #cond; \
00070                     wxLogFatalError(wxString(o.str().c_str(),wxConvISO8859_1)); \
00071             } \
00072         } while(0)
00073 #endif
00074 
00075 
00076 #endif // _BASE_WX_WXUTILS_H

Generated on 21 Jan 2018 for Hugintrunk by  doxygen 1.4.7