CVB++ 15.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 &other) noexcept= default;
32 LinearAccessData & operator =(const LinearAccessData &other) noexcept= default;
33 LinearAccessData(LinearAccessData&& other) noexcept = default;
34 LinearAccessData& operator =(LinearAccessData&& other) noexcept = default;
35 ~LinearAccessData() = default;
36
38
48 std::uintptr_t BasePtr() const noexcept
49 {
50 return reinterpret_cast<std::uintptr_t>(basePtr_);
51 }
52
54
59 std::intptr_t SampleInc() const noexcept
60 {
61 return sampleInc_;
62 }
63
65
70 std::intptr_t LineInc() const noexcept
71 {
72 return lineInc_;
73 }
74
76
81 std::intptr_t BandInc() const noexcept
82 {
83 return bandInc_;
84 }
85
87
97 template <class Type>
98 const Type& Value(int sample, int line, int band) const noexcept
99 {
100 return *reinterpret_cast<Type *>(basePtr_ + sample * sampleInc_ + line * lineInc_ + band * bandInc_);
101 }
102
104
114 template <class Type>
115 Type& Value(int sample, int line, int band) noexcept
116 {
117 return *reinterpret_cast<Type*>(basePtr_ + sample * sampleInc_ + line * lineInc_ + band * bandInc_);
118 }
119
120 private:
121
122
123 LinearAccessData(uintptr_t basePtr, intptr_t sampleInc, intptr_t lineInc, intptr_t bandInc) noexcept
124 : basePtr_(reinterpret_cast<std::uint8_t *>(basePtr))
125 , sampleInc_(sampleInc)
126 , lineInc_(lineInc)
127 , bandInc_(bandInc)
128 {
129 }
130
131 std::uint8_t * basePtr_ = nullptr;
132 std::intptr_t sampleInc_ = 0;
133 std::intptr_t lineInc_ = 0;
134 std::intptr_t bandInc_ = 0;
135 };
136
137 CVB_END_INLINE_NS
138 }
139}
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:70
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:115
std::uintptr_t BasePtr() const noexcept
Linear access base pointer.
Definition: linear_access_data.hpp:48
const Type & Value(int sample, int line, int band) const noexcept
Gets a pixel value at a given position.
Definition: linear_access_data.hpp:98
std::intptr_t BandInc() const noexcept
Band-increment for linear access.
Definition: linear_access_data.hpp:81
std::intptr_t SampleInc() const noexcept
Sample-increment for linear access.
Definition: linear_access_data.hpp:59
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24