USGS

Isis 3.0 Object Programmers' Reference

Home

Buffer.h

Go to the documentation of this file.
00001 #ifndef Buffer_h
00002 #define Buffer_h
00003 
00026 #include "iException.h"
00027 #include "PixelType.h"
00028 
00029 namespace Isis {
00066   class Buffer {
00067     public:
00068       Buffer();
00069       Buffer(const int nsamps, const int nlines, const int nbands,
00070              const Isis::PixelType type);
00071 
00072       ~Buffer();
00073 
00074       Buffer (const Buffer &);
00075 
00076       Buffer &operator=(const double &d);
00077   
00083       inline int SampleDimension() const { return (p_nsamps); }
00084 
00090       inline int LineDimension() const { return (p_nlines); }
00091 
00097       inline int BandDimension() const { return (p_nbands); }
00098 
00104       inline int size() const { return (p_npixels); }
00105   
00106       // Methods which return absolute coordinates relative to the buffer
00107       int Sample(const int index = 0) const;
00108       int Line(const int index = 0) const;
00109       int Band(const int index = 0) const;
00110       void Position(const int index, int &i_samp, int &i_line, int &i_band) const;
00111       int Index(const int i_samp, const int i_line, const int i_band) const
00112                 throw(Isis::iException &);
00113   
00114       // Methods which give info about the buffer or its contents
00115       double at(const int index) const;
00116 
00124       inline double &operator[](const int index) { return (p_buf[index]); }
00125 
00131       inline double *DoubleBuffer() const { return (p_buf); };
00132       void Copy (const Buffer &in);
00133   
00140       void *RawBuffer() const { return p_rawbuf; };
00141 
00147       Isis::PixelType PixelType () const { return p_pixelType; };
00148   
00149     protected:
00150       void SetBasePosition(const int start_sample, const int start_line,
00151                            const int start_band);
00152 
00158       inline void SetBaseSample(const int start_samp)
00159                   { p_sample = start_samp; return; }
00160 
00166       inline void SetBaseLine(const int start_line)
00167                   { p_line = start_line; return; }
00168 
00174       inline void SetBaseBand(const int start_band)
00175                   { p_band = start_band; return; }
00176 
00177       int p_sample;   
00178       int p_nsamps;   
00179                      
00180       int p_line;     
00181       int p_nlines;   
00182                      
00183       int p_band;     
00184       int p_nbands;   
00185                      
00186       int p_npixels;  
00187       double *p_buf;  
00190       const Isis::PixelType p_pixelType;  
00191       void *p_rawbuf;                     
00192 
00193       void Allocate();
00194 
00203       Buffer &operator=(const Buffer &rvalue) { 
00204         return const_cast<Buffer &>(rvalue); 
00205       };
00206 
00207   };
00208 };
00209 
00210 #endif