core/vil1/vil1_stream_core.h

Go to the documentation of this file.
00001 // This is core/vil1/vil1_stream_core.h
00002 #ifndef vil1_stream_core_h_
00003 #define vil1_stream_core_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief An in-core vil1_stream implementation
00010 // \author  fsm
00011 
00012 #include <vcl_vector.h>
00013 #include <vil1/vil1_stream.h>
00014 
00015 //: An in-core vil1_stream implementation.
00016 // This is an infinite stream - reads past the last point
00017 // written will succeed but will return garbage data.
00018 class vil1_stream_core : public vil1_stream
00019 {
00020   vil1_streampos curpos_;       // current file pointer.
00021   unsigned blocksize_;
00022   vcl_vector<char*> block_;
00023   vil1_streampos tailpos_; // size of file so far
00024 
00025  public:
00026   vil1_stream_core(unsigned block_size = 16384)
00027     : curpos_(0), blocksize_(block_size), tailpos_(0) {}
00028 
00029   //: get current file size
00030   unsigned size() const { return tailpos_; }
00031 
00032   //: Read or write n bytes at position pos.
00033   // This does not change the current position.
00034   // When read=false, buf is actually a "char const *".
00035   vil1_streampos m_transfer(char *buf, vil1_streampos pos, vil1_streampos n, bool read);
00036 
00037   // implement virtual vil1_stream interface:
00038   bool ok() const { return true; }
00039   vil1_streampos read (void       *buf, vil1_streampos n);
00040   vil1_streampos write(void const *buf, vil1_streampos n);
00041   vil1_streampos tell()     const    { return curpos_; }
00042   void seek(vil1_streampos position) { curpos_ = position; }
00043 
00044  protected:
00045   ~vil1_stream_core();
00046 };
00047 
00048 #endif // vil1_stream_core_h_

Generated on Mon Mar 8 05:09:33 2010 for core/vil1 by  doxygen 1.5.1