hamcast  Version 0.7
Public Member Functions | List of all members
hamcast::util::source Struct Referenceabstract

#include <source.hpp>

Inheritance diagram for hamcast::util::source:
hamcast::util::closeable hamcast::ref_counted hamcast::util::buffered_source< block_size, maximum_size > hamcast::util::read_buffer

Public Member Functions

virtual bool wait_for_data (long seconds, long microseconds)=0
 
virtual size_t read_some (size_t buf_size, void *buf)=0
 
virtual void read (size_t buf_size, void *buf)=0
 
- Public Member Functions inherited from hamcast::util::closeable
virtual void close ()=0
 
virtual bool closed () const =0
 
- Public Member Functions inherited from hamcast::ref_counted
long ref_count ()
 

Additional Inherited Members

- Static Public Member Functions inherited from hamcast::ref_counted
static void add_ref (ref_counted *rc)
 
static void release (ref_counted *rc)
 
- Protected Member Functions inherited from hamcast::ref_counted
 ref_counted ()
 
void ref ()
 
bool deref ()
 

Detailed Description

Describes an abstract (binary) data source.

Member Function Documentation

virtual void hamcast::util::source::read ( size_t  buf_size,
void *  buf 
)
pure virtual

Read buf_size bytes from the data source. This function blocks until enough bytes are available and throws and exception if the source becomes unreadable before buf_size bytes are read.

Parameters
buf_sizeThe size of buf.
bufThe target buffer.
Precondition
lock_read() was called
Exceptions
std::ios_base::failureon errors during read (e.g. if the source is closed)

Implemented in hamcast::util::read_buffer, and hamcast::util::buffered_source< block_size, maximum_size >.

virtual size_t hamcast::util::source::read_some ( size_t  buf_size,
void *  buf 
)
pure virtual

Read up to buf_size bytes from the data source and store the bytes in buf. A closed source always returns 0.

Parameters
buf_sizeThe size of buf.
bufThe target buffer.
Returns
The number of readed bytes (might be < buf_size).
Precondition
lock_read() was called
Exceptions
std::ios_base::failureon errors during read.

Implemented in hamcast::util::buffered_source< block_size, maximum_size >, and hamcast::util::read_buffer.

virtual bool hamcast::util::source::wait_for_data ( long  seconds,
long  microseconds 
)
pure virtual

Wait until this source becomes "ready" or until a timeout occurs.

Parameters
secondsThe seconds part of the maximum block time.
microsecondsThe microseconds part of the maximum block time.
Returns
true if there is data to read; otherwise false
Precondition
lock_read() was called
Exceptions
std::ios_base::failureif the source becomes closed

Implemented in hamcast::util::buffered_source< block_size, maximum_size >, and hamcast::util::read_buffer.


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