qmetaobject.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtCore module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QMETAOBJECT_H
00043 #define QMETAOBJECT_H
00044 
00045 #include <QtCore/qobjectdefs.h>
00046 #include <QtCore/qvariant.h>
00047 
00048 QT_BEGIN_HEADER
00049 
00050 QT_BEGIN_NAMESPACE
00051 
00052 QT_MODULE(Core)
00053 
00054 template <typename T> class QList;
00055 
00056 class Q_CORE_EXPORT QMetaMethod
00057 {
00058 public:
00059     inline QMetaMethod() : mobj(0),handle(0) {}
00060 
00061     const char *signature() const;
00062     const char *typeName() const;
00063     QList<QByteArray> parameterTypes() const;
00064     QList<QByteArray> parameterNames() const;
00065     const char *tag() const;
00066     enum Access { Private, Protected, Public };
00067     Access access() const;
00068     enum MethodType { Method, Signal, Slot, Constructor };
00069     MethodType methodType() const;
00070     enum Attributes { Compatibility = 0x1, Cloned = 0x2, Scriptable = 0x4 };
00071     int attributes() const;
00072     int methodIndex() const;
00073 
00074     inline const QMetaObject *enclosingMetaObject() const { return mobj; }
00075 
00076     bool invoke(QObject *object,
00077                 Qt::ConnectionType connectionType,
00078                 QGenericReturnArgument returnValue,
00079                 QGenericArgument val0 = QGenericArgument(0),
00080                 QGenericArgument val1 = QGenericArgument(),
00081                 QGenericArgument val2 = QGenericArgument(),
00082                 QGenericArgument val3 = QGenericArgument(),
00083                 QGenericArgument val4 = QGenericArgument(),
00084                 QGenericArgument val5 = QGenericArgument(),
00085                 QGenericArgument val6 = QGenericArgument(),
00086                 QGenericArgument val7 = QGenericArgument(),
00087                 QGenericArgument val8 = QGenericArgument(),
00088                 QGenericArgument val9 = QGenericArgument()) const;
00089     inline bool invoke(QObject *object,
00090                        QGenericReturnArgument returnValue,
00091                        QGenericArgument val0 = QGenericArgument(0),
00092                        QGenericArgument val1 = QGenericArgument(),
00093                        QGenericArgument val2 = QGenericArgument(),
00094                        QGenericArgument val3 = QGenericArgument(),
00095                        QGenericArgument val4 = QGenericArgument(),
00096                        QGenericArgument val5 = QGenericArgument(),
00097                        QGenericArgument val6 = QGenericArgument(),
00098                        QGenericArgument val7 = QGenericArgument(),
00099                        QGenericArgument val8 = QGenericArgument(),
00100                        QGenericArgument val9 = QGenericArgument()) const
00101     {
00102         return invoke(object, Qt::AutoConnection, returnValue,
00103                       val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
00104     }
00105     inline bool invoke(QObject *object,
00106                        Qt::ConnectionType connectionType,
00107                        QGenericArgument val0 = QGenericArgument(0),
00108                        QGenericArgument val1 = QGenericArgument(),
00109                        QGenericArgument val2 = QGenericArgument(),
00110                        QGenericArgument val3 = QGenericArgument(),
00111                        QGenericArgument val4 = QGenericArgument(),
00112                        QGenericArgument val5 = QGenericArgument(),
00113                        QGenericArgument val6 = QGenericArgument(),
00114                        QGenericArgument val7 = QGenericArgument(),
00115                        QGenericArgument val8 = QGenericArgument(),
00116                        QGenericArgument val9 = QGenericArgument()) const
00117     {
00118         return invoke(object, connectionType, QGenericReturnArgument(),
00119                       val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
00120     }
00121     inline bool invoke(QObject *object,
00122                        QGenericArgument val0 = QGenericArgument(0),
00123                        QGenericArgument val1 = QGenericArgument(),
00124                        QGenericArgument val2 = QGenericArgument(),
00125                        QGenericArgument val3 = QGenericArgument(),
00126                        QGenericArgument val4 = QGenericArgument(),
00127                        QGenericArgument val5 = QGenericArgument(),
00128                        QGenericArgument val6 = QGenericArgument(),
00129                        QGenericArgument val7 = QGenericArgument(),
00130                        QGenericArgument val8 = QGenericArgument(),
00131                        QGenericArgument val9 = QGenericArgument()) const
00132     {
00133         return invoke(object, Qt::AutoConnection, QGenericReturnArgument(),
00134                       val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
00135     }
00136 
00137 private:
00138     const QMetaObject *mobj;
00139     uint handle;
00140     friend struct QMetaObject;
00141 };
00142 Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE);
00143 
00144 class Q_CORE_EXPORT QMetaEnum
00145 {
00146 public:
00147     inline QMetaEnum() : mobj(0),handle(0) {}
00148 
00149     const char *name() const;
00150     bool isFlag() const;
00151 
00152     int keyCount() const;
00153     const char *key(int index) const;
00154     int value(int index) const;
00155 
00156     const char *scope() const;
00157 
00158     int keyToValue(const char *key) const;
00159     const char* valueToKey(int value) const;
00160     int keysToValue(const char * keys) const;
00161     QByteArray valueToKeys(int value) const;
00162 
00163     inline const QMetaObject *enclosingMetaObject() const { return mobj; }
00164 
00165     inline bool isValid() const { return name() != 0; }
00166 private:
00167     const QMetaObject *mobj;
00168     uint handle;
00169     friend struct QMetaObject;
00170 };
00171 Q_DECLARE_TYPEINFO(QMetaEnum, Q_MOVABLE_TYPE);
00172 
00173 class Q_CORE_EXPORT QMetaProperty
00174 {
00175 public:
00176     QMetaProperty();
00177 
00178     const char *name() const;
00179     const char *typeName() const;
00180     QVariant::Type type() const;
00181     int userType() const;
00182     int propertyIndex() const;
00183 
00184     bool isReadable() const;
00185     bool isWritable() const;
00186     bool isResettable() const;
00187     bool isDesignable(const QObject *obj = 0) const;
00188     bool isScriptable(const QObject *obj = 0) const;
00189     bool isStored(const QObject *obj = 0) const;
00190     bool isEditable(const QObject *obj = 0) const;
00191     bool isUser(const QObject *obj = 0) const;
00192     bool isConstant() const;
00193     bool isFinal() const;
00194 
00195     bool isFlagType() const;
00196     bool isEnumType() const;
00197     QMetaEnum enumerator() const;
00198 
00199     bool hasNotifySignal() const;
00200     QMetaMethod notifySignal() const;
00201     int notifySignalIndex() const;
00202 
00203     QVariant read(const QObject *obj) const;
00204     bool write(QObject *obj, const QVariant &value) const;
00205     bool reset(QObject *obj) const;
00206 
00207     bool hasStdCppSet() const;
00208     inline bool isValid() const { return isReadable(); }
00209     inline const QMetaObject *enclosingMetaObject() const { return mobj; }
00210 
00211 private:
00212     const QMetaObject *mobj;
00213     uint handle;
00214     int idx;
00215     QMetaEnum menum;
00216     friend struct QMetaObject;
00217 };
00218 
00219 class Q_CORE_EXPORT QMetaClassInfo
00220 {
00221 public:
00222     inline QMetaClassInfo() : mobj(0),handle(0) {}
00223     const char *name() const;
00224     const char *value() const;
00225     inline const QMetaObject *enclosingMetaObject() const { return mobj; }
00226 private:
00227     const QMetaObject *mobj;
00228     uint handle;
00229     friend struct QMetaObject;
00230 };
00231 Q_DECLARE_TYPEINFO(QMetaClassInfo, Q_MOVABLE_TYPE);
00232 
00233 QT_END_NAMESPACE
00234 
00235 QT_END_HEADER
00236 
00237 #endif // QMETAOBJECT_H