lib

Kross::Api::Object Class Reference

#include <object.h>

Inheritance diagram for Kross::Api::Object:

Kross::Api::Callable Kross::Api::Exception Kross::Api::Value< T, V > Kross::Api::Value< List, QMap< QString, Object::Ptr > > Kross::Api::Value< List, QValueList< Object::Ptr > > Kross::Api::Value< Variant, QVariant > Kross::Python::PythonObject Kross::Api::Event< T > Kross::Api::Event< EventAction > Kross::Api::Event< EventScript > Kross::Api::Event< EventSignal > Kross::Api::Event< EventSlot > Kross::Api::Event< Module > Kross::Api::Event< QtObject > Kross::Api::Dict Kross::Api::List Kross::Api::Variant List of all members.

Detailed Description

The common Object class all other object-classes are inheritated from.

The Object class is used as base class to provide common functionality. It's similar to what we know in Python as PyObject or in Qt as QObject.

Inherited from e.g. Value, Module and Class .

This class implementates reference counting for shared objects. So, no need to take care of freeing objects.

Definition at line 56 of file object.h.


Public Types

typedef KSharedPtr< ObjectPtr

Public Member Functions

 Object (const QString &name, Object::Ptr parent=0)
virtual ~Object ()
const QString & getName () const
virtual const QString getClassName () const =0
virtual const QString toString ()
Object::Ptr getParent () const
bool hasChild (const QString &name) const
Object::Ptr getChild (const QString &name) const
QMap< QString, Object::PtrgetChildren () const
bool addChild (Object::Ptr object, const QString &name=QString::null)
void removeChild (const QString &name)
void removeAllChildren ()
virtual Object::Ptr call (const QString &name, KSharedPtr< List > arguments)
virtual QStringList getCalls ()

Static Public Member Functions

template<class T>
static T * fromObject (Object::Ptr object)

Member Typedef Documentation

typedef KSharedPtr<Object> Kross::Api::Object::Ptr
 

Shared pointer to implement reference-counting.

Reimplemented in Kross::Api::Callable, Kross::Api::EventAction, Kross::Api::EventScript, Kross::Api::EventSignal, Kross::Api::EventSlot, Kross::Api::Exception, Kross::Api::List, Kross::Api::Module, Kross::Api::QtObject, Kross::Api::MainModule, Kross::Api::ScriptAction, and Kross::Api::ScriptContainer.

Definition at line 63 of file object.h.


Constructor & Destructor Documentation

Object::Object const QString &  name,
Object::Ptr  parent = 0
[explicit]
 

Constructor.

Parameters:
name The name this object has. Return it via getName() and set a new name via setName().
parent The parent Object or NULL if this object doesn't has an parent.

Definition at line 31 of file object.cpp.

Object::~Object  )  [virtual]
 

Destructor.

Definition at line 41 of file object.cpp.


Member Function Documentation

bool Object::addChild Object::Ptr  object,
const QString &  name = QString::null
 

Add a new child.

Replaces a possible already existing child with such a name.

Parameters:
name the name of the child
object The Object to add.
Returns:
true if the Object was added successfully else false.

Definition at line 79 of file object.cpp.

virtual Object::Ptr Kross::Api::Object::call const QString &  name,
KSharedPtr< List arguments
[virtual]
 

Pass a call to the object and evaluated it recursive down the object-hierachy.

Objects like Class are able to handle call's by just implementing this function. If the call is done the called() method will be executed recursive from bottom up the call hierachy.

Exceptions:
TypeException if the object or the name is not callable.
Parameters:
name Each call has a name that says what should be called. In the case of a Class the name is the functionname.
arguments The list of arguments passed to the call.
Returns:
The call-result as Object::Ptr instance or NULL if the call has no result.

Reimplemented in Kross::Api::EventScript, Kross::Api::EventSignal, and Kross::Api::EventSlot.

template<class T>
static T* Kross::Api::Object::fromObject Object::Ptr  object  )  [inline, static]
 

Try to convert the Object instance to the template class T.

Exceptions:
TypeException if the cast failed.
Parameters:
object The Object to cast.
Returns:
The to a instance from template type T casted Object.

Definition at line 198 of file object.h.

virtual QStringList Kross::Api::Object::getCalls  )  [inline, virtual]
 

Return a list of supported callable objects.

Returns:
List of supported calls.

Reimplemented in Kross::Python::PythonObject.

Definition at line 186 of file object.h.

Object::Ptr Object::getChild const QString &  name  )  const
 

Return the defined child or NULL if there is no such object with that name avaible.

Parameters:
name The name of the Object to return.
Returns:
The Object matching to the defined name or NULL if there is no such Object.

Definition at line 69 of file object.cpp.

QMap< QString, Object::Ptr > Object::getChildren  )  const
 

Return all children.

Returns:
A ObjectMap of children this Object has.

Definition at line 74 of file object.cpp.

virtual const QString Kross::Api::Object::getClassName  )  const [pure virtual]
 

Return the class name.

This could be something like "Kross::Api::Object" for this object. The value is mainly used for display purposes.

Returns:
The name of this class.

Implemented in Kross::Api::Callable, Kross::Api::Dict, Kross::Api::EventAction, Kross::Api::EventScript, Kross::Api::EventSignal, Kross::Api::EventSlot, Kross::Api::Exception, Kross::Api::List, Kross::Api::QtObject, Kross::Api::Variant, Kross::Api::MainModule, and Kross::Python::PythonObject.

const QString & Object::getName  )  const
 

Return the name this object has.

Returns:
Name of this object.

Reimplemented in Kross::Api::ScriptContainer.

Definition at line 49 of file object.cpp.

Object::Ptr Object::getParent  )  const
 

Return the parent object or NULL if this object doesn't has a parent.

Returns:
The parent-Object or NULL if this Object doesn't has a parent.

Definition at line 59 of file object.cpp.

bool Object::hasChild const QString &  name  )  const
 

Returns if the defined child is avaible.

Returns:
true if child exists else false.

Reimplemented in Kross::Api::MainModule.

Definition at line 64 of file object.cpp.

void Object::removeAllChildren  ) 
 

Remove all children.

Definition at line 104 of file object.cpp.

void Object::removeChild const QString &  name  ) 
 

Remove an existing child.

Parameters:
name The name of the Object to remove. If there doesn't exists an Object with such name just nothing will be done.

Definition at line 96 of file object.cpp.

const QString Object::toString  )  [virtual]
 

Returns:
a string representation of the object or it's content. This method is mainly used for debugging and testing purposes.

Reimplemented in Kross::Api::Dict, Kross::Api::Exception, Kross::Api::List, and Kross::Api::Variant.

Definition at line 54 of file object.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys