CVB++ 15.0
compressed_pfnc_buffer.hpp
1#pragma once
2
3#include "pfnc_buffer.hpp"
4
5namespace Cvb
6{
7
8 CVB_BEGIN_INLINE_NS
9
11
12 class CompressedPFNCBuffer : public PFNCBuffer
13 {
14 protected:
15 struct PrivateTag
16 {
17 };
18
19 public:
20 CompressedPFNCBuffer(HandleGuard<BufferBase> &&guard, PrivateTag)
21 : PFNCBuffer(std::move(guard), PFNCBuffer::PrivateTag{})
22 {
23 if (!CVB_CALL_CAPI(CVCIsCompressedPfncBuffer(Handle())))
24 throw std::runtime_error("handle must be a compressed pfnc buffer");
25 }
26
28 /*
29 * \param [in] guard Life time guard for C-API handle.
30 */
31 static CompressedPFNCBufferPtr FromHandle(HandleGuard<BufferBase> &&guard)
32 {
33 if (!guard.Handle())
34 throw std::runtime_error("handle must not be null");
35 return std::make_shared<CompressedPFNCBuffer>(std::move(guard), PrivateTag{});
36 }
37
38 template <class T>
39 static CompressedPFNCBufferPtr FromHandle(HandleGuard<BufferBase> &&guard)
40 {
41 static_assert(std::is_base_of<CompressedPFNCBuffer, T>::value, "CVB: Type must be derived from CompressedPFNCBuffer");
42 return FromHandle(std::move(guard));
43 }
44
45 CompressedBufferType GetCompressionType() const
46 {
47 CExports::cvbuint32_t type = static_cast <CExports::cvbuint32_t>(CompressedBufferType::Unknown);
48 CVB_CALL_CAPI_CHECKED(CVCBufferGetCompressedType(Handle(), type));
49 return static_cast<CompressedBufferType>(type);
50 }
51
52 };
53
54 CVB_END_INLINE_NS
55
56} // namespace Cvb
void * Handle() const noexcept
Classic API buffer handle.
Definition buffer_base.hpp:46
static CompressedPFNCBufferPtr FromHandle(HandleGuard< BufferBase > &&guard)
Creates a compressed pfnc buffer from a classic API handle.
Definition compressed_pfnc_buffer.hpp:31
T make_shared(T... args)
T move(T... args)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::shared_ptr< CompressedPFNCBuffer > CompressedPFNCBufferPtr
Convenience shared pointer for a compressed PFNCBuffer.
Definition global.hpp:74
CompressedBufferType
The possible image compression types a CVB buffer can transport within GenDC.
Definition global.hpp:132
@ Unknown
Definition global.hpp:136