USGS

Isis 3.0 Developer's Reference (API)

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 {
00068   class Buffer {
00069     public:
00070       Buffer();
00071       Buffer(const int nsamps, const int nlines, const int nbands,
00072              const Isis::PixelType type);
00073 
00074       ~Buffer();
00075 
00076       Buffer(const Buffer &);
00077 
00078       Buffer &operator=(const double &d);
00079 
00085       inline int SampleDimension() const {
00086         return (p_nsamps);
00087       }
00088 
00094       inline int LineDimension() const {
00095         return (p_nlines);
00096       }
00097 
00103       inline int BandDimension() const {
00104         return (p_nbands);
00105       }
00106 
00112       inline int size() const {
00113         return (p_npixels);
00114       }
00115 
00116       // Methods which return absolute coordinates relative to the buffer
00117       int Sample(const int index = 0) const;
00118       int Line(const int index = 0) const;
00119       int Band(const int index = 0) const;
00120       void Position(const int index, int &i_samp, int &i_line, int &i_band) const;
00121       int Index(const int i_samp, const int i_line, const int i_band) const
00122       throw(Isis::iException &);
00123 
00124       // Methods which give info about the buffer or its contents
00125       double at(const int index) const;
00126 
00134       inline double &operator[](const int index) {
00135         return (p_buf[index]);
00136       }
00137 
00145       const double &operator[](const int index) const {
00146         return (p_buf[index]);
00147       }
00148 
00154       inline double *DoubleBuffer() const {
00155         return (p_buf);
00156       };
00157       void Copy(const Buffer &in);
00158 
00165       void *RawBuffer() const {
00166         return p_rawbuf;
00167       };
00168 
00174       Isis::PixelType PixelType() const {
00175         return p_pixelType;
00176       };
00177 
00178     protected:
00179       void SetBasePosition(const int start_sample, const int start_line,
00180                            const int start_band);
00181 
00187       inline void SetBaseSample(const int start_samp) {
00188         p_sample = start_samp;
00189         return;
00190       }
00191 
00197       inline void SetBaseLine(const int start_line) {
00198         p_line = start_line;
00199         return;
00200       }
00201 
00207       inline void SetBaseBand(const int start_band) {
00208         p_band = start_band;
00209         return;
00210       }
00211 
00212       int p_sample;   
00213       int p_nsamps;   
00214 
00215       int p_line;     
00216       int p_nlines;   
00217 
00218       int p_band;     
00219       int p_nbands;   
00220 
00221       int p_npixels;  
00222       double *p_buf;  
00225       const Isis::PixelType p_pixelType;  
00226       void *p_rawbuf;                     
00227 
00228       void Allocate();
00229 
00238       Buffer &operator=(const Buffer &rvalue) {
00239         return const_cast<Buffer &>(rvalue);
00240       };
00241 
00242   };
00243 };
00244 
00245 #endif