lib

scriptcontainer.h
1/***************************************************************************
2 * scriptcontainer.h
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#ifndef KROSS_API_SCRIPTCONTAINER_H
21#define KROSS_API_SCRIPTCONTAINER_H
22
23#include "mainmodule.h"
24
25#include <tqstring.h>
26#include <tqvariant.h>
27#include <tqobject.h>
28#include <ksharedptr.h>
29
30namespace Kross { namespace Api {
31
32 // Forward declarations.
33 class Object;
34 class List;
35 class ScriptContainerPrivate;
36
50 class KOFFICE_EXPORT ScriptContainer : public MainModule
51 {
52 // We protected the constructor cause ScriptContainer
53 // instances should be created only within the
54 // Manager::getScriptContainer() method.
55 friend class Manager;
56
57 protected:
58
70 explicit ScriptContainer(const TQString& name = TQString());
71
72 public:
73
75 typedef TDESharedPtr<ScriptContainer> Ptr;
76
80 virtual ~ScriptContainer();
81
86 const TQString getName() const;
87
91 void setName(const TQString& name);
92
96 TQString getCode() const;
97
101 void setCode(const TQString& code);
102
107 TQString getInterpreterName() const;
108
113 void setInterpreterName(const TQString& interpretername);
114
119 TQString getFile() const;
120
128 void setFile(const TQString& scriptfile);
129
135 TQStringVariantMap& getOptions();
136
146 TQVariant getOption(const TQString name, TQVariant defaultvalue = TQVariant(), bool recursive = false);
147
151 bool setOption(const TQString name, const TQVariant& value);
152
157
162 const TQStringList getFunctionNames();
163
174 TDESharedPtr<Object> callFunction(const TQString& functionname, TDESharedPtr<List> arguments = 0);
175
179 TQStringList getClassNames();
180
184 TDESharedPtr<Object> classInstance(const TQString& classname);
185
192 bool initialize();
193
200 void finalize();
201
202 private:
204 ScriptContainerPrivate* d;
205 };
206
207}}
208
209#endif
210
The List class implementates Value to handle lists and collections.
Definition list.h:39
MainModule(const TQString &name)
Constructor.
The common Object class all other object-classes are inheritated from.
Definition object.h:50
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:56
void setFile(const TQString &scriptfile)
Set the filename which will be executed on execute.
ScriptContainer(const TQString &name=TQString())
Constructor.
void setName(const TQString &name)
Set the name this ScriptContainer is reachable as.
const TQString getName() const
Object::Ptr execute()
Execute the script container.
TDESharedPtr< Object > callFunction(const TQString &functionname, TDESharedPtr< List > arguments=0)
Call a function in the script container.
TQStringList getClassNames()
Return a list of classes.
TQStringVariantMap & getOptions()
bool initialize()
Initialize the Script instance.
TQVariant getOption(const TQString name, TQVariant defaultvalue=TQVariant(), bool recursive=false)
TQString getCode() const
Return the scriptcode this ScriptContainer holds.
bool setOption(const TQString name, const TQVariant &value)
Set the Interpreter::Option value.
void setInterpreterName(const TQString &interpretername)
Set the name of the interpreter used on execute.
TDESharedPtr< ScriptContainer > Ptr
Shared pointer to implement reference-counting.
TDESharedPtr< Object > classInstance(const TQString &classname)
Create and return a new class instance.
void setCode(const TQString &code)
Set the scriptcode this ScriptContainer holds.
void finalize()
Finalize the Script instance and free's any cached or still running executions.
const TQStringList getFunctionNames()
Return a list of functionnames the with setCode defined scriptcode spends.
The common Kross API used as common codebase.
Definition callable.h:33
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33