FBB::Sharedpos - Shared Memory offset controller
Contents
Bobcat
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
Bobcat Project Files
o https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
o libbobcat6: debian package containing the shared library, changelog and copyright note;
o libbobcat-dev: debian package containing the static library, headers, manual pages, and developer
info;
Bugs
None Reported.
Constructors
Default, copy and move constructors as well as the copy and move assignment operators are available. The
default constructor does not yet monitor the offset of an FBB::SharedSegment object. The member reset is
used to start monitoring offsets.
Copyright
This is free software, distributed under the terms of the GNU General Public License (GPL).
Description
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 a
FBB::SharedSegment(3bobcat) object for which SharedPos performs the offset-administration.
Example
See the sharedstream(3bobcat) man page.
Files
bobcat/sharedpos - defines the class interface
Inherits From
-
Member Functions
Note: the behavior of member functions returning values which refer to information of an
FBB::SharedSegment is undefined until the member reset has been called.
o boolatMaxOffset()const:
Returns true if offset equals the maximum offset that can be used for the configured
FBB::SharedSegment object.
o size_tblockIdx()const:
The index of the configured FBB::SharedSegment object’s shared segment data block to which offset
refers is returned.
o size_tblockOffset()const:
The offset within the shared segment data block matching the member offset’s return value is
returned.
o booleof()const:
Returns true if offset exceeds the maximum offset of any character ever written to the shared
memory to which the SharedPos object interfaces. If eof returns true information may still be
written to the shared memory: writing is possible until the maximum shared memory segment offset
has been reached.
o std::streamsizeeos()const:
The offset just beyond the maximum offset for the current shared segment data block is returned.
E.g., if blockIdx returns 5, and the size of the shared segment data blocks equals 2000, then eos
returns 12000 (the first offset of segment 6).
o std::streamsizemaxOffset()const:
The maximum possible offset that can be used for the currently monitored FBB::SharedSegment is
returned.
o std::streamsizeoffset()const:
The offset within the currently monitored shared memory segment is returned.
o voidreset(SharedSegment*sharedData):
The SharedPos object is reset to monitor the offset of the FBB::SharedSegment object whose address
is passed as argument to reset. The address must point to a sharedsegment(3bobcat) object that
must exist until the end of the SharedPos object’s lifetime or until its next reset call.
Immediately after calling reset offset is reset to 0.
o std::streamsizeshowmanyc()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 FBB::SharedSegment data before calling this
member. See also the sharedsegment(3bobcat) man-page.
o std::ios::pos_typeseek(std::ios::off_typeoffset,std::ios::seekdirorigin=std::ios::beg):
The monitored offset is changed to this member’s offset argument, relative to origin. Seeking
beyond eof is OK. However, -1 is returned when seeking beyond maxOffset or seeking before the
shared segment’s offset 0.
Name
FBB::Sharedpos - Shared Memory offset controller
Namespace
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the
namespace FBB.
Overloaded Operators
o voidoperator++():
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.
o voidoperator+=(size_tlen):
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.
o std::ostream&operator<<(std::ostream&out,SharedPosconst&pos):
Inserts information about the SharedPos object into out.
See Also
bobcat(7), isharedstream(3bobcat), osharedstream(3bobcat), sharedblock(3bobcat), sharedcondition(3bobcat), sharedmemory(3bobcat), sharedmutex(3bobcat), sharedreadme(7bobcat), sharedsegment(3bobcat), sharedstream(3bobcat), sharedbuf(3bobcat)
Synopsis
#include<bobcat/sharedpos>
Linking option: -lbobcat