FBB::O...Stream(3bobcat)

πŸ’– FBB::O...Stream(3bobcat) πŸ’–

okay bestie, so this one is all about std::ostream on shared memory β€” literally the page header says std::ostream on shared memory, and the whole thing lives under the FBB::O...Stream(3bobcat) name. It's the manual page for the bobcat library's shared-memory stream stuff. Sit down, hydrate, let's go 🫢


✨ NAME ✨

FBB::OSharedStream β€” std::ostream operations on shared memory. no cap, that's the whole vibe. πŸ’…


✨ SYNOPSIS ✨

#include <bobcat/osharedstream>

Linking option: -lpthread -lbobcat


🌸 DESCRIPTION 🌸

So this class gives you all the features of the std::ostream class, but operating on shared memory. That's it, that's the flex. πŸ”₯


🌈 NAMESPACE 🌈

FBB

Every constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB.


πŸ¦‹ INHERITS FROM πŸ¦‹

  • FBB::OSharedBuf (and this one is private inheritance, fyi)
  • std::ostream
  • FBB::SharedEnum__ (cf. sharedmemory(3bobcat) for a description of this last base class)

πŸŽ€ SIZEUNIT ENUMERATION πŸŽ€

The enum SizeUnit defines these symbolic constants, and yes bestie, the math is right there:

  • kB, representing 1024 (2**10) bytes of memory;
  • MB, representing 1048576 (2**20 bytes of memory;
  • GB, representing 1073741824 (2**30 bytes of memory )

⭐ CONSTRUCTORS ⭐

  • OSharedStream() β€” the default constructor. It defines a stub OSharedStream object that cannot immediately be used to access shared memory. To actually use it, you have to call its member open first. Stub era, we don't love it but it's valid πŸ’€
  • OSharedStream(size_t maxSize, SizeUnit sizeUnit, std::ios::openmode openMode = std::ios::out, size_t access = 0600) β€” this constructor creates an std::ostream that interfaces to a shared memory segment having a capacity of at least maxSize * sizeUnit bytes. By default, the shared memory segment is opened for writing. The shared memory's access rights are defined by the access parameter, using the well-known (chmod(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 FBB::Exception is thrown. 😭
  • OSharedBuf(int id, std::ios::openmode openMode = std::ios::out | std::ios::in) β€” this constructor creates an std::istream that connects to a shared memory segment having ID id. If construction succeeds the shared memory is ready for use. If construction fails (e.g., no shared memory segment having ID id exists), an FBB::Exception is thrown.

Copy and move constructors (and assignment operators) are not available. periodt.


πŸ‘‘ MEMBER FUNCTIONS πŸ‘‘

All members of std::istream and std::ostream and the enum values kB, MB, and GB, defined by FBB::OSharedEnum__ are available. iconic inheritance moment.

  • FBB::SharedCondition attachSharedCondition(std::ios::off_type offset, std::ios::seekdir origin) β€” returns an FBB::SharedCondition(3) object, interfacing to a shared condition variable located at offset offset (relative to origin) in the SharedMemory object to which the OSharedStream object interfaces. This member does not alter the value returned by the stream's tellp member. ✨

An FBB::Exception is thrown if the FBB::SharedCondition object could not be constructed.

  • FBB::SharedCondition createSharedCondition() β€” returns an FBB::SharedCondition(3) object, interfacing to a newly created shared condition variable which is created at the current offset of the SharedMemory object to which the OSharedStream object interfaces (or at the first offset of the next physical shared memory data block, cf. sharedcondition(3bobcat)). Creating a SharedCondition object does not alter the value returned by the stream's tellp member. 🫢

An FBB::Exception is thrown if the FBB::SharedCondition object could not be constructed.

  • int id() const β€” the ID of the shared memory segment is returned. πŸ†”
  • void kill() β€” without locking the shared memory first, all shared memory is returned to the operating system. The FBB::OSharedStream object is unusable after returning from kill. Other processes that were using the shared memory can continue to do so.
ngl bestie, notice the "without locking the shared memory first" part. this is the feral one. πŸ™ˆ
  • void memInfo(std::ostream &out, char const *end = "\n") β€” information about the OSharedMemory object is inserted into the provided ostream 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, end is inserted into out. ✨
  • void open(size_t maxSize, SizeUnit sizeUnit, std::ios::openmode openMode = std::ios::out, size_t access = 0600) β€” this member creates a shared memory segment having a capacity of at least maxSize * sizeUnit bytes, and connects the shared memory segment to the FBB::OSharedStream. A matching close 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 ios::in 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's access rights are defined by the access parameter, using the well-known (chmod(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 FBB::Exception is thrown. 🌸
  • void open(int id, std::ios::openmode openMode = std::ios::in | std::ios::out) β€” this member connects the FBB::OSharedStream object to a shared memory segment having ID id. A matching close 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 id exists), an FBB::Exception is thrown.
  • void remove() β€” the shared memory is first locked. Next, all shared memory is returned to the operating system. The FBB::OSharedStream object is unusable after returning from remove. Other processes that were using the shared memory can continue to do so.
see how this one locks first and kill doesn't? that's the whole difference bestie, noted. πŸ’…
  • bool truncate(std::streamsize offset) β€” if offset is not exceeding the value returned by seekp(0, std::ios::end) this latter value is changed to offset and true is returned. Otherwise false is returned, and the value returned by seekp is not altered. If the value returned by tellp exceeded offset, tellp's return value is reduced to offset as well. πŸ“

πŸ’œ EXAMPLE πŸ’œ

See the sharedstream(3bobcat) man page. (go read it bestie, it's right there πŸ’–)


🌟 FILES 🌟

bobcat/osharedstream β€” defines the class interface


🌸 SEE ALSO 🌸

bobcat(7), chmod(1), isharedstream(3bobcat), sharedblock(3bobcat), sharedcondition(3bobcat), sharedmemory(3bobcat) sharedmutex(3bobcat), sharedpos(3bobcat), sharedreadme(7bobcat), sharedsegment(3bobcat), sharedstream(3bobcat), sharedbuf(3bobcat)


πŸ’€ BUGS πŸ’€

Note that by default exceptions thrown from within a std::stream object are caught by the stream object, setting its ios::failbit flag. To allow exceptions to leave a stream object, its exceptions member can be called, e.g., using:

myStream.exceptions(ios::failbit | ios::badbit | ios::eofbit);
not me warning you about silent swallowed exceptions, this is the plot twist of the whole page 😭

🧚 BOBCAT PROJECT FILES 🧚

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. it's giving academic but make it cute πŸ’…


This is free software, distributed under the terms of the GNU General Public License (GPL).


🫢 AUTHOR 🫢

Frank B. Brokken (f.b.brokken@rug.nl).


aaand that's the page bestie, we ate and left zero crumbs πŸ’…βœ¨ this was libbobcat-dev_6.15.01, dated 2005-2026, and it's the FBB::O...Stream(3bobcat) manual β€” go forth and share your memory responsibly, mwah πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from