CVB++ 15.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
34 WrappedCube(const WrappedCube& other) = delete;
35 WrappedCube& operator=(const WrappedCube& other) = delete;
36 WrappedCube(WrappedCube&& other) = delete;
37 WrappedCube& operator=(WrappedCube&& other) = delete;
38 ~WrappedCube() = default;
39
41
55 int numSamples, int numLines, int numBands, Cvb::DataType datatype,
56 intptr_t sampleInc, intptr_t lineInc, intptr_t bandInc)
57 {
58 std::vector<CExports::cvbdim_t> dimensions = { numSamples, numLines, numBands };
59 std::vector<intptr_t> increments = { sampleInc, lineInc, bandInc };
60 return Internal::DoResCallObjectOut<WrappedCube>([&](void* & cubeOut)
61 {
62 return CVB_CALL_CAPI(CVSCreateCubeFromPointer(pBase,
63 dimensions.data(), datatype.NativeDescriptor(),
64 increments.data(),
65 [](void *, void *) {}, nullptr,
66 cubeOut));
67 });
68 }
69
71
79 static std::unique_ptr<WrappedCube> FromHandle(HandleGuard<WrappedCube>&& guard)
80 {
81 return std::unique_ptr<WrappedCube>(new WrappedCube(std::move(HandleGuard<Cube>(guard.Release()))));
82 }
83
84
85 protected:
86 explicit WrappedCube(HandleGuard<Cube>&& guard) noexcept
87 : Cube(std::move(guard))
88 {
89 }
90
91
92 };
93
94
95
96 }
97
98 using Spectral::WrappedCube;
99
100 CVB_END_INLINE_NS
101}
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:54
static std::unique_ptr< WrappedCube > FromHandle(HandleGuard< WrappedCube > &&guard)
Creates wrapped cube from a classic API handle.
Definition: wrapped_cube.hpp:79
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24