Changeset 31:bbd688924703 in xplcommon for src/xplcommon/BlockingStream.h


Ignore:
Timestamp:
01/02/13 13:58:25 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the data stream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/BlockingStream.h

    r30 r31  
    3535
    3636#include "BufferedStream.h"
     37
    3738#include "Waiter.h"
    3839#include "WaitableEvent.h"
     
    7677    size_t readingOffset;
    7778
     79    /**
     80     * Indicate if the end-of-file has been reached while reading.
     81     */
     82    bool eof;
     83
    7884public:
    7985    /**
     
    8389     */
    8490    BlockingStream(BufferedStream& stream);
     91
     92    /**
     93     * Determine if the stream has neither failed nor been
     94     * interrupted.
     95     */
     96    operator bool() const;
    8597
    8698    /**
     
    102114     */
    103115    bool read(void* dest, size_t length);
     116
     117    /**
     118     * Skip the given number of bytes.
     119     */
     120    bool skip(size_t length);
    104121
    105122    /**
     
    125142     */
    126143    bool fill();
     144
     145    /**
     146     * Check for the stream being interrupted.
     147     *
     148     * @return if the stream is interrupted, false otherwise
     149     */
     150    bool checkInterrupted();
    127151};
    128152
     
    135159    event(stream.getWaiter()),
    136160    interrupted(false),
    137     readingOffset(0)
     161    readingOffset(0),
     162    eof(false)
    138163{
     164}
     165
     166//------------------------------------------------------------------------------
     167
     168inline BlockingStream::operator bool() const
     169{
     170    return !failed() && !interrupted && !eof;
    139171}
    140172
     
    144176{
    145177    event.fire();
     178}
     179
     180//------------------------------------------------------------------------------
     181
     182inline bool BlockingStream::isInterrupted()
     183{
     184    return interrupted;
    146185}
    147186
Note: See TracChangeset for help on using the changeset viewer.