#ifndef BIWAK_IOSTREAM_H
#define BIWAK_IOSTREAM_H
//----------------------------------------------------------------------------
///
/// \brief  IO-Stream
///
///         Uart, CDC, file, ...
///
//----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


#include <lepto/ring.h>
#include <lepto/signal.h>


//---Declarations-------------------------------------------------------------


class CIOStream
{
    private:

    public:
         CRing<char> receiveBuffer;
         CRing<char> sendBuffer;
         #if defined CONFIG_BIWAK_IOSTREAM_SIGNAL
         CSignal<void, char> signalGotByte;
         #endif

        CIOStream( );
        CIOStream( int rxSize, int txSize );
        ~CIOStream( );

        virtual int write(const void *buf, int size) = 0;
        virtual void flushOutput() = 0;

        bool dataAvailable()
        {
           return( receiveBuffer.isDataAvailable() );
        }
        // getc() and getchar() may be makros in stdio.h
        int getch()
        {
           int value=-1;
           if( dataAvailable() )
           {
              value=(int)(uint8_t)receiveBuffer.popEntry();
           }
           return(value);
        }
        virtual void eventLoop(){};
};


//---fin-----------------------------------------------------------------------
#endif // ? ! BIWAK_IOSTREAM_H
