1 /****************************************************************************
2 ** Copyright (C) 2001-2007 Klarälvdalens Datakonsult AB. All rights reserved.
4 ** This file is part of the KD Tools library.
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
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__
28 #define KDAB_DISABLE_COPY( x ) private: x( const x & ); x & operator=( const x & )
31 # define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) operator unspecified_bool_type() const { return func; }
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 )(); \
37 operator unspecified_bool_type() const { \
38 return ( func ) ? &__safe_bool_dummy__::nonnull : 0 ; \
42 #define KDTOOLS_MAKE_RELATION_OPERATORS( Class, linkage ) \
43 linkage bool operator>( const Class & lhs, const Class & rhs ) { \
44 return operator<( lhs, rhs ); \
46 linkage bool operator!=( const Class & lhs, const Class & rhs ) { \
47 return !operator==( lhs, rhs ); \
49 linkage bool operator<=( const Class & lhs, const Class & rhs ) { \
50 return !operator>( lhs, rhs ); \
52 linkage bool operator>=( const Class & lhs, const Class & rhs ) { \
53 return !operator<( lhs, rhs ); \
57 inline T
& __kdtools__dereference_for_methodcall( T
& o
) {
62 inline T
& __kdtools__dereference_for_methodcall( T
* 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__ */