CVB++ 15.0
Loading...
Searching...
No Matches
detail_server_gev3.hpp
1#pragma once
2
3#ifndef NOMINMAX
4# define NOMINMAX
5#endif
6
7#include "../../_cexports/c_gev_server.h"
8#include "../_decl/decl_server_gev3.hpp"
9#include "../_decl/decl_stream_gev3.hpp"
10#include "../../driver/flow_set_pool.hpp"
11#include "../../driver/gendc_descriptor.hpp"
12#include <algorithm>
13
14namespace Cvb
15{
16 CVB_BEGIN_INLINE_NS
17 namespace GevServer
18 {
20 {
21 auto server = Internal::DoResCallShareOut<ServerGev3>([&](void *&handle) {
22 return CVB_CALL_CAPI(CVGSCreateGevServer3(static_cast<CExports::TDriver>(driverType), handle));
23 });
24 return server;
25 }
26
28 std::size_t alignment)
29 {
30 std::vector<FlowInfo> infos{std::max(descriptor.CalculateDataFlowCount(), std::size_t{1}), {0, alignment}};
31
32 infos[0].Size = descriptor.GetDescriptorSize();
33 for (const auto &component : descriptor.GetComponents())
34 {
35 for (const auto &part : component.GetParts())
36 {
37 visit([&infos](const GenDcPart &part) {
38 infos[part.GetFlowId()].Size += part.GetDataSize();
39 },
40 part);
41 }
42 }
43 return infos;
44 }
45
46 inline size_t ServerGev3::GetRegisteredFlowSetPoolSize() const noexcept
47 {
48 return registeredPoolSize_;
49 }
50
52 {
53 return registeredFlowSetInfo_;
54 }
55
57 std::function<void()> userCallback)
58 {
59 if (!pool)
60 throw std::invalid_argument("FlowSetPool must not be null");
61
62 if (!userCallback)
63 throw std::invalid_argument("User callback must not be null");
64
65 pool->SetUserCallback(userCallback);
66 CVB_CALL_CAPI_CHECKED(CVGSServerRegisterFlowSetPool(
67 Handle(), reinterpret_cast<CExports::CVDGNDCDESCRIPTORDATA *>(descriptor.Handle()),
68 reinterpret_cast<CExports::CVDFlowSet *>(pool->ToNativeStruct().data()), pool->PoolSize(),
69 pool->OnReleaseCallback, &*pool));
70 registeredPoolSize_ = pool->PoolSize();
71 registeredFlowSetInfo_ = pool->FlowSetInfo();
72 pool->SetReleaseThis(pool);
73 }
74
76 {
77 if (hasStream_)
78 return gsStream_.AtomicGet([&]() {
80 });
81 else
82 return nullptr;
83 }
84
85 } // namespace GevServer
86 CVB_END_INLINE_NS
87} // namespace Cvb
Class for a GenDC container descriptor.
Definition decl_gendc_descriptor.hpp:698
const std::vector< GenDcComponent > & GetComponents() const
Return the component descriptors of this GenDC container.
Definition detail_gendc_descriptor.hpp:620
size_t CalculateDataFlowCount() const
Return the number of data flows that are configured in the GenDC container.
Definition detail_gendc_descriptor.hpp:630
std::uint32_t GetDescriptorSize() const
Return the size of the GenDC container descriptor.
Definition detail_gendc_descriptor.hpp:615
void * Handle() const noexcept
Return the Handle to the internal resource.
Definition detail_gendc_descriptor.hpp:691
Class for a generic GenDC part descriptor.
Definition decl_gendc_descriptor.hpp:72
std::uint16_t GetFlowId() const
Return the Flow ID of this GenDC part.
Definition detail_gendc_descriptor.hpp:141
std::size_t GetDataSize() const
Return the Data size of this GenDC part.
Definition detail_gendc_descriptor.hpp:156
size_t GetRegisteredFlowSetPoolSize() const noexcept
Gets the size of the registered flow set pool.
Definition detail_server_gev3.hpp:46
std::vector< FlowInfo > GetRegisteredFlowSetInfo() const noexcept
Gets the registered flow set information about the count and size of the flows.
Definition detail_server_gev3.hpp:51
void RegisterFlowSetPool(const GenDcDescriptor &descriptor, FlowSetPoolPtr flowSetPool, std::function< void()> onFlowSetRelease)
Registers a flow set pool with the server. Uses a callback that will be called when the flow set pool...
Definition detail_server_gev3.hpp:56
StreamGev3Ptr Stream() const
Gets the Cvb::GevServer::StreamGev3 for sending GenDC data.
Definition detail_server_gev3.hpp:75
void * Handle() const noexcept override
Returns the internal handle of this server object.
Definition decl_server_gev3.hpp:70
static std::vector< FlowInfo > CreateFlowInfoForDescriptor(const Driver::GenDcDescriptor &descriptor, std::size_t alignment=1)
Creates the required flow infos required for a ServerGev3 for a given GenDC descriptor.
Definition detail_server_gev3.hpp:27
static ServerGev3Ptr Create(GevServer::DriverType driverType)
Creates a new ServerGev3 object with a client configurable payload in the format of GenDC.
Definition detail_server_gev3.hpp:19
T make_shared(T... args)
T max(T... args)
std::shared_ptr< FlowSetPool > FlowSetPoolPtr
Convenience shared pointer for FlowSetPool.
Definition driver.hpp:33
Namespace for GevServer based device configuration.
Definition decl_int_swiss_knife_node.hpp:11
DriverType
GigE Vision driver to use for communication and streaming.
Definition gevserver.hpp:167
std::shared_ptr< StreamGev3 > StreamGev3Ptr
Convenience shared pointer for StreamGev3.
Definition gevserver.hpp:68
std::shared_ptr< ServerGev3 > ServerGev3Ptr
Convenience shared pointer for a version 3 GevServer.
Definition gevserver.hpp:48
Root namespace for the Image Manager interface.
Definition version.hpp:11
T const_pointer_cast(T... args)