File indexing completed on 2024-05-12 16:59:21

0001 /*
0002  *   SPDX-FileCopyrightText: 2015-2016 Ivan Cukic <ivan.cukic@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef DEBUG_AND_RETURN_H
0008 #define DEBUG_AND_RETURN_H
0009 
0010 #ifdef QT_DEBUG
0011 #include <QDebug>
0012 #endif
0013 
0014 namespace kamd
0015 {
0016 namespace utils
0017 {
0018 template<typename T>
0019 T debug_and_return(const char *message, T &&value)
0020 {
0021 #ifdef QT_DEBUG
0022     qCDebug(KAMD_LOG_RESOURCES) << message << " " << value;
0023 #endif
0024 
0025     return std::forward<T>(value);
0026 }
0027 
0028 template<typename T>
0029 T debug_and_return(bool debug, const char *message, T &&value)
0030 {
0031 #ifdef QT_DEBUG
0032     if (debug) {
0033         qCDebug(KAMD_LOG_RESOURCES) << message << " " << value;
0034     }
0035 #endif
0036 
0037     return std::forward<T>(value);
0038 }
0039 
0040 } // namespace utils
0041 } // namespace kamd
0042 
0043 #endif // DEBUG_AND_RETURN_H