lib
object.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KROSS_API_OBJECT_H
00021 #define KROSS_API_OBJECT_H
00022
00023 #include <qstring.h>
00024 #include <qvaluelist.h>
00025 #include <qmap.h>
00026 #include <qvariant.h>
00027
00028 #include <ksharedptr.h>
00029
00030 #include "../main/krossconfig.h"
00031
00032 namespace Kross { namespace Api {
00033
00034
00035 class List;
00036
00050 class Object : public KShared
00051 {
00052 public:
00053
00057 typedef KSharedPtr<Object> Ptr;
00058
00062 explicit Object();
00063
00067 virtual ~Object();
00068
00076 virtual const QString getClassName() const = 0;
00077
00083 virtual const QString toString();
00084
00102 virtual Object::Ptr call(const QString& name, KSharedPtr<List> arguments);
00103
00109 virtual QStringList getCalls() { return QStringList(); }
00110
00111
00121 template<class T> static T* fromObject(Object::Ptr object);
00122
00131 template<typename TYPE>
00132 static Object::Ptr toObject(TYPE t) { return t; }
00133 };
00134
00135 }}
00136
00137 #include "exception.h"
00138
00139 namespace Kross { namespace Api {
00140
00141 template<class T> inline T* Object::fromObject(Object::Ptr object)
00142 {
00143 T* t = (T*) object.data();
00144 if(! t)
00145 throw KSharedPtr<Exception>( new Exception(QString("Object \"%1\" invalid.").arg(object ? object->getClassName() : "")) );
00146 return t;
00147 }
00148
00149 }}
00150
00151 #endif
00152
|