CVB++ 14.0
wrapped_cube.hpp
1#pragma once
2
3#include <memory>
4
5#include "../global.hpp"
6#include "../_cexports/c_img.h"
7#include "cube.hpp"
8
9
10
11namespace Cvb
12{
13 CVB_BEGIN_INLINE_NS
14
15 template <>
16 inline HandleGuard<Spectral::WrappedCube>::HandleGuard(void * handle) noexcept
17 : HandleGuard<Spectral::WrappedCube>(handle, [](void* handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
18 {
19 }
20
21 namespace Spectral
22 {
30 : public Cube
31 {
32 public:
33
35
49 int numSamples, int numLines, int numBands, Cvb::DataType datatype,
50 intptr_t sampleInc, intptr_t lineInc, intptr_t bandInc)
51 {
52 std::vector<CExports::cvbdim_t> dimensions = { numSamples, numLines, numBands };
53 std::vector<intptr_t> increments = { sampleInc, lineInc, bandInc };
54 return Internal::DoResCallObjectOut<WrappedCube>([&](void* & cubeOut)
55 {
56 return CVB_CALL_CAPI(CVSCreateCubeFromPointer(pBase,
57 dimensions.data(), datatype.NativeDescriptor(),
58 increments.data(),
59 [](void *, void *) {}, nullptr,
60 cubeOut));
61 });
62 }
63
64
66
69 void* Handle() const noexcept
70 {
71 return this->Handle();
72 }
73
74
76
84 static std::unique_ptr<WrappedCube> FromHandle(HandleGuard<WrappedCube>&& guard)
85 {
86 return std::unique_ptr<WrappedCube>(new WrappedCube(std::move(HandleGuard<Cube>(guard.Release()))));
87 }
88
89
90 protected:
91 WrappedCube(HandleGuard<Cube>&& guard) noexcept
92 : Cube(std::move(guard))
93 {
94 }
95
96 WrappedCube(WrappedCube && other) noexcept
97 : Cube(HandleGuard<Cube>(std::move(other.Handle())))
98 {
99 }
100
101 WrappedCube & operator=(WrappedCube && other) = default;
102 };
103
104
105
106 }
107
108 using Spectral::WrappedCube;
109
110 CVB_END_INLINE_NS
111}
Data type description for an image plane.
Definition: data_type.hpp:28
int NativeDescriptor() const noexcept
Native data type descriptor.
Definition: data_type.hpp:322
Spectral Cube object.
Definition: cube.hpp:51
Spectral Wrapped cube objects are linear non-owning cubes.
Definition: wrapped_cube.hpp:31
static std::unique_ptr< WrappedCube > Create(void *pBase, int numSamples, int numLines, int numBands, Cvb::DataType datatype, intptr_t sampleInc, intptr_t lineInc, intptr_t bandInc)
Creates a wrapped cube object of type linear non-owning.
Definition: wrapped_cube.hpp:48
static std::unique_ptr< WrappedCube > FromHandle(HandleGuard< WrappedCube > &&guard)
Creates wrapped cube from a classic API handle.
Definition: wrapped_cube.hpp:84
void * Handle() const noexcept
Returns C-API style handle to the Cube.
Definition: wrapped_cube.hpp:69
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24