barrier/lib/io/IInputStream.h

68 lines
1.8 KiB
C
Raw Normal View History

2002-08-02 19:57:46 +00:00
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
2001-10-06 14:13:28 +00:00
#ifndef IINPUTSTREAM_H
#define IINPUTSTREAM_H
#include "IInterface.h"
#include "BasicTypes.h"
//! Input stream interface
/*!
Defines the interface for all input streams.
*/
2001-10-06 14:13:28 +00:00
class IInputStream : public IInterface {
2002-04-29 14:40:01 +00:00
public:
//! @name manipulators
//@{
2001-10-06 14:13:28 +00:00
//! Close the stream
/*!
Closes the stream. Attempting to read() after close() throws
XIOClosed and getSize() always returns zero.
*/
virtual void close() = 0;
2001-10-06 14:13:28 +00:00
//! Read from stream
/*!
Read up to \c n bytes into buffer, returning the number read.
Blocks for up to \c timeout seconds if no data is available but does
not wait if any data is available, even if less than \c n bytes.
If \c timeout < 0 then it blocks indefinitely until data is available.
If \c buffer is NULL then the data is discarded. Returns (UInt32)-1 if
it times out and 0 if no data is available and the other end of the
stream has hungup.
2001-10-06 14:13:28 +00:00
(cancellation point)
*/
virtual UInt32 read(void* buffer, UInt32 n, double timeout) = 0;
2001-10-06 14:13:28 +00:00
//@}
//! @name accessors
//@{
//! Get remaining size of stream
/*!
Returns a conservative estimate of the available bytes to read
(i.e. a number not greater than the actual number of bytes).
Some streams may not be able to determine this and will always
return zero.
*/
virtual UInt32 getSize() const = 0;
//@}
2001-10-06 14:13:28 +00:00
};
#endif