Path: blob/devel/ElmerGUI/PythonQt/src/PythonQtClassInfo.h
3206 views
#ifndef _PYTHONQTCLASSINFO_H1#define _PYTHONQTCLASSINFO_H23/*4*5* Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.6*7* This library is free software; you can redistribute it and/or8* modify it under the terms of the GNU Lesser General Public9* License as published by the Free Software Foundation; either10* version 2.1 of the License, or (at your option) any later version.11*12* This library is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU15* Lesser General Public License for more details.16*17* Further, this software is distributed without any warranty that it is18* free of the rightful claim of any third person regarding infringement19* or the like. Any license provided herein, whether implied or20* otherwise, applies only to this software file. Patent licenses, if21* any, provided herein do not apply to combinations of this program with22* other software, or any other product whatsoever.23*24* You should have received a copy of the GNU Lesser General Public25* License along with this library; if not, write to the Free Software26* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA27*28* Contact information: MeVis Research GmbH, Universitaetsallee 29,29* 28359 Bremen, Germany or:30*31* http://www.mevis.de32*33*/3435#include <QMetaObject>36#include <QMetaMethod>37#include <QHash>38#include <QByteArray>39#include <QList>4041class PythonQtSlotInfo;4243struct PythonQtMemberInfo {44enum Type {45Invalid, Slot, EnumValue, Property46};4748PythonQtMemberInfo() { _type = Invalid; }4950PythonQtMemberInfo(PythonQtSlotInfo* info) {51_type = Slot;52_slot = info;53_enumValue = 0;54}5556PythonQtMemberInfo(unsigned int enumValue) {57_type = EnumValue;58_slot = NULL;59_enumValue = enumValue;60}6162PythonQtMemberInfo(const QMetaProperty& prop) {63_type = Property;64_slot = NULL;65_enumValue = 0;66_property = prop;67}6869PythonQtSlotInfo* _slot;70unsigned int _enumValue;71QMetaProperty _property;72Type _type;73};7475//! a class that stores all required information about a Qt object (and an optional associated C++ class name)76/*! for fast lookup of slots when calling the object from Python77*/78class PythonQtClassInfo {7980public:81PythonQtClassInfo(const QMetaObject* meta, const QByteArray& wrappedClassName = QByteArray());8283~PythonQtClassInfo();8485//! get the Python method definition for a given slot name (without return type and signature)86PythonQtMemberInfo member(const char* member);8788PythonQtSlotInfo* constructors();8990//! get the Qt classname91const char* className();9293//! get the classname of the wrapped C++ class94const QByteArray& wrappedCPPClassName();9596//! returns if the object is a CPP wrapper97bool isCPPWrapper() { return !_wrappedClassName.isEmpty(); }9899//! get the meta object100const QMetaObject* metaObject() { return _meta; }101102//! set the meta object, this will reset the caching103void setMetaObject(const QMetaObject* meta);104105//! returns if the meta object inherits the given classname106bool inherits(const char* name);107108//! get help string for the metaobject109QString help();110111//! get list of all members112QStringList memberList(bool metaOnly = false);113114private:115PythonQtSlotInfo* findDecoratorSlots(const char* classname, const char* memberName, int memberNameLen, PythonQtSlotInfo* tail, bool &found);116int findCharOffset(const char* sigStart, char someChar);117QHash<QByteArray, PythonQtMemberInfo> _cachedMembers;118PythonQtSlotInfo* _constructors;119const QMetaObject* _meta;120QByteArray _wrappedClassName;121};122123//---------------------------------------------------------------124125126#endif127128129