#include <dict.h>
Inheritance diagram for Kross::Api::Dict:


Definition at line 35 of file dict.h.
Public Types | |
| typedef KSharedPtr< Object > | Ptr |
Public Member Functions | |
| Dict (const QMap< QString, Object::Ptr > value, const QString &name="dict") | |
| virtual | ~Dict () |
| virtual const QString | getClassName () const |
| virtual const QString | toString () |
| V & | getValue () |
| const QString & | getName () const |
| 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) |
Friends | |
| class | Value< List, QMap< QString, 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. |
|
||||||||||||
|
Constructor.
Definition at line 25 of file dict.cpp. 00026 : Value< List, QMap<QString, Object::Ptr> >(value, name) 00027 { 00028 }
|
|
|
Destructor. Definition at line 30 of file dict.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 Kross::Api::Callable::call(), and Kross::Api::Callable::callChild(). |
|
||||||||||
|
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 Kross::Api::Callable::getChild().
|
|
|
Return all children.
Definition at line 74 of file object.cpp. Referenced by Kross::Api::Callable::getChildrenDict(), and Kross::Api::Callable::getChildrenList().
|
|
|
Implements Kross::Api::Object. Definition at line 34 of file dict.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(), Kross::Api::Callable::call(), Kross::Api::Callable::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 Kross::Api::Callable::hasChild(). 00065 { 00066 return m_children.contains(name); 00067 }
|
|
|
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 from Kross::Api::Object. Definition at line 39 of file dict.cpp. References QMap::begin(), QString::data(), QMap::end(), QString::endsWith(), Kross::Api::Value< T, V >::getValue(), QString::left(), and QString::length(). 00040 { 00041 QString s = "["; 00042 QMap<QString, Object::Ptr> list = getValue(); 00043 for(QMap<QString, Object::Ptr>::Iterator it = list.begin(); it != list.end(); ++it) 00044 s += "'" + it.key() + "' = '" + it.data()->toString() + "', "; 00045 return (s.endsWith(", ") ? s.left(s.length() - 2) : s) + "]"; 00046 }
|
1.4.6