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

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

okay so bestie, this whole page lives in the bobcat manual, and it's all about FBB::ISharedStream β€” the ✨ shared-memory edition ✨ of std::istream. Buckle up, it's lowkey iconic.


🌸 NAME 🌸

FBB::ISharedStream β€” literally std::istream operations, but on shared memory πŸ’…


✨ SYNOPSIS ✨

#include <bobcat/isharedstream>
Linking option: -lpthread -lbobcat

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this class is out here serving you all the features of the std::istream class, except it's operating on shared memory. that's the whole vibe. no cap 🫢


πŸ‘‘ NAMESPACE πŸ‘‘

FBB

every constructor, member, operator and manipulator that gets mentioned on this page is defined in the namespace FBB. periodt.


🌈 INHERITS FROM 🌈

  • FBB::ISharedBuf (private inheritance, iykyk)
  • std::istream
  • FBB::SharedEnum__ β€” and fr, check sharedmemory(3bobcat) if you wanna know what's up with this last base class πŸ’œ

🧚 SIZEUNIT ENUMERATION 🧚

the enum SizeUnit defines these symbolic constants, and they're giving units of memory:

  • 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 πŸŽ€

  • ISharedStream() β€” the default constructor. it defines a stub ISharedStream object that cannot immediately be used to access shared memory. to actually use it you have to call its member open first, bestie. no skipping steps πŸ’…
  • ISharedStream(size_t maxSize, SizeUnit sizeUnit, std::ios::openmode openMode = std::ios::in, size_t access = 0600) β€” this one creates an std::istream that interfaces to a shared memory segment with a capacity of at least maxSize * sizeUnit bytes. by default the shared memory segment is opened for reading. and here's the thing β€” 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 (or object), the information can be read. the shared memory's access rights are defined by the access parameter, using the well-known chmod(1) way to define 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 😭
  • ISharedStream(int id, std::ios::openmode openMode = 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. like, they simply do not exist. don't come for them.

🫢 MEMBER FUNCTIONS 🫢

all members of std::istream, and the enum values kB, MB, and GB, defined by FBB::ISharedEnum__, are available. slay.

  • 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 ISharedStream object interfaces. this member does not alter the value returned by the stream's tellg 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. cute and simple ✨
  • void kill() β€” without locking the shared memory first, all shared memory is returned to the operating system. the FBB::ISharedStream object is unusable after returning from kill. other processes that were using the shared memory can continue to do so. yeah, it's as dramatic as it sounds πŸ”₯
  • void memInfo(std::ostream &out, char const *end = "\n") β€” information about the ISharedMemory 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 all displayed. following the information about the shared memory, end is inserted into out πŸ’œ
  • void open(size_t maxSize, SizeUnit sizeUnit, std::ios::openmode openMode = std::ios::in, 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::ISharedStream. a matching close member does not exist and is not required (so don't go looking for one, babe). 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 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) β€” this member connects the FBB::ISharedStream 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::ISharedStream object is unusable after returning from remove. other processes that were using the shared memory can continue to do so. locked-then-nuked, that's the order of operations πŸ’…
  • bool truncate(std::streamsize offset) β€” if offset is not exceeding the value returned by seekg(0, std::ios::end), then this latter value is changed to offset and true is returned. otherwise false is returned, and the value returned by seekg is not altered. if the value returned by tellg exceeded offset, tellg's return value is reduced to offset as well. subsequent read operations on the shared memory can only succeed as long as tellg's return value hasn't reached the value offset ⭐

πŸ’€ EXAMPLE πŸ’€

see the sharedstream(3bobcat) man page. go go go πŸƒβ€β™€οΈ


🌸 FILES 🌸

bobcat/isharedstream β€” defines the class interface πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯

bobcat(7), chmod(1), osharedstream(3bobcat), sharedblock(3bobcat), sharedcondition(3bobcat), sharedmemory(3bobcat), sharedmutex(3bobcat), sharedpos(3bobcat), sharedreadme(7bobcat), sharedsegment(3bobcat), sharedstream(3bobcat), sharedbuf(3bobcat) β€” the whole friend group, fr fr 🫢


😭 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);

so yeah, if your exception is being swallowed, that's why bestie πŸ’€


πŸ¦‹ 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. ate that backronym up, honestly πŸ“


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 page, bestie! this one came from libbobcat-dev_6.15.01, dated 2005-2026, in the FBB::I...Stream(3bobcat) corner of the manual. stay hydrated, read your man pages, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from