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.
This commit is contained in:
parent
e86758084c
commit
97e4af36b8
|
@ -28,7 +28,7 @@ class Animator
|
||||||
|
|
||||||
friend class Item;
|
friend class Item;
|
||||||
|
|
||||||
Genode::List<Item> _items;
|
Genode::List<Genode::List_element<Item> > _items;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -41,10 +41,12 @@ class Animator
|
||||||
/**
|
/**
|
||||||
* Interface to be implemented by animated objects
|
* Interface to be implemented by animated objects
|
||||||
*/
|
*/
|
||||||
class Animator::Item : public Genode::List<Item>::Element
|
class Animator::Item
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Genode::List_element<Item> _element { this };
|
||||||
|
|
||||||
Animator &_animator;
|
Animator &_animator;
|
||||||
bool _animated = false;
|
bool _animated = false;
|
||||||
|
|
||||||
|
@ -62,9 +64,9 @@ class Animator::Item : public Genode::List<Item>::Element
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (animated)
|
if (animated)
|
||||||
_animator._items.insert(this);
|
_animator._items.insert(&_element);
|
||||||
else
|
else
|
||||||
_animator._items.remove(this);
|
_animator._items.remove(&_element);
|
||||||
|
|
||||||
_animated = animated;
|
_animated = animated;
|
||||||
}
|
}
|
||||||
|
@ -75,9 +77,9 @@ class Animator::Item : public Genode::List<Item>::Element
|
||||||
|
|
||||||
inline void Animator::animate()
|
inline void Animator::animate()
|
||||||
{
|
{
|
||||||
for (Item *item = _items.first(); item; ) {
|
for (Genode::List_element<Item> *item = _items.first(); item; ) {
|
||||||
Item *next = item->next();
|
Genode::List_element<Item> *next = item->next();
|
||||||
item->animate();
|
item->object()->animate();
|
||||||
item = next;
|
item = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user