Tool Libs
UMIT-TIROL Institute of Automation and Control Engineering library collection
 
Loading...
Searching...
No Matches
streams.h
Go to the documentation of this file.
1
6#pragma once
7#include <utility>
8
14template<typename T>
15struct Sink {
17 virtual bool full()=0;
20 virtual void push(const T& t) {
21 push(std::move(T{t}));
22 }
25 virtual void push(T&&)=0;
28 void trypush(T&& t) {
29 if (full()) return;
30 push(std::move(t));
31 }
32};
33
39template<typename T>
40struct Source {
42 virtual bool empty()=0;
45 virtual T pop()=0;
46};
generic object sink, i.e.
Definition streams.h:15
virtual bool full()=0
check if sink is full
void trypush(T &&t)
use this if you don't care if it's going to be successful. data gets discarded if sink is full.
Definition streams.h:28
virtual void push(T &&)=0
move semantics does not check for space. guard by using 'if (!full) { ... }'
virtual void push(const T &t)
copy semantics does not check for space. guard by using 'if (!full) { ... }'
Definition streams.h:20
generic object source, i.e.
Definition streams.h:40
virtual T pop()=0
pull object from source does not check for data. guard by using 'if (!empty) { ......
virtual bool empty()=0
check if source is empty