From 97e4af36b8d34563addaea6e4740786150722822 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 17 Aug 2017 16:56:29 +0200 Subject: [PATCH] gems/animator.h: use private 'List_element' This patch makes the use of 'List' invisible at the 'Animator' interface. This allows users of the utility to keep 'Animator::Items' in a custom 'List' with no aliasing problems. --- repos/gems/include/gems/animator.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/repos/gems/include/gems/animator.h b/repos/gems/include/gems/animator.h index 4f4b56bda..2ebaed407 100644 --- a/repos/gems/include/gems/animator.h +++ b/repos/gems/include/gems/animator.h @@ -28,7 +28,7 @@ class Animator friend class Item; - Genode::List _items; + Genode::List > _items; public: @@ -41,10 +41,12 @@ class Animator /** * Interface to be implemented by animated objects */ -class Animator::Item : public Genode::List::Element +class Animator::Item { private: + Genode::List_element _element { this }; + Animator &_animator; bool _animated = false; @@ -62,9 +64,9 @@ class Animator::Item : public Genode::List::Element return; if (animated) - _animator._items.insert(this); + _animator._items.insert(&_element); else - _animator._items.remove(this); + _animator._items.remove(&_element); _animated = animated; } @@ -75,9 +77,9 @@ class Animator::Item : public Genode::List::Element inline void Animator::animate() { - for (Item *item = _items.first(); item; ) { - Item *next = item->next(); - item->animate(); + for (Genode::List_element *item = _items.first(); item; ) { + Genode::List_element *next = item->next(); + item->object()->animate(); item = next; } }