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

qucom_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** $Id: qucom_p.h,v 1.2 2003/07/10 02:40:11 llornkcor Exp $
00003 **
00004 ** Definition of the QUcom interfaces
00005 **
00006 ** Created : 990101
00007 **
00008 ** Copyright (C) 1992-2002 Trolltech AS.  All rights reserved.
00009 **
00010 ** This file is part of the tools module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech AS of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QUCOM_P_H
00039 #define QUCOM_P_H
00040 
00041 //
00042 //  W A R N I N G
00043 //  -------------
00044 //
00045 // This file is not part of the Qt API.  It exists for the convenience
00046 // of a number of Qt sources files.  This header file may change from
00047 // version to version without notice, or even be removed.
00048 //
00049 // We mean it.
00050 //
00051 //
00052 
00053 #ifndef QT_H
00054 #include <qstring.h>
00055 #include "quuid.h"
00056 #endif // QT_H
00057 
00058 #ifdef check
00059 #undef check
00060 #endif
00061 
00062 struct QUObject;
00063 struct QUInterfaceDescription;
00064 struct QUnknownInterface;
00065 struct QDispatchInterface;
00066 
00067 
00068 struct Q_EXPORT QUBuffer
00069 {
00070     virtual long read( char *data, ulong maxlen ) = 0;
00071     virtual long write( const char *data, ulong len ) = 0;
00072 };
00073 
00074 
00075 // A type for a QUObject
00076 struct Q_EXPORT QUType
00077 {
00078     virtual const QUuid *uuid() const = 0;
00079     virtual const char *desc() const = 0;
00080 
00081 
00082     virtual bool canConvertFrom( QUObject *, QUType * ) = 0;
00083     // virtual private, only called by canConvertFrom
00084     virtual bool canConvertTo( QUObject *, QUType * ) = 0;
00085 
00086 
00087     virtual bool convertFrom( QUObject *, QUType * ) = 0;
00088     // virtual private, only called by convertFrom
00089     virtual bool convertTo( QUObject *, QUType * ) = 0;
00090 
00091     virtual void clear( QUObject * ) = 0;
00092 
00093     virtual int serializeTo( QUObject *, QUBuffer * ) = 0;
00094     virtual int serializeFrom( QUObject *, QUBuffer * ) = 0;
00095 
00096     static bool isEqual( const QUType *t1, const QUType *t2 );
00097     static bool check( QUObject* o, QUType* t );
00098 };
00099 
00100 
00101 // {DE56510E-4E9F-4b76-A3C2-D1E2EF42F1AC}
00102 extern Q_EXPORT const QUuid TID_QUType_Null;
00103 struct Q_EXPORT QUType_Null : public QUType
00104 {
00105     const QUuid *uuid() const;
00106     const char *desc() const;
00107 
00108     bool canConvertFrom( QUObject *, QUType * );
00109     bool canConvertTo( QUObject *, QUType * );
00110     bool convertFrom( QUObject *, QUType * );
00111     bool convertTo( QUObject *, QUType * );
00112     void clear( QUObject * );
00113     int serializeTo( QUObject *, QUBuffer * );
00114     int serializeFrom( QUObject *, QUBuffer * );
00115 };
00116 extern Q_EXPORT QUType_Null static_QUType_Null;
00117 
00118 
00119 // The magic QUObject
00120 struct Q_EXPORT QUObject
00121 {
00122 public: // scary MSVC bug makes this necessary
00123     QUObject() : type( &static_QUType_Null ) {}
00124     ~QUObject() { type->clear( this ); }
00125 
00126     QUType *type;
00127 
00128     // the unavoidable union
00129     union
00130     {
00131         bool b;
00132 
00133         char c;
00134         short s;
00135         int i;
00136         long l;
00137 
00138         unsigned char uc;
00139         unsigned short us;
00140         unsigned int ui;
00141         unsigned long ul;
00142 
00143         float f;
00144         double d;
00145 
00146         char byte[16];
00147 
00148         struct {
00149            char* data;
00150            unsigned long size;
00151         } bytearray;
00152 
00153         void* ptr;
00154 
00155         struct {
00156             void *ptr;
00157             bool owner;
00158         } voidstar;
00159 
00160         struct {
00161             char *ptr;
00162             bool owner;
00163         } charstar;
00164 
00165         struct {
00166             char *ptr;
00167             bool owner;
00168         } utf8;
00169 
00170         struct {
00171             char *ptr;
00172             bool owner;
00173         } local8bit;
00174 
00175         QUnknownInterface* iface;
00176         QDispatchInterface* idisp;
00177 
00178     } payload;
00179 
00180 };
00181 
00182 
00183 // A parameter description describes one method parameters. A
00184 // parameter has a name, a type and a flag describing whether it's an
00185 // in parameter, an out parameter, or both ways
00186 struct Q_EXPORT QUParameter
00187 {
00188     const char* name;
00189     QUType *type;
00190     const void* typeExtra; //Usually 0, UEnum* for QUType_enum, const char* for QUType_ptr, int* for QUType_varptr
00191     enum { In = 1, Out = 2, InOut = In | Out };
00192     int inOut;
00193 };
00194 
00195 // A method description describes one method. A method has a name and
00196 // an array of parameters.
00197 struct Q_EXPORT QUMethod
00198 {
00199     const char* name;
00200     int count;
00201     const QUParameter* parameters;
00202 };
00203 
00204 // A Property description. Not used yet in the example.
00205 struct Q_EXPORT QUProperty
00206 {
00207     const char* name;
00208     QUType* type;
00209     const void* typeExtra; //type dependend. Usually 0, but UEnum for QUTypeenum or const char* for QUTypeptr
00210 
00211     int set; // -1 undefined
00212     int get; // -1 undefined
00213 
00214     int designable; // -1 FALSE, -2 TRUE, else method
00215     int stored; // -1 FALSE, -2 TRUE, else method
00216 };
00217 
00218 // An interface description describes one interface, that is all its
00219 // methods and properties.
00220 struct Q_EXPORT QUInterfaceDescription
00221 {
00222     int methodCount;
00223     const QUMethod* methods;
00224     int propertyCount;
00225     const QUProperty* properties;
00226 };
00227 
00228 
00229 // A component description describe one component, that is its name,
00230 // vendor, release, info, its component uuid and all its interface
00231 // uuids.
00232 struct Q_EXPORT QUComponentDescription
00233 {
00234     const char* name;
00235     const char* vendor;
00236     const char* release;
00237     const char* info;
00238     QUuid cid;
00239     int count;
00240     const QUuid* interfaces;
00241 };
00242 
00243 
00244 // A component server description describe one component server, that
00245 // is its name, vendor, release, info and the descriptions of all
00246 // components it can instantiate.
00247 struct Q_EXPORT QUComponentServerDescription
00248 {
00249     const char* name;
00250     const char* vendor;
00251     const char* release;
00252     const char* info;
00253     int count;
00254     const QUComponentDescription* components;
00255 };
00256 
00257 
00258 
00259 struct Q_EXPORT QUEnumItem                              // - a name/value pair
00260 {
00261     const char *key;
00262     int value;
00263 };
00264 
00265 struct Q_EXPORT QUEnum
00266 {
00267     const char *name;                   // - enumerator name
00268     unsigned int count;                 // - number of values
00269     const QUEnumItem *items;            // - the name/value pairs
00270     bool set;                           // whether enum has to be treated as a set
00271 };
00272 
00273 inline bool QUType::isEqual( const QUType *t1, const QUType *t2 ) {
00274     return t1 == t2 || t1->uuid() == t2->uuid() ||
00275         *(t1->uuid()) == *(t2->uuid());
00276 }
00277 
00278 inline bool QUType::check( QUObject* o, QUType* t ) {
00279     return isEqual( o->type, t ) || t->convertFrom( o, o->type );
00280 }
00281 
00282 
00283 
00284 // {7EE17B08-5419-47e2-9776-8EEA112DCAEC}
00285 extern Q_EXPORT const QUuid TID_QUType_enum;
00286 struct Q_EXPORT QUType_enum : public QUType
00287 {
00288     const QUuid *uuid() const;
00289     const char *desc() const;
00290 
00291     void set( QUObject *, int );
00292     int &get( QUObject * o ) { return o->payload.i; }
00293     bool canConvertFrom( QUObject *, QUType * );
00294     bool canConvertTo( QUObject *, QUType * );
00295     bool convertFrom( QUObject *, QUType * );
00296     bool convertTo( QUObject *, QUType * );
00297     void clear( QUObject * ) {}
00298     int serializeTo( QUObject *, QUBuffer * );
00299     int serializeFrom( QUObject *, QUBuffer * );
00300 };
00301 extern Q_EXPORT QUType_enum static_QUType_enum;
00302 
00303 
00304 // {8AC26448-5AB4-49eb-968C-8F30AB13D732}
00305 extern Q_EXPORT const QUuid TID_QUType_ptr;
00306 struct Q_EXPORT QUType_ptr : public QUType
00307 {
00308     const QUuid *uuid() const;
00309     const char *desc() const;
00310 
00311     void set( QUObject *, const void* );
00312     void* &get( QUObject * o ) { return o->payload.ptr; }
00313     bool canConvertFrom( QUObject *, QUType * );
00314     bool canConvertTo( QUObject *, QUType * );
00315     bool convertFrom( QUObject *, QUType * );
00316     bool convertTo( QUObject *, QUType * );
00317     void clear( QUObject * ) {}
00318     int serializeTo( QUObject *, QUBuffer * );
00319     int serializeFrom( QUObject *, QUBuffer * );
00320 };
00321 extern Q_EXPORT QUType_ptr static_QUType_ptr;
00322 
00323 // {97A2594D-6496-4402-A11E-55AEF2D4D25C}
00324 extern Q_EXPORT const QUuid TID_QUType_iface;
00325 struct Q_EXPORT QUType_iface : public QUType
00326 {
00327     const QUuid *uuid() const;
00328     const char *desc() const;
00329 
00330     void set( QUObject *, QUnknownInterface* );
00331     QUnknownInterface* &get( QUObject *o ){ return o->payload.iface; }
00332     bool canConvertFrom( QUObject *, QUType * );
00333     bool canConvertTo( QUObject *, QUType * );
00334     bool convertFrom( QUObject *, QUType * );
00335     bool convertTo( QUObject *, QUType * );
00336     void clear( QUObject * ) {}
00337     int serializeTo( QUObject *, QUBuffer * );
00338     int serializeFrom( QUObject *, QUBuffer * );
00339 };
00340 extern Q_EXPORT QUType_iface static_QUType_iface;
00341 
00342 // {2F358164-E28F-4bf4-9FA9-4E0CDCABA50B}
00343 extern Q_EXPORT const QUuid TID_QUType_idisp;
00344 struct Q_EXPORT QUType_idisp : public QUType
00345 {
00346     const QUuid *uuid() const;
00347     const char *desc() const;
00348 
00349     void set( QUObject *, QDispatchInterface* );
00350     QDispatchInterface* &get( QUObject *o ){ return o->payload.idisp; }
00351     bool canConvertFrom( QUObject *, QUType * );
00352     bool canConvertTo( QUObject *, QUType * );
00353     bool convertFrom( QUObject *, QUType * );
00354     bool convertTo( QUObject *, QUType * );
00355     void clear( QUObject * ) {}
00356     int serializeTo( QUObject *, QUBuffer * );
00357     int serializeFrom( QUObject *, QUBuffer * );
00358 };
00359 extern Q_EXPORT QUType_idisp static_QUType_idisp;
00360 
00361 // {CA42115D-13D0-456c-82B5-FC10187F313E}
00362 extern Q_EXPORT const QUuid TID_QUType_bool;
00363 struct Q_EXPORT QUType_bool : public QUType
00364 {
00365     const QUuid *uuid() const;
00366     const char *desc() const;
00367 
00368     void set( QUObject *, bool );
00369     bool &get( QUObject *o ) { return o->payload.b; }
00370     bool canConvertFrom( QUObject *, QUType * );
00371     bool canConvertTo( QUObject *, QUType * );
00372     bool convertFrom( QUObject *, QUType * );
00373     bool convertTo( QUObject *, QUType * );
00374     void clear( QUObject * ) {}
00375     int serializeTo( QUObject *, QUBuffer * );
00376     int serializeFrom( QUObject *, QUBuffer * );
00377 };
00378 extern Q_EXPORT QUType_bool static_QUType_bool;
00379 
00380 // {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5}
00381 extern Q_EXPORT const QUuid TID_QUType_int;
00382 struct Q_EXPORT QUType_int : public QUType
00383 {
00384     const QUuid *uuid() const;
00385     const char *desc() const;
00386 
00387     void set( QUObject *, int );
00388     int &get( QUObject *o ) { return o->payload.i; }
00389     bool canConvertFrom( QUObject *, QUType * );
00390     bool canConvertTo( QUObject *, QUType * );
00391     bool convertFrom( QUObject *, QUType * );
00392     bool convertTo( QUObject *, QUType * );
00393     void clear( QUObject * ) {}
00394     int serializeTo( QUObject *, QUBuffer * );
00395     int serializeFrom( QUObject *, QUBuffer * );
00396 };
00397 extern Q_EXPORT QUType_int static_QUType_int;
00398 
00399 
00400 // {2D0974E5-0BA6-4ec2-8837-C198972CB48C}
00401 extern Q_EXPORT const QUuid TID_QUType_double;
00402 struct Q_EXPORT QUType_double : public QUType
00403 {
00404     const QUuid *uuid() const;
00405     const char *desc() const;
00406 
00407     void set( QUObject *, double );
00408     double &get( QUObject *o ) { return o->payload.d; }
00409     bool canConvertFrom( QUObject *, QUType * );
00410     bool canConvertTo( QUObject *, QUType * );
00411     bool convertFrom( QUObject *, QUType * );
00412     bool convertTo( QUObject *, QUType * );
00413     void clear( QUObject * ) {}
00414     int serializeTo( QUObject *, QUBuffer * );
00415     int serializeFrom( QUObject *, QUBuffer * );
00416 };
00417 extern Q_EXPORT QUType_double static_QUType_double;
00418 
00419 
00420 // {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9}
00421 extern Q_EXPORT const QUuid TID_QUType_charstar;
00422 struct Q_EXPORT QUType_charstar : public QUType
00423 {
00424     const QUuid *uuid() const;
00425     const char *desc() const;
00426 
00427     void set( QUObject *, const char*, bool take = FALSE );
00428     char* get( QUObject *o ){ return o->payload.charstar.ptr; }
00429     bool canConvertFrom( QUObject *, QUType * );
00430     bool canConvertTo( QUObject *, QUType * );
00431     bool convertFrom( QUObject *, QUType * );
00432     bool convertTo( QUObject *, QUType * );
00433     void clear( QUObject * );
00434     int serializeTo( QUObject *, QUBuffer * );
00435     int serializeFrom( QUObject *, QUBuffer * );
00436 
00437 };
00438 extern Q_EXPORT QUType_charstar static_QUType_charstar;
00439 
00440 // {44C2A547-01E7-4e56-8559-35AF9D2F42B7}
00441 extern const QUuid TID_QUType_QString;
00442 
00443 struct Q_EXPORT QUType_QString : public QUType
00444 {
00445     const QUuid *uuid() const;
00446     const char *desc() const;
00447 
00448     void set( QUObject *, const QString & );
00449     QString &get( QUObject * o ) { return *(QString*)o->payload.ptr; }
00450 
00451     bool canConvertFrom( QUObject *, QUType * );
00452     bool canConvertTo( QUObject *, QUType * );
00453     bool convertFrom( QUObject *, QUType * );
00454     bool convertTo( QUObject *, QUType * );
00455     void clear( QUObject * );
00456     int serializeTo( QUObject *, QUBuffer * );
00457     int serializeFrom( QUObject *, QUBuffer * );
00458 
00459 };
00460 extern Q_EXPORT QUType_QString static_QUType_QString;
00461 
00462 
00463 #endif // QUCOM_P_H

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