- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qplugin.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtCore module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QPLUGIN_H
    00043 #define QPLUGIN_H
    00044
    00045 #include <QtCore/qobject.h>
    00046 #include <QtCore/qpointer.h>
    00047
    00048 QT_BEGIN_HEADER
    00049
    00050 QT_BEGIN_NAMESPACE
    00051
    00052 QT_MODULE(Core)
    00053
    00054 #ifndef Q_EXTERN_C
    00055 #  ifdef __cplusplus
    00056 #    define Q_EXTERN_C extern "C"
    00057 #  else
    00058 #    define Q_EXTERN_C extern
    00059 #  endif
    00060 #endif
    00061
    00062 typedef QObject *(*QtPluginInstanceFunction)();
    00063
    00064 void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunction function);
    00065
    00066 #define Q_IMPORT_PLUGIN(PLUGIN) \
    00067         extern QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance_##PLUGIN(); \
    00068         class Static##PLUGIN##PluginInstance{ \
    00069         public: \
    00070                 Static##PLUGIN##PluginInstance() { \
    00071                 qRegisterStaticPluginInstanceFunction(qt_plugin_instance_##PLUGIN); \
    00072                 } \
    00073         }; \
    00074        static Static##PLUGIN##PluginInstance static##PLUGIN##Instance;
    00075
    00076 #define Q_PLUGIN_INSTANCE(IMPLEMENTATION) \
    00077         { \
    00078             static QT_PREPEND_NAMESPACE(QPointer)<QT_PREPEND_NAMESPACE(QObject)> _instance; \
    00079             if (!_instance)      \
    00080                 _instance = new IMPLEMENTATION; \
    00081             return _instance; \
    00082         }
    00083
    00084 #  define Q_EXPORT_PLUGIN(PLUGIN) \
    00085             Q_EXPORT_PLUGIN2(PLUGIN, PLUGIN)
    00086
    00087 #  define Q_EXPORT_STATIC_PLUGIN(PLUGIN) \
    00088             Q_EXPORT_STATIC_PLUGIN2(PLUGIN, PLUGIN)
    00089
    00090 #if defined(QT_STATICPLUGIN)
    00091
    00092 #  define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS) \
    00093             QT_PREPEND_NAMESPACE(QObject) \
    00094                 *qt_plugin_instance_##PLUGIN() \
    00095             Q_PLUGIN_INSTANCE(PLUGINCLASS)
    00096
    00097 #  define Q_EXPORT_STATIC_PLUGIN2(PLUGIN, PLUGINCLASS) \
    00098             Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS)
    00099
    00100 #else
    00101 // NOTE: if you change pattern, you MUST change the pattern in
    00102 // qlibrary.cpp as well.  changing the pattern will break all
    00103 // backwards compatibility as well (no old plugins will be loaded).
    00104 #  ifdef QPLUGIN_DEBUG_STR
    00105 #    undef QPLUGIN_DEBUG_STR
    00106 #  endif
    00107 #  ifdef QT_NO_DEBUG
    00108 #    define QPLUGIN_DEBUG_STR "false"
    00109 #  else
    00110 #    define QPLUGIN_DEBUG_STR "true"
    00111 #  endif
    00112 #  define Q_PLUGIN_VERIFICATION_DATA \
    00113     static const char qt_plugin_verification_data[] = \
    00114       "pattern=""QT_PLUGIN_VERIFICATION_DATA""\n" \
    00115       "version="QT_VERSION_STR"\n" \
    00116       "debug="QPLUGIN_DEBUG_STR"\n" \
    00117       "buildkey="QT_BUILD_KEY;
    00118
    00119 #  if defined (Q_OS_WIN32) && defined(Q_CC_BOR)
    00120 #     define Q_STANDARD_CALL __stdcall
    00121 #  else
    00122 #     define Q_STANDARD_CALL
    00123 #  endif
    00124
    00125 #  define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS)      \
    00126             Q_PLUGIN_VERIFICATION_DATA \
    00127             Q_EXTERN_C Q_DECL_EXPORT \
    00128             const char * Q_STANDARD_CALL qt_plugin_query_verification_data() \
    00129             { return qt_plugin_verification_data; } \
    00130             Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) * Q_STANDARD_CALL qt_plugin_instance() \
    00131             Q_PLUGIN_INSTANCE(PLUGINCLASS)
    00132
    00133 #  define Q_EXPORT_STATIC_PLUGIN2(PLUGIN, PLUGINCLASS)
    00134
    00135 #endif
    00136
    00137 QT_END_NAMESPACE
    00138
    00139 QT_END_HEADER
    00140
    00141 #endif // Q_PLUGIN_H