CVB++ 15.0
detail_composite.hpp
1#pragma once
2
3#include "../_decl/decl_composite.hpp"
4
5#include "detail_point_cloud.hpp"
6#include "detail_plane_enumerator.hpp"
7
8namespace Cvb
9{
10
11 CVB_BEGIN_INLINE_NS
12
13 template <class T>
14 inline CompositePtr Composite::FromObject(std::shared_ptr<T> object)
15 {
16 static_assert(std::is_base_of<PointCloud, T>::value || std::is_base_of<MultiPartImage, T>::value,
17 "CVB: T must be a capable class");
18 CVB_CALL_CAPI(ShareObject(object->Handle()));
19 return FromHandle(HandleGuard<Composite>(object->Handle()));
20 }
21
22 inline CompositeVariant Composite::MakeWrapperFrom(int index) const
23 {
24 CExports::OBJ obj = nullptr;
25 CVB_CALL_CAPI_CHECKED(CVCCompositeGetAt(Handle(), index, obj));
26
27 // Beware! Order is important here!
28 if (CVB_CALL_CAPI(IsImage(obj)))
29 {
30 return Image::FromHandle<Image>(HandleGuard<Image>(obj));
31 }
32 else if (CVB_CALL_CAPI(CVCIsPlane(obj)))
33 {
34 return Plane::FromHandle(HandleGuard<Plane>(obj));
35 }
36 else if (CVB_CALL_CAPI(CVCIsPlaneEnum(obj)))
37 {
38 return PlaneEnumerator::FromHandle(HandleGuard<PlaneEnumerator>(obj));
39 }
40 else if (CVB_CALL_CAPI(CVCIsCompressedPfncBuffer(obj)))
41 {
42 return CompressedPFNCBuffer::FromHandle(HandleGuard<BufferBase>(obj));
43 }
44 else if (CVB_CALL_CAPI(CVCIsPfncBuffer(obj)))
45 {
46 return PFNCBuffer::FromHandle(HandleGuard<BufferBase>(obj));
47 }
48 else if (CVB_CALL_CAPI(CVCIsBuffer(obj)))
49 {
50 return Buffer::FromHandle(HandleGuard<BufferBase>(obj));
51 }
52 else
53 {
54 return HandleOnly::FromHandle(HandleGuard<HandleOnly>{obj});
55 }
56 }
57
58 CVB_END_INLINE_NS
59
60} // namespace Cvb
static BufferPtr FromHandle(HandleGuard< BufferBase > &&guard)
Creates a buffer from a classic API handle.
Definition buffer.hpp:28
static CompositePtr FromObject(std::shared_ptr< T > object)
Returns a composite object from the given composite compatible object.
static std::unique_ptr< Composite > FromHandle(HandleGuard< Composite > &&guard)
Creates a composite from a classic API handle.
Definition decl_composite.hpp:109
void * Handle() const noexcept
Classic API node handle.
Definition decl_composite.hpp:96
static CompressedPFNCBufferPtr FromHandle(HandleGuard< BufferBase > &&guard)
Creates a compressed pfnc buffer from a classic API handle.
Definition compressed_pfnc_buffer.hpp:31
static std::shared_ptr< HandleOnly > FromHandle(HandleGuard< HandleOnly > &&guard)
Creates a handle only from a classic API handle.
Definition handle_only.hpp:44
static std::unique_ptr< Image > FromHandle(HandleGuard< Image > &&guard)
Creates an image from a classic API handle.
Definition decl_image.hpp:160
static PFNCBufferPtr FromHandle(HandleGuard< BufferBase > &&guard)
Creates a pfnc buffer from a classic API handle.
Definition pfnc_buffer.hpp:33
static PlaneEnumeratorPtr FromHandle(HandleGuard< PlaneEnumerator > &&guard)
Creates a plane enumerator from a classic API handle.
Definition decl_plane_enumerator.hpp:71
static PlanePtr FromHandle(HandleGuard< Plane > &&guard)
Creates a plane from a classic API handle.
Definition decl_plane.hpp:76
cvbbool_t ShareObject(OBJ Object)
cvbbool_t IsImage(IMG Image)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
Cvb::variant< ImagePtr, PlanePtr, PlaneEnumeratorPtr, BufferPtr, PFNCBufferPtr, CompressedPFNCBufferPtr, HandleOnlyPtr > CompositeVariant
Variant that can contain the different types of composite items.
Definition decl_composite.hpp:39
std::shared_ptr< Composite > CompositePtr
Convenience shared pointer for Composite.
Definition global.hpp:102