MPD  0.20.6
Public Member Functions | Protected Member Functions | Protected Attributes
ProxyInputStream Class Reference

An InputStream that forwards all methods call to another InputStream instance. More...

#include <ProxyInputStream.hxx>

Inheritance diagram for ProxyInputStream:
[legend]
Collaboration diagram for ProxyInputStream:
[legend]

Public Member Functions

gcc_nonnull_all ProxyInputStream (InputStream *_input)
 
virtual ~ProxyInputStream ()
 
 ProxyInputStream (const ProxyInputStream &)=delete
 
ProxyInputStreamoperator= (const ProxyInputStream &)=delete
 
void Check () override
 Check for errors that may have occurred in the I/O thread. More...
 
void Update () override
 Update the public attributes. More...
 
void Seek (offset_type new_offset) override
 Seeks to the specified position in the stream. More...
 
bool IsEOF () override
 Returns true if the stream has reached end-of-file. More...
 
TagReadTag () override
 Reads the tag from the stream. More...
 
bool IsAvailable () override
 Returns true if the next read operation will not block: either data is available, or end-of-stream has been reached, or an error has occurred. More...
 
size_t Read (void *ptr, size_t read_size) override
 Reads data from the stream into the caller-supplied buffer. More...
 
- Public Member Functions inherited from InputStream
 InputStream (const char *_uri, Mutex &_mutex, Cond &_cond)
 
virtual ~InputStream ()
 Close the input stream and free resources. More...
 
const char * GetURI () const
 The absolute URI which was used to open this stream. More...
 
void Lock ()
 
void Unlock ()
 
void SetReady ()
 
bool IsReady () const
 Return whether the stream is ready for reading and whether the other attributes in this struct are valid. More...
 
void WaitReady ()
 
void LockWaitReady ()
 Wrapper for WaitReady() which locks and unlocks the mutex; the caller must not be holding it already. More...
 
gcc_pure bool HasMimeType () const
 
gcc_pure const char * GetMimeType () const
 
void ClearMimeType ()
 
gcc_nonnull_all void SetMimeType (const char *_mime)
 
void SetMimeType (std::string &&_mime)
 
gcc_pure bool KnownSize () const
 
gcc_pure offset_type GetSize () const
 
void AddOffset (offset_type delta)
 
gcc_pure offset_type GetOffset () const
 
gcc_pure offset_type GetRest () const
 
gcc_pure bool IsSeekable () const
 
gcc_pure bool CheapSeeking () const
 Determines whether seeking is cheap. More...
 
void LockSeek (offset_type offset)
 Wrapper for Seek() which locks and unlocks the mutex; the caller must not be holding it already. More...
 
void Rewind ()
 Rewind to the beginning of the stream. More...
 
void LockRewind ()
 
void Skip (offset_type _offset)
 Skip input bytes. More...
 
void LockSkip (offset_type _offset)
 
gcc_pure bool LockIsEOF ()
 Wrapper for IsEOF() which locks and unlocks the mutex; the caller must not be holding it already. More...
 
gcc_malloc TagLockReadTag ()
 Wrapper for ReadTag() which locks and unlocks the mutex; the caller must not be holding it already. More...
 
gcc_nonnull_all size_t LockRead (void *ptr, size_t size)
 Wrapper for Read() which locks and unlocks the mutex; the caller must not be holding it already. More...
 
gcc_nonnull_all void ReadFull (void *ptr, size_t size)
 Reads the whole data from the stream into the caller-supplied buffer. More...
 
gcc_nonnull_all void LockReadFull (void *ptr, size_t size)
 Wrapper for ReadFull() which locks and unlocks the mutex; the caller must not be holding it already. More...
 

Protected Member Functions

void CopyAttributes ()
 Copy public attributes from the underlying input stream to the "rewind" input stream. More...
 

Protected Attributes

InputStreaminput
 
- Protected Attributes inherited from InputStream
bool ready
 indicates whether the stream is ready for reading and whether the other attributes in this struct are valid More...
 
bool seekable
 if true, then the stream is fully seekable More...
 
offset_type size
 the size of the resource, or UNKNOWN_SIZE if unknown More...
 
offset_type offset
 the current offset within the stream More...
 

Additional Inherited Members

- Public Types inherited from InputStream
typedef ::offset_type offset_type
 
- Static Public Member Functions inherited from InputStream
static gcc_nonnull_all InputStreamPtr Open (const char *uri, Mutex &mutex, Cond &cond)
 Opens a new input stream. More...
 
static gcc_nonnull_all InputStreamPtr OpenReady (const char *uri, Mutex &mutex, Cond &cond)
 Just like Open(), but waits for the stream to become ready. More...
 
- Data Fields inherited from InputStream
Mutexmutex
 A mutex that protects the mutable attributes of this object and its implementation. More...
 
Condcond
 A cond that gets signalled when the state of this object changes from the I/O thread. More...
 
- Static Protected Attributes inherited from InputStream
static constexpr offset_type UNKNOWN_SIZE = -1
 

Detailed Description

An InputStream that forwards all methods call to another InputStream instance.

This can be used as a base class to override selected methods.

Definition at line 32 of file ProxyInputStream.hxx.

Constructor & Destructor Documentation

gcc_nonnull_all ProxyInputStream::ProxyInputStream ( InputStream _input)
virtual ProxyInputStream::~ProxyInputStream ( )
virtual
ProxyInputStream::ProxyInputStream ( const ProxyInputStream )
delete

Member Function Documentation

void ProxyInputStream::Check ( )
overridevirtual

Check for errors that may have occurred in the I/O thread.

Throws std::runtime_error on error.

Reimplemented from InputStream.

void ProxyInputStream::CopyAttributes ( )
protected

Copy public attributes from the underlying input stream to the "rewind" input stream.

This function is called when a method of the underlying stream has returned, which may have modified these attributes.

bool ProxyInputStream::IsAvailable ( )
overridevirtual

Returns true if the next read operation will not block: either data is available, or end-of-stream has been reached, or an error has occurred.

The caller must lock the mutex.

Reimplemented from InputStream.

bool ProxyInputStream::IsEOF ( )
overridevirtual

Returns true if the stream has reached end-of-file.

The caller must lock the mutex.

Implements InputStream.

ProxyInputStream& ProxyInputStream::operator= ( const ProxyInputStream )
delete
size_t ProxyInputStream::Read ( void *  ptr,
size_t  size 
)
overridevirtual

Reads data from the stream into the caller-supplied buffer.

Returns 0 on error or eof (check with IsEOF()).

The caller must lock the mutex.

Throws std::runtime_error on error.

Parameters
ptrthe buffer to read into
sizethe maximum number of bytes to read
Returns
the number of bytes read

Implements InputStream.

Tag* ProxyInputStream::ReadTag ( )
overridevirtual

Reads the tag from the stream.

The caller must lock the mutex.

Returns
a tag object which must be freed by the caller, or nullptr if the tag has not changed since the last call

Reimplemented from InputStream.

void ProxyInputStream::Seek ( offset_type  offset)
overridevirtual

Seeks to the specified position in the stream.

This will most likely fail if the "seekable" flag is false.

The caller must lock the mutex.

Throws std::runtime_error on error.

Parameters
offsetthe relative offset

Reimplemented from InputStream.

void ProxyInputStream::Update ( )
overridevirtual

Update the public attributes.

Call before accessing attributes such as "ready" or "offset".

Reimplemented from InputStream.

Field Documentation

InputStream& ProxyInputStream::input
protected

Definition at line 34 of file ProxyInputStream.hxx.


The documentation for this class was generated from the following file: