.TH "FBB::ISharedStream" "3bobcat" "2005\-2023" "libbobcat\-dev_6\&.04\&.00" "std::istream on shared memory" .PP .SH "NAME" FBB::ISharedStream \- std::istream operations on shared memory .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lpthread \-lbobcat\fP .PP .SH "DESCRIPTION" .PP This class offers the features of the \fBstd::istream\fP class, operating on shared memory\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fBFBB::ISharedBuf\fP (private inheritance), .br \fBstd::istream\fP, .br \fBFBB::SharedEnum__\fP (cf\&. \fBsharedmemory(3bobcat)\fP for a description of this last base class)\&. .PP .SH "SIZEUNIT ENUMERATION" .PP The \fBenum SizeUnit\fP defines the following symbolic constants: .IP o \fBkB\fP, representing 1024 (2**10) bytes of memory; .IP o \fBMB\fP, representing 1048576 (2**20) bytes of memory; .IP o \fBGB\fP, representing 1073741824 (2**30) bytes of memory .PP .SH "CONSTRUCTORS" .IP o \fBISharedStream()\fP: .br The default constructor defines a stub a \fBISharedStream\fP object that cannot immediately be used to access shared memory\&. To use it, its member \fIopen\fP must first be called\&. .IP .IP o \fBISharedStream(size_t maxSize, SizeUnit sizeUnit, std::ios::openmode openMode = std::ios::in, size_t access = 0600)\fP: .br This constructor creates an \fIstd::istream\fP that interfaces to a shared memory segment having a capacity of at least \fImaxSize * sizeUnit\fP 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 \fIios::in\fP 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\(cq\&s access rights are defined by the \fIaccess\fP parameter, using the well\-known (\fBchmod\fP(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 \fIFBB::Exception\fP is thrown\&. .IP .IP o \fBISharedStream(int id, std::ios::openmode openMode = std::ios::in)\fP: .br This constructor creates an \fIstd::istream\fP that connects to a shared memory segment having ID \fIid\fP\&. If construction succeeds the shared memory is ready for use\&. If construction fails (e\&.g\&., no shared memory segment having ID \fIid\fP exists), an \fIFBB::Exception\fP is thrown\&. .PP Copy and move constructors (and assignment operators) are not available\&. .PP .SH "MEMBER FUNCTIONS" .PP All members of \fIstd::istream\fP, and the \fIenum\fP values \fIkB, MB\fP, and \fIGB\fP, defined by \fIFBB::ISharedEnum__\fP are available\&. .PP .IP o \fBFBB::SharedCondition attachSharedCondition(std::ios::off_type offset, std::ios::seekdir origin)\fP: .br Returns an \fBFBB::SharedCondition\fP(3) object, interfacing to a shared condition variable located at offset \fIoffset\fP (relative to \fIorigin\fP) in the \fISharedMemory\fP object to which the \fBISharedStream\fP object interfaces\&. This member does not alter the value returned by the stream\(cq\&s \fItellg\fP member\&. .IP An \fIFBB::Exception\fP is thrown if the \fIFBB::SharedCondition\fP object could not be constructed\&. .IP .IP o \fBint id() const\fP: .br The ID of the shared memory segment is returned\&. .IP .IP o \fBvoid kill()\fP: .br Without locking the shared memory first, all shared memory is returned to the operating system\&. The \fBFBB::ISharedStream\fP object is unusable after returning from \fIkill\fP\&. Other processes that were using the shared memory can continue to do so\&. .IP .IP o \fBvoid memInfo(std::ostream &out, char const *end = \(dq\&\en\(dq\&)\fP: .br Information about the \fIISharedMemory\fP object is inserted into the provide \fIostream\fP 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, \fIend\fP is inserted into \fIout\fP\&. .IP .IP o \fBvoid open(size_t maxSize, SizeUnit sizeUnit, std::ios::openmode openMode = std::ios::in, size_t access = 0600)\fP: .br This member creates a shared memory segment having a capacity of at least \fImaxSize * sizeUnit\fP bytes, and connects the shared memory segment to the \fBFBB::ISharedStream\fP\&. A matching \fIclose\fP 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 \fIios::in\fP 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\(cq\&s access rights are defined by the \fIaccess\fP parameter, using the well\-known (\fBchmod\fP(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 \fIFBB::Exception\fP is thrown\&. .IP .IP o \fBvoid open(int id, std::ios::openmode openMode = std::ios::in)\fP: .br This member connects the \fBFBB::ISharedStream\fP object to a shared memory segment having ID \fIid\fP\&. A matching \fIclose\fP 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 \fIid\fP exists), an \fIFBB::Exception\fP is thrown\&. .IP .IP o \fBvoid remove()\fP: .br The shared memory is first locked\&. Next, all shared memory is returned to the operating system\&. The \fBFBB::ISharedStream\fP object is unusable after returning from \fIremove\fP\&. Other processes that were using the shared memory can continue to do so\&. .IP .IP o \fBbool truncate(std::streamsize offset)\fP: .br If \fIoffset\fP is not exceeding the value returned by \fIseekg(0, std::ios::end)\fP, then this latter value is changed to \fIoffset\fP and \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned, and the value returned by \fIseekg\fP is not altered\&. If the value returned by \fItellg\fP exceeded \fIoffset\fP, \fItellg\fP\(cq\&s return value it is reduced to \fIoffset\fP as well\&. Subsequent read operations on the shared memory can only succeed as long as \fItellg\fP\(cq\&s return value hasn\(cq\&t reached the value \fIoffset\fP\&. .PP .SH "EXAMPLE" See the \fBsharedstream\fP(3bobcat) man page\&. .PP .SH "FILES" \fIbobcat/isharedstream\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBchmod\fP(1), \fBosharedstream\fP(3bobcat), \fBsharedblock\fP(3bobcat), \fBsharedcondition\fP(3bobcat), \fBsharedmemory\fP(3bobcat), \fBsharedmutex\fP(3bobcat), \fBsharedpos\fP(3bobcat), \fBsharedreadme\fP(7bobcat), \fBsharedsegment\fP(3bobcat), \fBsharedstream\fP(3bobcat), \fBsharedbuf\fP(3bobcat) .PP .SH "BUGS" Note that by default exceptions thrown from within a \fBstd::stream\fP object are caught by the stream object, setting its \fIios::failbit\fP flag\&. To allow exceptions to leave a stream object, its \fIexceptions\fP member can be called, e\&.g\&., using: .nf myStream\&.exceptions(ios::failbit | ios::badbit | ios::eofbit); .fi .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_6\&.04\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_6\&.04\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_6\&.04\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP