KTutorial  0.5.1
ScriptingModule.h
00001 /***************************************************************************
00002  *   Copyright (C) 2009 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00003  *   Copyright (C) 2010 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00004  *   Copyright (C) 2011 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00005  *   Copyright (C) 2012 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; If not, see <http://www.gnu.org/licenses/>.  *
00019  ***************************************************************************/
00020 
00021 #ifndef KTUTORIAL_SCRIPTING_SCRIPTINGMODULE_H
00022 #define KTUTORIAL_SCRIPTING_SCRIPTINGMODULE_H
00023 
00024 #include <QHash>
00025 #include <QObject>
00026 
00027 class Option;
00028 class WaitFor;
00029 
00030 namespace ktutorial {
00031 namespace scripting {
00032 class ScriptedStep;
00033 }
00034 }
00035 
00036 namespace ktutorial {
00037 namespace scripting {
00038 
00066 class ScriptingModule: public QObject {
00067 Q_OBJECT
00068 public:
00069 
00075     static ScriptingModule* self();
00076 
00080     virtual ~ScriptingModule();
00081 
00099     bool registerWaitForMetaObject(const QMetaObject& waitForMetaObject,
00100                                    const QString& typeName = QString());
00101 
00110     Q_INVOKABLE QObject* findObject(const QString& name);
00111 
00121     Q_INVOKABLE QObject* newOption(const QString& name);
00122 
00132     Q_INVOKABLE QObject* newStep(const QString& id);
00133 
00148     Q_INVOKABLE QObject* newWaitFor(const QString& typeName);
00149 
00150 private:
00151 
00155     QHash<QString, QMetaObject> mWaitForMetaObjects;
00156 
00160     static ScriptingModule* sSelf;
00161 
00166     ScriptingModule();
00167 
00174     bool inheritsWaitFor(const QMetaObject& metaObject) const;
00175 
00184     bool hasInvokableDefaultConstructor(const QMetaObject& metaObject) const;
00185 
00186 };
00187 
00188 }
00189 }
00190 
00191 #endif