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
14
19 class LinearAccessData final
20 {
21 friend class Cube;
22
23 public:
25
28 LinearAccessData() noexcept = default;
29 LinearAccessData(const LinearAccessData &other) noexcept = default;
30 LinearAccessData &operator=(const LinearAccessData &other) noexcept = default;
31 LinearAccessData(LinearAccessData &&other) noexcept = default;
32 LinearAccessData &operator=(LinearAccessData &&other) noexcept = default;
33 ~LinearAccessData() = default;
34
36
46 std::uintptr_t BasePtr() const noexcept
47 {
48 return reinterpret_cast<std::uintptr_t>(basePtr_);
49 }
50
52
57 std::intptr_t SampleInc() const noexcept
58 {
59 return sampleInc_;
60 }
61
63
68 std::intptr_t LineInc() const noexcept
69 {
70 return lineInc_;
71 }
72
74
79 std::intptr_t BandInc() const noexcept
80 {
81 return bandInc_;
82 }
83
85
95 template <class Type>
96 const Type &Value(int sample, int line, int band) const noexcept
97 {
98 return *reinterpret_cast<Type *>(basePtr_ + sample * sampleInc_ + line * lineInc_ + band * bandInc_);
99 }
100
102
112 template <class Type>
113 Type &Value(int sample, int line, int band) noexcept
114 {
115 return *reinterpret_cast<Type *>(basePtr_ + sample * sampleInc_ + line * lineInc_ + band * bandInc_);
116 }
117
118 private:
119 LinearAccessData(uintptr_t basePtr, intptr_t sampleInc, intptr_t lineInc, intptr_t bandInc) noexcept
120 : basePtr_(reinterpret_cast<std::uint8_t *>(basePtr))
121 , sampleInc_(sampleInc)
122 , lineInc_(lineInc)
123 , bandInc_(bandInc)
124 {
125 }
126
127 std::uint8_t *basePtr_ = nullptr;
128 std::intptr_t sampleInc_ = 0;
129 std::intptr_t lineInc_ = 0;
130 std::intptr_t bandInc_ = 0;
131 };
132
133 CVB_END_INLINE_NS
134 } // namespace Spectral
135} // namespace Cvb
Spectral Cube object.
Definition cube.hpp:59
std::intptr_t LineInc() const noexcept
Line-increment for linear access.
Definition linear_access_data.hpp:68
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:113
std::uintptr_t BasePtr() const noexcept
Linear access base pointer.
Definition linear_access_data.hpp:46
const Type & Value(int sample, int line, int band) const noexcept
Gets a pixel value at a given position.
Definition linear_access_data.hpp:96
std::intptr_t BandInc() const noexcept
Band-increment for linear access.
Definition linear_access_data.hpp:79
std::intptr_t SampleInc() const noexcept
Sample-increment for linear access.
Definition linear_access_data.hpp:57
Namespace for the Spectral package.
Definition arithmetic.hpp:14
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17