FBB::MemoryBridge(3bobcat)
π FBB::MemoryBridge β Memory Segments Data Structure π
okay bestie, welcome to the 3bobcat manual, Memory Segments edition β¨ this one's all about FBB::MemoryBridge, and ngl it's giving main character energy for the whole Bobcat memory situation π«Ά
πΈ SYNOPSIS πΈ
#include <bobcat/memorybridge>
Linking option: -lbobcat
β¨ DESCRIPTION β¨
so, the class FBB::MemoryBridge is literally the interface to the memory segments that Bobcat's Memory... classes use π
it reaches in and reads or modifies those segments through FBB::MemoryAccess wrapper class objects. and here's the tea: FBB::MemoryAccess objects are normally not directly defined by user programs β they only get made by FBB::MemoryBridge objects, which control all the read and write operations to the shared memory blocks π
now, multiple programs running in parallel can access the same shared memory, and lowkey that's a whole situation because FBB::MemoryBridge objects do not offer mutex facilities to stop those programs from accessing info while it's being modified π such mutex facilities could be made available using flock(2) though, so iykyk.
π NAMESPACE π
FBB
all constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. periodt.
π¦ INHERITS FROM π¦
-
π CONSTRUCTORS π
MemoryBridge()β the default constructor defines a stubMemoryBridgeobject that can't immediately be used to access memory segments. but don't worry bestie, the class's move-assignment operator can turn it into a usable object π«ΆMemoryBridge(std::string const &bufSize, bool erase, size_t access = 0600)β constructs aMemoryBridgeobject. its default capacity is specified bybufSize(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 specifies 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 π
MemoryBridge(int id, bool erase)β this constructor connects to a memory segment having IDid.
the erase parameter is used exactly 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. no copies bestie, we don't do that here π
β BUFSIZE β
the bufSize parameter required by the second MemoryStream constructor and the open member (see below) specifies the default number 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 automatically 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. lazy allocation, she's efficient π
π MEMBER FUNCTIONS π
most of the following members throw exceptions when called from a MemoryBridge object that was initialized by its default constructor. you've been warned bestie π«Ά
char *beginPtr() constβ returns a pointer to the first byte of the memory block (cf.memoryblock(3bobcat)) corresponding to the current offset (cf. memberoffset(), below).std::streamsize blockBegin() constβ returns the offset of the first byte of the memory block corresponding to the current offset.std::streamsize blockEnd() constβ returns the offset just beyond the last byte of the memory block corresponding to the current offset.std::streamsize blockSize() constβ returns the size of the used memory blocks.std::streamsize bufLimits()β computes the values returned byblockBeginandblockEndcorresponding to the current offset.char *endPtr() constβ returns a pointer to the memory block's byte corresponding to offsetblockEnd().char *endReadPtr() constβ returns a pointer to the position in the current memory block corresponding to the last written byte in that block.void extend()β extends the amount of memory blocks so that the current offset is located in a memory block that's available when bytes are written into that block.int id() constβ the ID of the memory block (cf.MemoryAccess(3bobcat)) controlling access to the memory data blocks is returned.void info(std::ostream &out)β information about theMemoryBridgeis inserted intoout: 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. it's giving full transparency πvoid load()β loads (makes available) the memory block corresponding to the current offset.std::streamsize maxEnd() constβ returns the offset position corresponding toblockEndof the current last available memory block. the value returned by this member can be updated to a larger value after callingextend().std::streamsize offset() constβ returns the current absolute offset position.void offset(std::streamsize pos) constβ sets the current absolute offset position topos.char *offsetPtr() constβ returns a pointer to the byte of the memory block corresponding to the current offset.size_t read(char *dest, std::streamsize len)β copies at mostlenbytes from theMemoryBridge's data todest, returning the actual number of copied bytes. reading always stops when reaching the value returned bywrittenUntil()(see below).void setErase(bool erase)β this member is used to change theerasesetting of aMemoryBridgeobject. it can be used by, e.g., forking programs where the program constructs aMemoryBridgeobject specifyingerase == 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 callingsetErase(true)in the parent process. parent privilege, iconic πstd::streamsize showmanyc() constβ returns the number of characters that can be read from the current offset to the offset returned bywrittenUntil().void swap(MemoryBridge &other)β the information of the currentMemoryBridgeobject is swapped with the information of theotherobject.bool truncate(std::streamsize offset)β this member reduces or enlarges the available memory size of aMemoryBridgeobject tosize. if it's reduced then the memory segments' data bytes fromsizeto its original size are set to0: newly allocated memory segments are always initialized to0byte values.size_t write(char *src, std::streamsize len)β copieslenbytes fromsrcto theMemoryBridge's data, starting atoffset, 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 πstd::streamsize writtenUntil() constβ returns the highest offset of the byte that was ever written to theMemoryBridge.void writtenUntil(std::streamsize offset) constβ updates the value returned bywrittenUntil()tooffsetifoffsetis larger than that value.
π§ EXAMPLE π§
see the memorystream(3bobcat) man page. go read it bestie, it's cute β¨
π 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. (slay, honestly)
π BOBCAT PROJECT FILES π
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;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).
and that's the whole vibe bestie, no cap π
this page is from libbobcat-dev_6.15.01, dated 2005-2026, and it's the FBB::MemoryBridge(3bobcat) manual β go forth and bridge those memory segments, you absolute icon πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms