/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. #ifndef QXTGLOBAL_H
  26. #define QXTGLOBAL_H
  27. #include <QtGlobal>
  28. #define QXT_VERSION 0x000600
  29. #define QXT_VERSION_STR "0.6.0"
  30. //--------------------------global macros------------------------------
  31. #ifndef QXT_NO_MACROS
  32. #endif // QXT_NO_MACROS
  33. //--------------------------export macros------------------------------
  34. #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE
  35. #if !defined(QXT_STATIC)
  36. # if defined(BUILD_QXT_CORE)
  37. # define QXT_CORE_EXPORT Q_DECL_EXPORT
  38. # else
  39. # define QXT_CORE_EXPORT Q_DECL_IMPORT
  40. # endif
  41. #else
  42. # define QXT_CORE_EXPORT
  43. #endif // BUILD_QXT_CORE
  44. #if !defined(QXT_STATIC)
  45. # if defined(BUILD_QXT_GUI)
  46. # define QXT_GUI_EXPORT Q_DECL_EXPORT
  47. # else
  48. # define QXT_GUI_EXPORT Q_DECL_IMPORT
  49. # endif
  50. #else
  51. # define QXT_GUI_EXPORT
  52. #endif // BUILD_QXT_GUI
  53. #if !defined(QXT_STATIC)
  54. # if defined(BUILD_QXT_NETWORK)
  55. # define QXT_NETWORK_EXPORT Q_DECL_EXPORT
  56. # else
  57. # define QXT_NETWORK_EXPORT Q_DECL_IMPORT
  58. # endif
  59. #else
  60. # define QXT_NETWORK_EXPORT
  61. #endif // BUILD_QXT_NETWORK
  62. #if !defined(QXT_STATIC)
  63. # if defined(BUILD_QXT_SQL)
  64. # define QXT_SQL_EXPORT Q_DECL_EXPORT
  65. # else
  66. # define QXT_SQL_EXPORT Q_DECL_IMPORT
  67. # endif
  68. #else
  69. # define QXT_SQL_EXPORT
  70. #endif // BUILD_QXT_SQL
  71. #if !defined(QXT_STATIC)
  72. # if defined(BUILD_QXT_WEB)
  73. # define QXT_WEB_EXPORT Q_DECL_EXPORT
  74. # else
  75. # define QXT_WEB_EXPORT Q_DECL_IMPORT
  76. # endif
  77. #else
  78. # define QXT_WEB_EXPORT
  79. #endif // BUILD_QXT_WEB
  80. #if !defined(QXT_STATIC)
  81. # if defined(BUILD_QXT_BERKELEY)
  82. # define QXT_BERKELEY_EXPORT Q_DECL_EXPORT
  83. # else
  84. # define QXT_BERKELEY_EXPORT Q_DECL_IMPORT
  85. # endif
  86. #else
  87. # define QXT_BERKELEY_EXPORT
  88. #endif // BUILD_QXT_BERKELEY
  89. #if !defined(QXT_STATIC)
  90. # if defined(BUILD_QXT_ZEROCONF)
  91. # define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT
  92. # else
  93. # define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT
  94. # endif
  95. #else
  96. # define QXT_ZEROCONF_EXPORT
  97. #endif // QXT_ZEROCONF_EXPORT
  98. #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
  99. # define BUILD_QXT
  100. #endif
  101. QXT_CORE_EXPORT const char* qxtVersion();
  102. #ifndef QT_BEGIN_NAMESPACE
  103. #define QT_BEGIN_NAMESPACE
  104. #endif
  105. #ifndef QT_END_NAMESPACE
  106. #define QT_END_NAMESPACE
  107. #endif
  108. #ifndef QT_FORWARD_DECLARE_CLASS
  109. #define QT_FORWARD_DECLARE_CLASS(Class) class Class;
  110. #endif
  111. /****************************************************************************
  112. ** This file is derived from code bearing the following notice:
  113. ** The sole author of this file, Adam Higerd, has explicitly disclaimed all
  114. ** copyright interest and protection for the content within. This file has
  115. ** been placed in the public domain according to United States copyright
  116. ** statute and case law. In jurisdictions where this public domain dedication
  117. ** is not legally recognized, anyone who receives a copy of this file is
  118. ** permitted to use, modify, duplicate, and redistribute this file, in whole
  119. ** or in part, with no restrictions or conditions. In these jurisdictions,
  120. ** this file shall be copyright (C) 2006-2008 by Adam Higerd.
  121. ****************************************************************************/
  122. #define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d;
  123. #define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
  124. #define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this);
  125. #define QXT_D(PUB) PUB##Private& d = qxt_d()
  126. #define QXT_P(PUB) PUB& p = qxt_p()
  127. template <typename PUB>
  128. class QxtPrivate
  129. {
  130. public:
  131. virtual ~QxtPrivate()
  132. {}
  133. inline void QXT_setPublic(PUB* pub)
  134. {
  135. qxt_p_ptr = pub;
  136. }
  137. protected:
  138. inline PUB& qxt_p()
  139. {
  140. return *qxt_p_ptr;
  141. }
  142. inline const PUB& qxt_p() const
  143. {
  144. return *qxt_p_ptr;
  145. }
  146. private:
  147. PUB* qxt_p_ptr;
  148. };
  149. template <typename PUB, typename PVT>
  150. class QxtPrivateInterface
  151. {
  152. friend class QxtPrivate<PUB>;
  153. public:
  154. QxtPrivateInterface()
  155. {
  156. pvt = new PVT;
  157. }
  158. ~QxtPrivateInterface()
  159. {
  160. delete pvt;
  161. }
  162. inline void setPublic(PUB* pub)
  163. {
  164. pvt->QXT_setPublic(pub);
  165. }
  166. inline PVT& operator()()
  167. {
  168. return *static_cast<PVT*>(pvt);
  169. }
  170. inline const PVT& operator()() const
  171. {
  172. return *static_cast<PVT*>(pvt);
  173. }
  174. private:
  175. QxtPrivateInterface(const QxtPrivateInterface&) { }
  176. QxtPrivateInterface& operator=(const QxtPrivateInterface&) { }
  177. QxtPrivate<PUB>* pvt;
  178. };
  179. #endif // QXT_GLOBAL