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
9namespace Cvb
10{
11 CVB_BEGIN_INLINE_NS
12
13 template <>
14 inline HandleGuard<Spectral::WrappedCube>::HandleGuard(void *handle) noexcept
15 : HandleGuard<Spectral::WrappedCube>(handle, [](void *handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
16 {
17 }
18
19 namespace Spectral
20 {
27 class WrappedCube : public Cube
28 {
29 public:
30 WrappedCube(const WrappedCube &other) = delete;
31 WrappedCube &operator=(const WrappedCube &other) = delete;
32 WrappedCube(WrappedCube &&other) = delete;
33 WrappedCube &operator=(WrappedCube &&other) = delete;
34 ~WrappedCube() = default;
35
37
50 static std::unique_ptr<WrappedCube> Create(void *pBase, int numSamples, int numLines, int numBands,
51 Cvb::DataType datatype, intptr_t sampleInc, intptr_t lineInc,
52 intptr_t bandInc)
53 {
54 std::vector<CExports::cvbdim_t> dimensions = {numSamples, numLines, numBands};
55 std::vector<intptr_t> increments = {sampleInc, lineInc, bandInc};
56 return Internal::DoResCallObjectOut<WrappedCube>([&](void *&cubeOut) {
57 return CVB_CALL_CAPI(CVSCreateCubeFromPointer(
58 pBase, dimensions.data(), datatype.NativeDescriptor(), increments.data(), [](void *, void *) {}, nullptr,
59 cubeOut));
60 });
61 }
62
64
72 static std::unique_ptr<WrappedCube> FromHandle(HandleGuard<WrappedCube> &&guard)
73 {
74 return std::unique_ptr<WrappedCube>(new WrappedCube(std::move(HandleGuard<Cube>(guard.Release()))));
75 }
76
77 protected:
78 explicit WrappedCube(HandleGuard<Cube> &&guard) noexcept
79 : Cube(std::move(guard))
80 {
81 }
82 };
83
84 } // namespace Spectral
85
87
88 CVB_END_INLINE_NS
89} // namespace Cvb
Data type description for an image plane.
Definition data_type.hpp:23
int NativeDescriptor() const noexcept
Native data type descriptor.
Definition data_type.hpp:312
Spectral Cube object.
Definition cube.hpp:59
Spectral Wrapped cube objects are linear non-owning cubes.
Definition wrapped_cube.hpp:28
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:50
static std::unique_ptr< WrappedCube > FromHandle(HandleGuard< WrappedCube > &&guard)
Creates wrapped cube from a classic API handle.
Definition wrapped_cube.hpp:72
cvbbool_t ReleaseObject(OBJ &Object)
T move(T... args)
Namespace for the Spectral package.
Definition arithmetic.hpp:14
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17