lib

scriptcontainer.h

00001 /***************************************************************************
00002  * scriptcontainer.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_SCRIPTCONTAINER_H
00021 #define KROSS_API_SCRIPTCONTAINER_H
00022 
00023 #include "mainmodule.h"
00024 
00025 #include <qstring.h>
00026 #include <qvariant.h>
00027 #include <qobject.h>
00028 #include <ksharedptr.h>
00029 
00030 namespace Kross { namespace Api {
00031 
00032     // Forward declarations.
00033     class Object;
00034     class List;
00035     class ScriptContainerPrivate;
00036 
00050     class ScriptContainer : public MainModule
00051     {
00052             // We protected the constructor cause ScriptContainer
00053             // instances should be created only within the
00054             // Manager::getScriptContainer() method.
00055             friend class Manager;
00056 
00057         protected:
00058 
00070             explicit ScriptContainer(const QString& name = QString::null);
00071 
00072         public:
00073 
00075             typedef KSharedPtr<ScriptContainer> Ptr;
00076 
00080             virtual ~ScriptContainer();
00081 
00086             const QString getName() const;
00087 
00091             void setName(const QString& name);
00092 
00096             QString getCode() const;
00097 
00101             void setCode(const QString& code);
00102 
00107             QString getInterpreterName() const;
00108 
00113             void setInterpreterName(const QString& interpretername);
00114 
00119             QString getFile() const;
00120 
00128             void setFile(const QString& scriptfile);
00129 
00135             QMap<QString, QVariant>& getOptions();
00136 
00146             QVariant getOption(const QString name, QVariant defaultvalue = QVariant(), bool recursive = false);
00147 
00151             bool setOption(const QString name, const QVariant& value);
00152 
00156             Object::Ptr execute();
00157 
00162             const QStringList getFunctionNames();
00163 
00174             KSharedPtr<Object> callFunction(const QString& functionname, KSharedPtr<List> arguments = 0);
00175 
00179             QStringList getClassNames();
00180 
00184             KSharedPtr<Object> classInstance(const QString& classname);
00185 
00192             bool initialize();
00193 
00200             void finalize();
00201 
00202         private:
00204             ScriptContainerPrivate* d;
00205     };
00206 
00207 }}
00208 
00209 #endif
00210 
KDE Home | KDE Accessibility Home | Description of Access Keys