CVB++ 14.0
linear_access_data.hpp
1#pragma once
2
3#include "../global.hpp"
4
5namespace Cvb
6{
7 CVB_BEGIN_INLINE_NS
8
9 namespace Spectral
10 {
11 class Cube;
12
13
15
20 class LinearAccessData final
21 {
22 friend class Cube;
23
24 public:
25
27
30 LinearAccessData() noexcept = default;
31 LinearAccessData(const LinearAccessData &) = default;
32 LinearAccessData & operator =(const LinearAccessData &) = default;
33
35
45 std::uintptr_t BasePtr() const noexcept
46 {
47 return reinterpret_cast<std::uintptr_t>(basePtr_);
48 }
49
51
56 std::intptr_t SampleInc() const noexcept
57 {
58 return sampleInc_;
59 }
60
62
67 std::intptr_t LineInc() const noexcept
68 {
69 return lineInc_;
70 }
71
73
78 std::intptr_t BandInc() const noexcept
79 {
80 return bandInc_;
81 }
82
84
94 template <class Type>
95 const Type& Value(int sample, int line, int band) const noexcept
96 {
97 return *reinterpret_cast<Type *>(basePtr_ + sample * sampleInc_ + line * lineInc_ + band * bandInc_);
98 }
99
101
111 template <class Type>
112 Type& Value(int sample, int line, int band) noexcept
113 {
114 return *reinterpret_cast<Type*>(basePtr_ + sample * sampleInc_ + line * lineInc_ + band * bandInc_);
115 }
116
117 private:
118
119
120 LinearAccessData(uintptr_t basePtr, intptr_t sampleInc, intptr_t lineInc, intptr_t bandInc) noexcept
121 : basePtr_(reinterpret_cast<std::uint8_t *>(basePtr))
122 , sampleInc_(sampleInc)
123 , lineInc_(lineInc)
124 , bandInc_(bandInc)
125 {
126 }
127
128 std::uint8_t * basePtr_ = nullptr;
129 std::intptr_t sampleInc_ = 0;
130 std::intptr_t lineInc_ = 0;
131 std::intptr_t bandInc_ = 0;
132 };
133
134 CVB_END_INLINE_NS
135 }
136}
Spectral Cube object.
Definition: cube.hpp:51
Linear access properties.
Definition: linear_access_data.hpp:21
std::intptr_t LineInc() const noexcept
Line-increment for linear access.
Definition: linear_access_data.hpp:67
LinearAccessData() noexcept=default
Create a default linear access data set.
Type & Value(int sample, int line, int band) noexcept
Gets a settable pixel value at a given position.
Definition: linear_access_data.hpp:112
std::uintptr_t BasePtr() const noexcept
Linear access base pointer.
Definition: linear_access_data.hpp:45
const Type & Value(int sample, int line, int band) const noexcept
Gets a pixel value at a given position.
Definition: linear_access_data.hpp:95
std::intptr_t BandInc() const noexcept
Band-increment for linear access.
Definition: linear_access_data.hpp:78
std::intptr_t SampleInc() const noexcept
Sample-increment for linear access.
Definition: linear_access_data.hpp:56
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24