Kross
interpreter.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * interpreter.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2006 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #ifndef KROSS_INTERPRETER_H 00021 #define KROSS_INTERPRETER_H 00022 00023 #include "errorinterface.h" 00024 00025 #include <QtCore/QStringList> 00026 #include <QtCore/QVariant> 00027 #include <QtCore/QMap> 00028 #include <QtCore/QObject> 00029 00030 namespace Kross { 00031 00032 // Forward declaration. 00033 class Manager; 00034 class Action; 00035 class Script; 00036 class Interpreter; 00037 00043 class KROSSCORE_EXPORT InterpreterInfo 00044 { 00045 public: 00046 00051 class Option 00052 { 00053 public: 00054 00058 typedef QMap< QString, Option* > Map; 00059 00067 Option(const QString& comment, const QVariant& value) 00068 : comment(comment), value(value) {} 00069 00071 QString comment; 00072 00074 QVariant value; 00075 }; 00076 00102 InterpreterInfo(const QString& interpretername, void* funcPtr, const QString& wildcard, const QStringList& mimetypes, const Option::Map& options = Option::Map()); 00103 00107 ~InterpreterInfo(); 00108 00112 const QString interpreterName() const; 00113 00120 const QString wildcard() const; 00121 00126 const QStringList mimeTypes() const; 00127 00131 bool hasOption(const QString& name) const; 00132 00136 Option* option(const QString& name) const; 00137 00141 Option::Map& options(); 00142 00148 const QVariant optionValue(const QString& name, const QVariant& defaultvalue = QVariant()) const; 00149 00158 Interpreter* interpreter(); 00159 00160 private: 00162 class Private; 00164 Private* const d; 00165 }; 00166 00177 class KROSSCORE_EXPORT Interpreter : public QObject, public ErrorInterface 00178 { 00179 Q_OBJECT 00180 public: 00181 00188 explicit Interpreter(InterpreterInfo* info); 00189 00193 virtual ~Interpreter(); 00194 00199 InterpreterInfo* interpreterInfo() const; 00200 00209 virtual Script* createScript(Action* Action) = 0; 00210 00211 private: 00213 class Private; 00215 Private* const d; 00216 }; 00217 00218 } 00219 00220 #endif 00221