PageRenderTime 163ms CodeModel.GetById 91ms app.highlight 3ms RepoModel.GetById 67ms app.codeStats 0ms

/src/libtomahawk/thirdparty/kdsingleapplicationguard/kdtoolsglobal.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 114 lines | 99 code | 15 blank | 0 comment | 1 complexity | 3de58c8752b0b7236a80eb4c6c87881b MD5 | raw file
  1#ifndef __KDTOOLS_KDTOOLSGLOBAL_H__
  2#define __KDTOOLS_KDTOOLSGLOBAL_H__
  3
  4#include <QtCore/QtGlobal>
  5
  6#define KDAB_DISABLE_COPY( x ) private: x( const x & ); x & operator=( const x & )
  7
  8#ifdef KDTOOLS_SHARED
  9#  ifdef BUILD_SHARED_KDTOOLSCORE
 10#    define KDTOOLSCORE_EXPORT Q_DECL_EXPORT
 11#  else
 12#    define KDTOOLSCORE_EXPORT Q_DECL_IMPORT
 13#  endif
 14#  ifdef BUILD_SHARED_KDTOOLSGUI
 15#    define KDTOOLSGUI_EXPORT Q_DECL_EXPORT
 16#  else
 17#    define KDTOOLSGUI_EXPORT Q_DECL_IMPORT
 18#  endif
 19#  ifdef BUILD_SHARED_KDTOOLSXML
 20#    define KDTOOLSXML_EXPORT Q_DECL_EXPORT
 21#  else
 22#    define KDTOOLSXML_EXPORT Q_DECL_IMPORT
 23#  endif
 24#  ifdef BUILD_SHARED_KDUPDATER
 25#    define KDTOOLS_UPDATER_EXPORT    Q_DECL_EXPORT
 26#  else
 27#    define KDTOOLS_UPDATER_EXPORT    Q_DECL_IMPORT
 28#  endif
 29#else // KDTOOLS_SHARED
 30#  define KDTOOLSCORE_EXPORT
 31#  define KDTOOLSGUI_EXPORT
 32#  define KDTOOLSXML_EXPORT
 33#  define KDTOOLS_UPDATER_EXPORT
 34#endif // KDTOOLS_SHARED
 35
 36#define MAKEINCLUDES_EXPORT
 37
 38#define DOXYGEN_PROPERTY( x )
 39#ifdef DOXYGEN_RUN
 40# define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) operator unspecified_bool_type() const { return func; }
 41# define KDAB_USING_SAFE_BOOL_OPERATOR( Class ) operator unspecified_bool_type() const;
 42#else
 43# define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func )                      \
 44    private:                                                            \
 45        struct __safe_bool_dummy__ { void nonnull() {} };               \
 46    public:                                                             \
 47        typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
 48        operator unspecified_bool_type() const {                        \
 49            return ( func ) ? &__safe_bool_dummy__::nonnull : 0 ;       \
 50        }
 51#define KDAB_USING_SAFE_BOOL_OPERATOR( Class ) \
 52    using Class::operator Class::unspecified_bool_type;
 53#endif
 54
 55#define KDTOOLS_MAKE_RELATION_OPERATORS( Class, linkage )             \
 56    linkage bool operator>( const Class & lhs, const Class & rhs ) {  \
 57        return operator<( rhs, lhs );                                 \
 58    }                                                                 \
 59    linkage bool operator!=( const Class & lhs, const Class & rhs ) { \
 60        return !operator==( lhs, rhs );                               \
 61    }                                                                 \
 62    linkage bool operator<=( const Class & lhs, const Class & rhs ) { \
 63        return !operator>( lhs, rhs );                                \
 64    }                                                                 \
 65    linkage bool operator>=( const Class & lhs, const Class & rhs ) { \
 66        return !operator<( lhs, rhs );                                \
 67    }
 68
 69template <typename T>
 70inline T & __kdtools__dereference_for_methodcall( T & o ) {
 71    return o;
 72}
 73
 74template <typename T>
 75inline T & __kdtools__dereference_for_methodcall( T * o ) {
 76    return *o;
 77}
 78
 79#define KDAB_SET_OBJECT_NAME( x ) __kdtools__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
 80
 81KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( int major, int minor=0, int patchlevel=0 );
 82static inline bool kdCheckQtVersion( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 ) {
 83    return (major<<16|minor<<8|patchlevel) <= static_cast<unsigned int>(QT_VERSION)
 84	|| _kdCheckQtVersion_impl( major, minor, patchlevel );
 85}
 86
 87#define KDTOOLS_DECLARE_PRIVATE_BASE( Class )                        \
 88protected:                                                           \
 89    class Private;                                                   \
 90    Private * d_func() { return _d; }                                \
 91    const Private * d_func() const { return _d; }                    \
 92    Class( Private * _d_, bool b ) : _d( _d_ ) { init(b); }          \
 93private:                                                             \
 94    void init(bool);                                                 \
 95private:                                                             \
 96    Private * _d
 97
 98#define KDTOOLS_DECLARE_PRIVATE_DERIVED( Class, Base )                  \
 99protected:                                                              \
100    class Private;                                                      \
101    Private * d_func() {                                                \
102        return reinterpret_cast<Private*>( Base::d_func() );            \
103    }                                                                   \
104    const Private * d_func() const {                                    \
105        return reinterpret_cast<const Private*>( Base::d_func() );      \
106    }                                                                   \
107    Class( Private * _d_, bool b )                                      \
108        : Base( reinterpret_cast<Base::Private*>(_d_), b ) { init(b); } \
109private:                                                                \
110    void init(bool)
111
112
113#endif /* __KDTOOLS_KDTOOLSGLOBAL_H__ */
114