00001 /* 00002 * $Id: RawInputStream.h 562 2007-12-02 08:04:16Z mindstorm2600 $ 00003 * 00004 * X-VR2 00005 * 00006 * Copyright (C) Juan V. Guerrero 2007 00007 * 00008 * Juan V. Guerrero <mindstorm2600@users.sourceforge.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License Version 2. See the LICENSE file 00012 * at the top of the source tree. 00013 */ 00014 #ifndef __XVR2_RAW_INPUT_STREAM_H__ 00015 #define __XVR2_RAW_INPUT_STREAM_H__ 00016 #include<xvr2/StreamInterface.h> 00017 #include<xvr2/RawStreamInterface.h> 00018 #include<xvr2/SystemException.h> 00019 #include<cerrno> 00020 00021 namespace xvr2 { 00022 00024 class RawInputStream : public ReadableStream, public RawStreamInterface { 00025 private: 00026 bool reached_eof; 00027 public: 00028 RawInputStream(); 00029 virtual ~RawInputStream(); 00030 RawInputStream(int __fd); 00031 RawInputStream(const String &fname); 00032 void open(int __fd); 00033 void open(const String &fname); 00034 virtual void close(); 00035 00036 virtual UInt32 read(void *data, UInt32 size); 00037 int fd(); 00038 bool eof(); 00039 virtual void seek(FileOffsetT _pos); 00040 virtual void seekEnd(); 00041 virtual void seekBegin(); 00042 virtual void seekStep(FileOffsetT _step); 00043 virtual bool ready(int timeout = 100); 00044 }; 00045 00046 class RawInputStreamTimeoutException : public StreamException { 00047 protected: 00048 int _fd; 00049 int _msecs; 00050 public: 00051 RawInputStreamTimeoutException(int __fd); 00052 RawInputStreamTimeoutException(int __fd, int __msecs); 00053 int fd(); 00054 int millis(); 00055 }; 00056 } 00057 00058 #endif 00059