PageRenderTime 103ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 54ms app.codeStats 0ms

/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 207 lines | 142 code | 28 blank | 37 comment | 13 complexity | 47134062150227e7ef5c351674e922c0 MD5 | raw file
  1/****************************************************************************
  2 **
  3 ** Copyright (C) Qxt Foundation. Some rights reserved.
  4 **
  5 ** This file is part of the QxtCore module of the Qxt library.
  6 **
  7 ** This library is free software; you can redistribute it and/or modify it
  8 ** under the terms of the Common Public License, version 1.0, as published
  9 ** by IBM, and/or under the terms of the GNU Lesser General Public License,
 10 ** version 2.1, as published by the Free Software Foundation.
 11 **
 12 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
 13 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
 14 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
 15 ** FITNESS FOR A PARTICULAR PURPOSE.
 16 **
 17 ** You should have received a copy of the CPL and the LGPL along with this
 18 ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
 19 ** included with the source distribution for more information.
 20 ** If you did not receive a copy of the licenses, contact the Qxt Foundation.
 21 **
 22 ** <http://libqxt.org>  <foundation@libqxt.org>
 23 **
 24 ****************************************************************************/
 25
 26#ifndef QXTGLOBAL_H
 27#define QXTGLOBAL_H
 28
 29#include <QtGlobal>
 30
 31#define QXT_VERSION 0x000600
 32#define QXT_VERSION_STR "0.6.0"
 33
 34//--------------------------global macros------------------------------
 35
 36#ifndef QXT_NO_MACROS
 37
 38#endif // QXT_NO_MACROS
 39
 40//--------------------------export macros------------------------------
 41
 42#define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE
 43
 44#if !defined(QXT_STATIC)
 45#    if defined(BUILD_QXT_CORE)
 46#        define QXT_CORE_EXPORT Q_DECL_EXPORT
 47#    else
 48#        define QXT_CORE_EXPORT Q_DECL_IMPORT
 49#    endif
 50#else
 51#    define QXT_CORE_EXPORT
 52#endif // BUILD_QXT_CORE
 53 
 54#if !defined(QXT_STATIC)
 55#    if defined(BUILD_QXT_GUI)
 56#        define QXT_GUI_EXPORT Q_DECL_EXPORT
 57#    else
 58#        define QXT_GUI_EXPORT Q_DECL_IMPORT
 59#    endif
 60#else
 61#    define QXT_GUI_EXPORT
 62#endif // BUILD_QXT_GUI
 63 
 64#if !defined(QXT_STATIC)
 65#    if defined(BUILD_QXT_NETWORK)
 66#        define QXT_NETWORK_EXPORT Q_DECL_EXPORT
 67#    else
 68#        define QXT_NETWORK_EXPORT Q_DECL_IMPORT
 69#    endif
 70#else
 71#    define QXT_NETWORK_EXPORT
 72#endif // BUILD_QXT_NETWORK
 73 
 74#if !defined(QXT_STATIC)
 75#    if defined(BUILD_QXT_SQL)
 76#        define QXT_SQL_EXPORT Q_DECL_EXPORT
 77#    else
 78#        define QXT_SQL_EXPORT Q_DECL_IMPORT
 79#    endif
 80#else
 81#    define QXT_SQL_EXPORT
 82#endif // BUILD_QXT_SQL
 83 
 84#if !defined(QXT_STATIC)
 85#    if defined(BUILD_QXT_WEB)
 86#        define QXT_WEB_EXPORT Q_DECL_EXPORT
 87#    else
 88#        define QXT_WEB_EXPORT Q_DECL_IMPORT
 89#    endif
 90#else
 91#    define QXT_WEB_EXPORT
 92#endif // BUILD_QXT_WEB
 93 
 94#if !defined(QXT_STATIC)
 95#    if defined(BUILD_QXT_BERKELEY)
 96#        define QXT_BERKELEY_EXPORT Q_DECL_EXPORT
 97#    else
 98#        define QXT_BERKELEY_EXPORT Q_DECL_IMPORT
 99#    endif
100#else
101#    define QXT_BERKELEY_EXPORT
102#endif // BUILD_QXT_BERKELEY
103
104#if !defined(QXT_STATIC)
105#    if defined(BUILD_QXT_ZEROCONF)
106#        define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT
107#    else
108#        define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT
109#    endif
110#else
111#    define QXT_ZEROCONF_EXPORT
112#endif // QXT_ZEROCONF_EXPORT
113
114#if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined  BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF
115#   define BUILD_QXT
116#endif
117
118QXT_CORE_EXPORT const char* qxtVersion();
119
120#ifndef QT_BEGIN_NAMESPACE
121#define QT_BEGIN_NAMESPACE
122#endif
123
124#ifndef QT_END_NAMESPACE
125#define QT_END_NAMESPACE
126#endif
127
128#ifndef QT_FORWARD_DECLARE_CLASS
129#define QT_FORWARD_DECLARE_CLASS(Class) class Class;
130#endif
131
132/****************************************************************************
133** This file is derived from code bearing the following notice:
134** The sole author of this file, Adam Higerd, has explicitly disclaimed all
135** copyright interest and protection for the content within. This file has
136** been placed in the public domain according to United States copyright
137** statute and case law. In jurisdictions where this public domain dedication
138** is not legally recognized, anyone who receives a copy of this file is
139** permitted to use, modify, duplicate, and redistribute this file, in whole
140** or in part, with no restrictions or conditions. In these jurisdictions,
141** this file shall be copyright (C) 2006-2008 by Adam Higerd.
142****************************************************************************/
143
144#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d;
145#define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
146#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this);
147#define QXT_D(PUB) PUB##Private& d = qxt_d()
148#define QXT_P(PUB) PUB& p = qxt_p()
149
150template <typename PUB>
151class QxtPrivate
152{
153public:
154    virtual ~QxtPrivate()
155    {}
156    inline void QXT_setPublic(PUB* pub)
157    {
158        qxt_p_ptr = pub;
159    }
160
161protected:
162    inline PUB& qxt_p()
163    {
164        return *qxt_p_ptr;
165    }
166    inline const PUB& qxt_p() const
167    {
168        return *qxt_p_ptr;
169    }
170
171private:
172    PUB* qxt_p_ptr;
173};
174
175template <typename PUB, typename PVT>
176class QxtPrivateInterface
177{
178    friend class QxtPrivate<PUB>;
179public:
180    QxtPrivateInterface()
181    {
182        pvt = new PVT;
183    }
184    ~QxtPrivateInterface()
185    {
186        delete pvt;
187    }
188
189    inline void setPublic(PUB* pub)
190    {
191        pvt->QXT_setPublic(pub);
192    }
193    inline PVT& operator()()
194    {
195        return *static_cast<PVT*>(pvt);
196    }
197    inline const PVT& operator()() const
198    {
199        return *static_cast<PVT*>(pvt);
200    }
201private:
202    QxtPrivateInterface(const QxtPrivateInterface&) { }
203    QxtPrivateInterface& operator=(const QxtPrivateInterface&) { }
204    QxtPrivate<PUB>* pvt;
205};
206
207#endif // QXT_GLOBAL