00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef QCOM_P_H
00037 #define QCOM_P_H
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
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
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
00086 #ifndef IID_QDispatch
00087 #define IID_QDispatch QUuid( 0xfbac965e, 0xa441, 0x413f, 0x93, 0x5e, 0xcd, 0xf5, 0x82, 0x57, 0x3f, 0xab)
00088 #endif
00089
00090
00091
00092 struct Q_EXPORT QDispatchInterface : public QUnknownInterface
00093 {
00094
00095 virtual const QUInterfaceDescription* interfaceDescription() const = 0;
00096
00097
00098 virtual const QUInterfaceDescription* eventsDescription() const = 0;
00099
00100
00101
00102 virtual QRESULT invoke( int id, QUObject* o ) = 0;
00103
00104
00105 virtual void installListener( QDispatchInterface* listener ) = 0;
00106
00107
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
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
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
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
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
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
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
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
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
00286
00287
00288
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
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