annotate base/Debug.h @ 1033:3a48b22fed48

Debug reporting from FileSource
author Chris Cannam
date Thu, 26 Feb 2015 09:43:12 +0000
parents 0b15c9328003
children 16dc7307d43a
rev   line source
Chris@685 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@685 2
Chris@685 3 /*
Chris@685 4 Sonic Visualiser
Chris@685 5 An audio file viewer and annotation editor.
Chris@685 6 Centre for Digital Music, Queen Mary, University of London.
Chris@685 7 This file copyright 2010-2011 Chris Cannam and QMUL.
Chris@685 8
Chris@685 9 This program is free software; you can redistribute it and/or
Chris@685 10 modify it under the terms of the GNU General Public License as
Chris@685 11 published by the Free Software Foundation; either version 2 of the
Chris@685 12 License, or (at your option) any later version. See the file
Chris@685 13 COPYING included with this distribution for more information.
Chris@685 14 */
Chris@685 15
Chris@685 16 #ifndef _DEBUG_H_
Chris@685 17 #define _DEBUG_H_
Chris@685 18
Chris@685 19 #include <QDebug>
Chris@685 20 #include <QTextStream>
Chris@843 21
Chris@871 22 #include <vamp-hostsdk/RealTime.h>
Chris@871 23
Chris@685 24 #include <string>
Chris@685 25 #include <iostream>
Chris@685 26
Chris@685 27 class QString;
Chris@685 28 class QUrl;
Chris@685 29
Chris@685 30 QDebug &operator<<(QDebug &, const std::string &);
Chris@685 31 std::ostream &operator<<(std::ostream &, const QString &);
Chris@685 32 std::ostream &operator<<(std::ostream &, const QUrl &);
Chris@685 33
Chris@843 34 using std::cout;
Chris@843 35 using std::cerr;
Chris@843 36 using std::endl;
Chris@843 37
Chris@685 38 #ifndef NDEBUG
Chris@685 39
Chris@685 40 extern QDebug &getSVDebug();
Chris@685 41
Chris@690 42 #define SVDEBUG getSVDebug()
Chris@685 43
Chris@871 44 inline QDebug &operator<<(QDebug &d, const Vamp::RealTime &rt) {
Chris@871 45 d << rt.toString();
Chris@871 46 return d;
Chris@871 47 }
Chris@871 48
Chris@685 49 template <typename T>
Chris@685 50 inline QDebug &operator<<(QDebug &d, const T &t) {
Chris@685 51 QString s;
Chris@685 52 QTextStream ts(&s);
Chris@685 53 ts << t;
Chris@685 54 d << s;
Chris@685 55 return d;
Chris@685 56 }
Chris@685 57
Chris@685 58 #else
Chris@685 59
Chris@685 60 class NoDebug
Chris@685 61 {
Chris@685 62 public:
Chris@685 63 inline NoDebug() {}
Chris@685 64 inline ~NoDebug(){}
Chris@685 65
Chris@685 66 template <typename T>
Chris@685 67 inline NoDebug &operator<<(const T &) { return *this; }
Chris@685 68
Chris@685 69 inline NoDebug &operator<<(QTextStreamFunction) { return *this; }
Chris@685 70 };
Chris@685 71
Chris@690 72 #define SVDEBUG NoDebug()
Chris@685 73
Chris@685 74 #endif /* !NDEBUG */
Chris@685 75
Chris@685 76 #endif /* !_DEBUG_H_ */
Chris@685 77