Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qcom_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** $Id: qcom_p.h,v 1.2 2003/07/10 02:40:11 llornkcor Exp $
00003 **
00004 ** ...
00005 **
00006 ** Copyright (C) 2001-2002 Trolltech AS.  All rights reserved.
00007 **
00008 ** This file is part of the tools module of the Qt GUI Toolkit.
00009 **
00010 ** This file may be distributed under the terms of the Q Public License
00011 ** as defined by Trolltech AS of Norway and appearing in the file
00012 ** LICENSE.QPL included in the packaging of this file.
00013 **
00014 ** This file may be distributed and/or modified under the terms of the
00015 ** GNU General Public License version 2 as published by the Free Software
00016 ** Foundation and appearing in the file LICENSE.GPL included in the
00017 ** packaging of this file.
00018 **
00019 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00020 ** licenses may use this file in accordance with the Qt Commercial License
00021 ** Agreement provided with the Software.
00022 **
00023 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00024 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 **
00026 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00027 **   information about Qt Commercial License Agreements.
00028 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00029 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00030 **
00031 ** Contact info@trolltech.com if any conditions of this licensing are
00032 ** not clear to you.
00033 **
00034 **********************************************************************/
00035 
00036 #ifndef QCOM_P_H
00037 #define QCOM_P_H
00038 
00039 //
00040 //  W A R N I N G
00041 //  -------------
00042 //
00043 // This file is not part of the Qt API.  It exists for the convenience
00044 // of a number of Qt sources files.  This header file may change from
00045 // version to version without notice, or even be removed.
00046 //
00047 // We mean it.
00048 //
00049 //
00050 
00051 #ifndef QT_H
00052 #include "qstringlist.h"
00053 #include "quuid.h"
00054 #endif // QT_H
00055 
00056 #ifndef QT_NO_COMPONENT
00057 
00058 class QObject;
00059 struct QUInterfaceDescription;
00060 struct QUObject;
00061 
00062 #define QRESULT         unsigned long
00063 #define QS_OK           (QRESULT)0x00000000
00064 #define QS_FALSE        (QRESULT)0x00000001
00065 
00066 #define QE_NOTIMPL      (QRESULT)0x80000001
00067 #define QE_OUTOFMEMORY  (QRESULT)0x80000002
00068 #define QE_INVALIDARG   (QRESULT)0x80000003
00069 #define QE_NOINTERFACE  (QRESULT)0x80000004
00070 #define QE_NOCOMPONENT  (QRESULT)0x80000005
00071 
00072 
00073 // {1D8518CD-E8F5-4366-99E8-879FD7E482DE}
00074 #ifndef IID_QUnknown
00075 #define IID_QUnknown QUuid(0x1d8518cd, 0xe8f5, 0x4366, 0x99, 0xe8, 0x87, 0x9f, 0xd7, 0xe4, 0x82, 0xde)
00076 #endif
00077 
00078 struct Q_EXPORT QUnknownInterface
00079 {
00080     virtual QRESULT queryInterface( const QUuid&, QUnknownInterface** ) = 0;
00081     virtual ulong   addRef() = 0;
00082     virtual ulong   release() = 0;
00083 };
00084 
00085 // {FBAC965E-A441-413F-935E-CDF582573FAB}
00086 #ifndef IID_QDispatch
00087 #define IID_QDispatch QUuid( 0xfbac965e, 0xa441, 0x413f, 0x93, 0x5e, 0xcd, 0xf5, 0x82, 0x57, 0x3f, 0xab)
00088 #endif
00089 
00090 // the dispatch interface that inherits the unknown interface.. It is
00091 // used to explore interfaces during runtime and to do dynamic calls.
00092 struct Q_EXPORT QDispatchInterface : public QUnknownInterface
00093 {
00094     // returns the interface description of this dispatch interface.
00095     virtual const QUInterfaceDescription* interfaceDescription() const = 0;
00096 
00097     // returns the event description of this dispatch interface.
00098     virtual const QUInterfaceDescription* eventsDescription() const = 0;
00099 
00100     // invokes method id with parameters V*. Returns some sort of
00101     // exception code.
00102     virtual QRESULT invoke( int id, QUObject* o ) = 0;
00103 
00104     // installs listener as event listener
00105     virtual void installListener( QDispatchInterface* listener ) = 0;
00106 
00107     // remove listener as event listener
00108     virtual void removeListener( QDispatchInterface* listener ) = 0;
00109 };
00110 
00111 template <class T>
00112 class QInterfacePtr
00113 {
00114 public:
00115     QInterfacePtr():iface(0){}
00116 
00117     QInterfacePtr( T* i) {
00118         if ( (iface = i) )
00119             iface->addRef();
00120     }
00121 
00122     QInterfacePtr(const QInterfacePtr<T> &p) {
00123         if ( (iface = p.iface) )
00124             iface->addRef();
00125     }
00126 
00127     ~QInterfacePtr() {
00128         if ( iface )
00129             iface->release();
00130     }
00131 
00132     QInterfacePtr<T> &operator=(const QInterfacePtr<T> &p) {
00133         if ( iface != p.iface ) {
00134             if ( iface )
00135                 iface->release();
00136             if ( (iface = p.iface) )
00137                 iface->addRef();
00138         }
00139         return *this;
00140     }
00141 
00142     QInterfacePtr<T> &operator=(T* i) {
00143         if (iface != i ) {
00144             if ( iface )
00145                 iface->release();
00146             if ( (iface = i) )
00147                 iface->addRef();
00148         }
00149         return *this;
00150     }
00151 
00152     bool operator==( const QInterfacePtr<T> &p ) const { return iface == p.iface; }
00153 
00154     bool operator!= ( const QInterfacePtr<T>& p ) const {  return !( *this == p ); }
00155 
00156     bool isNull() const { return !iface; }
00157 
00158     T* operator->() const { return iface; }
00159 
00160     T& operator*() const { return *iface; }
00161 
00162     operator T*() const { return iface; }
00163 
00164     QUnknownInterface** operator &() const {
00165         if( iface )
00166             iface->release();
00167         return (QUnknownInterface**)&iface;
00168     }
00169 
00170     T** operator &() {
00171         if ( iface )
00172             iface->release();
00173         return &iface;
00174     }
00175 
00176 private:
00177     T* iface;
00178 };
00179 
00180 // {10A1501B-4C5F-4914-95DD-C400486CF900}
00181 #ifndef IID_QObject
00182 #define IID_QObject QUuid( 0x10a1501b, 0x4c5f, 0x4914, 0x95, 0xdd, 0xc4, 0x00, 0x48, 0x6c, 0xf9, 0x00)
00183 #endif
00184 
00185 struct Q_EXPORT QObjectInterface
00186 {
00187     virtual QObject*   qObject() = 0;
00188 };
00189 
00190 // {5F3968A5-F451-45b1-96FB-061AD98F926E}
00191 #ifndef IID_QComponentInformation
00192 #define IID_QComponentInformation QUuid(0x5f3968a5, 0xf451, 0x45b1, 0x96, 0xfb, 0x6, 0x1a, 0xd9, 0x8f, 0x92, 0x6e)
00193 #endif
00194 
00195 struct Q_EXPORT QComponentInformationInterface : public QUnknownInterface
00196 {
00197     virtual QString name() const = 0;
00198     virtual QString description() const = 0;
00199     virtual QString author() const = 0;
00200     virtual QString version() const = 0;
00201 };
00202 
00203 // {6CAA771B-17BB-4988-9E78-BA5CDDAAC31E}
00204 #ifndef IID_QComponentFactory
00205 #define IID_QComponentFactory QUuid( 0x6caa771b, 0x17bb, 0x4988, 0x9e, 0x78, 0xba, 0x5c, 0xdd, 0xaa, 0xc3, 0x1e)
00206 #endif
00207 
00208 struct Q_EXPORT QComponentFactoryInterface : public QUnknownInterface
00209 {
00210     virtual QRESULT createInstance( const QUuid &cid, const QUuid &iid, QUnknownInterface** instance, QUnknownInterface *outer ) = 0;
00211 };
00212 
00213 // {D16111D4-E1E7-4C47-8599-24483DAE2E07}
00214 #ifndef IID_QLibrary
00215 #define IID_QLibrary QUuid( 0xd16111d4, 0xe1e7, 0x4c47, 0x85, 0x99, 0x24, 0x48, 0x3d, 0xae, 0x2e, 0x07)
00216 #endif
00217 
00218 struct Q_EXPORT QLibraryInterface : public QUnknownInterface
00219 {
00220     virtual bool    init() = 0;
00221     virtual void    cleanup() = 0;
00222     virtual bool    canUnload() const = 0;
00223 };
00224 
00225 // {3F8FDC44-3015-4f3e-B6D6-E4AAAABDEAAD}
00226 #ifndef IID_QFeatureList
00227 #define IID_QFeatureList QUuid(0x3f8fdc44, 0x3015, 0x4f3e, 0xb6, 0xd6, 0xe4, 0xaa, 0xaa, 0xbd, 0xea, 0xad)
00228 #endif
00229 
00230 struct Q_EXPORT QFeatureListInterface : public QUnknownInterface
00231 {
00232     virtual QStringList featureList() const = 0;
00233 };
00234 
00235 // {B5FEB5DE-E0CD-4E37-B0EB-8A812499A0C1}
00236 #ifndef IID_QComponentRegistration
00237 #define IID_QComponentRegistration QUuid( 0xb5feb5de, 0xe0cd, 0x4e37, 0xb0, 0xeb, 0x8a, 0x81, 0x24, 0x99, 0xa0, 0xc1)
00238 #endif
00239 
00240 struct Q_EXPORT QComponentRegistrationInterface : public QUnknownInterface
00241 {
00242     virtual bool    registerComponents( const QString &filepath ) const = 0;
00243     virtual bool    unregisterComponents() const = 0;
00244 };
00245 
00246 // internal class that wraps an initialized ulong
00247 struct Q_EXPORT QtULong
00248 {
00249     QtULong() : ref( 0 ) { }
00250     operator unsigned long () const { return ref; }
00251     unsigned long& operator++() { return ++ref; }
00252     unsigned long operator++( int ) { return ref++; }
00253     unsigned long& operator--() { return --ref; }
00254     unsigned long operator--( int ) { return ref--; }
00255 
00256     unsigned long ref;
00257 };
00258 // default implementation of ref counting. A variable "ulong ref" has to be a member
00259 
00260 
00261 #define Q_REFCOUNT \
00262 private:           \
00263     QtULong qtrefcount;   \
00264 public:            \
00265     ulong addRef() {return qtrefcount++;} \
00266     ulong release() {if(!--qtrefcount){delete this;return 0;}return qtrefcount;}
00267 
00268 #ifndef Q_EXPORT_COMPONENT
00269 #if defined(QT_THREAD_SUPPORT)
00270 #define QT_THREADED_BUILD 1
00271 #define Q_UCM_FLAGS_STRING "11"
00272 #else
00273 #define QT_THREADED_BUILD 0
00274 #define Q_UCM_FLAGS_STRING "01"
00275 #endif
00276 
00277 #ifndef Q_EXTERN_C
00278 #ifdef __cplusplus
00279 #define Q_EXTERN_C    extern "C"
00280 #else
00281 #define Q_EXTERN_C    extern
00282 #endif
00283 #endif
00284 
00285 // this is duplicated at Q_PLUGIN_VERIFICATION_DATA in qgplugin.h
00286 // NOTE: if you change pattern, you MUST change the pattern in
00287 // qcomlibrary.cpp as well.  changing the pattern will break all
00288 // backwards compatibility as well (no old plugins will be loaded).
00289 #ifndef Q_UCM_VERIFICATION_DATA
00290 #  define Q_UCM_VERIFICATION_DATA \
00291         static const char *qt_ucm_verification_data =                   \
00292             "pattern=""QT_UCM_VERIFICATION_DATA""\n"                    \
00293             "version="QT_VERSION_STR"\n"                                \
00294             "flags="Q_UCM_FLAGS_STRING"\n"                              \
00295             "buildkey="QT_BUILD_KEY"\0";
00296 #endif // Q_UCM_VERIFICATION_DATA
00297 
00298 // This macro expands to the default implementation of ucm_instantiate.
00299 #ifndef Q_CREATE_INSTANCE
00300 #    define Q_CREATE_INSTANCE( IMPLEMENTATION )         \
00301         IMPLEMENTATION *i = new IMPLEMENTATION;         \
00302         QUnknownInterface* iface = 0;                   \
00303         i->queryInterface( IID_QUnknown, &iface );      \
00304         return iface;
00305 #endif // Q_CREATE_INSTANCE
00306 
00307 #    ifdef Q_WS_WIN
00308 #       ifdef Q_CC_BOR
00309 #           define Q_EXPORT_COMPONENT() \
00310                 Q_UCM_VERIFICATION_DATA \
00311                 Q_EXTERN_C __declspec(dllexport) \
00312                 const char * __stdcall qt_ucm_query_verification_data() \
00313                 { return qt_ucm_verification_data; } \
00314                 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* \
00315                 __stdcall ucm_instantiate()
00316 #       else
00317 #           define Q_EXPORT_COMPONENT() \
00318                 Q_UCM_VERIFICATION_DATA \
00319                 Q_EXTERN_C __declspec(dllexport) \
00320                 const char *qt_ucm_query_verification_data() \
00321                 { return qt_ucm_verification_data; } \
00322                 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* ucm_instantiate()
00323 #       endif
00324 #    else
00325 #       define Q_EXPORT_COMPONENT() \
00326             Q_UCM_VERIFICATION_DATA \
00327             Q_EXTERN_C \
00328             const char *qt_ucm_query_verification_data() \
00329             { return qt_ucm_verification_data; } \
00330             Q_EXTERN_C QUnknownInterface* ucm_instantiate()
00331 #    endif
00332 #    define Q_EXPORT_INTERFACE() Q_EXPORT_COMPONENT()
00333 #endif
00334 
00335 #endif //QT_NO_COMPONENT
00336 
00337 #endif //QCOM_P_H

Generated on Sat Nov 5 16:18:22 2005 for OPIE by  doxygen 1.4.2