#ifndef INCLUDED_BOBCAT_IFDBUFS_
#define INCLUDED_BOBCAT_IFDBUFS_

#include <bobcat/ifdbuf>
#include <bobcat/selector>

namespace FBB
{

class IFdBufS: public  IFdBuf   //EoiBuf
{
    Selector d_selector;                        // to wait for available input

    public:
        IFdBufS() = default;                           // 1

        IFdBufS(IFdBufS const &other) = delete;

        explicit IFdBufS(Mode mode);                   // 2
        explicit IFdBufS(int fd, size_t size = 1);     // 3
        IFdBufS(int fd, Mode mode, size_t size = 1);   // 4

        ~IFdBufS() override;

//        IFdBufS &operator=(IFdBufS const &other) = delete;

        void reset(int xfd, Mode mode, size_t size = 1);        // .cc
        void reset(int xfd, size_t size = 1);                   // .f

//        void close();                                           // .f

//        int fd() const;                                         // .f

    private:
        int underflow() override;
        std::streamsize xsgetn(char *dest, std::streamsize n) override;

        void cleanup(Mode mode);
};

inline void IFdBufS::reset(int fd, size_t size)
{
    reset(fd, mode(), size);
}
// #include "close.f"
// #include "fd.f"

} // FBB

#endif
