lib

callable.h
1/***************************************************************************
2 * callable.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_CALLABLE_H
21#define KROSS_API_CALLABLE_H
22
23#include "koffice_export.h"
24
25#include "object.h"
26#include "list.h"
27//#include "exception.h"
28
29#include <tqstring.h>
30#include <tqvaluelist.h>
31#include <ksharedptr.h>
32
33namespace Kross { namespace Api {
34
41 class KOFFICE_EXPORT Callable : public Object
42 {
43 public:
44
48 typedef TDESharedPtr<Callable> Ptr;
49
56 Callable(const TQString& name);
57
61 virtual ~Callable();
62
68 const TQString getName() const;
69
77 virtual const TQString getClassName() const;
78
84 bool hasChild(const TQString& name) const;
85
94 Object::Ptr getChild(const TQString& name) const;
95
101 TQMap<TQString, Object::Ptr> getChildren() const;
102
112 bool addChild(const TQString& name, Object* object);
113
118 bool addChild(Callable* object);
119
127 void removeChild(const TQString& name);
128
132 void removeAllChildren();
133
137 virtual Object::Ptr call(const TQString& name, List::Ptr arguments);
138
139 private:
141 TQString m_name;
143 TQMap<TQString, Object::Ptr> m_children;
144 };
145
146}}
147
148#endif
149
TQMap< TQString, Object::Ptr > getChildren() const
Return all children.
Definition callable.cpp:57
TDESharedPtr< Callable > Ptr
Shared pointer to implement reference-counting.
Definition callable.h:48
bool hasChild(const TQString &name) const
Returns if the defined child is avaible.
Definition callable.cpp:47
virtual Object::Ptr call(const TQString &name, List::Ptr arguments)
Call the object.
Definition callable.cpp:93
bool addChild(const TQString &name, Object *object)
Add a new child.
Definition callable.cpp:62
const TQString getName() const
Definition callable.cpp:37
Callable(const TQString &name)
Constructor.
Definition callable.cpp:27
Object::Ptr getChild(const TQString &name) const
Return the defined child or NULL if there is no such object with that name avaible.
Definition callable.cpp:52
virtual const TQString getClassName() const
Return the class name.
Definition callable.cpp:42
void removeAllChildren()
Remove all children.
Definition callable.cpp:85
void removeChild(const TQString &name)
Remove an existing child.
Definition callable.cpp:77
TDESharedPtr< List > Ptr
Shared pointer to implement reference-counting.
Definition list.h:46
Object()
Constructor.
Definition object.cpp:29
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:56
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