Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: quickdispatchobject.h 1.1.4 edited 2006-02-23T15:39:57$ 00003 ** 00004 ** Copyright (C) 2001-2006 Trolltech AS. All rights reserved. 00005 ** 00006 ** This file is part of the Qt Script for Applications framework (QSA). 00007 ** 00008 ** This file may be distributed and/or modified under the terms of the 00009 ** GNU General Public License version 2 as published by the Free Software 00010 ** Foundation and appearing in the file LICENSE.GPL included in the 00011 ** packaging of this file. 00012 ** 00013 ** Licensees holding a valid Qt Script for Applications license may use 00014 ** this file in accordance with the Qt Script for Applications License 00015 ** Agreement provided with the Software. 00016 ** 00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00019 ** 00020 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00021 ** information about QSA Commercial License Agreements. 00022 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00023 ** 00024 ** Contact info@trolltech.com if any conditions of this licensing are 00025 ** not clear to you. 00026 ** 00027 *****************************************************************************/ 00028 00029 #ifndef QUICKDISPATCHOBJECT_H 00030 #define QUICKDISPATCHOBJECT_H 00031 00032 #include <qobject.h> 00033 #include <qptrvector.h> 00034 #include <qvaluelist.h> 00035 00036 class QuickInterpreter; 00037 class QuickDispatchObjectFactoryPrivate; 00038 00039 class QSObjectFactory; 00040 class QSWrapperFactory; 00041 00042 class QuickDispatchObjectFactory 00043 { 00044 public: 00045 QuickDispatchObjectFactory(QuickInterpreter *i); 00046 ~QuickDispatchObjectFactory(); 00047 00048 bool constructInterface(const QCString &className, 00049 void *ptr, 00050 QPtrVector<QObject> &result); 00051 00052 bool constructInstance(const QString &className, 00053 const QValueList<QVariant> &args, 00054 QPtrVector<QObject> &result); 00055 00056 QMap<QString, QObject *> staticDescriptors() const; 00057 QMap<QString, QString> instanceDescriptors() const; 00058 00059 QStringList classes() const; 00060 00061 void throwError(const QString &message) const; 00062 00063 QuickInterpreter *interpreter() const { 00064 return ip; 00065 } 00066 00067 void addObjectFactory(QSObjectFactory *factory); 00068 void addWrapperFactory(QSWrapperFactory *factory); 00069 00070 void removeObjectFactory(QSObjectFactory *factory); 00071 void removeWrapperFactory(QSWrapperFactory *factory); 00072 00073 private: 00074 bool createInterface(const QCString &className, void *ptr, QPtrVector<QObject> *); 00075 bool createInstance(const QString &className, 00076 const QValueList<QVariant> &args, 00077 QPtrVector<QObject> *); 00078 00079 void addInterface(QObject *iface, QPtrVector<QObject> *); 00080 void addObject(QObject *obj, QPtrVector<QObject> *); 00081 00082 private: 00083 QuickDispatchObjectFactoryPrivate *d; 00084 QuickInterpreter *ip; 00085 bool recurseBlock; 00086 }; 00087 00088 00089 class QuickUnnamedObject : public QObject 00090 { 00091 Q_OBJECT 00092 public: 00093 QuickUnnamedObject(QObject *p = 0, const char *n = 0) : QObject(p, n) {} 00094 QuickInterpreter *interpreter() const; 00095 void throwError(const QString &message) const; 00096 }; 00097 00098 00099 class QuickPtrDispatchObject : public QuickUnnamedObject 00100 { 00101 Q_OBJECT 00102 public: 00103 QuickPtrDispatchObject(const char *n, void *p); 00104 ~QuickPtrDispatchObject(); 00105 00106 void *pointer() const { 00107 return ptr; 00108 } 00109 void setPointer(void *p); 00110 00111 public slots: 00112 bool isValid() const { 00113 return !!ptr; 00114 } 00115 00116 private: 00117 void *ptr; 00118 }; 00119 00120 #endif