includefile(include/header)

COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::ISharedStream)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
                    (std::istream on shared memory)

manpagename(FBB::ISharedStream)(std::istream operations on shared memory)

manpagesynopsis()
    bf(#include <bobcat/isharedstream>)nl()
    Linking option: tt(-lpthread -lbobcat) 

manpagedescription()

    This class offers the features of the bf(std::istream) class, operating on
shared memory.

includefile(include/namespace)

manpagesection(INHERITS FROM)
    bf(FBB::ISharedBuf) (private inheritance),nl()
    bf(std::istream),nl()
    bf(FBB::SharedEnum__) (cf. bf(sharedmemory(3bobcat)) for a description of
        this last base class).

manpagesection(SIZEUNIT ENUMERATION)

The bf(enum SizeUnit) defines the following symbolic constants:
        itemization(
        it() bf(kB), representing 1024 (2**10) bytes of memory;
        it() bf(MB), representing 1048576 (2**20) bytes of memory;
        it() bf(GB), representing 1073741824 (2**30) bytes of memory
        )

manpagesection(CONSTRUCTORS)
    itemization(
    itb(ISharedStream())
       The default constructor defines a stub a bf(ISharedStream) object that
        cannot immediately be used to access shared memory. To use it, its
        member tt(open) must first be called.

    itb(ISharedStream(size_t maxSize, SizeUnit sizeUnit, 
            std::ios::openmode openMode = std::ios::in,
            size_t access = 0600))
       This constructor creates an tt(std::istream) that interfaces to a
        shared memory segment having a capacity of at least tt(maxSize *
        sizeUnit) bytes. By default, the shared memory segment is opened for
        reading. Different from the open modes used for file streams, creating
        a shared memory stream with open modes tt(ios::in) is OK. In this case
        the shared memory segment is created and once information has been
        written to the shared memory by another process (or object) the
        information can be read. The shared memory's access rights are defined
        by the tt(access) parameter, using the well-known (bf(chmod)(1)) way
        to define the access rights for the owner, the group and others, using
        octal digits. If construction succeeds the shared memory is ready for
        use. If construction fails, an tt(FBB::Exception) is thrown.

    itb(ISharedStream(int id, std::ios::openmode openMode = std::ios::in)) 
       This constructor creates an tt(std::istream) that connects to a shared
        memory segment having ID tt(id). If construction succeeds the shared
        memory is ready for use. If construction fails (e.g., no shared memory
        segment having ID tt(id) exists), an tt(FBB::Exception) is thrown.
    )


    Copy and move constructors (and assignment operators) are not available.

manpagesection(MEMBER FUNCTIONS)

     All members of tt(std::istream), and the tt(enum) values tt(kB, MB), and
tt(GB), defined by tt(FBB::ISharedEnum__) are available.

    itemization(
    itb(FBB::SharedCondition attachSharedCondition(std::ios::off_type offset,
                                        std::ios::seekdir origin))
       Returns an bf(FBB::SharedCondition)(3) object, interfacing to a shared
        condition variable located at offset tt(offset) (relative to
        tt(origin)) in the tt(SharedMemory) object to which the
        bf(ISharedStream) object interfaces.  This member does not alter the
        value returned by the stream's tt(tellg) member.

        An tt(FBB::Exception) is thrown if the tt(FBB::SharedCondition) object
        could not be constructed.

COMMENT(
    itb(FBB::SharedCondition createSharedCondition())
       Returns an bf(FBB::SharedCondition)(3) object, interfacing to a newly
        created shared condition variable which is created at the current
        offset of the tt(SharedMemory) object to which the bf(ISharedStream)
        object interfaces (or at the first offset of the next physical shared
        memory data block, cf. bf(sharedcondition)(3bobcat)).  Creating a
        tt(SharedCondition) object does not alter the value returned by the
        stream's tt(tellg) member.

        Note that this member em(changes)
        the information within the object's tt(SharedMemory) substrate, which
        is somewhat counter-intuitive for an em(std::istream) type of stream.

        An tt(FBB::Exception) is thrown if the tt(FBB::SharedCondition) object
        could not be constructed.
END)

    itb(int id() const)
       The ID of the shared memory segment is returned.

    itb(void kill())
       Without locking the shared memory first,  all shared memory is returned
        to the operating system. The bf(FBB::ISharedStream) object is unusable
        after returning from tt(kill). Other processes that were using the
        shared memory can continue to do so.

    itb(void memInfo(std::ostream &out, char const *end = "\n"))
       Information about the tt(ISharedMemory) object is inserted into the
        provide tt(ostream) object. The IDs of the shared segments, their
        sizes, the maximum number of shared memory segments, the number of
        bytes that can be read from the shared memory, and its actual storage
        capacity, etc., are displayed. Following the information about the
        shaed memory, tt(end) is inserted into tt(out).

    itb(void open(size_t maxSize, SizeUnit sizeUnit,
            std::ios::openmode openMode = std::ios::in,
            size_t access = 0600))
       This member creates a shared memory segment having a capacity of at
        least tt(maxSize * sizeUnit) bytes, and connects the shared memory
        segment to the bf(FBB::ISharedStream). A matching tt(close) member
        does not exist and is not required. By default, the shared memory
        segment is opened for reading. Different from the open modes used for
        file streams, creating a shared memory stream with open modes
        tt(ios::in) is OK. In this case the shared memory segment is created
        and once information has been written to the shared memory by another
        process it can be read. The shared memory's access rights are defined
        by the tt(access) parameter, using the well-known (bf(chmod)(1)) way
        to define the access rights for the owner, the group and others, using
        octal digits. If opening succeeds the shared memory is ready for
        use. If opening fails, an tt(FBB::Exception) is thrown.

    itb(void open(int id, std::ios::openmode openMode = std::ios::in)) 
       This member connects the bf(FBB::ISharedStream) object to a shared
        memory segment having ID tt(id). A matching tt(close) member does
        not exist and is not required. If opening succeeds the shared
        memory is ready for use. If opening fails (e.g., no shared memory
        segment having ID tt(id) exists), an tt(FBB::Exception) is
        thrown.

    itb(void remove())
       The shared memory is first locked. Next, all shared memory is returned
        to the operating system. The bf(FBB::ISharedStream) object is unusable
        after returning from tt(remove). Other processes that were using the
        shared memory can continue to do so.

    itb(bool truncate(std::streamsize offset))
       If tt(offset) is not exceeding the value returned by tt(seekg(0,
        std::ios::end)), then this latter value is changed to tt(offset) and
        tt(true) is returned. Otherwise tt(false) is returned, and the value
        returned by tt(seekg) is not altered. If the value returned by
        tt(tellg) exceeded tt(offset), tt(tellg)'s return value it is reduced
        to tt(offset) as well. Subsequent read operations on the shared memory
        can only succeed as long as tt(tellg)'s return value hasn't reached
        the value tt(offset). 
    )


manpagesection(EXAMPLE)
    See the bf(sharedstream)(3bobcat) man page.

manpagefiles()
    em(bobcat/isharedstream) - defines the class interface

manpageseealso()
    bf(bobcat)(7),  bf(chmod)(1),
        bf(osharedstream)(3bobcat),
        bf(sharedblock)(3bobcat),
        bf(sharedcondition)(3bobcat), 
        bf(sharedmemory)(3bobcat),
        bf(sharedmutex)(3bobcat), 
        bf(sharedpos)(3bobcat), 
        bf(sharedreadme)(7bobcat), 
        bf(sharedsegment)(3bobcat),
        bf(sharedstream)(3bobcat),
        bf(sharedbuf)(3bobcat)

manpagebugs()
    Note that by default exceptions thrown from within a bf(std::stream)
object are caught by the stream object, setting its tt(ios::failbit) flag. To
allow exceptions to leave a stream object, its tt(exceptions) member can be
called, e.g., using:
        verb(
    myStream.exceptions(ios::failbit | ios::badbit | ios::eofbit);
        )

includefile(include/trailer)
