CVB++ 15.0
detail_genicam_device.hpp
1#pragma once
2
3#include "../_decl/decl_genicam_device.hpp"
4
5#include "../image_stream.hpp"
6#include "../composite_stream.hpp"
7#include "../point_cloud_stream.hpp"
8
9namespace Cvb
10{
11
12 CVB_BEGIN_INLINE_NS
13
14 namespace Driver
15 {
16
17 template <class T>
19 {
22 "unsupported composite stream type");
23 auto streamBase = CreateOrGetStreamHelper<T>(index);
24 auto stream = std::dynamic_pointer_cast<T>(streamBase);
25 if (!stream)
26 throw std::logic_error("impossible to get the same stream with different types");
27 return stream;
28 }
29
30 inline StreamBasePtr GenICamDevice::CreateStream(int index, StreamType streamType) const
31 {
32 auto getStreamHandle = [this, index](CExports::CVDSTREAM &handle) {
33 return CExports::CVDDeviceGetStreamAt(Handle(), index, handle);
34 };
35
36 switch (streamType)
37 {
38 default:
39 case StreamType::Legacy:
40 throw std::logic_error("legacy stream cannot be created from handle");
41
42 case StreamType::Image:
43 return Internal::DoResCallShareOut<ImageStream>(getStreamHandle,
44 std::const_pointer_cast<Device>(shared_from_this()));
45
46 case StreamType::Composite:
47 return Internal::DoResCallShareOut<CompositeStream>(getStreamHandle,
48 std::const_pointer_cast<Device>(shared_from_this()));
49
50 case StreamType::PointCloud:
51 return Internal::DoResCallShareOut<PointCloudStream>(getStreamHandle,
52 std::const_pointer_cast<Device>(shared_from_this()));
53 }
54 }
55
56 } // namespace Driver
57
59
60 CVB_END_INLINE_NS
61
62} // namespace Cvb
void * Handle() const noexcept
Classic API device handle.
Definition decl_device.hpp:122
A device representing a GenICam compliant device.
Definition decl_genicam_device.hpp:19
std::shared_ptr< T > Stream() const
Get the first stream for this device.
Definition decl_genicam_device.hpp:47
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
std::shared_ptr< StreamBase > StreamBasePtr
Convenience shared pointer for StreamBase.
Definition driver.hpp:113
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
T dynamic_pointer_cast(T... args)