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"
|
|
|
|
|
2002-07-28 17:25:13 +00:00
|
|
|
//! 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:
|
2002-07-28 17:25:13 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2001-10-06 14:13:28 +00:00
|
|
|
|
2002-07-28 17:25:13 +00:00
|
|
|
//! Close the stream
|
|
|
|
/*!
|
|
|
|
Closes the stream. Attempting to read() after close() throws
|
|
|
|
XIOClosed and getSize() always returns zero.
|
|
|
|
*/
|
2001-10-14 16:58:01 +00:00
|
|
|
virtual void close() = 0;
|
2001-10-06 14:13:28 +00:00
|
|
|
|
2002-07-28 17:25:13 +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
|
|
|
|
2002-07-28 17:25:13 +00:00
|
|
|
(cancellation point)
|
|
|
|
*/
|
|
|
|
virtual UInt32 read(void* buffer, UInt32 n, double timeout) = 0;
|
2001-10-06 14:13:28 +00:00
|
|
|
|
2002-07-28 17:25:13 +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.
|
|
|
|
*/
|
2001-10-14 16:58:01 +00:00
|
|
|
virtual UInt32 getSize() const = 0;
|
2002-07-28 17:25:13 +00:00
|
|
|
|
|
|
|
//@}
|
2001-10-06 14:13:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|