mirror of
https://github.com/autc04/Retro68.git
synced 2024-09-08 05:54:40 +00:00
27 lines
492 B
C++
27 lines
492 B
C++
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <vector>
|
|
|
|
class StreamListener
|
|
{
|
|
public:
|
|
virtual size_t onReceive(const uint8_t* p, size_t n) = 0;
|
|
};
|
|
|
|
class Stream
|
|
{
|
|
StreamListener *listener_;
|
|
std::vector<uint8_t> buffer_;
|
|
public:
|
|
Stream();
|
|
virtual ~Stream();
|
|
|
|
void setListener(StreamListener *l) { listener_ = l; }
|
|
|
|
virtual void write(const void* p, size_t n) = 0;
|
|
long read(void *p, size_t n);
|
|
|
|
protected:
|
|
void onReceive(const uint8_t* p, size_t n);
|
|
};
|