home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qmetaobject.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  8KB  |  255 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qmetaobject.h   3.0.0   edited Oct 8 17:13 $
  3. **
  4. ** Definition of QMetaObject class
  5. **
  6. ** Created : 930419
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the kernel module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QMETAOBJECT_H
  39. #define QMETAOBJECT_H
  40.  
  41. #ifndef QT_H
  42. #include "qconnection.h"
  43. #include "qstrlist.h"
  44. #endif // QT_H
  45.  
  46. #ifndef Q_MOC_OUTPUT_REVISION
  47. #define Q_MOC_OUTPUT_REVISION 19
  48. #endif
  49.  
  50. class QObject;
  51. struct QUMethod;
  52. class QMetaObjectPrivate;
  53.  
  54. struct QMetaData                // - member function meta data
  55. {                        //   for signal and slots
  56.     const char *name;                // - member name
  57.     const QUMethod* method;            // - detailed method description
  58.     enum Access { Private, Protected, Public };
  59.     Access access;                // - access permission
  60. };
  61.  
  62. #ifndef QT_NO_PROPERTIES
  63. struct QMetaEnum                // enumerator meta data
  64. {                        //  for properties
  65.     const char *name;                // - enumerator name
  66.     uint count;                    // - number of values
  67.     struct Item                    // - a name/value pair
  68.     {
  69.     const char *key;
  70.     int value;
  71.     };
  72.     const Item *items;                // - the name/value pairs
  73.     bool set;                    // whether enum has to be treated as a set
  74. };
  75. #endif
  76.  
  77. #ifndef QT_NO_PROPERTIES
  78.  
  79. class Q_EXPORT QMetaProperty            // property meta data
  80. {
  81. public:
  82.     const char*    type() const { return t; }    // type of the property
  83.     const char*    name() const { return n; }    // name of the property
  84.  
  85.     bool writable() const;
  86.     bool isValid() const;
  87.  
  88.     bool isSetType() const;
  89.     bool isEnumType() const;
  90.     QStrList enumKeys() const;            // enumeration names
  91.  
  92.     int keyToValue( const char* key ) const;    // enum and set conversion functions
  93.     const char* valueToKey( int value ) const;
  94.     int keysToValue( const QStrList& keys ) const;
  95.     QStrList valueToKeys( int value ) const;
  96.  
  97.     bool designable( QObject* ) const;
  98.     bool scriptable( QObject* ) const;
  99.     bool stored( QObject* ) const;
  100.  
  101.     bool reset( QObject* ) const;
  102.  
  103.     const char* t;            // internal
  104.     const char* n;            // internal
  105.  
  106.     enum Flags  {
  107.     Invalid        = 0x00000000,
  108.     Readable    = 0x00000001,
  109.     Writable    = 0x00000002,
  110.     EnumOrSet    = 0x00000004,
  111.     StdSet        = 0x00000100,
  112.     Override    = 0x00000200
  113.     };
  114.  
  115.     uint flags; // internal
  116.     bool testFlags( uint f ) const;    // internal
  117.     bool stdSet() const;         // internal
  118.     int id() const;             // internal
  119.     
  120.     QMetaObject** meta;         // internal
  121.     const QMetaEnum* enumData;        // internal
  122.     int _id;                 // internal
  123.     void clear();             // internal
  124. };
  125.  
  126. inline bool QMetaProperty::testFlags( uint f ) const 
  127. { return (flags & (uint)f) != (uint)0; }
  128.  
  129. #endif // QT_NO_PROPERTIES
  130.  
  131. struct QClassInfo                // class info meta data
  132. {
  133.     const char* name;                // - name of the info
  134.     const char* value;                // - value of the info
  135. };
  136.  
  137. class Q_EXPORT QMetaObject            // meta object class
  138. {
  139. public:
  140.     QMetaObject( const char * const class_name, QMetaObject *superclass,
  141.          const QMetaData * const slot_data, int n_slots,
  142.          const QMetaData * const signal_data, int n_signals,
  143. #ifndef QT_NO_PROPERTIES
  144.          const QMetaProperty *const prop_data, int n_props,
  145.          const QMetaEnum *const enum_data, int n_enums,
  146. #endif
  147.          const QClassInfo *const class_info, int n_info );
  148.  
  149.  
  150.     virtual ~QMetaObject();
  151.  
  152.     const char    *className()        const { return classname; }
  153.     const char    *superClassName()    const { return superclassname; }
  154.  
  155.     QMetaObject *superClass()        const { return superclass; }
  156.  
  157.     bool    inherits( const char* clname ) const;
  158.  
  159.     int    numSlots( bool super = FALSE ) const;
  160.     int        numSignals( bool super = FALSE ) const;
  161.  
  162.     int        findSlot( const char *, bool super = FALSE ) const;
  163.     int        findSignal( const char *, bool super = FALSE ) const;
  164.  
  165.     const QMetaData     *slot( int index, bool super = FALSE ) const;
  166.     const QMetaData     *signal( int index, bool super = FALSE ) const;
  167.  
  168.     QStrList    slotNames( bool super = FALSE ) const;
  169.     QStrList    signalNames( bool super = FALSE ) const;
  170.  
  171.     int        slotOffset() const;
  172.     int        signalOffset() const;
  173.     int        propertyOffset() const;
  174.  
  175.     int        numClassInfo( bool super = FALSE ) const;
  176.     const QClassInfo    *classInfo( int index, bool super = FALSE ) const;
  177.     const char    *classInfo( const char* name, bool super = FALSE ) const;
  178.  
  179. #ifndef QT_NO_PROPERTIES
  180.     const QMetaProperty    *property( int index, bool super = FALSE ) const;
  181.     int findProperty( const char *name, bool super = FALSE ) const;
  182.     int indexOfProperty( const QMetaProperty*, bool super = FALSE ) const;
  183.     const QMetaProperty* resolveProperty( const QMetaProperty* ) const;
  184.     int resolveProperty( int ) const;
  185.     QStrList        propertyNames( bool super = FALSE ) const;
  186.     int        numProperties( bool super = FALSE ) const;
  187. #endif
  188.  
  189.     // static wrappers around constructors, necessary to work around a
  190.     // Windows-DLL limitation: objects can only be deleted within a
  191.     // DLL if they were actually created within that DLL.
  192.     static QMetaObject    *new_metaobject( const char *, QMetaObject *,
  193.                     const QMetaData *const, int,
  194.                     const QMetaData *const, int,
  195. #ifndef QT_NO_PROPERTIES
  196.                     const QMetaProperty *const prop_data, int n_props,
  197.                     const QMetaEnum *const enum_data, int n_enums,
  198. #endif
  199.                     const QClassInfo *const  class_info, int n_info );
  200. #ifndef QT_NO_PROPERTIES
  201.     const QMetaEnum        *enumerator( const char* name, bool super = FALSE ) const;
  202. #endif
  203.  
  204.     static QMetaObject *metaObject( const char *class_name );
  205.  
  206. private:
  207.     QMemberDict        *init( const QMetaData *, int );
  208.  
  209.     const char        *classname;        // class name
  210.     const char        *superclassname;    // super class name
  211.     QMetaObject    *superclass;            // super class meta object
  212.     QMetaObjectPrivate    *d;            // private data for...
  213.     void    *reserved;            // ...binary compatibility
  214.     const QMetaData        *slotData;    // slot meta data
  215.     QMemberDict    *slotDict;            // slot dictionary
  216.     const QMetaData        *signalData;    // signal meta data
  217.     QMemberDict    *signalDict;            // signal dictionary
  218.     int signaloffset;
  219.     int slotoffset;
  220. #ifndef QT_NO_PROPERTIES
  221.     int propertyoffset;
  222. #endif
  223.  
  224. private:    // Disabled copy constructor and operator=
  225. #if defined(Q_DISABLE_COPY)
  226.     QMetaObject( const QMetaObject & );
  227.     QMetaObject &operator=( const QMetaObject & );
  228. #endif
  229. };
  230.  
  231. inline int QMetaObject::slotOffset() const
  232. { return slotoffset; }
  233.  
  234. inline int QMetaObject::signalOffset() const
  235. { return signaloffset; }
  236.  
  237. #ifndef QT_NO_PROPERTIES
  238. inline int QMetaObject::propertyOffset() const
  239. { return propertyoffset; }
  240. #endif
  241.  
  242. class Q_EXPORT QMetaObjectCleanUp
  243. {
  244. public:
  245.     QMetaObjectCleanUp();
  246.     ~QMetaObjectCleanUp();
  247.  
  248.     void setMetaObject( QMetaObject *&mo );
  249.  
  250. private:
  251.     QMetaObject **metaObject;
  252. };
  253.  
  254. #endif // QMETAOBJECT_H
  255.