#ifndef INCLUDED_BOBCAT_ISHAREDSTREAM_
#define INCLUDED_BOBCAT_ISHAREDSTREAM_

#include <istream>

#include <bobcat/sharedbuf>

namespace FBB
{

struct ISharedStream: private SharedBuf, public std::istream,
                      public virtual SharedEnum__
{
    ISharedStream();

    ISharedStream(
            size_t maxSize, SizeUnit sizeUnit,
            std::ios::openmode openMode = std::ios::in,
            size_t access = 0600);

    ISharedStream(
            size_t id, 
            std::ios::openmode openMode = std::ios::in);

    using SharedBuf::attachSharedCondition;
    using std::istream::clear;
    using SharedBuf::id;
    using SharedBuf::kill;

    void memInfo(std::ostream &out, char const *end = "\n") const;

    void open(
            size_t maxSize, SizeUnit sizeUnit,
            std::ios::openmode openMode = std::ios::in,
            size_t access = 0600);

    void open(
            int id,
            std::ios::openmode openMode = std::ios::in);

    using SharedBuf::remove;

    bool truncate(std::streamsize offset);
};

#include "truncate.f"

} // FBB        
#endif
