00001 // This is core/vil/vil_stream.h 00002 #ifndef vil_stream_h_ 00003 #define vil_stream_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief Stream interface for VIL image loaders 00010 // \author awf@robots.ox.ac.uk 00011 // \date 16 Feb 00 00012 00013 #include <vxl_config.h> 00014 #if VXL_HAS_INT_64 00015 typedef vxl_int_64 vil_streampos; 00016 #else //VXL_HAS_INT_64 00017 typedef vxl_int_32 vil_streampos; 00018 #endif //VXL_HAS_INT_64 00019 00020 //: Stream interface for VIL image loaders 00021 // This allows the loaders to be used with any type of stream. 00022 class vil_stream 00023 { 00024 public: 00025 //: Return false if the stream is broken. 00026 virtual bool ok() const = 0; 00027 00028 //: Write n bytes from buf. Returns number of bytes written. 00029 // The return value is less than n only in case of device failure. 00030 virtual vil_streampos write(void const* buf, vil_streampos n) = 0; 00031 00032 //: Read n bytes into buf. Returns number of bytes read. 00033 // The return value is less than n only at eof. 00034 virtual vil_streampos read(void* buf, vil_streampos n) = 0; 00035 00036 //: Return file pointer 00037 virtual vil_streampos tell() const = 0; 00038 00039 //: Goto file pointer 00040 virtual void seek(vil_streampos position) = 0; 00041 00042 //: Amount of data in the stream 00043 virtual vil_streampos file_size() const = 0; 00044 00045 //: up/down the reference count 00046 void ref() { ++refcount_; } 00047 00048 void unref(); 00049 00050 protected: 00051 vil_stream(); 00052 virtual ~vil_stream(); 00053 00054 private: // use the methods, Luke! 00055 int refcount_; 00056 }; 00057 00058 #endif // vil_stream_h_
1.4.4