75 lines
1.1 KiB
C++
75 lines
1.1 KiB
C++
#pragma once
|
|
#ifndef _NB_DATASINK
|
|
#define _NB_DATASINK
|
|
|
|
namespace nb {
|
|
|
|
template <typename T>
|
|
class SinkBase {
|
|
using InputType = T;
|
|
public:
|
|
virtual bool in(const T&) = 0;
|
|
|
|
protected:
|
|
SinkBase();
|
|
|
|
};
|
|
|
|
/* template <typename T>
|
|
class Sink : public SinkBase {
|
|
public:
|
|
Sink& operator=(const Sink&) = 0;
|
|
|
|
template<typename U>
|
|
virtual bool in(const U&) = 0;
|
|
|
|
protected:
|
|
Sink();
|
|
|
|
}; */
|
|
|
|
template <typename T>
|
|
class SourceBase {
|
|
using OutputType = T;
|
|
public:
|
|
SourceBase& operator=(const SourceBase&) = 0;
|
|
|
|
virtual bool out(T*) = 0;
|
|
|
|
|
|
protected:
|
|
SourceBase();
|
|
SinkBase<T>* _sink;
|
|
|
|
};
|
|
|
|
template <typename T>
|
|
class Pipe : public SinkBase<T>, public SourceBase<T>{
|
|
using Input = SourceBase<T>;
|
|
using Output = SinkBase<T>;
|
|
public:
|
|
Pipe(Sink<T>& sink) : Input::_sink{&sink} {}
|
|
|
|
bool in(const T&) = 0;
|
|
|
|
protected:
|
|
using Input::_sink;
|
|
};
|
|
|
|
|
|
|
|
/* template <typename T>
|
|
class Source : SourceBase {
|
|
public:
|
|
Source& operator=(const Source&) = 0;
|
|
|
|
template<typename U>
|
|
virtual bool out(const U&) = 0;
|
|
|
|
protected:
|
|
Source();
|
|
|
|
}; */
|
|
|
|
} // namespace nb
|
|
#endif // _NB_DATASINK
|