lib

interpreter.h

00001 /***************************************************************************
00002  * interpreter.h
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 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_API_INTERPRETER_H
00021 #define KROSS_API_INTERPRETER_H
00022 
00023 #include <qstring.h>
00024 #include <qmap.h>
00025 #include <kdebug.h>
00026 
00027 #include "object.h"
00028 
00029 namespace Kross { namespace Api {
00030 
00031     // Forward declaration.
00032     class Manager;
00033     class ScriptContainer;
00034     class Script;
00035     class Interpreter;
00036 
00042     class InterpreterInfo
00043     {
00044         public:
00045 
00050             class Option
00051             {
00052                 public:
00053 
00057                     typedef QMap<QString, Option*> Map;
00058 
00067                     Option(const QString& name, const QString& comment, const QVariant& value)
00068                         : name(name), comment(comment), value(value) {}
00069 
00071                     QString name;
00072 
00074                     QString comment;
00075 
00077                     QVariant value;
00078             };
00079 
00083             InterpreterInfo(const QString& interpretername, const QString& library, const QString& wildcard, QStringList mimetypes, Option::Map options);
00084 
00088             ~InterpreterInfo();
00089 
00093             const QString& getInterpretername();
00094 
00101             const QString& getWildcard();
00102 
00109             const QStringList getMimeTypes();
00110 
00114             bool hasOption(const QString& key);
00115 
00119             Option* getOption(const QString name);
00120 
00126             const QVariant& getOptionValue(const QString name, QVariant defaultvalue = QVariant());
00127 
00131             Option::Map getOptions();
00132 
00137             Interpreter* getInterpreter();
00138 
00139         private:
00141             QString m_interpretername;
00143             QString m_library;
00145             QString m_wildcard;
00147             QStringList m_mimetypes;
00149             Option::Map m_options;
00151             Interpreter* m_interpreter;
00152     };
00153 
00163     class Interpreter
00164     {
00165         public:
00166 
00173             Interpreter(InterpreterInfo* info);
00174 
00178             virtual ~Interpreter();
00179 
00188             virtual Script* createScript(ScriptContainer* scriptcontainer) = 0;
00189 
00190         protected:
00192             InterpreterInfo* m_interpreterinfo;
00193     };
00194 
00195 }}
00196 
00197 #endif
00198 
KDE Home | KDE Accessibility Home | Description of Access Keys