The class SharedPos is a support class for Bobcat's shared memory
handling classes. It controls the shared memory read/write ofset and ensures
that shared memory operations never exceed the shared memory's maximum offset.
The class SharedPos has several public members, but they are primarily
useful for other Shared* classes offered by Bobcat. There is probably
little use for a stand-alone SharedPos object.
In the descriptions of the class's member functions offset refers to
the read/write offset within the available shared memory.
NAMESPACE
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
INHERITS FROM
-
TYPEDEFS AND ENUMS
CONSTRUCTORS
Default, copy and move constructors are available. The default constructor
does not yet monitor the offsets for a shared memory segment. The
member reset is used to start monitoring offsets.
OVERLOADED OPERATORS
void operator++():
The offset is incremented. If this member is called when the offset is
equal to the shared memory's maximum offset an FBB::Exception is
thrown.
void operator+=(size_t len):
The offset is incremented by len. If offset + len exceeds the
shared memory's maximum offset then the offset is set to the maximum
offset and an FBB::Exception is thrown.
std::ostream &operator<<(std::ostream &out, SharedPos const &pos):
Inserts information about the FBB::SharedPos object into out.
The copy and move assignment operators are available.
MEMBER FUNCTIONS
bool atMaxOffset() const:
Returns true if offset equals the maximum offset that can be used
for the current shared memory segment.
The behavior of this member is undefined until setup has been
called.
size_t blockIdx() const:
The index of the shared segment data block in which offset is located
is returned.
size_t blockOffset() const:
The index within the shared segment data block matching offset is
returned.
bool eof() const:
Returns true if offset exceeds the maximum offset of any character
ever written to the shared memory pointed at by
sharedData. If eof returns true information may still
be written to the shared memory: writting is possible until the
maximum shared memory segment offset has been reached.
The behavior of this member is undefined until setup has been
called.
std::streamsize eos() const:
The offset just beyond the maximum offset for the current shared
segment data block is returned.
The behavior of this member is undefined until setup has been
called.
std::streamsize maxOffset() const:
The maximum possible offset that can be used for the currently
monitored shared memory segment is returned. Zero is returned until
setup has been called.
std::streamsize offset() const:
The offset within the currently monitored shared memory segment is
returned. Zero is returned until setup has been called.
void setup(SharedSegment *sharedData):
The SharedPos object is reset to monitor the offset of a new
FBB::SharedSegment object. The SharedSegment * must point to a
SharedSegment segment (cf. sharedsegment(3bobcat)) that must exist
until the end of the FBB::SharedPos object's lifetime or until the
next reset call. Immediately after calling reset offset has
the value 0.
std::streamsize showmanyc() const:
The number of characters that can be read from the current shared
segment data block is returned. This member interrogates the number
of readable characters in the shared memory segment. This number may
change while this member is being executed. In order to receive a
stable return value, calling functions should have obtained a lock on
the shared memory segment before calling this member. See also the
sharedsegment(3bobcat) man-page.
The behavior of this member is undefined until setup has been
called.
std::ios::pos_type seek(std::ios::off_type offset,
std::ios::seekdir way = std::ios::beg):
The monitored offset is changed to this member's offset argument,
relative to way. Seeking beyond eof is OK; -1 is returned when
seeking beyond maxOffset or seeking before the shared segment's
offset 0.