#include "Object.h" #include "Event.h" #include Object::Object(Object* parent) : m_parent(parent) { if (m_parent) m_parent->addChild(*this); } Object::~Object() { if (m_parent) m_parent->removeChild(*this); auto childrenToDelete = std::move(m_children); for (auto* child : childrenToDelete) delete child; } void Object::event(Event& event) { switch (event.type()) { case Event::Invalid: ASSERT_NOT_REACHED(); break; default: break; } } void Object::addChild(Object& object) { m_children.append(&object); } void Object::removeChild(Object& object) { // Oh geez, Vector needs a remove() huh... Vector newList; for (auto* child : m_children) { if (child != &object) newList.append(child); } m_children = std::move(newList); }