2018-10-10 15:12:38 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-10 16:49:36 +02:00
|
|
|
#include <AK/Vector.h>
|
2018-10-13 17:00:45 +02:00
|
|
|
#include <AK/Weakable.h>
|
2018-10-10 16:49:36 +02:00
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
class Event;
|
2018-10-12 12:18:59 +02:00
|
|
|
class TimerEvent;
|
2018-10-10 15:12:38 +02:00
|
|
|
|
2018-10-13 17:00:45 +02:00
|
|
|
class Object : public Weakable<Object> {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
|
|
|
Object(Object* parent = nullptr);
|
|
|
|
virtual ~Object();
|
|
|
|
|
2018-11-15 15:36:35 +01:00
|
|
|
virtual const char* class_name() const { return "Object"; }
|
2018-10-10 16:49:36 +02:00
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
virtual void event(Event&);
|
|
|
|
|
2018-10-10 16:49:36 +02:00
|
|
|
Vector<Object*>& children() { return m_children; }
|
|
|
|
|
2018-10-12 01:03:22 +02:00
|
|
|
Object* parent() { return m_parent; }
|
|
|
|
const Object* parent() const { return m_parent; }
|
|
|
|
|
2018-10-12 12:18:59 +02:00
|
|
|
void startTimer(int ms);
|
|
|
|
void stopTimer();
|
|
|
|
bool hasTimer() const { return m_timerID; }
|
|
|
|
|
2018-10-10 16:49:36 +02:00
|
|
|
void addChild(Object&);
|
|
|
|
void removeChild(Object&);
|
|
|
|
|
2018-10-14 01:23:01 +02:00
|
|
|
void deleteLater();
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void timerEvent(TimerEvent&);
|
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
Object* m_parent { nullptr };
|
2018-10-10 16:49:36 +02:00
|
|
|
|
2018-10-12 12:18:59 +02:00
|
|
|
int m_timerID { 0 };
|
|
|
|
|
2018-10-10 16:49:36 +02:00
|
|
|
Vector<Object*> m_children;
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|