Panda3D
|
This class provides a locking wrapper around an arbitrary istream pointer. More...
#include "streamWrapper.h"
Public Member Functions | |
IStreamWrapper (std::istream &stream) | |
IStreamWrapper (std::istream *stream, bool owns_pointer) | |
int | get () |
Atomically reads a single character from the stream. | |
std::istream * | get_istream () const |
void | read (char *buffer, std::streamsize num_bytes) |
void | read (char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes) |
void | read (char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes, bool &eof) |
std::streamsize | seek_gpos_eof () |
Atomically seeks to EOF and returns the gpos there; that is, returns the file size. | |
void | seek_read (std::streamsize pos, char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes, bool &eof) |
Atomically seeks to a particular offset from the beginning of the file, and reads a number of bytes from the stream. | |
![]() | |
void | acquire () |
Acquires the internal lock. | |
void | ref () const |
Increments the reference count. | |
void | release () |
Releases the internal lock. | |
bool | unref () const |
Decrements the reference count. | |
Public Attributes | |
get_istream | |
Returns the istream this object is wrapping. | |
This class provides a locking wrapper around an arbitrary istream pointer.
A thread may use this class to perform an atomic seek/read/gcount operation.
Definition at line 59 of file streamWrapper.h.
|
inline |
Definition at line 82 of file streamWrapper.I.
|
inlineexplicit |
Definition at line 92 of file streamWrapper.I.
IStreamWrapper::~IStreamWrapper | ( | ) |
Definition at line 21 of file streamWrapper.cxx.
|
inline |
Atomically reads a single character from the stream.
Definition at line 110 of file streamWrapper.I.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
streamsize IStreamWrapper::seek_gpos_eof | ( | ) |
Atomically seeks to EOF and returns the gpos there; that is, returns the file size.
Note that the EOF might have been moved in another thread by the time this method returns.
Definition at line 122 of file streamWrapper.cxx.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
Referenced by SubStreamBuf::seekoff().
void IStreamWrapper::seek_read | ( | std::streamsize | pos, |
char * | buffer, | ||
std::streamsize | num_bytes, | ||
std::streamsize & | read_bytes, | ||
bool & | eof ) |
Atomically seeks to a particular offset from the beginning of the file, and reads a number of bytes from the stream.
Returns the number of bytes actually read, and whether an eof condition was detected by the operation.
Definition at line 104 of file streamWrapper.cxx.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
Referenced by Multifile::read_subfile().
|
inline |
Returns the istream this object is wrapping.
Definition at line 67 of file streamWrapper.h.
Referenced by Multifile::flush().