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 #include <vcl_atomic_count.h> 00015 00016 #if VXL_HAS_INT_64 00017 typedef vxl_int_64 vil_streampos; 00018 #else //VXL_HAS_INT_64 00019 typedef vxl_int_32 vil_streampos; 00020 #endif //VXL_HAS_INT_64 00021 00022 //: Stream interface for VIL image loaders 00023 // This allows the loaders to be used with any type of stream. 00024 class vil_stream 00025 { 00026 public: 00027 //: Return false if the stream is broken. 00028 virtual bool ok() const = 0; 00029 00030 //: Write n bytes from buf. Returns number of bytes written. 00031 // The return value is less than n only in case of device failure. 00032 virtual vil_streampos write(void const* buf, vil_streampos n) = 0; 00033 00034 //: Read n bytes into buf. Returns number of bytes read. 00035 // The return value is less than n only at eof. 00036 virtual vil_streampos read(void* buf, vil_streampos n) = 0; 00037 00038 //: Return file pointer 00039 virtual vil_streampos tell() const = 0; 00040 00041 //: Goto file pointer 00042 virtual void seek(vil_streampos position) = 0; 00043 00044 //: Amount of data in the stream 00045 virtual vil_streampos file_size() const = 0; 00046 00047 //: up/down the reference count 00048 void ref() { ++refcount_; } 00049 00050 void unref(); 00051 00052 protected: 00053 vil_stream(); 00054 virtual ~vil_stream(); 00055 00056 private: // use the methods, Luke! 00057 vcl_atomic_count refcount_; 00058 }; 00059 00060 #endif // vil_stream_h_
1.5.1