File indexing completed on 2024-12-01 12:29:49

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #ifndef BLUEZQT_MACROS_H
0010 #define BLUEZQT_MACROS_H
0011 
0012 // clang-format off
0013 
0014 // Change property value and emit propertyChanged signal
0015 #define PROPERTY_CHANGED(var, type_cast, signal) \
0016     if (var != value.type_cast()) { \
0017         var = value.type_cast(); \
0018         Q_EMIT q.lock()->signal(var); \
0019     }
0020 
0021 #define PROPERTY_CHANGED2(var, value, signal) \
0022     const auto &val = value; \
0023     if (var != val) { \
0024         var = val; \
0025         Q_EMIT q.lock()->signal(var); \
0026     }
0027 
0028 // Clears property value and emit propertyChanged signal
0029 #define PROPERTY_INVALIDATED(var, empty, signal) \
0030     if (var != empty) { \
0031         var = empty; \
0032         Q_EMIT q.lock()->signal(var); \
0033     }
0034 
0035 #endif // BLUEZQT_MACROS_H