base: provide class Genode::Fifo_element

ref #528
This commit is contained in:
Martin Stein
2013-09-06 01:27:53 +02:00
committed by Norman Feske
parent 9826294e6c
commit bf37159eb9
2 changed files with 231 additions and 0 deletions

View File

@@ -145,6 +145,29 @@ namespace Genode {
return result;
}
};
/**
* Helper for using member variables as FIFO elements
*
* \param T type of compound object to be organized in a FIFO
*
* This helper allow the creation of FIFOs that use member variables to
* connect their elements. This way, the organized type does not need to
* publicly inherit 'Fifo<QT>::Element'. Furthermore objects can easily
* be organized in multiple FIFOs by embedding multiple 'Fifo_element'
* member variables.
*/
template <typename T>
class Fifo_element : public Fifo<Fifo_element<T> >::Element
{
T *_object;
public:
Fifo_element(T *object) : _object(object) { }
inline T *object() { return _object; }
};
}
#endif /* _INCLUDE__UTIL__FIFO_H_ */