Isis 3 Programmer Reference
Buffer.h
1 #ifndef Buffer_h
2 #define Buffer_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include "PixelType.h"
11 
12 namespace Isis {
53  class Buffer {
54  public:
55  Buffer();
56  Buffer(const int nsamps, const int nlines, const int nbands,
57  const Isis::PixelType type);
58 
59  ~Buffer();
60 
61  Buffer(const Buffer &);
62 
63  Buffer &operator=(const double &d);
64 
70  inline int SampleDimension() const {
71  return (p_nsamps);
72  }
73 
79  inline int LineDimension() const {
80  return (p_nlines);
81  }
82 
88  inline int BandDimension() const {
89  return (p_nbands);
90  }
91 
97  inline int size() const {
98  return (p_npixels);
99  }
100 
101  // Methods which return absolute coordinates relative to the buffer
102  int Sample(const int index = 0) const;
103  int Line(const int index = 0) const;
104  int Band(const int index = 0) const;
105  void Position(const int index, int &i_samp, int &i_line, int &i_band) const;
106  int Index(const int i_samp, const int i_line, const int i_band) const;
107 
108  // Methods which give info about the buffer or its contents
109  double at(const int index) const;
110 
118  inline double &operator[](const int index) {
119  return (p_buf[index]);
120  }
121 
129  const double &operator[](const int index) const {
130  return (p_buf[index]);
131  }
132 
138  inline double *DoubleBuffer() const {
139  return (p_buf);
140  };
141  void Copy(const Buffer &in, bool includeRawBuf = true);
142 
143  bool CopyOverlapFrom(const Buffer &in);
144 
151  void *RawBuffer() const {
152  return p_rawbuf;
153  };
154 
161  return p_pixelType;
162  };
163 
164  protected:
165  void SetBasePosition(const int start_sample, const int start_line,
166  const int start_band);
167 
173  inline void SetBaseSample(const int start_samp) {
174  p_sample = start_samp;
175  return;
176  }
177 
183  inline void SetBaseLine(const int start_line) {
184  p_line = start_line;
185  return;
186  }
187 
193  inline void SetBaseBand(const int start_band) {
194  p_band = start_band;
195  return;
196  }
197 
198  int p_sample;
199  int p_nsamps;
200 
201  int p_line;
202  int p_nlines;
203 
204  int p_band;
205  int p_nbands;
206 
207  int p_npixels;
208  double *p_buf;
212  void *p_rawbuf;
213 
214  void Allocate();
215 
224  Buffer &operator=(const Buffer &rvalue) {
225  return const_cast<Buffer &>(rvalue);
226  };
227 
228  };
229 };
230 
231 #endif
Isis::Buffer::SetBaseBand
void SetBaseBand(const int start_band)
This method is used to set the base band position of the shape buffer.
Definition: Buffer.h:193
Isis::Buffer::SampleDimension
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition: Buffer.h:70
Isis::Buffer::Allocate
void Allocate()
Size or resize the memory buffer.
Definition: Buffer.cpp:340
Isis::Buffer::DoubleBuffer
double * DoubleBuffer() const
Returns the value of the shape buffer.
Definition: Buffer.h:138
Isis::Buffer::Index
int Index(const int i_samp, const int i_line, const int i_band) const
Given a sample, line, and band position, this returns the appropriate index in the shape buffer.
Definition: Buffer.cpp:197
Isis::Buffer::operator=
Buffer & operator=(const Buffer &rvalue)
Copy operator.
Definition: Buffer.h:224
Isis::Buffer::CopyOverlapFrom
bool CopyOverlapFrom(const Buffer &in)
Allows copying of the buffer contents of a larger buffer to another same size or smaller Buffer,...
Definition: Buffer.cpp:285
Isis::Buffer::RawBuffer
void * RawBuffer() const
Returns a void pointer to the raw buffer.
Definition: Buffer.h:151
Isis::Buffer::SetBaseLine
void SetBaseLine(const int start_line)
This method is used to set the base line position of the shape buffer.
Definition: Buffer.h:183
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::Buffer::Buffer
Buffer()
Default constructor for proper initialization purposes.
Definition: Buffer.cpp:25
Isis::Buffer::Copy
void Copy(const Buffer &in, bool includeRawBuf=true)
Allows copying of the buffer contents to another Buffer.
Definition: Buffer.cpp:255
Isis::Buffer::SetBasePosition
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
Definition: Buffer.cpp:106
Isis::Buffer::operator=
Buffer & operator=(const double &d)
Assign the entire buffer to a constant double value.
Definition: Buffer.cpp:89
Isis::Buffer::LineDimension
int LineDimension() const
Returns the number of lines in the shape buffer.
Definition: Buffer.h:79
Isis::Buffer::at
double at(const int index) const
Returns the value in the shape buffer at the given index.
Definition: Buffer.cpp:231
Isis::Buffer::Position
void Position(const int index, int &i_samp, int &i_line, int &i_band) const
Returns the sample, line, and band position associated with a shape buffer index.
Definition: Buffer.cpp:177
Isis::Buffer::p_line
int p_line
Starting line to read/write.
Definition: Buffer.h:201
Isis::Buffer::Band
int Band(const int index=0) const
Returns the band position associated with a shape buffer index.
Definition: Buffer.cpp:162
Isis::PixelType
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:27
Isis::Buffer::p_pixelType
const Isis::PixelType p_pixelType
The pixel type of the raw buffer.
Definition: Buffer.h:211
Isis::Buffer::p_rawbuf
void * p_rawbuf
The raw dm read from the disk.
Definition: Buffer.h:212
Isis::Buffer::p_nsamps
int p_nsamps
Number of samples to read/write.
Definition: Buffer.h:199
Isis::Buffer::operator[]
const double & operator[](const int index) const
Returns the value in the shape buffer at given index.
Definition: Buffer.h:129
Isis::Buffer::p_band
int p_band
Starting band to read/write.
Definition: Buffer.h:204
Isis::Buffer::p_nlines
int p_nlines
Number of lines to read/write.
Definition: Buffer.h:202
Isis::Buffer::size
int size() const
Returns the total number of pixels in the shape buffer.
Definition: Buffer.h:97
Isis::Buffer::operator[]
double & operator[](const int index)
Returns the value in the shape buffer at given index.
Definition: Buffer.h:118
Isis::Buffer::~Buffer
~Buffer()
Destroys the Buffer object and frees shape buffer.
Definition: Buffer.cpp:68
Isis::Buffer::p_npixels
int p_npixels
Number of pixels (nsamps * nlines * nbands)
Definition: Buffer.h:207
Isis::Buffer::SetBaseSample
void SetBaseSample(const int start_samp)
This method is used to set the base sample position of the shape buffer.
Definition: Buffer.h:173
Isis::Buffer::Sample
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index.
Definition: Buffer.cpp:127
Isis::Buffer::PixelType
Isis::PixelType PixelType() const
Returns the raw buffer pixel type.
Definition: Buffer.h:160
Isis::Buffer::Line
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition: Buffer.cpp:145
Isis::Buffer::p_sample
int p_sample
Starting sample to read/write.
Definition: Buffer.h:198
Isis::Buffer::BandDimension
int BandDimension() const
Returns the number of bands in the shape buffer.
Definition: Buffer.h:88
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Buffer::p_buf
double * p_buf
Shape buffer allocated to the size of npixels for handling reads/writes.
Definition: Buffer.h:208
Isis::Buffer::p_nbands
int p_nbands
Number of bands to read/write.
Definition: Buffer.h:205