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 "object.h"
24#include "list.h"
25//#include "exception.h"
26
27#include <tqstring.h>
28#include <tqvaluelist.h>
29#include <ksharedptr.h>
30
31namespace Kross { namespace Api {
32
39 class Callable : public Object
40 {
41 public:
42
46 typedef TDESharedPtr<Callable> Ptr;
47
54 Callable(const TQString& name);
55
59 virtual ~Callable();
60
66 const TQString getName() const;
67
75 virtual const TQString getClassName() const;
76
82 bool hasChild(const TQString& name) const;
83
92 Object::Ptr getChild(const TQString& name) const;
93
99 TQMap<TQString, Object::Ptr> getChildren() const;
100
110 bool addChild(const TQString& name, Object* object);
111
116 bool addChild(Callable* object);
117
125 void removeChild(const TQString& name);
126
130 void removeAllChildren();
131
135 virtual Object::Ptr call(const TQString& name, List::Ptr arguments);
136
137 private:
139 TQString m_name;
141 TQMap<TQString, Object::Ptr> m_children;
142 };
143
144}}
145
146#endif
147
Base class for callable objects.
Definition callable.h:40
TQMap< TQString, Object::Ptr > getChildren() const
Return all children.
Definition callable.cpp:58
virtual ~Callable()
Destructor.
Definition callable.cpp:34
TDESharedPtr< Callable > Ptr
Shared pointer to implement reference-counting.
Definition callable.h:46
bool hasChild(const TQString &name) const
Returns if the defined child is avaible.
Definition callable.cpp:48
virtual Object::Ptr call(const TQString &name, List::Ptr arguments)
Call the object.
Definition callable.cpp:94
bool addChild(const TQString &name, Object *object)
Add a new child.
Definition callable.cpp:63
const TQString getName() const
Definition callable.cpp:38
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:53
virtual const TQString getClassName() const
Return the class name.
Definition callable.cpp:43
void removeAllChildren()
Remove all children.
Definition callable.cpp:86
void removeChild(const TQString &name)
Remove an existing child.
Definition callable.cpp:78
TDESharedPtr< List > Ptr
Shared pointer to implement reference-counting.
Definition list.h:44
The common Object class all other object-classes are inheritated from.
Definition object.h:51
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:57
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:31