00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GLUON_ENGINE_COMPONENT_H
00022 #define GLUON_ENGINE_COMPONENT_H
00023
00024 #include "gluon_engine_export.h"
00025 #include "core/gluonobject.h"
00026
00027 #include <QtCore/QSharedData>
00028 #include <QtPlugin>
00029
00034 namespace GluonEngine
00035 {
00036 class GameObject;
00037 class ComponentPrivate;
00038
00061 class GLUON_ENGINE_EXPORT Component : public GluonCore::GluonObject
00062 {
00063 Q_OBJECT
00069 Q_PROPERTY( QString description READ description WRITE setDescription )
00074 Q_PROPERTY( bool enabled READ enabled WRITE setEnabled )
00075
00076
00077 public:
00078 Q_INVOKABLE Component( QObject* parent = 0 );
00079 Component( const Component& other, QObject* parent = 0 );
00080 ~Component();
00081
00086 virtual QString category() const;
00087
00093 virtual QVariant toVariant( GluonObject* wrapThis );
00094
00099 virtual void initialize() {}
00105 virtual void start() {};
00115 virtual void update( int elapsedMilliseconds );
00129 virtual void draw( int timeLapse = 0 );
00130
00137 virtual void stop() {};
00138
00143 virtual void cleanup() {}
00144
00152 QString description() const;
00157 void setDescription( const QString& newDescription );
00158
00165 bool enabled() const;
00171 void setEnabled( bool newEnabled );
00172
00182 GameObject* gameObject();
00189 void setGameObject( GameObject* newGameObject );
00190
00197 void sanitize();
00198
00207 virtual QString stringFromProperty( const QString& propertyName, const QString& indentChars ) const;
00208
00209 private:
00210 ComponentPrivate* const d;
00211 };
00212 }
00213
00214 Q_DECLARE_INTERFACE( GluonEngine::Component, "com.gluon.Component/1.0" )
00215 Q_DECLARE_METATYPE( GluonEngine::Component )
00216 Q_DECLARE_METATYPE( GluonEngine::Component* )
00217
00218 #endif // GLUON_COMPONENT_H