1 /* clang-format off */ 2 /***************************************************************************** 3 4 SPDX-FileCopyrightText: Copyright © 2010 Pavel Karelin (hkarel), <hkarel@yandex.ru> 5 SPDX-License-Identifier: MIT 6 --- 7 8 This header is defined macros of general purpose. 9 10 *****************************************************************************/ 11 12 13 #ifndef DEFMAC_H 14 #define DEFMAC_H 15 16 #pragma once 17 18 #define DISABLE_DEFAULT_CONSTRUCT( ClassName ) \ 19 ClassName () = delete; \ 20 ClassName ( ClassName && ) = delete; \ 21 ClassName ( const ClassName & ) = delete; 22 23 #define DISABLE_DEFAULT_COPY( ClassName ) \ 24 ClassName ( ClassName && ) = delete; \ 25 ClassName ( const ClassName & ) = delete; \ 26 ClassName & operator = ( ClassName && ) = delete; \ 27 ClassName & operator = ( const ClassName & ) = delete; 28 29 #define DISABLE_DEFAULT_FUNC( ClassName ) \ 30 ClassName () = delete; \ 31 ClassName ( ClassName && ) = delete; \ 32 ClassName ( const ClassName & ) = delete; \ 33 ClassName & operator = ( ClassName && ) = delete; \ 34 ClassName & operator = ( const ClassName & ) = delete; 35 36 #ifndef NDEBUG 37 #define QCONNECT_ASSERT(COND_) assert(COND_) 38 #else 39 #define QCONNECT_ASSERT(COND_) COND_ 40 #endif 41 42 /** 43 The chk_connect macro is used to check result returned by the function 44 QObject::connect() in debug mode, it looks like on assert() function. 45 However, in the release mode, unlike assert() function, test expression 46 is not removed. 47 */ 48 49 #define chk_connect(SOURCE_, SIGNAL_, DEST_, SLOT_) \ 50 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_)); 51 52 #define chk_connect_unique(SOURCE_, SIGNAL_, DEST_, SLOT_, CONNECT_TYPE_) \ 53 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_, CONNECT_TYPE_ | Qt::UniqueConnection)); 54 55 56 #define chk_connect_custom(SOURCE_, SIGNAL_, DEST_, SLOT_, CONNECT_TYPE_) \ 57 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_, CONNECT_TYPE_)); 58 59 #define chk_connect_a(SOURCE_, SIGNAL_, DEST_, SLOT_) \ 60 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_, \ 61 Qt::ConnectionType(Qt::AutoConnection | Qt::UniqueConnection))); 62 63 #define chk_connect_d(SOURCE_, SIGNAL_, DEST_, SLOT_) \ 64 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_, \ 65 Qt::ConnectionType(Qt::DirectConnection | Qt::UniqueConnection))); 66 67 #define chk_connect_q(SOURCE_, SIGNAL_, DEST_, SLOT_) \ 68 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_, \ 69 Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection))); 70 71 #define chk_connect_bq(SOURCE_, SIGNAL_, DEST_, SLOT_) \ 72 QCONNECT_ASSERT(QObject::connect(SOURCE_, SIGNAL_, DEST_, SLOT_, \ 73 Qt::ConnectionType(Qt::BlockingQueuedConnection | Qt::UniqueConnection))); 74 75 #if defined(__MINGW32__) || defined(__MINGW64__) 76 #define MINGW 77 #endif 78 79 #endif /* DEFMAC_H */ 80