Provided by: libbobcat-dev_6.11.00-1_amd64 

NAME
FBB::MemoryBridge - Memory Segments Data Structure
SYNOPSIS
#include <bobcat/memorybridge>
Linking option: -lbobcat
DESCRIPTION
The class FBB::MemoryBridge provides the interface to the memory segments used by Bobcat’s Memory...
classes. Bobcat’s MemoryBridge class accesses or modifies those segments via FBB::MemoryAccess wrapper
class objects. FBB::MemoryAccess objects are normally not directly defined by user programs but only by
FBB::MemoryBridge objects, controlling all read and write operations to the shared memory blocks.
Although multiple programs executed in parallel may access the same shared memory FBB::MemoryBridge
objects do not offer mutex facilities to prevent those programs from accessing information while it’s
being modified. Such mutex facilities could be made available using flock(2).
NAMESPACE
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the
namespace FBB.
INHERITS FROM
-
CONSTRUCTORS
o MemoryBridge():
The default constructor defines a stub MemoryBridge object that cannot immediately be used to
access memory segments. The class’s move-assignment operator can be used to turn it into a usable
object.
o MemoryBridge(std::string const &bufSize, bool erase, size_t access = 0600):
Constructs a MemoryBridge object. Its default capacity is specified by bufSize (cf. section
BUFSIZE), using memory segments containing the stream’s bytes.
The access rights of the data stored in MemoryStream objects are defined by the access parameter,
interpreted as an octal value, using the specifications used by (chmod(1)).
The erase parameter is used to specify what happens to the memory segments once the MemoryBridge
object goes out of scope. When specified as false the allocated memory segments are not destroyed
when the object goes out of scope (and can be reaccessed until the computer is rebooted) using the
memory object’s ID (see the next constructor). When specified as true the memory segments are
erased from memory when the object goes out of scope.
If construction fails, an FBB::Exception is thrown.
o MemoryBridge(int id, bool erase):
This constructor connects to a memory segment having ID id.
The erase parameter is used as it is used by the previous constructor.
An FBB::Exception is thrown if construction fails (e.g., no memory segment having ID id exists),
The move constructor and move-assignment operator are available, the copy constructor and copy-assignment
operator are not available.
BUFSIZE
The bufSize parameter required by the second MemoryStream constructor and the open member (see below)
specifies the default number nummber of shared memory memory blocks and their sizes. The size of the
memory blocks is specified as k, M or G, indicating block sizes in kilo-, Mega- and GigaBytes. Before
those letters the default number of blocks is specified. E.g., "100M". Internally the number of kiloBytes
is converted to `pages’, using the system’s page size, which is commonly equal to 4 kB (so when
specifying "5k" then the stream prepares for two shared data segments, each having a capacity of 4 kB.
The number of MegaBytes is used as specified, and when specifying GB the data segments are .5 GB.
The number of shared data segments is aotomatically enlarged when the current capacity is exceeded, and
the potentially available data segments are initially not allocated: they’re allocated once information
is written into their areas.
MEMBER FUNCTIONS
Most of the following members throw exceptions when called from a MemoryBridge object that was
initialized by its default constructor.
o char *beginPtr() const:
Returns a pointer to the first byte of the memory block (cf. memoryblock(3bobcat)) corresponding
to the current offset (cf. member offset(), below).
o std::streamsize blockBegin() const:
Returns the offset of the first byte of the memory block corresponding to the current offset.
o std::streamsize blockEnd() const:
Returns the offset just beyond the last byte of the memory block corresponding to the current
offset.
o std::streamsize blockSize() const:
Returns the size of the used memory blocks.
o std::streamsize bufLimits():
Computes the values returned by blockBegin and blockEnd corresponding to the current offset.
o char *endPtr() const:
Returns a pointer to the memory block’s byte corresponding to offset blockEnd().
o char *endReadPtr() const:
Returns a pointer to the position in the current memory block corresponding to the last written
byte in that block.
o void extend():
Extends the amount of memory blocks so that the current offsets is located in a memory block
that’s available when bytes are written into that block.
o int id() const:
The ID of the memory block (cf. MemoryAccess(3bobcat)) controlling access to the memory data
blocks is returned.
o void info(std::ostream &out):
Information about the MemoryBridge is inserted into out: the IDs of the memory data blocks, their
sizes, the current maximum number of memory data blocks, the number of bytes that can be read from
the memory segments, and its actual storage capacity.
o void load():
Loads (makes available) the memory block corresponding to the current offset.
o std::streamsize maxEnd() const:
Returns the offset position corresponding to blockEnd of the current last available memory block.
The value returned by this member can be updated to a larger value after calling extend().
o std::streamsize offset() const:
Returns the current absolute offset position.
o void offset(std::streamsize pos) const:
Sets the current absolute offset position to pos.
o char *offsetPtr() const:
Returns a pointer to the byte of the memory block corresponding to the current offset.
o size_t read(char *dest, std::streamsize len):
Copies at most len bytes from the MemoryBridge’s data to dest, returning the actual number of
copied bytes. Reading always stops when reaching the value returned by writtenUntil() (see below).
o void setErase(bool erase):
This member is used to change the erase setting of a MemoryBridge object. It can be used by, e.g.,
forking programs where the program constructs a MemoryBridge object specifying erase == false, but
whose memory segments should be erased when the parent process ends but not also when the child
process ends. This is accomplished by calling setErase(true) in the parent process.
o std::streamsize showmanyc() const:
Returns the number of characters that can be read from the current offset to the offset returned
by writtenUntil().
o void swap(MemoryBridge &other):
The information of the current MemoryBridge object is swapped with the information of the other
object.
o bool truncate(std::streamsize offset):
This member reduces or enlarges the available memory size of a MemoryBridge object to size. If
it’s reduced then the memory segments’ data bytes from size to its original size are set to 0:
newly allocated memory sements are always initialized to 0 byte values.
o size_t write(char *src, std::streamsize len):
Copies len bytes from src to the MemoryBridge’s data, starting at offset, returning the actual
number of copied bytes. Unless there’s no more physical memory available writing succeeds. If the
physical memory is exhausted an exception is thrown.
o std::streamsize writtenUntil() const:
Returns the highest offset of the byte that was ever written to the MemoryBridge.
o void writtenUntil(std::streamsize offset) const:
Updates the value returned by writtenUntil() to offset if offset is larger than that value.
EXAMPLE
See the memorystream(3bobcat) man page.
FILES
bobcat/memorybridge - defines the class interface
SEE ALSO
bobcat(7), chmod(1), flock(2), memoryaccess(3bobcat), memorybuf(3bobcat), memoryreadme(7bobcat),
memorystream(3bobcat),
BUGS
None Reported.
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;
BOBCAT
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL).
AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl).
libbobcat-dev_6.11.00 2005-2025 FBB::MemoryBridge(3bobcat)