12#define MAX_FDBUFFER_FIFO_BUFFERS (20)
20 virtual int read(
char *buf,
int nbytes) = 0;
21 virtual int write(
const char *buf,
int nbytes) = 0;
22 virtual int close() = 0;
23 static int sread(
int fd,
char *buf,
int nbytes);
24 static int swrite(
int fd,
const char *buf,
int nbytes);
25 static int sclose(
int fd);
26 static fd_adapter *GetFromFD(
int fd);
29 fd_adapter() {my_fd=0; inDtor =
false;};
35 ~fd_adapter() { inDtor =
true;
if (my_fd) ::close(my_fd); };
36 operator int() {
if(my_fd==0) GetActiveFD();
return my_fd;};
41class FDCounter :
public fd_adapter
45 virtual int read(
char *buf,
int nbytes);
46 virtual int write(
const char *buf,
int nbytes);
50 FDCounter() { nwr = 0; };
51 ~FDCounter() {
if (my_fd) ::close(my_fd); }
53 int SpaceUsed() {
return nwr; };
56class FDFlash :
public fd_adapter
64 virtual int read(
char *buf,
int nbytes);
65 virtual int write(
const char *buf,
int nbytes);
80 uint32_t cs() {
return m_cs; };
82 uint32_t len() {
return m_len; };
85class FDBuffer :
public fd_adapter
90 int read(
char *buf,
int nbytes)
override;
91 int write(
const char *buf,
int nbytes)
override;
97 bs.
Reset(MAX_FDBUFFER_FIFO_BUFFERS);
101 bool StreamTo(
int fd);
103 FDBuffer() { nwr = 0; };
105 int SpaceUsed() {
return nwr; };
108class FDcBuf :
public fd_adapter
118 int read(
char *buf,
int nbytes)
override;
119 int write(
const char *buf,
int nbytes)
override;
120 int close()
override;
123 inline void Reset(
int nWritten = -1)
126 if ((nWritten >= 0) && (nWritten < (bufLen-1)))
133 FDcBuf(uint8_t *buf,
int _bufLen,
int _blockWaitSkip = 1)
134 : cbuf(buf), rdIdx(0), wrIdx(0), bufLen(_bufLen),
135 blockWaitSkip(_blockWaitSkip), empty(true)
144 inline int SpaceUsed() {
return wrIdx - rdIdx + ((rdIdx > wrIdx)*bufLen); };
FIFO buffer storage using linked pool buffers.
Definition buffers.h:443
void Reset(uint8_t max_buffers)
Reset buffer storage and free all data.