Eneboo - Documentación para desarrolladores
src/qt/include/private/qcom_p.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qcom_p.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** ...
00005 **
00006 ** Copyright (C) 2001-2007 Trolltech ASA.  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 ASA 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 #if __GNUC__ - 0 > 3
00057 #pragma GCC system_header
00058 #endif
00059 
00060 #ifndef QT_NO_COMPONENT
00061 
00062 class QObject;
00063 struct QUInterfaceDescription;
00064 struct QUObject;
00065 
00066 #define QRESULT         unsigned long
00067 #define QS_OK           (QRESULT)0x00000000
00068 #define QS_FALSE        (QRESULT)0x00000001
00069 
00070 #define QE_NOTIMPL      (QRESULT)0x80000001
00071 #define QE_OUTOFMEMORY  (QRESULT)0x80000002
00072 #define QE_INVALIDARG   (QRESULT)0x80000003
00073 #define QE_NOINTERFACE  (QRESULT)0x80000004
00074 #define QE_NOCOMPONENT  (QRESULT)0x80000005
00075 
00076 
00077 // {1D8518CD-E8F5-4366-99E8-879FD7E482DE}
00078 #ifndef IID_QUnknown
00079 #define IID_QUnknown QUuid(0x1d8518cd, 0xe8f5, 0x4366, 0x99, 0xe8, 0x87, 0x9f, 0xd7, 0xe4, 0x82, 0xde)
00080 #endif
00081 
00082 struct Q_EXPORT QUnknownInterface
00083 {
00084     virtual QRESULT queryInterface( const QUuid&, QUnknownInterface** ) = 0;
00085     virtual ulong   addRef() = 0;
00086     virtual ulong   release() = 0;
00087 };
00088 
00089 // {FBAC965E-A441-413F-935E-CDF582573FAB}
00090 #ifndef IID_QDispatch
00091 #define IID_QDispatch QUuid( 0xfbac965e, 0xa441, 0x413f, 0x93, 0x5e, 0xcd, 0xf5, 0x82, 0x57, 0x3f, 0xab)
00092 #endif
00093 
00094 // the dispatch interface that inherits the unknown interface.. It is
00095 // used to explore interfaces during runtime and to do dynamic calls.
00096 struct Q_EXPORT QDispatchInterface : public QUnknownInterface
00097 {
00098     // returns the interface description of this dispatch interface.
00099     virtual const QUInterfaceDescription* interfaceDescription() const = 0;
00100 
00101     // returns the event description of this dispatch interface.
00102     virtual const QUInterfaceDescription* eventsDescription() const = 0;
00103 
00104     // invokes method id with parameters V*. Returns some sort of
00105     // exception code.
00106     virtual QRESULT invoke( int id, QUObject* o ) = 0;
00107 
00108     // installs listener as event listener
00109     virtual void installListener( QDispatchInterface* listener ) = 0;
00110 
00111     // remove listener as event listener
00112     virtual void removeListener( QDispatchInterface* listener ) = 0;
00113 };
00114 
00115 template <class T>
00116 class QInterfacePtr
00117 {
00118 public:
00119     QInterfacePtr():iface(0){}
00120 
00121     QInterfacePtr( T* i) {
00122         if ( (iface = i) )
00123             iface->addRef();
00124     }
00125 
00126     QInterfacePtr(const QInterfacePtr<T> &p) {
00127         if ( (iface = p.iface) )
00128             iface->addRef();
00129     }
00130 
00131     ~QInterfacePtr() {
00132         if ( iface )
00133             iface->release();
00134     }
00135 
00136     QInterfacePtr<T> &operator=(const QInterfacePtr<T> &p) {
00137         if ( iface != p.iface ) {
00138             if ( iface )
00139                 iface->release();
00140             if ( (iface = p.iface) )
00141                 iface->addRef();
00142         }
00143         return *this;
00144     }
00145 
00146     QInterfacePtr<T> &operator=(T* i) {
00147         if (iface != i ) {
00148             if ( iface )
00149                 iface->release();
00150             if ( (iface = i) )
00151                 iface->addRef();
00152         }
00153         return *this;
00154     }
00155 
00156     bool operator==( const QInterfacePtr<T> &p ) const { return iface == p.iface; }
00157 
00158     bool operator!= ( const QInterfacePtr<T>& p ) const {  return !( *this == p ); }
00159 
00160     bool isNull() const { return !iface; }
00161 
00162     T* operator->() const { return iface; }
00163 
00164     T& operator*() const { return *iface; }
00165 
00166     operator T*() const { return iface; }
00167 
00168     QUnknownInterface** operator &() const {
00169         if( iface )
00170             iface->release();
00171         return (QUnknownInterface**)&iface;
00172     }
00173 
00174     T** operator &() {
00175         if ( iface )
00176             iface->release();
00177         return &iface;
00178     }
00179 
00180 private:
00181     T* iface;
00182 };
00183 
00184 // {10A1501B-4C5F-4914-95DD-C400486CF900}
00185 #ifndef IID_QObject
00186 #define IID_QObject QUuid( 0x10a1501b, 0x4c5f, 0x4914, 0x95, 0xdd, 0xc4, 0x00, 0x48, 0x6c, 0xf9, 0x00)
00187 #endif
00188 
00189 struct Q_EXPORT QObjectInterface
00190 {
00191     virtual QObject*   qObject() = 0;
00192 };
00193 
00194 // {5F3968A5-F451-45b1-96FB-061AD98F926E}
00195 #ifndef IID_QComponentInformation
00196 #define IID_QComponentInformation QUuid(0x5f3968a5, 0xf451, 0x45b1, 0x96, 0xfb, 0x6, 0x1a, 0xd9, 0x8f, 0x92, 0x6e)
00197 #endif
00198 
00199 struct Q_EXPORT QComponentInformationInterface : public QUnknownInterface
00200 {
00201     virtual QString name() const = 0;
00202     virtual QString description() const = 0;
00203     virtual QString author() const = 0;
00204     virtual QString version() const = 0;
00205 };
00206 
00207 // {6CAA771B-17BB-4988-9E78-BA5CDDAAC31E}
00208 #ifndef IID_QComponentFactory
00209 #define IID_QComponentFactory QUuid( 0x6caa771b, 0x17bb, 0x4988, 0x9e, 0x78, 0xba, 0x5c, 0xdd, 0xaa, 0xc3, 0x1e)
00210 #endif
00211 
00212 struct Q_EXPORT QComponentFactoryInterface : public QUnknownInterface
00213 {
00214     virtual QRESULT createInstance( const QUuid &cid, const QUuid &iid, QUnknownInterface** instance, QUnknownInterface *outer ) = 0;
00215 };
00216 
00217 // {D16111D4-E1E7-4C47-8599-24483DAE2E07}
00218 #ifndef IID_QLibrary
00219 #define IID_QLibrary QUuid( 0xd16111d4, 0xe1e7, 0x4c47, 0x85, 0x99, 0x24, 0x48, 0x3d, 0xae, 0x2e, 0x07)
00220 #endif
00221 
00222 struct Q_EXPORT QLibraryInterface : public QUnknownInterface
00223 {
00224     virtual bool    init() = 0;
00225     virtual void    cleanup() = 0;
00226     virtual bool    canUnload() const = 0;
00227 };
00228 
00229 // {3F8FDC44-3015-4f3e-B6D6-E4AAAABDEAAD}
00230 #ifndef IID_QFeatureList
00231 #define IID_QFeatureList QUuid(0x3f8fdc44, 0x3015, 0x4f3e, 0xb6, 0xd6, 0xe4, 0xaa, 0xaa, 0xbd, 0xea, 0xad)
00232 #endif
00233 
00234 struct Q_EXPORT QFeatureListInterface : public QUnknownInterface
00235 {
00236     virtual QStringList featureList() const = 0;
00237 };
00238 
00239 // {B5FEB5DE-E0CD-4E37-B0EB-8A812499A0C1}
00240 #ifndef IID_QComponentRegistration
00241 #define IID_QComponentRegistration QUuid( 0xb5feb5de, 0xe0cd, 0x4e37, 0xb0, 0xeb, 0x8a, 0x81, 0x24, 0x99, 0xa0, 0xc1)
00242 #endif
00243 
00244 struct Q_EXPORT QComponentRegistrationInterface : public QUnknownInterface
00245 {
00246     virtual bool    registerComponents( const QString &filepath ) const = 0;
00247     virtual bool    unregisterComponents() const = 0;
00248 };
00249 
00250 // internal class that wraps an initialized ulong
00251 struct Q_EXPORT QtULong
00252 {
00253     QtULong() : ref( 0 ) { }
00254     operator unsigned long () const { return ref; }
00255     unsigned long& operator++() { return ++ref; }
00256     unsigned long operator++( int ) { return ref++; }
00257     unsigned long& operator--() { return --ref; }
00258     unsigned long operator--( int ) { return ref--; }
00259 
00260     unsigned long ref;
00261 };
00262 // default implementation of ref counting. A variable "ulong ref" has to be a member
00263 
00264 
00265 #define Q_REFCOUNT \
00266 private:           \
00267     QtULong qtrefcount;   \
00268 public:            \
00269     ulong addRef() {return qtrefcount++;} \
00270     ulong release() {if(!--qtrefcount){delete this;return 0;}return qtrefcount;}
00271 
00272 #ifndef Q_EXPORT_COMPONENT
00273 #if defined(QT_THREAD_SUPPORT)
00274 #define QT_THREADED_BUILD 1
00275 #define Q_UCM_FLAGS_STRING "11"
00276 #else
00277 #define QT_THREADED_BUILD 0
00278 #define Q_UCM_FLAGS_STRING "01"
00279 #endif
00280 
00281 #ifndef Q_EXTERN_C
00282 #ifdef __cplusplus
00283 #define Q_EXTERN_C    extern "C"
00284 #else
00285 #define Q_EXTERN_C    extern
00286 #endif
00287 #endif
00288 
00289 // this is duplicated at Q_PLUGIN_VERIFICATION_DATA in qgplugin.h
00290 // NOTE: if you change pattern, you MUST change the pattern in
00291 // qcomlibrary.cpp as well.  changing the pattern will break all
00292 // backwards compatibility as well (no old plugins will be loaded).
00293 #ifndef Q_UCM_VERIFICATION_DATA
00294 #  define Q_UCM_VERIFICATION_DATA \
00295         static const char *qt_ucm_verification_data =                   \
00296             "pattern=""QT_UCM_VERIFICATION_DATA""\n"                    \
00297             "version="QT_VERSION_STR"\n"                                \
00298             "flags="Q_UCM_FLAGS_STRING"\n"                              \
00299             "buildkey="QT_BUILD_KEY"\0";
00300 #endif // Q_UCM_VERIFICATION_DATA
00301 
00302 // This macro expands to the default implementation of ucm_instantiate.
00303 #ifndef Q_CREATE_INSTANCE
00304 #    define Q_CREATE_INSTANCE( IMPLEMENTATION )         \
00305         IMPLEMENTATION *i = new IMPLEMENTATION;         \
00306         QUnknownInterface* iface = 0;                   \
00307         i->queryInterface( IID_QUnknown, &iface );      \
00308         return iface;
00309 #endif // Q_CREATE_INSTANCE
00310 
00311 #    ifdef Q_WS_WIN
00312 #       ifdef Q_CC_BOR
00313 #           define Q_EXPORT_COMPONENT() \
00314                 Q_UCM_VERIFICATION_DATA \
00315                 Q_EXTERN_C __declspec(dllexport) \
00316                 const char * __stdcall qt_ucm_query_verification_data() \
00317                 { return qt_ucm_verification_data; } \
00318                 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* \
00319                 __stdcall ucm_instantiate()
00320 #       else
00321 #           define Q_EXPORT_COMPONENT() \
00322                 Q_UCM_VERIFICATION_DATA \
00323                 Q_EXTERN_C __declspec(dllexport) \
00324                 const char *qt_ucm_query_verification_data() \
00325                 { return qt_ucm_verification_data; } \
00326                 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* ucm_instantiate()
00327 #       endif
00328 #    else
00329 #       define Q_EXPORT_COMPONENT() \
00330             Q_UCM_VERIFICATION_DATA \
00331             Q_EXTERN_C \
00332             const char *qt_ucm_query_verification_data() \
00333             { return qt_ucm_verification_data; } \
00334             Q_EXTERN_C QUnknownInterface* ucm_instantiate()
00335 #    endif
00336 #    define Q_EXPORT_INTERFACE() Q_EXPORT_COMPONENT()
00337 #endif
00338 
00339 #endif //QT_NO_COMPONENT
00340 
00341 #endif //QCOM_P_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'