1 #ifndef __NDS_COMPOSER_HH__
2 #define __NDS_COMPOSER_HH__
5 #include "nds_export.hh"
6 #include "nds_channel_selection.hh"
17 composer(
const composer& other ) =
delete;
18 composer( composer&& other ) =
delete;
19 composer& operator=(
const composer& other ) =
delete;
20 composer& operator=( composer other ) =
delete;
23 composer( request_fragment::working_buffers& buffers,
24 const NDS::connection::channel_names_type& channel_names,
25 const NDS::detail::buffer_initializer& initializer,
26 const gap_handler& _gap_handler,
27 bool buffers_have_been_initialized );
29 DLL_EXPORT
void add_segment(
const buffers_type& cur_bufs );
39 template <
typename T >
48 if ( !initialized && !empty_is_safe )
50 NDS::channels_type chans;
51 chans.reserve( buffers.size( ) );
53 _channel_names.begin( ),
54 _channel_names.end( ),
55 std::back_inserter( chans ),
56 [&selector](
const std::string& name ) -> NDS::channel {
59 channel_selector::selection_method::
62 initialize_buffers( chans );
65 throw connection::daq_error(
67 "Internal client error, unable to "
68 "determine the channel meta data for a "
72 do_finish_gap_handling( );
76 template <
typename T >
78 initialize_buffers(
const T& ref_set )
84 if ( ref_set.size( ) != buffers.size( ) )
89 for (
typename T::const_iterator cur_buf = ref_set.begin( );
90 cur_buf != ref_set.end( );
93 initializer.reset_buffer( buffers[ j ], *cur_buf );
95 <<
"Initializing buffer for " << buffers[ j ]->Name( )
96 <<
" with " << buffers[ j ]->Samples( ) <<
" entries"
102 void fill_gap( buffer& cur_buffer,
103 buffer::size_type start_sample,
104 buffer::size_type end_sample );
106 void bounds_check(
const buffer& cur_buffer,
107 buffer::size_type cur_fill,
108 buffer::size_type offset_start,
109 buffer::size_type offset_end );
111 void do_finish_gap_handling( );
113 request_fragment::working_buffers& buffers;
114 const NDS::connection::channel_names_type _channel_names;
115 const NDS::detail::buffer_initializer initializer;
116 const gap_handler& _gap_handler;
117 std::vector< buffer::size_type > cur_progress;
118 std::vector< std::unique_ptr< delayed_gap_handler > >
124 static fixed_point_gap_handler zero_gap_handler;
128 composer::fill_gap( buffer& cur_buffer,
129 buffer::size_type start_sample,
130 buffer::size_type end_sample )
132 static const std::string tname(
".n,s-trend" );
133 static const std::string cmp(
".n," );
141 const std::string& name = cur_buffer.Name( );
142 if ( name.size( ) > tname.size( ) &&
144 name.size( ) - tname.size( ), cmp.size( ), cmp ) == 0 )
146 zero_gap_handler.fill_gap(
147 cur_buffer, start_sample, end_sample );
151 std::unique_ptr< delayed_gap_handler > tmp(
152 _gap_handler.fill_gap(
153 cur_buffer, start_sample, end_sample ) );
156 delayed_handlers.push_back( std::move( tmp ) );
164 #endif // __NDS_COMPOSER_H__