Helper class that hands out input streams to an underlying, managed stream of arbitrary type. More...
#include <InputStream.h>
Public Member Functions | |
virtual | ~InputStream () |
virtual std::shared_ptr< std::istream > | get () const =0 |
Gets an input stream to the underlying stream. More... | |
bool | inUse () const |
Whether or not anything is still using this stream. More... | |
virtual std::optional< std::filesystem::path > | getFilename () const |
Gets the underlying filename, if any. More... | |
Protected Member Functions | |
void | addSharedStream (const std::weak_ptr< std::istream > stream) const |
Internal method to be called by derived classes to add a shared stream to _shared_streams (so that it can be tracked). More... | |
Private Attributes | |
std::vector< std::weak_ptr< std::istream > > | _shared_streams |
The streams that have been handed out by get() More... | |
Helper class that hands out input streams to an underlying, managed stream of arbitrary type.
Definition at line 22 of file InputStream.h.
|
virtual |
Definition at line 14 of file InputStream.C.
|
protected |
Internal method to be called by derived classes to add a shared stream to _shared_streams (so that it can be tracked).
Should be called in the overridden get() by derived classes.
Definition at line 21 of file InputStream.C.
Referenced by FileInputStream::get(), and StringInputStream::get().
|
pure virtual |
Gets an input stream to the underlying stream.
This is returned as a shared_ptr so that this class can tell whether or not another object is still using the stream.
Implemented in StringInputStream, and FileInputStream.
Referenced by RestartableDataReader::deserializeValue(), and RestartableDataReader::readHeader().
|
virtual |
Gets the underlying filename, if any.
Reimplemented in FileInputStream.
Definition at line 44 of file InputStream.C.
Referenced by RestartableDataReader::deserializeValue(), and RestartableDataReader::readHeader().
bool InputStream::inUse | ( | ) | const |
Whether or not anything is still using this stream.
This is checked by seeing whether or not the use count of any of the streams handed out by get() is > 1 (with the only use count being the one stored in _shared_streams)
Definition at line 35 of file InputStream.C.
Referenced by StringInputStream::release(), and ~InputStream().
|
mutableprivate |
The streams that have been handed out by get()
Definition at line 60 of file InputStream.h.
Referenced by addSharedStream(), and inUse().