StreamInterface.h

Go to the documentation of this file.
00001 /*
00002  * $Id: StreamInterface.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_FILEINTERFACE_H__
00015 #define __XVR2_FILEINTERFACE_H__
00016 
00017 #include<xvr2/Object.h>
00018 #include<xvr2/Buffer.h>
00019 #include<xvr2/String.h>
00020 #include<xvr2/StreamException.h>
00021 
00022 namespace xvr2 {
00023         
00026         class StreamInterface : public Object {
00027                 private:
00028                 protected:
00029                 public:
00030                         StreamInterface();
00031                         virtual ~StreamInterface();
00032                         virtual void open(const String &path) = 0;
00033                         virtual void close() = 0;
00034                         virtual bool opened() = 0;
00035                         virtual FileSizeT size() = 0;
00036                         virtual FileOffsetT tell() = 0;
00037                         virtual void seek(FileOffsetT _pos) = 0;
00038                         virtual void seekEnd() = 0;
00039                         virtual void seekBegin() = 0;
00040                         virtual void seekStep(FileOffsetT _step) = 0;
00041                         virtual void flush() = 0;
00042                         virtual bool eof() = 0;
00043         };
00044         
00056         class ReadableStream : public virtual StreamInterface {
00057                 protected:
00058                         bool handles_timeouts;
00059                         int timeout_msecs;
00060                 public:
00061                         ReadableStream(){
00062                                 handles_timeouts = false;
00063                                 timeout_msecs = 0;
00064                         }
00065                         virtual ReadableStream &operator >> (UInt32 n);
00066                         virtual ReadableStream &operator >> (double n);
00067                         virtual ReadableStream &operator >> (UInt64 n);
00068                         UInt32 read(UInt32 n);
00069                         UInt32 read(double n);
00070                         UInt32 read(UInt64 n);
00071                         virtual UInt32 read(void *data, UInt32 size) = 0;
00072                         virtual UInt32 read(Buffer &data, UInt32 size);
00075                         virtual ReadableStream &read(Buffer &b);
00077                         virtual ReadableStream &readAll(Buffer &b);
00078                         virtual void flush();
00079                         virtual void setTimeout(int millisecs){
00080                                 timeout_msecs = millisecs;
00081                         }
00082         }; 
00083         
00085         class WriteableStream : public virtual StreamInterface {
00086                 public:
00087                         virtual WriteableStream &operator << (const Buffer &b);
00088                         virtual WriteableStream &operator << (const String &s);
00089                         virtual WriteableStream &write(void *data, UInt32 size) = 0;
00090                         virtual WriteableStream &write(const Buffer &data);
00091                         virtual WriteableStream &write(const String &s);
00092                         virtual void seek(FileOffsetT _pos);
00093                         virtual void seekEnd();
00094                         virtual void seekBegin();
00095                         virtual void seekStep(FileOffsetT _step);
00096         };
00097 
00098         //class RandomAccessStream : public virtual StreamInterface {
00099         //};
00100 }
00101 
00102 #endif
00103 

Generated on Fri Jun 20 22:55:47 2008 for X-VR2 SDK by  doxygen 1.5.5