svcore
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2010-2011 Chris Cannam and QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _DEBUG_H_ 00017 #define _DEBUG_H_ 00018 00019 #include <QDebug> 00020 #include <QTextStream> 00021 00022 #include <vamp-hostsdk/RealTime.h> 00023 00024 #include <string> 00025 #include <iostream> 00026 00027 class QString; 00028 class QUrl; 00029 00030 QDebug &operator<<(QDebug &, const std::string &); 00031 std::ostream &operator<<(std::ostream &, const QString &); 00032 std::ostream &operator<<(std::ostream &, const QUrl &); 00033 00034 using std::cout; 00035 using std::cerr; 00036 using std::endl; 00037 00038 #ifndef NDEBUG 00039 00040 extern QDebug &getSVDebug(); 00041 00042 #define SVDEBUG getSVDebug() 00043 00044 inline QDebug &operator<<(QDebug &d, const Vamp::RealTime &rt) { 00045 d << rt.toString(); 00046 return d; 00047 } 00048 00049 template <typename T> 00050 inline QDebug &operator<<(QDebug &d, const T &t) { 00051 QString s; 00052 QTextStream ts(&s); 00053 ts << t; 00054 d << s; 00055 return d; 00056 } 00057 00058 #else 00059 00060 class NoDebug 00061 { 00062 public: 00063 inline NoDebug() {} 00064 inline ~NoDebug(){} 00065 00066 template <typename T> 00067 inline NoDebug &operator<<(const T &) { return *this; } 00068 00069 inline NoDebug &operator<<(QTextStreamFunction) { return *this; } 00070 }; 00071 00072 #define SVDEBUG NoDebug() 00073 00074 #endif /* !NDEBUG */ 00075 00076 #endif /* !_DEBUG_H_ */ 00077