#include <callable.h>
Inheritance diagram for Kross::Api::Callable:


Definition at line 41 of file callable.h.
Public Types | |
| typedef KSharedPtr< Callable > | Ptr |
Public Member Functions | |
| Callable (const QString &name, Object::Ptr parent, const ArgumentList &arglist) | |
| virtual | ~Callable () |
| virtual const QString | getClassName () const |
| virtual Object::Ptr | call (const QString &name, List::Ptr arguments) |
| Object::Ptr | hasChild (List::Ptr args) |
| Object::Ptr | getChild (List::Ptr args) |
| Object::Ptr | getChildrenList (List::Ptr args) |
| Object::Ptr | getChildrenDict (List::Ptr args) |
| Object::Ptr | callChild (List::Ptr args) |
| const QString & | getName () const |
| virtual const QString | toString () |
| Object::Ptr | getParent () const |
| bool | hasChild (const QString &name) const |
| Object::Ptr | getChild (const QString &name) const |
| QMap< QString, Object::Ptr > | getChildren () 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) |
Protected Attributes | |
| ArgumentList | m_arglist |
|
|
Shared pointer to implement reference-counting. Reimplemented from Kross::Api::Object. Reimplemented in Kross::Api::EventAction, Kross::Api::EventScript, Kross::Api::EventSignal, Kross::Api::EventSlot, Kross::Api::Module, Kross::Api::QtObject, Kross::Api::MainModule, Kross::Api::ScriptAction, and Kross::Api::ScriptContainer. Definition at line 48 of file callable.h. |
|
||||||||||||||||
|
Constructor.
Definition at line 28 of file callable.cpp.
|
|
|
Destructor. Definition at line 34 of file callable.cpp.
|
|
||||||||||||
|
Add a new child. Replaces a possible already existing child with such a name.
Definition at line 79 of file object.cpp. References QString::arg(), QString::isEmpty(), QString::isNull(), and QMap::replace(). Referenced by Kross::Api::MainModule::addKAction(), Kross::Api::MainModule::addQObject(), Kross::Api::MainModule::addSignal(), Kross::Api::MainModule::addSlot(), Kross::Api::QtObject::QtObject(), and TestPluginModule::TestPluginModule(). 00080 { 00081 QString n = name.isNull() ? object->getName() : name; 00082 00083 #ifdef KROSS_API_OBJECT_ADDCHILD_DEBUG 00084 kdDebug() << QString("Kross::Api::Object::addChild() object.name='%2' object.classname='%3'") 00085 .arg(n).arg(object->getClassName()) << endl; 00086 #endif 00087 00088 if(n.isEmpty()) // prevent invalid items. 00089 return false; //throw Exception::Ptr( new Exception( QString("Failed to add child object to object '%1'. Invalid name for class '%2'.").arg(getName()).arg(object->getClassName()) ) ); 00090 00091 object->m_parent = this; 00092 m_children.replace(n, object); 00093 return true; 00094 }
|
|
||||||||||||
|
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.
Reimplemented in Kross::Api::EventScript, Kross::Api::EventSignal, and Kross::Api::EventSlot. Referenced by call(), and callChild(). |
|
||||||||||||
|
Call the object. Reimplemented in Kross::Api::Event< T >, Kross::Api::Event< EventSignal >, Kross::Api::Event< Module >, Kross::Api::Event< EventSlot >, Kross::Api::Event< EventAction >, Kross::Api::Event< TestPluginObject >, Kross::Api::Event< EventScript >, and Kross::Api::Event< QtObject >. Definition at line 43 of file callable.cpp. References Kross::Api::Object::call(), callChild(), getChild(), getChildrenDict(), getChildrenList(), Kross::Api::Object::getName(), and hasChild(). 00044 { 00045 #ifdef KROSS_API_CALLABLE_CALL_DEBUG 00046 kdDebug() << QString("Kross::Api::Callable::call() name=%1 getName()=%2 arguments=%3").arg(name).arg(getName()).arg(arguments ? arguments->toString() : QString("")) << endl; 00047 #endif 00048 00049 if(name == "get") { 00050 //checkArguments( ArgumentList() << Argument("Kross::Api::Variant::String") ); 00051 return getChild(arguments); 00052 } 00053 else if(name == "has") { 00054 //checkArguments( ArgumentList() << Argument("Kross::Api::Variant::String") ); 00055 return hasChild(arguments); 00056 } 00057 else if(name == "call") { 00058 //checkArguments( ArgumentList() << Argument("Kross::Api::Variant::String") << Argument("Kross::Api::List", new List( QValueList<Object::Ptr>() )) ); 00059 return callChild(arguments); 00060 } 00061 else if(name == "list") { 00062 //checkArguments( ArgumentList() << Argument("Kross::Api::Variant::String") << Argument("Kross::Api::List", new List( QValueList<Object::Ptr>() )) ); 00063 return getChildrenList(arguments); 00064 } 00065 else if(name == "dict") { 00066 //checkArguments( ArgumentList() << Argument("Kross::Api::Variant::String") << Argument("Kross::Api::List", new List( QValueList<Object::Ptr>() )) ); 00067 return getChildrenDict(arguments); 00068 } 00069 00070 return Object::call(name, arguments); 00071 }
|
|
|
Wrapper for the Kross::Api::Object::call() method to call a children. Definition at line 172 of file callable.cpp. References Kross::Api::Object::call(), and Kross::Api::Variant::toString(). Referenced by call(). 00173 { 00174 //kdDebug() << QString("Kross::Api::Callable::callChild() getName()=%1").arg(getName()) << endl; 00175 return Object::call(Variant::toString(args->item(0)), args); 00176 }
|
|
||||||||||
|
Try to convert the Object instance to the template class T.
Definition at line 198 of file object.h. 00199 { 00200 T* t = (T*) object.data(); 00201 if(! t) 00202 throw KSharedPtr<Exception>( new Exception(QString("Object \"%1\" invalid.").arg(object ? object->getClassName() : "")) ); 00203 return t; 00204 }
|
|
|
Return a list of supported callable objects.
Reimplemented in Kross::Python::PythonObject. Definition at line 186 of file object.h. 00186 { return QStringList(); }
|
|
|
Return the defined child or NULL if there is no such object with that name avaible.
Definition at line 69 of file object.cpp. Referenced by getChild().
|
|
|
Wrapper for the Kross::Api::Object::getChild() method to return a children this object has. Definition at line 146 of file callable.cpp. References Kross::Api::Object::getChild(), Kross::Api::Object::getName(), and Kross::Api::Variant::toString(). Referenced by call(). 00147 { 00148 QString s = Variant::toString(args->item(0)); 00149 //kdDebug() << QString("Kross::Api::Callable::getChild() getName()=%1 childName=%2").arg(getName()).arg(s) << endl; 00150 Object::Ptr obj = Object::getChild(s); 00151 if(! obj) 00152 throw Exception::Ptr( new Exception(QString("The object '%1' has no child object '%2'").arg(getName()).arg(s)) ); 00153 return obj; 00154 }
|
|
|
Return all children.
Definition at line 74 of file object.cpp. Referenced by getChildrenDict(), and getChildrenList().
|
|
|
Wrapper for the Kross::Api::Object::getChild() method to return a dictonary of children this object has.
Definition at line 166 of file callable.cpp. References Kross::Api::Object::getChildren(). Referenced by call(). 00167 { 00168 //kdDebug()<<"Kross::Api::Callable::getChildrenDict()"<<endl; 00169 return new Dict(Object::getChildren(), "Kross::Api::Callable::getChildrenDict::Dict"); 00170 }
|
|
|
Wrapper for the Kross::Api::Object::getChildren() method to return a list of childrennames this object has.
Definition at line 156 of file callable.cpp. References QMap::begin(), QMap::end(), and Kross::Api::Object::getChildren(). Referenced by call(). 00157 { 00158 QStringList list; 00159 QMap<QString, Object::Ptr> children = getChildren(); 00160 QMap<QString, Object::Ptr>::Iterator it( children.begin() ); 00161 for(; it != children.end(); ++it) 00162 list.append( it.key() ); 00163 return new Variant(list); 00164 }
|
|
|
Return the class name. This could be something like "Kross::Api::Callable" for this object. The value is mainly used for display purposes.
Implements Kross::Api::Object. Reimplemented in Kross::Api::EventAction, Kross::Api::EventScript, Kross::Api::EventSignal, Kross::Api::EventSlot, Kross::Api::QtObject, Kross::Api::MainModule, TestPluginObject, and TestPluginModule. Definition at line 38 of file callable.cpp.
|
|
|
Return the name this object has.
Reimplemented in Kross::Api::ScriptContainer. Definition at line 49 of file object.cpp. Referenced by Kross::Api::Event< QtObject >::call(), call(), getChild(), and Kross::Api::Module::~Module().
|
|
|
Return the parent object or NULL if this object doesn't has a parent.
Definition at line 59 of file object.cpp.
|
|
|
Returns if the defined child is avaible.
Reimplemented in Kross::Api::MainModule. Definition at line 64 of file object.cpp. References QMap::contains(). Referenced by Kross::Api::MainModule::hasChild(), and hasChild(). 00065 { 00066 return m_children.contains(name); 00067 }
|
|
|
Wrapper for the Kross::Api::Object::hasChild() method to check if this object has children. Definition at line 139 of file callable.cpp. References Kross::Api::Object::hasChild(), and Kross::Api::Variant::toString(). Referenced by call(). 00140 { 00141 //kdDebug() << QString("Kross::Api::Callable::hasChild() getName()=%1").arg(getName()) << endl; 00142 return new Variant( Object::hasChild( Variant::toString(args->item(0)) ), 00143 "Kross::Api::Callable::hasChild::Bool" ); 00144 }
|
|
|
Remove all children. Definition at line 104 of file object.cpp. References QMap::clear(). 00105 { 00106 #ifdef KROSS_API_OBJECT_REMCHILD_DEBUG 00107 kdDebug() << "Kross::Api::Object::removeAllChildren()" << endl; 00108 #endif 00109 m_children.clear(); 00110 }
|
|
|
Remove an existing child.
Definition at line 96 of file object.cpp. References QMap::remove(). 00097 { 00098 #ifdef KROSS_API_OBJECT_REMCHILD_DEBUG 00099 kdDebug() << QString("Kross::Api::Object::removeChild() name='%1'").arg(name) << endl; 00100 #endif 00101 m_children.remove(name); 00102 }
|
|
|
Reimplemented in Kross::Api::Dict, Kross::Api::Exception, Kross::Api::List, and Kross::Api::Variant. Definition at line 54 of file object.cpp. References QString::arg(), and Kross::Api::Object::getClassName(). 00055 { 00056 return QString("%1 (%2)").arg(m_name).arg(getClassName()); 00057 }
|
|
|
List of arguments this callable object supports. Definition at line 123 of file callable.h. |
1.4.6