Better wording
[kdepim.git] / kleopatra / utils / kdtoolsglobal.h
blobd3d71e9a3b1e241bbcd50d01baf83194e6d517e1
1 /****************************************************************************
2 ** Copyright (C) 2001-2007 Klarälvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Tools library.
5 **
6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file.
11 ** Licensees holding valid commercial KD Tools licenses may use this file in
12 ** accordance with the KD Tools Commercial License Agreement provided with
13 ** the Software.
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
19 ** licensing are not clear to you.
21 **********************************************************************/
23 #ifndef __KDTOOLS_KDTOOLSGLOBAL_H__
24 #define __KDTOOLS_KDTOOLSGLOBAL_H__
26 #include <qglobal.h>
28 #define KDAB_DISABLE_COPY( x ) private: x( const x & ); x & operator=( const x & )
30 #ifdef DOXYGEN_RUN
31 # define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) operator unspecified_bool_type() const { return func; }
32 #else
33 # define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) \
34 private: struct __safe_bool_dummy__ { void nonnull(); }; \
35 typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
36 public: \
37 operator unspecified_bool_type() const { \
38 return ( func ) ? &__safe_bool_dummy__::nonnull : 0 ; \
40 #endif
42 #define KDTOOLS_MAKE_RELATION_OPERATORS( Class, linkage ) \
43 linkage bool operator>( const Class & lhs, const Class & rhs ) { \
44 return operator<( lhs, rhs ); \
45 } \
46 linkage bool operator!=( const Class & lhs, const Class & rhs ) { \
47 return !operator==( lhs, rhs ); \
48 } \
49 linkage bool operator<=( const Class & lhs, const Class & rhs ) { \
50 return !operator>( lhs, rhs ); \
51 } \
52 linkage bool operator>=( const Class & lhs, const Class & rhs ) { \
53 return !operator<( lhs, rhs ); \
56 template <typename T>
57 inline T & __kdtools__dereference_for_methodcall( T & o ) {
58 return o;
61 template <typename T>
62 inline T & __kdtools__dereference_for_methodcall( T * o ) {
63 return *o;
66 #define KDAB_SET_OBJECT_NAME( x ) __kdtools__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
68 #define KDAB_SYNCHRONIZED( mutex ) if ( bool __counter_##__LINE__ = false ) {} else \
69 for ( QMutexLocker __locker_##__LINE__( &__kdtools__dereference_for_methodcall( mutex ) ) ; !__counter_##__LINE__ ; __counter_##__LINE__ = true )
71 #endif /* __KDTOOLS_KDTOOLSGLOBAL_H__ */