summaryrefslogtreecommitdiff
path: root/gr-blocks/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r--gr-blocks/lib/CMakeLists.txt87
-rw-r--r--gr-blocks/lib/ConfigChecks.cmake13
-rw-r--r--gr-blocks/lib/abs_blk_impl.cc (renamed from gr-blocks/lib/abs_XX_impl.cc.t)33
-rw-r--r--gr-blocks/lib/abs_blk_impl.h (renamed from gr-blocks/lib/abs_XX_impl.h.t)16
-rw-r--r--gr-blocks/lib/add_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/add_blk_impl.cc106
-rw-r--r--gr-blocks/lib/add_blk_impl.h (renamed from gr-blocks/lib/add_XX_impl.h.t)16
-rw-r--r--gr-blocks/lib/add_const_v_impl.cc (renamed from gr-blocks/lib/add_const_vXX_impl.cc.t)34
-rw-r--r--gr-blocks/lib/add_const_v_impl.h (renamed from gr-blocks/lib/add_const_vXX_impl.h.t)23
-rw-r--r--gr-blocks/lib/add_ff_impl.cc65
-rw-r--r--gr-blocks/lib/and_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/and_blk_impl.cc (renamed from gr-blocks/lib/multiply_XX_impl.cc.t)33
-rw-r--r--gr-blocks/lib/and_blk_impl.h (renamed from gr-blocks/lib/and_XX_impl.h.t)16
-rw-r--r--gr-blocks/lib/and_const_XX_impl.h.t51
-rw-r--r--gr-blocks/lib/and_const_impl.cc (renamed from gr-blocks/lib/and_const_XX_impl.cc.t)29
-rw-r--r--gr-blocks/lib/and_const_impl.h51
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.cc2
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.h1
-rw-r--r--gr-blocks/lib/argmax_impl.cc (renamed from gr-blocks/lib/argmax_XX_impl.cc.t)45
-rw-r--r--gr-blocks/lib/argmax_impl.h (renamed from gr-blocks/lib/argmax_XX_impl.h.t)19
-rw-r--r--gr-blocks/lib/control_loop.cc4
-rw-r--r--gr-blocks/lib/divide_cc_impl.cc66
-rw-r--r--gr-blocks/lib/divide_ff_impl.cc66
-rw-r--r--gr-blocks/lib/divide_impl.cc130
-rw-r--r--gr-blocks/lib/divide_impl.h (renamed from gr-blocks/lib/divide_cc_impl.h)15
-rw-r--r--gr-blocks/lib/file_meta_sink_impl.cc60
-rw-r--r--gr-blocks/lib/file_meta_sink_impl.h14
-rw-r--r--gr-blocks/lib/file_source_impl.cc200
-rw-r--r--gr-blocks/lib/file_source_impl.h14
-rw-r--r--gr-blocks/lib/integrate_impl.cc (renamed from gr-blocks/lib/integrate_XX_impl.cc.t)32
-rw-r--r--gr-blocks/lib/integrate_impl.h (renamed from gr-blocks/lib/integrate_XX_impl.h.t)16
-rw-r--r--gr-blocks/lib/interleaved_char_to_complex_impl.cc3
-rw-r--r--gr-blocks/lib/interleaved_char_to_complex_impl.h1
-rw-r--r--gr-blocks/lib/interleaved_short_to_complex_impl.cc2
-rw-r--r--gr-blocks/lib/interleaved_short_to_complex_impl.h1
-rw-r--r--gr-blocks/lib/max_blk_impl.cc (renamed from gr-blocks/lib/max_XX_impl.cc.t)48
-rw-r--r--gr-blocks/lib/max_blk_impl.h (renamed from gr-blocks/lib/min_XX_impl.h.t)18
-rw-r--r--gr-blocks/lib/message_burst_source_impl.cc149
-rw-r--r--gr-blocks/lib/message_burst_source_impl.h58
-rw-r--r--gr-blocks/lib/message_sink_impl.cc132
-rw-r--r--gr-blocks/lib/message_sink_impl.h56
-rw-r--r--gr-blocks/lib/message_source_impl.cc151
-rw-r--r--gr-blocks/lib/message_source_impl.h62
-rw-r--r--gr-blocks/lib/message_strobe_impl.cc4
-rw-r--r--gr-blocks/lib/message_strobe_impl.h8
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.cc10
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.h2
-rw-r--r--gr-blocks/lib/min_blk_impl.cc (renamed from gr-blocks/lib/min_XX_impl.cc.t)53
-rw-r--r--gr-blocks/lib/min_blk_impl.h (renamed from gr-blocks/lib/max_XX_impl.h.t)18
-rw-r--r--gr-blocks/lib/moving_average_impl.cc (renamed from gr-blocks/lib/moving_average_XX_impl.cc.t)52
-rw-r--r--gr-blocks/lib/moving_average_impl.h (renamed from gr-blocks/lib/moving_average_XX_impl.h.t)30
-rw-r--r--gr-blocks/lib/multiply_XX_impl.h.t47
-rw-r--r--gr-blocks/lib/multiply_cc_impl.cc66
-rw-r--r--gr-blocks/lib/multiply_cc_impl.h47
-rw-r--r--gr-blocks/lib/multiply_const_XX_impl.cc.t78
-rw-r--r--gr-blocks/lib/multiply_const_cc_impl.cc91
-rw-r--r--gr-blocks/lib/multiply_const_cc_impl.h52
-rw-r--r--gr-blocks/lib/multiply_const_ff_impl.cc89
-rw-r--r--gr-blocks/lib/multiply_const_ff_impl.h54
-rw-r--r--gr-blocks/lib/multiply_const_impl.cc139
-rw-r--r--gr-blocks/lib/multiply_const_impl.h (renamed from gr-blocks/lib/multiply_const_XX_impl.h.t)22
-rw-r--r--gr-blocks/lib/multiply_const_vXX_impl.cc.t66
-rw-r--r--gr-blocks/lib/multiply_const_vXX_impl.h.t51
-rw-r--r--gr-blocks/lib/multiply_const_v_impl.cc138
-rw-r--r--gr-blocks/lib/multiply_const_v_impl.h50
-rw-r--r--gr-blocks/lib/multiply_const_vcc_impl.cc100
-rw-r--r--gr-blocks/lib/multiply_const_vcc_impl.h52
-rw-r--r--gr-blocks/lib/multiply_const_vff_impl.cc96
-rw-r--r--gr-blocks/lib/multiply_const_vff_impl.h52
-rw-r--r--gr-blocks/lib/multiply_ff_impl.cc66
-rw-r--r--gr-blocks/lib/multiply_ff_impl.h47
-rw-r--r--gr-blocks/lib/multiply_impl.cc132
-rw-r--r--gr-blocks/lib/multiply_impl.h (renamed from gr-blocks/lib/add_ff_impl.h)18
-rw-r--r--gr-blocks/lib/multiply_matrix_cc_impl.cc182
-rw-r--r--gr-blocks/lib/multiply_matrix_cc_impl.h56
-rw-r--r--gr-blocks/lib/multiply_matrix_ff_impl.cc182
-rw-r--r--gr-blocks/lib/multiply_matrix_impl.cc327
-rw-r--r--gr-blocks/lib/multiply_matrix_impl.h (renamed from gr-blocks/lib/multiply_matrix_ff_impl.h)24
-rw-r--r--gr-blocks/lib/mute_impl.cc (renamed from gr-blocks/lib/mute_XX_impl.cc.t)43
-rw-r--r--gr-blocks/lib/mute_impl.h (renamed from gr-blocks/lib/mute_XX_impl.h.t)18
-rw-r--r--gr-blocks/lib/nlog10_ff_impl.cc30
-rw-r--r--gr-blocks/lib/nlog10_ff_impl.h4
-rw-r--r--gr-blocks/lib/not_blk_impl.cc (renamed from gr-blocks/lib/not_XX_impl.cc.t)29
-rw-r--r--gr-blocks/lib/not_blk_impl.h (renamed from gr-blocks/lib/divide_XX_impl.h.t)16
-rw-r--r--gr-blocks/lib/or_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/or_blk_impl.cc67
-rw-r--r--gr-blocks/lib/or_blk_impl.h (renamed from gr-blocks/lib/or_XX_impl.h.t)17
-rw-r--r--gr-blocks/lib/packed_to_unpacked_impl.cc (renamed from gr-blocks/lib/packed_to_unpacked_XX_impl.cc.t)71
-rw-r--r--gr-blocks/lib/packed_to_unpacked_impl.h (renamed from gr-blocks/lib/unpacked_to_packed_XX_impl.h.t)23
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.cc6
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.h1
-rw-r--r--gr-blocks/lib/peak_detector2_fb_impl.h1
-rw-r--r--gr-blocks/lib/peak_detector_impl.cc (renamed from gr-blocks/lib/peak_detector_XX_impl.cc.t)37
-rw-r--r--gr-blocks/lib/peak_detector_impl.h (renamed from gr-blocks/lib/peak_detector_XX_impl.h.t)20
-rw-r--r--gr-blocks/lib/probe_rate_impl.cc3
-rw-r--r--gr-blocks/lib/probe_rate_impl.h1
-rw-r--r--gr-blocks/lib/probe_signal_impl.cc (renamed from gr-blocks/lib/probe_signal_X_impl.cc.t)32
-rw-r--r--gr-blocks/lib/probe_signal_impl.h52
-rw-r--r--gr-blocks/lib/probe_signal_v_impl.cc (renamed from gr-blocks/lib/probe_signal_vX_impl.cc.t)33
-rw-r--r--gr-blocks/lib/probe_signal_v_impl.h (renamed from gr-blocks/lib/probe_signal_vX_impl.h.t)23
-rw-r--r--gr-blocks/lib/qa_rotator.cc29
-rw-r--r--gr-blocks/lib/sample_and_hold_XX_impl.h.t50
-rw-r--r--gr-blocks/lib/sample_and_hold_impl.cc (renamed from gr-blocks/lib/sample_and_hold_XX_impl.cc.t)35
-rw-r--r--gr-blocks/lib/sample_and_hold_impl.h (renamed from gr-blocks/lib/probe_signal_X_impl.h.t)22
-rw-r--r--gr-blocks/lib/socket_pdu_impl.h1
-rw-r--r--gr-blocks/lib/stream_pdu_base.h1
-rw-r--r--gr-blocks/lib/sub_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/sub_XX_impl.h.t48
-rw-r--r--gr-blocks/lib/sub_ff_impl.h47
-rw-r--r--gr-blocks/lib/sub_impl.cc (renamed from gr-blocks/lib/sub_ff_impl.cc)60
-rw-r--r--gr-blocks/lib/sub_impl.h (renamed from gr-blocks/lib/not_XX_impl.h.t)16
-rw-r--r--gr-blocks/lib/tcp_server_sink_impl.h2
-rw-r--r--gr-blocks/lib/tsb_vector_sink_impl.cc (renamed from gr-blocks/lib/tsb_vector_sink_X_impl.cc.t)44
-rw-r--r--gr-blocks/lib/tsb_vector_sink_impl.h (renamed from gr-blocks/lib/tsb_vector_sink_X_impl.h.t)22
-rw-r--r--gr-blocks/lib/udp_source_impl.cc2
-rw-r--r--gr-blocks/lib/udp_source_impl.h1
-rw-r--r--gr-blocks/lib/unpacked_to_packed_impl.cc (renamed from gr-blocks/lib/unpacked_to_packed_XX_impl.cc.t)61
-rw-r--r--gr-blocks/lib/unpacked_to_packed_impl.h (renamed from gr-blocks/lib/packed_to_unpacked_XX_impl.h.t)20
-rw-r--r--gr-blocks/lib/vector_insert_impl.cc (renamed from gr-blocks/lib/vector_insert_X_impl.cc.t)50
-rw-r--r--gr-blocks/lib/vector_insert_impl.h (renamed from gr-blocks/lib/vector_insert_X_impl.h.t)22
-rw-r--r--gr-blocks/lib/vector_sink_impl.cc (renamed from gr-blocks/lib/vector_sink_X_impl.cc.t)43
-rw-r--r--gr-blocks/lib/vector_sink_impl.h (renamed from gr-blocks/lib/vector_sink_X_impl.h.t)20
-rw-r--r--gr-blocks/lib/vector_source_impl.cc (renamed from gr-blocks/lib/vector_source_X_impl.cc.t)46
-rw-r--r--gr-blocks/lib/vector_source_impl.h (renamed from gr-blocks/lib/vector_source_X_impl.h.t)23
-rw-r--r--gr-blocks/lib/xor_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/xor_XX_impl.h.t48
-rw-r--r--gr-blocks/lib/xor_blk_impl.cc (renamed from gr-blocks/lib/divide_XX_impl.cc.t)34
-rw-r--r--gr-blocks/lib/xor_blk_impl.h (renamed from gr-blocks/lib/divide_ff_impl.h)15
128 files changed, 2295 insertions, 3778 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 4d2cdeb0f4..cfb728ce22 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -23,40 +23,6 @@
include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake)
########################################################################
-# Invoke macro to generate various sources
-########################################################################
-include(GrMiscUtils)
-GR_EXPAND_X_CC_H_IMPL(blocks abs_XX ss ii ff)
-GR_EXPAND_X_CC_H_IMPL(blocks add_XX ss ii cc)
-GR_EXPAND_X_CC_H_IMPL(blocks add_const_vXX bb ss ii ff cc)
-GR_EXPAND_X_CC_H_IMPL(blocks and_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks and_const_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks argmax_XX fs is ss)
-GR_EXPAND_X_CC_H_IMPL(blocks divide_XX ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks integrate_XX ss ii ff cc)
-GR_EXPAND_X_CC_H_IMPL(blocks max_XX ss ii ff)
-GR_EXPAND_X_CC_H_IMPL(blocks min_XX ss ii ff)
-GR_EXPAND_X_CC_H_IMPL(blocks moving_average_XX ss ii ff cc)
-GR_EXPAND_X_CC_H_IMPL(blocks multiply_XX ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_XX ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_vXX ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks mute_XX ss ii ff cc)
-GR_EXPAND_X_CC_H_IMPL(blocks not_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks or_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks peak_detector_XX fb ib sb)
-GR_EXPAND_X_CC_H_IMPL(blocks probe_signal_X b s i f c)
-GR_EXPAND_X_CC_H_IMPL(blocks probe_signal_vX b s i f c)
-GR_EXPAND_X_CC_H_IMPL(blocks sample_and_hold_XX bb ss ii ff)
-GR_EXPAND_X_CC_H_IMPL(blocks sub_XX ss ii cc)
-GR_EXPAND_X_CC_H_IMPL(blocks tsb_vector_sink_X b s i f c)
-GR_EXPAND_X_CC_H_IMPL(blocks xor_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks packed_to_unpacked_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks unpacked_to_packed_XX bb ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks vector_insert_X b s i f c)
-GR_EXPAND_X_CC_H_IMPL(blocks vector_sink_X b s i f c)
-GR_EXPAND_X_CC_H_IMPL(blocks vector_source_X b s i f c)
-
-########################################################################
# Setup the include and linker paths
########################################################################
include_directories(
@@ -78,14 +44,40 @@ endif(ENABLE_GR_CTRLPORT)
# Setup library
########################################################################
list(APPEND gr_blocks_sources
- ${generated_sources}
+ abs_blk_impl.cc
+ add_blk_impl.cc
+ add_const_v_impl.cc
+ and_blk_impl.cc
+ and_const_impl.cc
+ argmax_impl.cc
+ divide_impl.cc
+ integrate_impl.cc
+ max_blk_impl.cc
+ min_blk_impl.cc
+ moving_average_impl.cc
+ multiply_const_impl.cc
+ multiply_impl.cc
+ mute_impl.cc
+ not_blk_impl.cc
+ packed_to_unpacked_impl.cc
+ peak_detector_impl.cc
+ probe_signal_impl.cc
+ probe_signal_v_impl.cc
+ sample_and_hold_impl.cc
+ sub_impl.cc
+ tsb_vector_sink_impl.cc
+ unpacked_to_packed_impl.cc
+ vector_insert_impl.cc
+ vector_sink_impl.cc
+ vector_source_impl.cc
+ xor_blk_impl.cc
+ or_blk_impl.cc
control_loop.cc
count_bits.cc
file_sink_base.cc
pack_k_bits.cc
unpack_k_bits.cc
wavfile.cc
- add_ff_impl.cc
add_const_bb_impl.cc
add_const_ss_impl.cc
add_const_ii_impl.cc
@@ -111,8 +103,6 @@ list(APPEND gr_blocks_sources
conjugate_cc_impl.cc
copy_impl.cc
deinterleave_impl.cc
- divide_cc_impl.cc
- divide_ff_impl.cc
delay_impl.cc
endian_swap_impl.cc
exponentiate_const_cci_impl.cc
@@ -140,20 +130,11 @@ list(APPEND gr_blocks_sources
keep_one_in_n_impl.cc
lfsr_32k_source_s_impl.cc
message_debug_impl.cc
- message_sink_impl.cc
- message_source_impl.cc
message_strobe_impl.cc
message_strobe_random_impl.cc
- message_burst_source_impl.cc
- multiply_cc_impl.cc
- multiply_ff_impl.cc
multiply_conjugate_cc_impl.cc
- multiply_const_cc_impl.cc
- multiply_const_vcc_impl.cc
- multiply_const_ff_impl.cc
- multiply_const_vff_impl.cc
- multiply_matrix_cc_impl.cc
- multiply_matrix_ff_impl.cc
+ multiply_const_v_impl.cc
+ multiply_matrix_impl.cc
multiply_by_tag_value_cc_impl.cc
nlog10_ff_impl.cc
nop_impl.cc
@@ -189,7 +170,6 @@ list(APPEND gr_blocks_sources
streams_to_stream_impl.cc
streams_to_vector_impl.cc
stretch_ff_impl.cc
- sub_ff_impl.cc
tag_share_impl.cc
tagged_file_sink_impl.cc
tagged_stream_to_pdu_impl.cc
@@ -255,10 +235,9 @@ list(APPEND blocks_libs
)
add_library(gnuradio-blocks SHARED ${gr_blocks_sources})
-add_dependencies(gnuradio-blocks blocks_generated_includes)
target_link_libraries(gnuradio-blocks ${blocks_libs})
-GR_LIBRARY_FOO(gnuradio-blocks RUNTIME_COMPONENT "blocks_runtime" DEVEL_COMPONENT "blocks_devel")
+GR_LIBRARY_FOO(gnuradio-blocks)
if(ENABLE_STATIC_LIBS)
# Remove controlport-specific source files from staticlibs build
@@ -281,7 +260,7 @@ if(ENABLE_STATIC_LIBS)
add_library(gnuradio-blocks_static STATIC ${gr_blocks_sources})
- add_dependencies(gnuradio-blocks_static blocks_generated_includes)
+ add_dependencies(gnuradio-blocks_static)
if(NOT WIN32)
set_target_properties(gnuradio-blocks_static
@@ -289,7 +268,7 @@ if(ENABLE_STATIC_LIBS)
endif(NOT WIN32)
install(TARGETS gnuradio-blocks_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "blocks_devel" # .lib file
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
)
endif(ENABLE_STATIC_LIBS)
diff --git a/gr-blocks/lib/ConfigChecks.cmake b/gr-blocks/lib/ConfigChecks.cmake
index 1effaa8360..d359a54d95 100644
--- a/gr-blocks/lib/ConfigChecks.cmake
+++ b/gr-blocks/lib/ConfigChecks.cmake
@@ -25,10 +25,8 @@ IF(MSVC) #add this directory for our provided headers
LIST(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/msvc)
ENDIF(MSVC)
-GR_CHECK_HDR_N_DEF(netdb.h HAVE_NETDB_H)
GR_CHECK_HDR_N_DEF(sys/time.h HAVE_SYS_TIME_H)
GR_CHECK_HDR_N_DEF(sys/types.h HAVE_SYS_TYPES_H)
-GR_CHECK_HDR_N_DEF(sys/select.h HAVE_SYS_SELECT_H)
GR_CHECK_HDR_N_DEF(sys/socket.h HAVE_SYS_SOCKET_H)
GR_CHECK_HDR_N_DEF(io.h HAVE_IO_H)
GR_CHECK_HDR_N_DEF(sys/mman.h HAVE_SYS_MMAN_H)
@@ -37,21 +35,10 @@ GR_CHECK_HDR_N_DEF(sys/shm.h HAVE_SYS_SHM_H)
GR_CHECK_HDR_N_DEF(signal.h HAVE_SIGNAL_H)
GR_CHECK_HDR_N_DEF(netinet/in.h HAVE_NETINET_IN_H)
GR_CHECK_HDR_N_DEF(arpa/inet.h HAVE_ARPA_INET_H)
-GR_CHECK_HDR_N_DEF(byteswap.h HAVE_BYTESWAP_H)
-GR_CHECK_HDR_N_DEF(linux/ppdev.h HAVE_LINUX_PPDEV_H)
-GR_CHECK_HDR_N_DEF(dev/ppbus/ppi.h HAVE_DEV_PPBUS_PPI_H)
GR_CHECK_HDR_N_DEF(unistd.h HAVE_UNISTD_H)
GR_CHECK_HDR_N_DEF(malloc.h HAVE_MALLOC_H)
########################################################################
-CHECK_CXX_SOURCE_COMPILES("
- #include <sys/select.h>
- int main(){select(0, 0, 0, 0, 0); return 0;}
- " HAVE_SELECT
-)
-GR_ADD_COND_DEF(HAVE_SELECT)
-
-########################################################################
CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H)
IF(HAVE_WINDOWS_H)
ADD_DEFINITIONS(-DHAVE_WINDOWS_H -DUSING_WINSOCK)
diff --git a/gr-blocks/lib/abs_XX_impl.cc.t b/gr-blocks/lib/abs_blk_impl.cc
index 195d8dff3d..aab0c8552a 100644
--- a/gr-blocks/lib/abs_XX_impl.cc.t
+++ b/gr-blocks/lib/abs_blk_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,46 +20,51 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "abs_blk_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr @NAME@::make(size_t vlen)
+ template <class T>
+ typename abs_blk<T>::sptr abs_blk<T>::make(size_t vlen)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
+ return gnuradio::get_initial_sptr(new abs_blk_impl<T> (vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, 1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
+ template <class T>
+ abs_blk_impl<T> ::abs_blk_impl (size_t vlen)
+ : sync_block("abs_blk",
+ io_signature::make (1, 1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
d_vlen(vlen)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ abs_blk_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0];
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+ T *iptr = (T *) input_items[0];
+ T *optr = (T *) output_items[0];
for(size_t i=0; i<noutput_items*d_vlen; i++) {
- @I_TYPE@ val = iptr[i];
- optr[i] = ((val < ((@I_TYPE@)0)) ? -val : val);
+ T val = iptr[i];
+ optr[i] = ((val < ((T)0)) ? -val : val);
}
return noutput_items;
}
+template class abs_blk<std::int16_t>;
+template class abs_blk<std::int32_t>;
+template class abs_blk<float>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/abs_XX_impl.h.t b/gr-blocks/lib/abs_blk_impl.h
index fa96c84073..787a056767 100644
--- a/gr-blocks/lib/abs_XX_impl.h.t
+++ b/gr-blocks/lib/abs_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,23 +20,23 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef ABS_BLK_IMPL_H
+#define ABS_BLK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/abs_blk.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+ class BLOCKS_API abs_blk_impl : public abs_blk<T>
{
private:
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
+ abs_blk_impl(size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -46,4 +46,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* ABS_BLK_IMPL_H */
diff --git a/gr-blocks/lib/add_XX_impl.cc.t b/gr-blocks/lib/add_XX_impl.cc.t
deleted file mode 100644
index a88398d89b..0000000000
--- a/gr-blocks/lib/add_XX_impl.cc.t
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
-
- int ninputs = input_items.size ();
-
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc += ((@I_TYPE@ *) input_items[j])[i];
-
- *optr++ = (@O_TYPE@) acc;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/add_blk_impl.cc b/gr-blocks/lib/add_blk_impl.cc
new file mode 100644
index 0000000000..9cda4d080e
--- /dev/null
+++ b/gr-blocks/lib/add_blk_impl.cc
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "add_blk_impl.h"
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ template <class T>
+ typename add_blk<T>::sptr add_blk<T>::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr(new add_blk_impl<T> (vlen));
+ }
+
+
+ template <>
+ add_blk_impl<float>::add_blk_impl(size_t vlen)
+ : sync_block("add_ff",
+ io_signature::make (1, -1, sizeof(float)*vlen),
+ io_signature::make (1, 1, sizeof(float)*vlen)),
+ d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+ }
+
+ template <>
+ int
+ add_blk_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(float));
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_add_32f(out, out, (const float*)input_items[i], noi);
+ return noutput_items;
+ }
+
+
+
+ template <class T>
+ add_blk_impl<T> ::add_blk_impl (size_t vlen)
+ : sync_block ("add_blk",
+ io_signature::make (1, -1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ template <class T>
+ int
+ add_blk_impl<T> ::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ T *optr = (T *) output_items[0];
+
+ int ninputs = input_items.size ();
+
+ for (size_t i = 0; i < noutput_items*d_vlen; i++){
+ T acc = ((T *) input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc += ((T *) input_items[j])[i];
+
+ *optr++ = (T) acc;
+ }
+
+ return noutput_items;
+ }
+
+template class add_blk<std::int16_t>;
+template class add_blk<std::int32_t>;
+template class add_blk<gr_complex>;
+template class add_blk<float>;
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/add_XX_impl.h.t b/gr-blocks/lib/add_blk_impl.h
index 22292b9fa5..74f3e1bac1 100644
--- a/gr-blocks/lib/add_XX_impl.h.t
+++ b/gr-blocks/lib/add_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,23 +20,23 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef ADD_BLK_IMPL_H
+#define ADD_BLK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/add_blk.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+class BLOCKS_API add_blk_impl : public add_blk<T>
{
private:
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
+ add_blk_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -46,4 +46,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* ADD_BLK_IMPL_H */
diff --git a/gr-blocks/lib/add_const_vXX_impl.cc.t b/gr-blocks/lib/add_const_v_impl.cc
index 28471ddeb1..38a4883485 100644
--- a/gr-blocks/lib/add_const_vXX_impl.cc.t
+++ b/gr-blocks/lib/add_const_v_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,40 +20,41 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include <add_const_v_impl.h>
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr @NAME@::make(std::vector<@O_TYPE@> k)
+ template <class T>
+ typename add_const_v<T>::sptr add_const_v<T>::make(std::vector<T> k)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(k));
+ return gnuradio::get_initial_sptr(new add_const_v_impl<T>(k));
}
- @NAME_IMPL@::@NAME_IMPL@(std::vector<@O_TYPE@> k)
- : sync_block ("@NAME@",
- io_signature::make (1, 1, sizeof (@I_TYPE@)*k.size()),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*k.size())),
+ template <class T>
+ add_const_v_impl<T>::add_const_v_impl(std::vector<T> k)
+ : sync_block ("add_const_v",
+ io_signature::make (1, 1, sizeof (T)*k.size()),
+ io_signature::make (1, 1, sizeof (T)*k.size())),
d_k(k)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ add_const_v_impl<T>::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0];
- @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+ T *iptr = (T *)input_items[0];
+ T *optr = (T *)output_items[0];
- int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@);
+ int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(T);
for (int i = 0; i < noutput_items; i++)
for (int j = 0; j < nitems_per_block; j++)
@@ -62,5 +63,10 @@ namespace gr {
return noutput_items;
}
+ template class add_const_v<std::uint8_t>;
+ template class add_const_v<std::int16_t>;
+ template class add_const_v<std::int32_t>;
+ template class add_const_v<float>;
+ template class add_const_v<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_vXX_impl.h.t b/gr-blocks/lib/add_const_v_impl.h
index 6c087d9461..1257ec08a0 100644
--- a/gr-blocks/lib/add_const_vXX_impl.h.t
+++ b/gr-blocks/lib/add_const_v_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2006,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2006,2010,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,25 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef ADD_CONST_V_IMPL_H
+#define ADD_CONST_V_IMPL_H
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/add_const_v.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+ template <class T>
+ class BLOCKS_API add_const_v_impl: public add_const_v<T>
{
- std::vector<@O_TYPE@> d_k;
+ std::vector<T> d_k;
public:
- @NAME_IMPL@(std::vector<@O_TYPE@> k);
+ add_const_v_impl(std::vector<T> k);
- std::vector<@O_TYPE@> k() const { return d_k; }
- void set_k(std::vector<@O_TYPE@> k) { d_k = k; }
+ std::vector<T> k() const { return d_k; }
+ void set_k(std::vector<T> k) { d_k = k; }
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -48,4 +47,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* ADD_CONST_V_IMPL_H */
diff --git a/gr-blocks/lib/add_ff_impl.cc b/gr-blocks/lib/add_ff_impl.cc
deleted file mode 100644
index e99b121816..0000000000
--- a/gr-blocks/lib/add_ff_impl.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "add_ff_impl.h"
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- add_ff::sptr add_ff::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new add_ff_impl(vlen));
- }
-
- add_ff_impl::add_ff_impl(size_t vlen)
- : sync_block("add_ff",
- io_signature::make (1, -1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- add_ff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *out = (float *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- memcpy(out, input_items[0], noi*sizeof(float));
- for(size_t i = 1; i < input_items.size(); i++)
- volk_32f_x2_add_32f(out, out, (const float*)input_items[i], noi);
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
diff --git a/gr-blocks/lib/and_XX_impl.cc.t b/gr-blocks/lib/and_XX_impl.cc.t
deleted file mode 100644
index c2aa31c50c..0000000000
--- a/gr-blocks/lib/and_XX_impl.cc.t
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
-
- int ninputs = input_items.size ();
-
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc &= ((@I_TYPE@ *) input_items[j])[i];
-
- *optr++ = (@O_TYPE@) acc;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_XX_impl.cc.t b/gr-blocks/lib/and_blk_impl.cc
index d9b41b3d9f..f0f329dae4 100644
--- a/gr-blocks/lib/multiply_XX_impl.cc.t
+++ b/gr-blocks/lib/and_blk_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,50 +20,55 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "and_blk_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr @NAME@::make(size_t vlen)
+ template <class T>
+ typename and_blk<T>::sptr and_blk<T>::make(size_t vlen)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
+ return gnuradio::get_initial_sptr(new and_blk_impl<T> (vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
+ template <class T>
+ and_blk_impl<T> ::and_blk_impl (size_t vlen)
+ : sync_block ("and_blk",
+ io_signature::make (1, -1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
d_vlen(vlen)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ and_blk_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+ T *optr = (T *) output_items[0];
int ninputs = input_items.size ();
for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
+ T acc = ((T *) input_items[0])[i];
for (int j = 1; j < ninputs; j++)
- acc *= ((@I_TYPE@ *) input_items[j])[i];
+ acc &= ((T *) input_items[j])[i];
- *optr++ = (@O_TYPE@) acc;
+ *optr++ = (T) acc;
}
return noutput_items;
}
+template class and_blk<std::uint8_t>;
+template class and_blk<std::int16_t>;
+template class and_blk<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/and_XX_impl.h.t b/gr-blocks/lib/and_blk_impl.h
index f7db3f2162..54d721111e 100644
--- a/gr-blocks/lib/and_XX_impl.h.t
+++ b/gr-blocks/lib/and_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,22 +20,22 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef AND_BLK_IMPL_H
+#define AND_BLK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/and_blk.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+ class BLOCKS_API and_blk_impl : public and_blk<T>
{
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
+ and_blk_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -45,4 +45,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* AND_BLK_IMPL_H */
diff --git a/gr-blocks/lib/and_const_XX_impl.h.t b/gr-blocks/lib/and_const_XX_impl.h.t
deleted file mode 100644
index 186fda9508..0000000000
--- a/gr-blocks/lib/and_const_XX_impl.h.t
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
- {
- @O_TYPE@ d_k;
-
- public:
- @NAME_IMPL@(@O_TYPE@ k);
-
- @O_TYPE@ k() const { return d_k; }
- void set_k(@O_TYPE@ k) { d_k = k; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/and_const_XX_impl.cc.t b/gr-blocks/lib/and_const_impl.cc
index 975dd9334a..d319f0c25e 100644
--- a/gr-blocks/lib/and_const_XX_impl.cc.t
+++ b/gr-blocks/lib/and_const_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,38 +20,40 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include <and_const_impl.h>
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr @NAME@::make(@O_TYPE@ k)
+ template <class T>
+ typename and_const<T>::sptr and_const<T>::make(T k)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(k));
+ return gnuradio::get_initial_sptr(new and_const_impl<T> (k));
}
- @NAME_IMPL@::@NAME_IMPL@(@O_TYPE@ k)
- : sync_block ("@NAME@",
- io_signature::make (1, 1, sizeof (@I_TYPE@)),
- io_signature::make (1, 1, sizeof (@O_TYPE@))),
+ template <class T>
+ and_const_impl<T> ::and_const_impl (T k)
+ : sync_block ("and_const",
+ io_signature::make (1, 1, sizeof (T)),
+ io_signature::make (1, 1, sizeof (T))),
d_k(k)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ and_const_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0];
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+ T *iptr = (T *) input_items[0];
+ T *optr = (T *) output_items[0];
int size = noutput_items;
@@ -73,5 +75,8 @@ namespace gr {
return noutput_items;
}
+template class and_const<std::uint8_t>;
+template class and_const<std::int16_t>;
+template class and_const<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/and_const_impl.h b/gr-blocks/lib/and_const_impl.h
new file mode 100644
index 0000000000..3af7651e22
--- /dev/null
+++ b/gr-blocks/lib/and_const_impl.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef AND_CONST_IMPL_H
+#define AND_CONST_IMPL_H
+
+#include <gnuradio/blocks/and_const.h>
+
+namespace gr {
+ namespace blocks {
+
+template<class T>
+ class BLOCKS_API and_const_impl : public and_const<T>
+ {
+ T d_k;
+
+ public:
+ and_const_impl (T k);
+
+ T k() const { return d_k; }
+ void set_k(T k) { d_k = k; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* AND_CONST_IMPL_H */
diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc
index a7d8ce9d3d..cf26728193 100644
--- a/gr-blocks/lib/annotator_1to1_impl.cc
+++ b/gr-blocks/lib/annotator_1to1_impl.cc
@@ -44,7 +44,7 @@ namespace gr {
: sync_block("annotator_1to1",
io_signature::make(1, -1, sizeof_stream_item),
io_signature::make(1, -1, sizeof_stream_item)),
- d_itemsize(sizeof_stream_item), d_when((uint64_t)when)
+ d_when((uint64_t)when)
{
set_tag_propagation_policy(TPP_ONE_TO_ONE);
diff --git a/gr-blocks/lib/annotator_1to1_impl.h b/gr-blocks/lib/annotator_1to1_impl.h
index 2da73c8a66..206366ca17 100644
--- a/gr-blocks/lib/annotator_1to1_impl.h
+++ b/gr-blocks/lib/annotator_1to1_impl.h
@@ -31,7 +31,6 @@ namespace gr {
class annotator_1to1_impl : public annotator_1to1
{
private:
- size_t d_itemsize;
uint64_t d_when;
uint64_t d_tag_counter;
std::vector<tag_t> d_stored_tags;
diff --git a/gr-blocks/lib/argmax_XX_impl.cc.t b/gr-blocks/lib/argmax_impl.cc
index 87e025e2d7..b3fd548aee 100644
--- a/gr-blocks/lib/argmax_XX_impl.cc.t
+++ b/gr-blocks/lib/argmax_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2013 Free Software Foundation, Inc.
+ * Copyright 2007,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,67 +20,72 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "argmax_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(size_t vlen)
+ template <class T>
+ typename argmax<T>::sptr
+ argmax<T>::make(size_t vlen)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(vlen));
+ (new argmax_impl<T>(vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block("@BASE_NAME@",
- io_signature::make(1, -1, vlen*sizeof(@I_TYPE@)),
- io_signature::make(2, 2, sizeof(@O_TYPE@))),
+ template <class T>
+ argmax_impl<T>::argmax_impl(size_t vlen)
+ : sync_block("argmax",
+ io_signature::make(1, -1, vlen*sizeof(T)),
+ io_signature::make(2, 2, sizeof(std::int16_t))),
d_vlen(vlen)
{
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ argmax_impl<T>::~argmax_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ argmax_impl<T>::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
int ninputs = input_items.size ();
- @O_TYPE@ *x_optr = (@O_TYPE@ *)output_items[0];
- @O_TYPE@ *y_optr = (@O_TYPE@ *)output_items[1];
+ std::int16_t *x_optr = (std::int16_t *)output_items[0];
+ std::int16_t *y_optr = (std::int16_t *)output_items[1];
for(int i = 0; i < noutput_items; i++) {
- @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen];
+ T max = ((T *)input_items[0])[i*d_vlen];
int x = 0;
int y = 0;
for(int j = 0; j < (int)d_vlen; j++ ) {
for(int k = 0; k < ninputs; k++) {
- if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) {
- max = ((@I_TYPE@ *)input_items[k])[i*d_vlen + j];
+ if(((T *)input_items[k])[i*d_vlen + j] > max) {
+ max = ((T *)input_items[k])[i*d_vlen + j];
x = j;
y = k;
}
}
}
- *x_optr++ = (@O_TYPE@)x;
- *y_optr++ = (@O_TYPE@)y;
+ *x_optr++ = (std::int16_t)x;
+ *y_optr++ = (std::int16_t)y;
}
return noutput_items;
}
+ template class argmax<float>;
+ template class argmax<std::int32_t>;
+ template class argmax<std::int16_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/argmax_XX_impl.h.t b/gr-blocks/lib/argmax_impl.h
index 79da4e1d82..e6609930dc 100644
--- a/gr-blocks/lib/argmax_XX_impl.h.t
+++ b/gr-blocks/lib/argmax_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2013 Free Software Foundation, Inc.
+ * Copyright 2007,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,24 +20,23 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef ARGMAX_IMPL_H
+#define ARGMAX_IMPL_H
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/argmax.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+ template <class T>
+ class argmax_impl : public argmax<T>
{
private:
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
- ~@NAME_IMPL@();
+ argmax_impl(size_t vlen);
+ ~argmax_impl();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -47,4 +46,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* ARGMAX_IMPL_H */
diff --git a/gr-blocks/lib/control_loop.cc b/gr-blocks/lib/control_loop.cc
index 7104e7439e..30260b5646 100644
--- a/gr-blocks/lib/control_loop.cc
+++ b/gr-blocks/lib/control_loop.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011,2013 Free Software Foundation, Inc.
+ * Copyright 2011,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -31,7 +31,7 @@
namespace gr {
namespace blocks {
-#define M_TWOPI (2.0f*M_PI)
+#define M_TWOPI (2.0f*GR_M_PI)
control_loop::control_loop(float loop_bw,
float max_freq, float min_freq)
diff --git a/gr-blocks/lib/divide_cc_impl.cc b/gr-blocks/lib/divide_cc_impl.cc
deleted file mode 100644
index 56ce09e04c..0000000000
--- a/gr-blocks/lib/divide_cc_impl.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004-2016 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <divide_cc_impl.h>
-#include <volk/volk.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- divide_cc::sptr divide_cc::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new divide_cc_impl(vlen));
- }
-
- divide_cc_impl::divide_cc_impl(size_t vlen)
- : sync_block ("divide_cc",
- io_signature::make (2, -1, sizeof (gr_complex)*vlen),
- io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- divide_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *optr = (gr_complex *) output_items[0];
- size_t ninputs = input_items.size ();
- gr_complex *numerator = (gr_complex *) input_items[0];
- for(size_t inp = 1; inp < ninputs; ++inp)
- {
- volk_32fc_x2_divide_32fc(optr, numerator, (gr_complex*) input_items[inp], noutput_items * d_vlen);
- numerator = optr;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/divide_ff_impl.cc b/gr-blocks/lib/divide_ff_impl.cc
deleted file mode 100644
index 5bd5f88d84..0000000000
--- a/gr-blocks/lib/divide_ff_impl.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004-2016 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <divide_ff_impl.h>
-#include <volk/volk.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- divide_ff::sptr divide_ff::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new divide_ff_impl(vlen));
- }
-
- divide_ff_impl::divide_ff_impl(size_t vlen)
- : sync_block ("divide_ff",
- io_signature::make (2, -1, sizeof (float)*vlen),
- io_signature::make (1, 1, sizeof (float)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- divide_ff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *optr = (float *) output_items[0];
- size_t ninputs = input_items.size ();
- float *numerator = (float *) input_items[0];
- for(size_t inp = 1; inp < ninputs; ++inp)
- {
- volk_32f_x2_divide_32f(optr, numerator, (float*) input_items[inp], noutput_items * d_vlen);
- numerator = optr;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/divide_impl.cc b/gr-blocks/lib/divide_impl.cc
new file mode 100644
index 0000000000..5fe08f95d1
--- /dev/null
+++ b/gr-blocks/lib/divide_impl.cc
@@ -0,0 +1,130 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "divide_impl.h"
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ template <class T>
+ typename divide<T>::sptr divide<T>::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr(new divide_impl<T> (vlen));
+ }
+
+ template <>
+ divide_impl<float>::divide_impl(size_t vlen)
+ : sync_block ("divide",
+ io_signature::make (2, -1, sizeof (float)*vlen),
+ io_signature::make (1, 1, sizeof (float)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ template <>
+ int
+ divide_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float *optr = (float *) output_items[0];
+ size_t ninputs = input_items.size ();
+ float *numerator = (float *) input_items[0];
+ for(size_t inp = 1; inp < ninputs; ++inp)
+ {
+ volk_32f_x2_divide_32f(optr, numerator, (float*) input_items[inp], noutput_items * d_vlen);
+ numerator = optr;
+ }
+
+ return noutput_items;
+ }
+
+ template <>
+ divide_impl<gr_complex>::divide_impl(size_t vlen)
+ : sync_block ("divide_cc",
+ io_signature::make (2, -1, sizeof (gr_complex)*vlen),
+ io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ template <>
+ int
+ divide_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gr_complex *optr = (gr_complex *) output_items[0];
+ size_t ninputs = input_items.size ();
+ gr_complex *numerator = (gr_complex *) input_items[0];
+ for(size_t inp = 1; inp < ninputs; ++inp)
+ {
+ volk_32fc_x2_divide_32fc(optr, numerator, (gr_complex*) input_items[inp], noutput_items * d_vlen);
+ numerator = optr;
+ }
+
+ return noutput_items;
+ }
+
+ template <class T>
+ divide_impl<T> ::divide_impl (size_t vlen)
+ : sync_block ("divide",
+ io_signature::make (1, -1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ template <class T>
+ int
+ divide_impl<T> ::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ T *optr = (T *) output_items[0];
+
+ int ninputs = input_items.size ();
+
+ for (size_t i = 0; i < noutput_items*d_vlen; i++){
+ T acc = ((T *) input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc /= ((T *) input_items[j])[i];
+
+ *optr++ = (T) acc;
+ }
+
+ return noutput_items;
+ }
+
+template class divide<std::int16_t>;
+template class divide<std::int32_t>;
+ template class divide<float>;
+ template class divide<gr_complex>;
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/divide_cc_impl.h b/gr-blocks/lib/divide_impl.h
index 2bcd698818..cc9045c711 100644
--- a/gr-blocks/lib/divide_cc_impl.h
+++ b/gr-blocks/lib/divide_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004-2016 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -21,20 +21,21 @@
*/
-#ifndef __DIVIDE_CC_IMPL_H__
-#define __DIVIDE_CC_IMPL_H__
+#ifndef DIVIDE_IMPL_H
+#define DIVIDE_IMPL_H
-#include <gnuradio/blocks/divide_cc.h>
+#include <gnuradio/blocks/divide.h>
namespace gr {
namespace blocks {
- class BLOCKS_API divide_cc_impl : public divide_cc
+template<class T>
+ class BLOCKS_API divide_impl : public divide<T>
{
size_t d_vlen;
public:
- divide_cc_impl(size_t vlen);
+ divide_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -44,4 +45,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* include guard */
+#endif /* DIVIDE_IMPL_H */
diff --git a/gr-blocks/lib/file_meta_sink_impl.cc b/gr-blocks/lib/file_meta_sink_impl.cc
index b6d858489d..fed28c7352 100644
--- a/gr-blocks/lib/file_meta_sink_impl.cc
+++ b/gr-blocks/lib/file_meta_sink_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -56,12 +56,15 @@ namespace gr {
file_meta_sink::sptr
- file_meta_sink::make(size_t itemsize, const std::string &filename,
- double samp_rate, double relative_rate,
- gr_file_types type, bool complex,
- size_t max_segment_size,
- const std::string &extra_dict,
- bool detached_header)
+ file_meta_sink::make(size_t itemsize,
+ const std::string &filename,
+ double samp_rate,
+ double relative_rate,
+ gr_file_types type,
+ bool complex,
+ size_t max_segment_size,
+ pmt::pmt_t extra_dict,
+ bool detached_header)
{
return gnuradio::get_initial_sptr
(new file_meta_sink_impl(itemsize, filename,
@@ -73,19 +76,19 @@ namespace gr {
}
file_meta_sink_impl::file_meta_sink_impl(size_t itemsize,
- const std::string &filename,
- double samp_rate, double relative_rate,
- gr_file_types type, bool complex,
- size_t max_segment_size,
- const std::string &extra_dict,
- bool detached_header)
+ const std::string &filename,
+ double samp_rate, double relative_rate,
+ gr_file_types type, bool complex,
+ size_t max_segment_size,
+ pmt::pmt_t extra_dict,
+ bool detached_header)
: sync_block("file_meta_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
- d_itemsize(itemsize),
- d_samp_rate(samp_rate), d_relative_rate(relative_rate),
- d_max_seg_size(max_segment_size), d_total_seg_size(0),
- d_updated(false), d_unbuffered(false)
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(0, 0, 0)),
+ d_itemsize(itemsize),
+ d_samp_rate(samp_rate), d_relative_rate(relative_rate),
+ d_max_seg_size(max_segment_size), d_total_seg_size(0),
+ d_updated(false), d_unbuffered(false)
{
d_fp = 0;
d_new_fp = 0;
@@ -105,16 +108,13 @@ namespace gr {
// handle extra dictionary
d_extra = pmt::make_dict();
- if(extra_dict.size() > 0) {
- pmt::pmt_t extras = pmt::deserialize_str(extra_dict);
- pmt::pmt_t keys = pmt::dict_keys(extras);
- pmt::pmt_t vals = pmt::dict_values(extras);
- size_t nitems = pmt::length(keys);
- for(size_t i = 0; i < nitems; i++) {
- d_extra = pmt::dict_add(d_extra,
- pmt::nth(i, keys),
- pmt::nth(i, vals));
- }
+ pmt::pmt_t keys = pmt::dict_keys(extra_dict);
+ pmt::pmt_t vals = pmt::dict_values(extra_dict);
+ size_t nitems = pmt::length(keys);
+ for(size_t i = 0; i < nitems; i++) {
+ d_extra = pmt::dict_add(d_extra,
+ pmt::nth(i, keys),
+ pmt::nth(i, vals));
}
d_extra_size = pmt::serialize_str(d_extra).size();
@@ -248,7 +248,7 @@ namespace gr {
std::string extra_str = pmt::serialize_str(extra);
if((header_str.size() != METADATA_HEADER_SIZE) && (extra_str.size() != d_extra_size))
- throw std::runtime_error("file_meta_sink: header or extras is wrong size.\n");
+ throw std::runtime_error("file_meta_sink: header or extra_dict is wrong size.\n");
size_t nwritten = 0;
while(nwritten < header_str.size()) {
diff --git a/gr-blocks/lib/file_meta_sink_impl.h b/gr-blocks/lib/file_meta_sink_impl.h
index 5e678729b2..b274b3e8ed 100644
--- a/gr-blocks/lib/file_meta_sink_impl.h
+++ b/gr-blocks/lib/file_meta_sink_impl.h
@@ -66,12 +66,14 @@ namespace gr {
bool _open(FILE **fp, const char *filename);
public:
- file_meta_sink_impl(size_t itemsize, const std::string &filename,
- double samp_rate=1, double relative_rate=1,
- gr_file_types type=GR_FILE_FLOAT, bool complex=true,
- size_t max_segment_size=1000000,
- const std::string &extra_dict="",
- bool detached_header=false);
+ file_meta_sink_impl(size_t itemsize, const std::string &filename,
+ double samp_rate=1,
+ double relative_rate=1,
+ gr_file_types type=GR_FILE_FLOAT,
+ bool complex=true,
+ size_t max_segment_size=1000000,
+ pmt::pmt_t extra_dict=pmt::make_dict(),
+ bool detached_header=false);
~file_meta_sink_impl();
bool open(const std::string &filename);
diff --git a/gr-blocks/lib/file_source_impl.cc b/gr-blocks/lib/file_source_impl.cc
index c077c74fd9..6f4f8fde26 100644
--- a/gr-blocks/lib/file_source_impl.cc
+++ b/gr-blocks/lib/file_source_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012, 2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -39,35 +39,38 @@
#include <io.h>
#endif
#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
+#define OUR_O_BINARY O_BINARY
#else
-#define OUR_O_BINARY 0
+#define OUR_O_BINARY 0
#endif
// should be handled via configure
#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
#else
-#define OUR_O_LARGEFILE 0
+#define OUR_O_LARGEFILE 0
#endif
namespace gr {
namespace blocks {
- file_source::sptr file_source::make(size_t itemsize, const char *filename, bool repeat)
+ file_source::sptr file_source::make(size_t itemsize, const char *filename, bool repeat,
+ size_t start_offset_items, size_t length_items)
{
return gnuradio::get_initial_sptr
- (new file_source_impl(itemsize, filename, repeat));
+ (new file_source_impl(itemsize, filename, repeat, start_offset_items, length_items));
}
- file_source_impl::file_source_impl(size_t itemsize, const char *filename, bool repeat)
+ file_source_impl::file_source_impl(size_t itemsize, const char *filename, bool repeat,
+ size_t start_offset_items, size_t length_items)
: sync_block("file_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_fp(0), d_new_fp(0), d_repeat(repeat),
- d_updated(false), d_file_begin(true), d_repeat_cnt(0),
- d_add_begin_tag(pmt::PMT_NIL)
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_start_offset_items(start_offset_items), d_length_items(length_items),
+ d_fp(0), d_new_fp(0), d_repeat(repeat), d_updated(false),
+ d_file_begin(true), d_repeat_cnt(0), d_add_begin_tag(pmt::PMT_NIL)
{
- open(filename, repeat);
+ open(filename, repeat, start_offset_items, length_items);
do_update();
std::stringstream str;
@@ -86,12 +89,35 @@ namespace gr {
bool
file_source_impl::seek(long seek_point, int whence)
{
- return fseek((FILE*)d_fp, seek_point *d_itemsize, whence) == 0;
+ seek_point += d_start_offset_items;
+
+ switch(whence) {
+ case SEEK_SET:
+ break;
+ case SEEK_CUR:
+ seek_point += (d_length_items - d_items_remaining);
+ break;
+ case SEEK_END:
+ seek_point = d_length_items - seek_point;
+ break;
+ default:
+ GR_LOG_WARN(d_logger, "bad seek mode");
+ return 0;
+ }
+
+ if ((seek_point < (long)d_start_offset_items)
+ || (seek_point > (long)(d_start_offset_items+d_length_items-1))) {
+ GR_LOG_WARN(d_logger, "bad seek point");
+ return 0;
+ }
+
+ return fseek((FILE*)d_fp, seek_point * d_itemsize, SEEK_SET) == 0;
}
void
- file_source_impl::open(const char *filename, bool repeat)
+ file_source_impl::open(const char *filename, bool repeat,
+ size_t start_offset_items, size_t length_items)
{
// obtain exclusive access for duration of this function
gr::thread::scoped_lock lock(fp_mutex);
@@ -100,33 +126,61 @@ namespace gr {
// we use "open" to use to the O_LARGEFILE flag
if((fd = ::open(filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) {
- perror(filename);
- throw std::runtime_error("can't open file");
+ GR_LOG_ERROR(d_logger, boost::format("%s: %s") % filename % strerror(errno));
+ throw std::runtime_error("can't open file");
}
if(d_new_fp) {
- fclose(d_new_fp);
- d_new_fp = 0;
+ fclose(d_new_fp);
+ d_new_fp = 0;
}
if((d_new_fp = fdopen (fd, "rb")) == NULL) {
- perror(filename);
- ::close(fd); // don't leak file descriptor if fdopen fails
- throw std::runtime_error("can't open file");
+ GR_LOG_ERROR(d_logger, boost::format("%s: %s") % filename % strerror(errno));
+ ::close(fd); // don't leak file descriptor if fdopen fails
+ throw std::runtime_error("can't open file");
}
//Check to ensure the file will be consumed according to item size
fseek(d_new_fp, 0, SEEK_END);
int file_size = ftell(d_new_fp);
- rewind (d_new_fp);
- //Warn the user if part of the file will not be consumed.
- if(file_size % d_itemsize){
- GR_LOG_WARN(d_logger, "WARNING: File will not be fully consumed with the current output type");
+ // Make sure there will be at least one item available
+ if ((file_size / d_itemsize) < (start_offset_items+1)) {
+ if (start_offset_items) {
+ GR_LOG_WARN(d_logger, "file is too small for start offset");
+ }
+ else {
+ GR_LOG_WARN(d_logger, "file is too small");
+ }
+ fclose(d_new_fp);
+ throw std::runtime_error("file is too small");
+ }
+
+ size_t items_available = (file_size / d_itemsize - start_offset_items);
+
+ // If length is not specified, use the remainder of the file. Check alignment at end.
+ if (length_items == 0) {
+ length_items = items_available;
+ if (file_size % d_itemsize){
+ GR_LOG_WARN(d_logger, "file size is not a multiple of item size");
+ }
+ }
+
+ // Check specified length. Warn and use available items instead of throwing an exception.
+ if (length_items > items_available) {
+ length_items = items_available;
+ GR_LOG_WARN(d_logger, "file too short, will read fewer than requested items");
}
+ // Rewind to start offset
+ fseek(d_new_fp, start_offset_items * d_itemsize, SEEK_SET);
+
d_updated = true;
d_repeat = repeat;
+ d_start_offset_items = start_offset_items;
+ d_length_items = length_items;
+ d_items_remaining = length_items;
}
void
@@ -136,8 +190,8 @@ namespace gr {
gr::thread::scoped_lock lock(fp_mutex);
if(d_new_fp != NULL) {
- fclose(d_new_fp);
- d_new_fp = NULL;
+ fclose(d_new_fp);
+ d_new_fp = NULL;
}
d_updated = true;
}
@@ -146,15 +200,15 @@ namespace gr {
file_source_impl::do_update()
{
if(d_updated) {
- gr::thread::scoped_lock lock(fp_mutex); // hold while in scope
+ gr::thread::scoped_lock lock(fp_mutex); // hold while in scope
- if(d_fp)
- fclose(d_fp);
+ if(d_fp)
+ fclose(d_fp);
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
- d_updated = false;
- d_file_begin = true;
+ d_fp = d_new_fp; // install new file pointer
+ d_new_fp = 0;
+ d_updated = false;
+ d_file_begin = true;
}
}
@@ -166,60 +220,62 @@ namespace gr {
int
file_source_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
char *o = (char*)output_items[0];
- int i;
int size = noutput_items;
do_update(); // update d_fp is reqd
if(d_fp == NULL)
- throw std::runtime_error("work with file not open");
+ throw std::runtime_error("work with file not open");
gr::thread::scoped_lock lock(fp_mutex); // hold for the rest of this function
+ // No items remaining - all done
+ if (d_items_remaining == 0)
+ return WORK_DONE;
+
while(size) {
+
// Add stream tag whenever the file starts again
if (d_file_begin && d_add_begin_tag != pmt::PMT_NIL) {
- add_item_tag(0, nitems_written(0) + noutput_items - size, d_add_begin_tag, pmt::from_long(d_repeat_cnt), _id);
+ add_item_tag(0, nitems_written(0) + noutput_items - size,
+ d_add_begin_tag, pmt::from_long(d_repeat_cnt), _id);
d_file_begin = false;
}
- i = fread(o, d_itemsize, size, (FILE*)d_fp);
-
- size -= i;
- o += i * d_itemsize;
-
- if(size == 0) // done
- break;
-
- if(i > 0) // short read, try again
- continue;
-
- // We got a zero from fread. This is either EOF or error. In
- // any event, if we're in repeat mode, seek back to the beginning
- // of the file and try again, else break
- if(!d_repeat)
- break;
-
- if(fseek ((FILE *) d_fp, 0, SEEK_SET) == -1) {
- fprintf(stderr, "[%s] fseek failed\n", __FILE__);
- exit(-1);
- }
- if (d_add_begin_tag != pmt::PMT_NIL) {
- d_file_begin = true;
- d_repeat_cnt++;
+ size_t nitems_to_read = std::min((size_t)size, d_items_remaining);
+
+ // Since the bounds of the file are known, unexpected nitems is an error
+ if (nitems_to_read != fread(o, d_itemsize, nitems_to_read, (FILE*)d_fp))
+ throw std::runtime_error("fread error");
+
+ size -= nitems_to_read;
+ d_items_remaining -= nitems_to_read;
+ o += nitems_to_read * d_itemsize;
+
+ // Ran out of items ("EOF")
+ if (d_items_remaining == 0) {
+
+ // Repeat: rewind and request tag
+ if (d_repeat) {
+ fseek(d_fp, d_start_offset_items * d_itemsize, SEEK_SET);
+ d_items_remaining = d_length_items;
+ if (d_add_begin_tag != pmt::PMT_NIL) {
+ d_file_begin = true;
+ d_repeat_cnt++;
+ }
+ }
+
+ // No repeat: return
+ else {
+ break;
+ }
}
}
- if(size > 0) { // EOF or error
- if(size == noutput_items) // we didn't read anything; say we're done
- return -1;
- return noutput_items - size; // else return partial result
- }
-
- return noutput_items;
+ return (noutput_items - size);
}
} /* namespace blocks */
diff --git a/gr-blocks/lib/file_source_impl.h b/gr-blocks/lib/file_source_impl.h
index 19f393fc1d..6de3fc0d16 100644
--- a/gr-blocks/lib/file_source_impl.h
+++ b/gr-blocks/lib/file_source_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012, 2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -33,6 +33,9 @@ namespace gr {
{
private:
size_t d_itemsize;
+ size_t d_start_offset_items;
+ size_t d_length_items;
+ size_t d_items_remaining;
FILE *d_fp;
FILE *d_new_fp;
bool d_repeat;
@@ -47,16 +50,17 @@ namespace gr {
void do_update();
public:
- file_source_impl(size_t itemsize, const char *filename, bool repeat);
+ file_source_impl(size_t itemsize, const char *filename, bool repeat,
+ size_t offset, size_t len);
~file_source_impl();
bool seek(long seek_point, int whence);
- void open(const char *filename, bool repeat);
+ void open(const char *filename, bool repeat, size_t offset, size_t len);
void close();
int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
void set_begin_tag(pmt::pmt_t val);
};
diff --git a/gr-blocks/lib/integrate_XX_impl.cc.t b/gr-blocks/lib/integrate_impl.cc
index cb7a448ced..3c2cf022cb 100644
--- a/gr-blocks/lib/integrate_XX_impl.cc.t
+++ b/gr-blocks/lib/integrate_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,44 +20,46 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include <integrate_impl.h>
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr @NAME@::make(int decim, int vlen)
+ template <class T>
+ typename integrate<T>::sptr integrate<T>::make(int decim, int vlen)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(decim, vlen));
+ return gnuradio::get_initial_sptr(new integrate_impl<T> (decim, vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(int decim, int vlen)
- : sync_decimator("@NAME@",
- io_signature::make(1, 1, sizeof (@I_TYPE@) * vlen),
- io_signature::make(1, 1, sizeof (@O_TYPE@) * vlen),
+ template <class T>
+ integrate_impl<T> ::integrate_impl(int decim, int vlen)
+ : sync_decimator("integrate",
+ io_signature::make(1, 1, sizeof (T) * vlen),
+ io_signature::make(1, 1, sizeof (T) * vlen),
decim),
d_decim(decim),
d_vlen(vlen)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ integrate_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const @I_TYPE@ *in = (const @I_TYPE@ *)input_items[0];
- @O_TYPE@ *out = (@O_TYPE@ *)output_items[0];
+ const T *in = (const T *)input_items[0];
+ T *out = (T *)output_items[0];
for (int i = 0; i < noutput_items; i++) {
for (int j = 0; j < d_vlen; ++j) {
- out[i*d_vlen + j] = (@O_TYPE@)0;
+ out[i*d_vlen + j] = (T)0;
}
for (int j = 0; j < d_decim; j++) {
for (int k = 0; k < d_vlen; ++k) {
@@ -69,5 +71,9 @@ namespace gr {
return noutput_items;
}
+template class integrate<std::int16_t>;
+template class integrate<std::int32_t>;
+template class integrate<float>;
+template class integrate<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/integrate_XX_impl.h.t b/gr-blocks/lib/integrate_impl.h
index 67e6fce43a..efe475e103 100644
--- a/gr-blocks/lib/integrate_XX_impl.h.t
+++ b/gr-blocks/lib/integrate_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,23 +20,23 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef INTEGRATE_IMPL_H
+#define INTEGRATE_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/integrate.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+class BLOCKS_API integrate_impl : public integrate<T>
{
int d_decim;
int d_vlen;
public:
- @NAME_IMPL@(int decim, int vlen);
+ integrate_impl (int decim, int vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -46,4 +46,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* INTEGRATE_IMPL_H */
diff --git a/gr-blocks/lib/interleaved_char_to_complex_impl.cc b/gr-blocks/lib/interleaved_char_to_complex_impl.cc
index b16e3c4c73..ab6364a6d4 100644
--- a/gr-blocks/lib/interleaved_char_to_complex_impl.cc
+++ b/gr-blocks/lib/interleaved_char_to_complex_impl.cc
@@ -40,8 +40,7 @@ namespace gr {
: sync_decimator("interleaved_char_to_complex",
gr::io_signature::make (1, 1, (vector_input?2:1)*sizeof(char)),
gr::io_signature::make (1, 1, sizeof(gr_complex)),
- vector_input?1:2),
- d_vector_input(vector_input)
+ vector_input?1:2)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(gr_complex);
diff --git a/gr-blocks/lib/interleaved_char_to_complex_impl.h b/gr-blocks/lib/interleaved_char_to_complex_impl.h
index 484c33c9f4..f07805788c 100644
--- a/gr-blocks/lib/interleaved_char_to_complex_impl.h
+++ b/gr-blocks/lib/interleaved_char_to_complex_impl.h
@@ -31,7 +31,6 @@ namespace gr {
class BLOCKS_API interleaved_char_to_complex_impl : public interleaved_char_to_complex
{
private:
- bool d_vector_input;
public:
interleaved_char_to_complex_impl(bool vector_input=false);
diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.cc b/gr-blocks/lib/interleaved_short_to_complex_impl.cc
index 6c7108b550..ca0dfc9064 100644
--- a/gr-blocks/lib/interleaved_short_to_complex_impl.cc
+++ b/gr-blocks/lib/interleaved_short_to_complex_impl.cc
@@ -41,7 +41,7 @@ namespace gr {
gr::io_signature::make (1, 1, (vector_input?2:1)*sizeof(short)),
gr::io_signature::make (1, 1, sizeof(gr_complex)),
vector_input?1:2),
- d_vector_input(vector_input), d_swap(swap)
+ d_swap(swap)
{
}
diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.h b/gr-blocks/lib/interleaved_short_to_complex_impl.h
index 8370786187..7a3ca419c9 100644
--- a/gr-blocks/lib/interleaved_short_to_complex_impl.h
+++ b/gr-blocks/lib/interleaved_short_to_complex_impl.h
@@ -31,7 +31,6 @@ namespace gr {
class BLOCKS_API interleaved_short_to_complex_impl : public interleaved_short_to_complex
{
private:
- bool d_vector_input;
bool d_swap;
public:
interleaved_short_to_complex_impl(bool vector_input=false, bool swap=false);
diff --git a/gr-blocks/lib/max_XX_impl.cc.t b/gr-blocks/lib/max_blk_impl.cc
index 36c97260ae..eef6366804 100644
--- a/gr-blocks/lib/max_XX_impl.cc.t
+++ b/gr-blocks/lib/max_blk_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014,2015 Free Software Foundation, Inc.
+ * Copyright 2014,2015,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,77 +20,83 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include <max_blk_impl.h>
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(size_t vlen, size_t vlen_out)
+ template <class T>
+ typename max_blk<T>::sptr
+ max_blk<T>::make(size_t vlen, size_t vlen_out)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(vlen,vlen_out));
+ (new max_blk_impl<T> (vlen,vlen_out));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen, size_t vlen_out)
- : sync_block("@BASE_NAME@",
- io_signature::make(1, -1, vlen*sizeof(@I_TYPE@)),
- io_signature::make(1, 1, vlen_out*sizeof(@O_TYPE@))),
+ template <class T>
+ max_blk_impl<T> ::max_blk_impl(size_t vlen, size_t vlen_out)
+ : sync_block("max_blk",
+ io_signature::make(1, -1, vlen*sizeof(T)),
+ io_signature::make(1, 1, vlen_out*sizeof(T))),
d_vlen(vlen), d_vlen_out(vlen_out)
{
assert((vlen_out == vlen) || (vlen_out == 1));
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ max_blk_impl<T> ::~max_blk_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ max_blk_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+ T *optr = (T *)output_items[0];
int ninputs = input_items.size();
if(d_vlen_out == 1)
for(int i = 0; i < noutput_items; i++) {
- @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen];
+ T max = ((T *)input_items[0])[i*d_vlen];
for(int j = 0; j < (int)d_vlen; j++ ) {
for(int k = 0; k < ninputs; k++) {
- if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) {
- max = ((@I_TYPE@*)input_items[k])[i*d_vlen + j];
+ if(((T *)input_items[k])[i*d_vlen + j] > max) {
+ max = ((T*)input_items[k])[i*d_vlen + j];
}
}
}
- *optr++ = (@O_TYPE@)max;
+ *optr++ = (T)max;
}
else // vector mode output
for(size_t i = 0; i < (size_t)noutput_items * d_vlen_out; i++) {
- @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i];
+ T max = ((T *)input_items[0])[i];
for(int k = 1; k < ninputs; k++) {
- if(((@I_TYPE@ *)input_items[k])[i] > max) {
- max = ((@I_TYPE@*)input_items[k])[i];
+ if(((T *)input_items[k])[i] > max) {
+ max = ((T*)input_items[k])[i];
}
}
- *optr++ = (@O_TYPE@)max;
+ *optr++ = (T)max;
}
return noutput_items;
}
+template class max_blk<std::int16_t>;
+template class max_blk<std::int32_t>;
+template class max_blk<float>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/min_XX_impl.h.t b/gr-blocks/lib/max_blk_impl.h
index c829ab0514..af62d9f4a8 100644
--- a/gr-blocks/lib/min_XX_impl.h.t
+++ b/gr-blocks/lib/max_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014,2015 Free Software Foundation, Inc.
+ * Copyright 2014,2015,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,24 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef MAX_BLK_IMPL_H
+#define MAX_BLK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/max_blk.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class max_blk_impl : public max_blk<T>
{
private:
size_t d_vlen, d_vlen_out;
public:
- @NAME_IMPL@(size_t vlen, size_t vlen_out);
- ~@NAME_IMPL@();
+ max_blk_impl (size_t vlen, size_t vlen_out);
+ ~max_blk_impl ();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -47,4 +47,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* MAX_BLK_IMPL_H */
diff --git a/gr-blocks/lib/message_burst_source_impl.cc b/gr-blocks/lib/message_burst_source_impl.cc
deleted file mode 100644
index 0ce0a9284f..0000000000
--- a/gr-blocks/lib/message_burst_source_impl.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012-2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "message_burst_source_impl.h"
-#include <gnuradio/io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-#include <gnuradio/tags.h>
-
-namespace gr {
- namespace blocks {
-
- message_burst_source::sptr
- message_burst_source::make(size_t itemsize, int msgq_limit)
- {
- return gnuradio::get_initial_sptr
- (new message_burst_source_impl(itemsize, msgq_limit));
- }
-
- message_burst_source::sptr
- message_burst_source::make(size_t itemsize, msg_queue::sptr msgq)
- {
- return gnuradio::get_initial_sptr
- (new message_burst_source_impl(itemsize, msgq));
- }
-
- message_burst_source_impl::message_burst_source_impl(size_t itemsize, int msgq_limit)
- : sync_block("message_burst_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msg_queue::make(msgq_limit)),
- d_msg_offset(0), d_eof(false)
- {
- std::stringstream id;
- id << name() << unique_id();
- d_me = pmt::string_to_symbol(id.str());
- }
-
- message_burst_source_impl::message_burst_source_impl(size_t itemsize, msg_queue::sptr msgq)
- : sync_block("message_burst_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq),
- d_msg_offset(0), d_eof(false)
- {
- std::stringstream id;
- id << name() << unique_id();
- d_me = pmt::string_to_symbol(id.str());
- }
-
- message_burst_source_impl::~message_burst_source_impl()
- {
- }
-
- int
- message_burst_source_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- char *out = (char*)output_items[0];
- int nn = 0;
-
- uint64_t abs_sample_count = nitems_written(0);
-
- while(nn < noutput_items) {
- if(d_msg) {
- //
- // Consume whatever we can from the current message
- //
-
- int mm = std::min(noutput_items - nn,
- (int)((d_msg->length() - d_msg_offset) / d_itemsize));
- memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
-
- nn += mm;
- out += mm * d_itemsize;
- d_msg_offset += mm * d_itemsize;
- assert(d_msg_offset <= d_msg->length());
-
- if(d_msg_offset == d_msg->length()) {
- if(d_msg->type() == 1) // type == 1 sets EOF
- d_eof = true;
- d_msg.reset();
- //tag end of burst
- add_item_tag(0, //stream ID
- abs_sample_count+nn-1, //sample number
- pmt::string_to_symbol("tx_eob"),
- pmt::from_bool(1),
- d_me); //block src id
- }
- }
- else {
- //
- // No current message
- //
- if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got
- break;
- }
-
- if(d_eof)
- return -1;
-
- d_msg = d_msgq->delete_head(); // block, waiting for a message
- d_msg_offset = 0;
- //tag start of burst
- add_item_tag(0, //stream ID
- abs_sample_count+nn, //sample number
- pmt::string_to_symbol("tx_sob"),
- pmt::from_bool(1),
- d_me); //block src id
-
- if((d_msg->length() % d_itemsize) != 0)
- throw std::runtime_error("msg length is not a multiple of d_itemsize");
- }
- }
-
- return nn;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/message_burst_source_impl.h b/gr-blocks/lib/message_burst_source_impl.h
deleted file mode 100644
index a389a23942..0000000000
--- a/gr-blocks/lib/message_burst_source_impl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012-2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H
-#define INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H
-
-#include <gnuradio/blocks/message_burst_source.h>
-#include <gnuradio/message.h>
-
-namespace gr {
- namespace blocks {
-
- class message_burst_source_impl : public message_burst_source
- {
- private:
- size_t d_itemsize;
- msg_queue::sptr d_msgq;
- message::sptr d_msg;
- unsigned d_msg_offset;
- bool d_eof;
-
- pmt::pmt_t d_me;
-
- public:
- message_burst_source_impl(size_t itemsize, int msgq_limit);
- message_burst_source_impl(size_t itemsize, msg_queue::sptr msgq);
- ~message_burst_source_impl();
-
- msg_queue::sptr msgq() const { return d_msgq; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/message_sink_impl.cc b/gr-blocks/lib/message_sink_impl.cc
deleted file mode 100644
index 3dc4102c48..0000000000
--- a/gr-blocks/lib/message_sink_impl.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2010,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "message_sink_impl.h"
-#include <gnuradio/io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-
-namespace gr {
- namespace blocks {
-
- message_sink::sptr
- message_sink::make(size_t itemsize, msg_queue::sptr msgq, bool dont_block)
- {
- return gnuradio::get_initial_sptr
- (new message_sink_impl(itemsize, msgq, dont_block));
- }
-
- message_sink::sptr
- message_sink::make(size_t itemsize, msg_queue::sptr msgq, bool dont_block,
- const std::string& lengthtagname)
- {
- return gnuradio::get_initial_sptr
- (new message_sink_impl(itemsize, msgq, dont_block, lengthtagname));
- }
-
- message_sink_impl::message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block)
- : sync_block("message_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
- d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block),
- d_tags(false), d_items_read(0)
- {
- }
-
- message_sink_impl::message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block,
- const std::string& lengthtagname)
- : sync_block("message_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
- d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block),
- d_tags(true), d_lengthtagname(lengthtagname), d_items_read(0)
- {
- }
-
- message_sink_impl::~message_sink_impl()
- {
- }
-
- int
- message_sink_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const char *in = (const char *) input_items[0];
-
- if (d_tags) {
- long packet_length = 0;
- std::vector<tag_t> tags;
- this->get_tags_in_range(tags, 0, d_items_read, d_items_read+1);
- //const size_t ninput_items = noutput_items; //assumption for sync block, this can change
- for (unsigned int i = 0; i < tags.size(); i++) {
- if (pmt::symbol_to_string(tags[i].key) == d_lengthtagname) {
- packet_length = pmt::to_long(tags[i].value);
- }
- }
- assert(packet_length != 0);
-
- // FIXME run this multiple times if input_items >= N * packet_length
- if (noutput_items >= packet_length ) {
- // If the message queue is full we drop the packet.
- if (!d_msgq->full_p()) {
- message::sptr msg = message::make(0, // msg type
- d_itemsize, // arg1 for other end
- packet_length, // arg2 for other end (redundant)
- packet_length * d_itemsize); // len of msg
- memcpy(msg->msg(), in, packet_length * d_itemsize);
- d_msgq->handle(msg); // send it
- }
- d_items_read += packet_length;
- return packet_length;
- } else {
- return 0;
- }
- } else {
- // If the queue if full we drop all the data we got.
- if (!d_msgq->full_p()) {
- // build a message to hold whatever we've got
- message::sptr msg = message::make(0, // msg type
- d_itemsize, // arg1 for other end
- noutput_items, // arg2 for other end (redundant)
- noutput_items * d_itemsize); // len of msg
- memcpy(msg->msg(), in, noutput_items * d_itemsize);
-
- d_msgq->handle(msg); // send it
- }
-
- return noutput_items;
- }
- }
-
- } /* namespace blocks */
-} /* namespace gr */
-
diff --git a/gr-blocks/lib/message_sink_impl.h b/gr-blocks/lib/message_sink_impl.h
deleted file mode 100644
index e0ae3d00c0..0000000000
--- a/gr-blocks/lib/message_sink_impl.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_MESSAGE_SINK_IMPL_H
-#define INCLUDED_GR_MESSAGE_SINK_IMPL_H
-
-#include <gnuradio/blocks/message_sink.h>
-
-namespace gr {
- namespace blocks {
-
- class message_sink_impl : public message_sink
- {
- private:
- size_t d_itemsize;
- msg_queue::sptr d_msgq;
- bool d_dont_block;
- bool d_tags;
- std::string d_lengthtagname;
- uint64_t d_items_read;
-
- public:
- message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block);
- message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block,
- const std::string& lengthtagname);
-
- ~message_sink_impl();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_MESSAGE_SINK_IMPL_H */
diff --git a/gr-blocks/lib/message_source_impl.cc b/gr-blocks/lib/message_source_impl.cc
deleted file mode 100644
index b4e9ba6ed7..0000000000
--- a/gr-blocks/lib/message_source_impl.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2010,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "message_source_impl.h"
-#include <gnuradio/io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-
-namespace gr {
- namespace blocks {
-
- message_source::sptr
- message_source::make(size_t itemsize, int msgq_limit)
- {
- return gnuradio::get_initial_sptr
- (new message_source_impl(itemsize, msgq_limit));
- }
-
- message_source::sptr
- message_source::make(size_t itemsize, msg_queue::sptr msgq)
- {
- return gnuradio::get_initial_sptr
- (new message_source_impl(itemsize, msgq));
- }
-
- message_source::sptr
- message_source::make(size_t itemsize, msg_queue::sptr msgq,
- const std::string& lengthtagname)
- {
- return gnuradio::get_initial_sptr
- (new message_source_impl(itemsize, msgq, lengthtagname));
- }
-
- message_source_impl::message_source_impl(size_t itemsize, int msgq_limit)
- : sync_block("message_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msg_queue::make(msgq_limit)),
- d_msg_offset(0), d_eof(false), d_tags(false)
- {
- }
-
- message_source_impl::message_source_impl(size_t itemsize, msg_queue::sptr msgq)
- : sync_block("message_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq),
- d_msg_offset(0), d_eof(false), d_tags(false)
- {
- }
-
- message_source_impl::message_source_impl(size_t itemsize, msg_queue::sptr msgq,
- const std::string& lengthtagname)
- : sync_block("message_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false),
- d_tags(true), d_lengthtagname(lengthtagname)
- {
- }
-
- message_source_impl::~message_source_impl()
- {
- }
-
- int
- message_source_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- char *out = (char*)output_items[0];
- int nn = 0;
-
- while(nn < noutput_items) {
- if (d_msg){
- //
- // Consume whatever we can from the current message
- //
- int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize));
- memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
-
- if (d_tags && (d_msg_offset == 0)) {
- const uint64_t offset = this->nitems_written(0) + nn;
- pmt::pmt_t key = pmt::string_to_symbol(d_lengthtagname);
- pmt::pmt_t value = pmt::from_long(d_msg->length());
- this->add_item_tag(0, offset, key, value);
- }
- nn += mm;
- out += mm * d_itemsize;
- d_msg_offset += mm * d_itemsize;
- assert(d_msg_offset <= d_msg->length());
-
- if (d_msg_offset == d_msg->length()){
- if (d_msg->type() == 1) // type == 1 sets EOF
- d_eof = true;
- d_msg.reset();
- }
- }
- else {
- //
- // No current message
- //
- if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got
- break;
- }
-
- if (d_eof)
- return -1;
-
- d_msg = d_msgq->delete_head(); // block, waiting for a message
- d_msg_offset = 0;
-
- if ((d_msg->length() % d_itemsize) != 0)
- throw std::runtime_error("msg length is not a multiple of d_itemsize");
- }
-
- }
-
- return nn;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/message_source_impl.h b/gr-blocks/lib/message_source_impl.h
deleted file mode 100644
index bbc8f728d5..0000000000
--- a/gr-blocks/lib/message_source_impl.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_MESSAGE_SOURCE_IMPL_H
-#define INCLUDED_GR_MESSAGE_SOURCE_IMPL_H
-
-#include <gnuradio/blocks/message_source.h>
-#include <gnuradio/message.h>
-
-namespace gr {
- namespace blocks {
-
- class message_source_impl : public message_source
- {
- private:
- size_t d_itemsize;
- msg_queue::sptr d_msgq;
- message::sptr d_msg;
- unsigned d_msg_offset;
- bool d_eof;
- bool d_tags;
- // FIXME: Is this adequate tagname length.
- std::string d_lengthtagname;
-
- public:
- message_source_impl(size_t itemsize, int msgq_limit);
- message_source_impl(size_t itemsize, msg_queue::sptr msgq);
- message_source_impl(size_t itemsize, msg_queue::sptr msgq,
- const std::string& lengthtagname);
-
- ~message_source_impl();
-
- msg_queue::sptr msgq() const { return d_msgq; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_MESSAGE_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
index cee7bfccf3..bedec78a57 100644
--- a/gr-blocks/lib/message_strobe_impl.cc
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -39,13 +39,13 @@ namespace gr {
namespace blocks {
message_strobe::sptr
- message_strobe::make(pmt::pmt_t msg, float period_ms)
+ message_strobe::make(pmt::pmt_t msg, long period_ms)
{
return gnuradio::get_initial_sptr
(new message_strobe_impl(msg, period_ms));
}
- message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, float period_ms)
+ message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, long period_ms)
: block("message_strobe",
io_signature::make(0, 0, 0),
io_signature::make(0, 0, 0)),
diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h
index 0ae27817b7..0ee1cf1f3d 100644
--- a/gr-blocks/lib/message_strobe_impl.h
+++ b/gr-blocks/lib/message_strobe_impl.h
@@ -33,20 +33,20 @@ namespace gr {
private:
boost::shared_ptr<gr::thread::thread> d_thread;
bool d_finished;
- float d_period_ms;
+ long d_period_ms;
pmt::pmt_t d_msg;
const pmt::pmt_t d_port;
void run();
public:
- message_strobe_impl(pmt::pmt_t msg, float period_ms);
+ message_strobe_impl(pmt::pmt_t msg, long period_ms);
~message_strobe_impl();
void set_msg(pmt::pmt_t msg) { d_msg = msg; }
pmt::pmt_t msg() const { return d_msg; }
- void set_period(float period_ms) { d_period_ms = period_ms; }
- float period() const { return d_period_ms; }
+ void set_period(long period_ms) { d_period_ms = period_ms; }
+ long period() const { return d_period_ms; }
// Overloading these to start and stop the internal thread that
// periodically produces the message.
diff --git a/gr-blocks/lib/message_strobe_random_impl.cc b/gr-blocks/lib/message_strobe_random_impl.cc
index 08bfd1ff1f..5c2055ddbd 100644
--- a/gr-blocks/lib/message_strobe_random_impl.cc
+++ b/gr-blocks/lib/message_strobe_random_impl.cc
@@ -71,15 +71,15 @@ namespace gr {
boost::bind(&message_strobe_random_impl::set_msg, this, _1));
}
- float message_strobe_random_impl::next_delay(){
+ long message_strobe_random_impl::next_delay(){
switch(d_dist){
case STROBE_POISSON:
//return d_variate_poisson->operator()();
- return d_variate_poisson->operator()();
+ return static_cast<long>(d_variate_poisson->operator()());
case STROBE_GAUSSIAN:
- return d_variate_normal->operator()();
+ return static_cast<long>(d_variate_normal->operator()());
case STROBE_UNIFORM:
- return d_variate_uniform->operator()();
+ return static_cast<long>(d_variate_uniform->operator()());
default:
throw std::runtime_error("message_strobe_random_impl::d_distribution is very unhappy with you");
}
@@ -110,7 +110,7 @@ namespace gr {
void message_strobe_random_impl::run()
{
while(!d_finished) {
- boost::this_thread::sleep(boost::posix_time::milliseconds(static_cast<long>(std::max(0.0f,next_delay()))));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(std::max(0L, next_delay())));
if(d_finished) {
return;
}
diff --git a/gr-blocks/lib/message_strobe_random_impl.h b/gr-blocks/lib/message_strobe_random_impl.h
index 67e0e490c1..08f966921c 100644
--- a/gr-blocks/lib/message_strobe_random_impl.h
+++ b/gr-blocks/lib/message_strobe_random_impl.h
@@ -43,7 +43,7 @@ namespace gr {
message_strobe_random_distribution_t d_dist;
pmt::pmt_t d_msg;
void run();
- float next_delay();
+ long next_delay();
boost::mt19937 d_rng;
boost::shared_ptr< boost::variate_generator <boost::mt19937, boost::poisson_distribution<> > > d_variate_poisson;
diff --git a/gr-blocks/lib/min_XX_impl.cc.t b/gr-blocks/lib/min_blk_impl.cc
index 0f7059f7cd..df3b6b0896 100644
--- a/gr-blocks/lib/min_XX_impl.cc.t
+++ b/gr-blocks/lib/min_blk_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014,2015,2016 Free Software Foundation, Inc.
+ * Copyright 2014,2015,2016,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,77 +20,78 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include <min_blk_impl.h>
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(size_t vlen, size_t vlen_out)
+ template <class T>
+ typename min_blk<T>::sptr
+ min_blk<T>::make(size_t vlen, size_t vlen_out)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(vlen,vlen_out));
+ (new min_blk_impl<T> (vlen,vlen_out));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen, size_t vlen_out)
- : sync_block("@BASE_NAME@",
- io_signature::make(1, -1, vlen*sizeof(@I_TYPE@)),
- io_signature::make(1, 1, vlen_out*sizeof(@O_TYPE@))),
+ template <class T>
+ min_blk_impl<T> ::min_blk_impl(size_t vlen, size_t vlen_out)
+ : sync_block("min",
+ io_signature::make(1, -1, vlen*sizeof(T)),
+ io_signature::make(1, 1, vlen_out*sizeof(T))),
d_vlen(vlen), d_vlen_out(vlen_out)
{
assert((vlen_out == vlen) || (vlen_out == 1));
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ min_blk_impl<T> ::~min_blk_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ min_blk_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+ T *optr = (T *)output_items[0];
int ninputs = input_items.size();
if(d_vlen_out == 1)
for(int i = 0; i < noutput_items; i++) {
- @I_TYPE@ min = ((@I_TYPE@ *)input_items[0])[i*d_vlen];
-
+ T min = ((T *)input_items[0])[i*d_vlen];
for(int j = 0; j < (int)d_vlen; j++ ) {
for(int k = 0; k < ninputs; k++) {
- if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] < min) {
- min = ((@I_TYPE@*)input_items[k])[i*d_vlen + j];
+ if(((T *)input_items[k])[i*d_vlen + j] < min) {
+ min = ((T*)input_items[k])[i*d_vlen + j];
}
}
}
-
- *optr++ = (@O_TYPE@)min;
+ *optr++ = (T)min;
}
else // vector mode output
for(size_t i = 0; i < noutput_items * d_vlen_out; i++) {
- @I_TYPE@ min = ((@I_TYPE@ *)input_items[0])[i];
-
+ T min = ((T *)input_items[0])[i];
for(int k = 1; k < ninputs; k++) {
- if(((@I_TYPE@ *)input_items[k])[i] < min) {
- min = ((@I_TYPE@*)input_items[k])[i];
+ if(((T *)input_items[k])[i] < min) {
+ min = ((T*)input_items[k])[i];
}
}
-
- *optr++ = (@O_TYPE@)min;
+ *optr++ = (T)min;
}
-
return noutput_items;
}
+template class min_blk<std::int16_t>;
+template class min_blk<std::int32_t>;
+template class min_blk<float>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/max_XX_impl.h.t b/gr-blocks/lib/min_blk_impl.h
index c829ab0514..151b97b391 100644
--- a/gr-blocks/lib/max_XX_impl.h.t
+++ b/gr-blocks/lib/min_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014,2015 Free Software Foundation, Inc.
+ * Copyright 2014,2015,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,24 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef MIN_BLK_IMPL_H
+#define MIN_BLK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/min_blk.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class min_blk_impl : public min_blk<T>
{
private:
size_t d_vlen, d_vlen_out;
public:
- @NAME_IMPL@(size_t vlen, size_t vlen_out);
- ~@NAME_IMPL@();
+ min_blk_impl (size_t vlen, size_t vlen_out);
+ ~min_blk_impl ();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -47,4 +47,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* MIN_BLK_IMPL_H */
diff --git a/gr-blocks/lib/moving_average_XX_impl.cc.t b/gr-blocks/lib/moving_average_impl.cc
index fe0a2bdebd..b77a70a440 100644
--- a/gr-blocks/lib/moving_average_XX_impl.cc.t
+++ b/gr-blocks/lib/moving_average_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2010,2013,2017 Free Software Foundation, Inc.
+ * Copyright 2008,2010,2013,2017,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,29 +20,30 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "@NAME_IMPL@.h"
+#include "moving_average_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(int length, @O_TYPE@ scale, int max_iter, unsigned int vlen)
+ template <class T>
+ typename moving_average<T>::sptr
+ moving_average<T>::make(int length, T scale, int max_iter, unsigned int vlen)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(length, scale, max_iter, vlen));
+ (new moving_average_impl<T> (length, scale, max_iter, vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(int length, @O_TYPE@ scale, int max_iter, unsigned int vlen)
- : sync_block("@NAME@",
- io_signature::make(1, 1, sizeof(@I_TYPE@)*vlen),
- io_signature::make(1, 1, sizeof(@O_TYPE@)*vlen)),
+ template <class T>
+ moving_average_impl<T>::moving_average_impl(int length, T scale, int max_iter, unsigned int vlen)
+ : sync_block("moving_average",
+ io_signature::make(1, 1, sizeof(T)*vlen),
+ io_signature::make(1, 1, sizeof(T)*vlen)),
d_length(length),
d_scale(scale),
d_max_iter(max_iter),
@@ -51,59 +52,64 @@ namespace gr {
d_new_scale(scale),
d_updated(false)
{
- set_history(length);
+ this->set_history(length);
//we don't have C++11's <array>, so initialize the stored vector instead
//we store this vector so that work() doesn't spend its time allocating and freeing vector storage
if(d_vlen > 1) {
- d_sum = std::vector<@I_TYPE@>(d_vlen);
+ d_sum = std::vector<T>(d_vlen);
}
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ moving_average_impl<T> ::~moving_average_impl()
{
}
+ template <class T>
void
- @NAME_IMPL@::set_length_and_scale(int length, @O_TYPE@ scale)
+ moving_average_impl<T> ::set_length_and_scale(int length, T scale)
{
d_new_length = length;
d_new_scale = scale;
d_updated = true;
}
+ template <class T>
void
- @NAME_IMPL@::set_length(int length)
+ moving_average_impl<T> ::set_length(int length)
{
d_new_length = length;
d_updated = true;
}
+ template <class T>
void
- @NAME_IMPL@::set_scale(@O_TYPE@ scale)
+ moving_average_impl<T> ::set_scale(T scale)
{
d_new_scale = scale;
d_updated = true;
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ moving_average_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
if(d_updated) {
d_length = d_new_length;
d_scale = d_new_scale;
- set_history(d_length);
+ this->set_history(d_length);
d_updated = false;
return 0; // history requirements might have changed
}
- const @I_TYPE@ *in = (const @I_TYPE@ *)input_items[0];
- @O_TYPE@ *out = (@O_TYPE@ *)output_items[0];
+ const T *in = (const T *)input_items[0];
+ T *out = (T *)output_items[0];
unsigned int num_iter = (unsigned int)((noutput_items>d_max_iter) ? d_max_iter : noutput_items);
if(d_vlen == 1) {
- @I_TYPE@ sum = in[0];
+ T sum = in[0];
for(int i = 1; i < d_length-1; i++) {
sum += in[i];
}
@@ -137,5 +143,9 @@ namespace gr {
return num_iter;
}
+template class moving_average<std::int16_t>;
+template class moving_average<std::int32_t>;
+template class moving_average<float>;
+template class moving_average<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/moving_average_XX_impl.h.t b/gr-blocks/lib/moving_average_impl.h
index f90a666bbf..a4e248d05d 100644
--- a/gr-blocks/lib/moving_average_XX_impl.h.t
+++ b/gr-blocks/lib/moving_average_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2013,2017 Free Software Foundation, Inc.
+ * Copyright 2008,2013,2017-2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,45 +20,45 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef MOVING_AVERAGE_IMPL_H
+#define MOVING_AVERAGE_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/moving_average.h>
#include <vector>
#include <algorithm>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class moving_average_impl : public moving_average<T>
{
private:
int d_length;
- @O_TYPE@ d_scale;
+ T d_scale;
int d_max_iter;
unsigned int d_vlen;
- std::vector<@I_TYPE@> d_sum;
+ std::vector<T> d_sum;
int d_new_length;
- @O_TYPE@ d_new_scale;
+ T d_new_scale;
bool d_updated;
public:
- @NAME_IMPL@(int length, @O_TYPE@ scale,
+ moving_average_impl (int length, T scale,
int max_iter = 4096,
unsigned int vlen = 1);
- ~@NAME_IMPL@();
+ ~moving_average_impl ();
int length() const { return d_new_length; }
- @O_TYPE@ scale() const { return d_new_scale; }
+ T scale() const { return d_new_scale; }
unsigned int vlen() const { return d_vlen; }
- void set_length_and_scale(int length, @O_TYPE@ scale);
+ void set_length_and_scale(int length, T scale);
void set_length(int length);
- void set_scale(@O_TYPE@ scale);
+ void set_scale(T scale);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -69,4 +69,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* MOVING_AVERAGE_IMPL_H */
diff --git a/gr-blocks/lib/multiply_XX_impl.h.t b/gr-blocks/lib/multiply_XX_impl.h.t
deleted file mode 100644
index 2b0ea25a1b..0000000000
--- a/gr-blocks/lib/multiply_XX_impl.h.t
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
- {
- size_t d_vlen;
-
- public:
- @NAME_IMPL@(size_t vlen);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/multiply_cc_impl.cc b/gr-blocks/lib/multiply_cc_impl.cc
deleted file mode 100644
index 1f58ffd386..0000000000
--- a/gr-blocks/lib/multiply_cc_impl.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <multiply_cc_impl.h>
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- multiply_cc::sptr multiply_cc::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_cc_impl(vlen));
- }
-
- multiply_cc_impl::multiply_cc_impl(size_t vlen)
- : sync_block("multiply_cc",
- io_signature::make (1, -1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- multiply_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *out = (gr_complex *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- memcpy(out, input_items[0], noi*sizeof(gr_complex));
- for(size_t i = 1; i < input_items.size(); i++)
- volk_32fc_x2_multiply_32fc(out, out, (gr_complex*)input_items[i], noi);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
diff --git a/gr-blocks/lib/multiply_cc_impl.h b/gr-blocks/lib/multiply_cc_impl.h
deleted file mode 100644
index 86b4334bf8..0000000000
--- a/gr-blocks/lib/multiply_cc_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_BLOCKS_MULTIPLY_CC_IMPL_H
-#define INCLUDED_BLOCKS_MULTIPLY_CC_IMPL_H
-
-#include <gnuradio/blocks/multiply_cc.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API multiply_cc_impl : public multiply_cc
- {
- size_t d_vlen;
-
- public:
- multiply_cc_impl(size_t vlen);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-
-#endif /* INCLUDED_BLOCKS_MULTIPLY_CC_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_XX_impl.cc.t b/gr-blocks/lib/multiply_const_XX_impl.cc.t
deleted file mode 100644
index 3835ce028e..0000000000
--- a/gr-blocks/lib/multiply_const_XX_impl.cc.t
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(@O_TYPE@ k, size_t vlen)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(k, vlen));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(@O_TYPE@ k, size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, 1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
- d_k(k),
- d_vlen(vlen)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0];
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
-
- int size = noutput_items*d_vlen;
-
- while (size >= 8){
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- size -= 8;
- }
-
- while (size-- > 0)
- *optr++ = *iptr++ * d_k;
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.cc b/gr-blocks/lib/multiply_const_cc_impl.cc
deleted file mode 100644
index e7c5e3b08e..0000000000
--- a/gr-blocks/lib/multiply_const_cc_impl.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2010,2012,2015 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <multiply_const_cc_impl.h>
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- multiply_const_cc::sptr multiply_const_cc::make(gr_complex k, size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_const_cc_impl(k, vlen));
- }
-
- multiply_const_cc_impl::multiply_const_cc_impl(gr_complex k, size_t vlen)
- : sync_block ("multiply_const_cc",
- io_signature::make (1, 1, sizeof (gr_complex)*vlen),
- io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
- d_k(k), d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- multiply_const_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- gr_complex *out = (gr_complex *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- volk_32fc_s32fc_multiply_32fc(out, in, d_k, noi);
-
- return noutput_items;
- }
-
- void
- multiply_const_cc_impl::setup_rpc()
- {
-#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<multiply_const_cc, gr_complex>(
- alias(), "Constant",
- &multiply_const_cc::k,
- pmt::from_complex(-1024.0f, 0.0f),
- pmt::from_complex(1024.0f, 0.0f),
- pmt::from_complex(0.0f, 0.0f),
- "", "Constant to multiply", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
-
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<multiply_const_cc, gr_complex>(
- alias(), "Constant",
- &multiply_const_cc::set_k,
- pmt::from_complex(-1024.0f, 0.0f),
- pmt::from_complex(1024.0f, 0.0f),
- pmt::from_complex(0.0f, 0.0f),
- "", "Constant to multiply",
- RPC_PRIVLVL_MIN, DISPNULL)));
-#endif /* GR_CTRLPORT */
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h b/gr-blocks/lib/multiply_const_cc_impl.h
deleted file mode 100644
index 06f60b13dc..0000000000
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_cc.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API multiply_const_cc_impl : public multiply_const_cc
- {
- gr_complex d_k;
- size_t d_vlen;
-
- public:
- multiply_const_cc_impl(gr_complex k, size_t vlen);
-
- void setup_rpc();
-
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_MULTIPLY_CONST_CC_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_ff_impl.cc b/gr-blocks/lib/multiply_const_ff_impl.cc
deleted file mode 100644
index c5d0ce1e9a..0000000000
--- a/gr-blocks/lib/multiply_const_ff_impl.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2010,2012,2015 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <multiply_const_ff_impl.h>
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- multiply_const_ff::sptr multiply_const_ff::make(float k, size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_const_ff_impl(k, vlen));
- }
-
- multiply_const_ff_impl::multiply_const_ff_impl(float k, size_t vlen)
- : sync_block ("multiply_const_ff",
- io_signature::make (1, 1, sizeof (float)*vlen),
- io_signature::make (1, 1, sizeof (float)*vlen)),
- d_k(k), d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- multiply_const_ff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const float *in = (const float *) input_items[0];
- float *out = (float *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- volk_32f_s32f_multiply_32f(out, in, d_k, noi);
-
- return noutput_items;
- }
-
- void
- multiply_const_ff_impl::setup_rpc()
- {
-#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<multiply_const_ff, float>(
- alias(), "coefficient",
- &multiply_const_ff::k,
- pmt::mp(-1024.0f), pmt::mp(1024.0f), pmt::mp(0.0f),
- "", "Coefficient", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTSTRIP)));
-
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<multiply_const_ff, float>(
- alias(), "coefficient",
- &multiply_const_ff::set_k,
- pmt::mp(-1024.0f), pmt::mp(1024.0f), pmt::mp(0.0f),
- "", "Coefficient",
- RPC_PRIVLVL_MIN, DISPNULL)));
-#endif /* GR_CTRLPORT */
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_ff_impl.h b/gr-blocks/lib/multiply_const_ff_impl.h
deleted file mode 100644
index 4eb1c19f76..0000000000
--- a/gr-blocks/lib/multiply_const_ff_impl.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef INCLUDED_MULTIPLY_CONST_FF_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_FF_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_ff.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API multiply_const_ff_impl : public multiply_const_ff
- {
- float d_k;
- size_t d_vlen;
-
- public:
- multiply_const_ff_impl(float k, size_t vlen);
-
- void setup_rpc();
-
- float k() const { return d_k; }
- void set_k(float k) { d_k = k; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_MULTIPLY_CONST_FF_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_impl.cc b/gr-blocks/lib/multiply_const_impl.cc
new file mode 100644
index 0000000000..03ac054a0e
--- /dev/null
+++ b/gr-blocks/lib/multiply_const_impl.cc
@@ -0,0 +1,139 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "multiply_const_impl.h"
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ template <class T>
+ typename multiply_const<T>::sptr multiply_const<T>::make(T k, size_t vlen)
+ {
+ return gnuradio::get_initial_sptr(new multiply_const_impl<T> (k, vlen));
+ }
+
+ template <>
+ multiply_const_impl<float>::multiply_const_impl(float k, size_t vlen)
+ : sync_block ("multiply_const_ff",
+ io_signature::make (1, 1, sizeof (float)*vlen),
+ io_signature::make (1, 1, sizeof (float)*vlen)),
+ d_k(k), d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1,alignment_multiple));
+ }
+
+ template<>
+ int
+ multiply_const_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float *) input_items[0];
+ float *out = (float *) output_items[0];
+ int noi = noutput_items * d_vlen;
+
+ volk_32f_s32f_multiply_32f(out, in, d_k, noi);
+
+ return noutput_items;
+ }
+
+ template <>
+ multiply_const_impl<gr_complex>::multiply_const_impl(gr_complex k, size_t vlen)
+ : sync_block ("multiply_const_cc",
+ io_signature::make (1, 1, sizeof (gr_complex)*vlen),
+ io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
+ d_k(k), d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
+ }
+
+ template <>
+ int
+ multiply_const_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = noutput_items * d_vlen;
+
+ volk_32fc_s32fc_multiply_32fc(out, in, d_k, noi);
+
+ return noutput_items;
+ }
+
+
+ template <class T>
+ multiply_const_impl<T> ::multiply_const_impl(T k, size_t vlen)
+ : sync_block ("multiply_const",
+ io_signature::make (1, 1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
+ d_k(k), d_vlen(vlen)
+ {
+ }
+
+ template <class T>
+ int
+ multiply_const_impl<T> ::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ T *iptr = (T *) input_items[0];
+ T *optr = (T *) output_items[0];
+
+ int size = noutput_items * d_vlen;
+
+ while (size >= 8){
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ size -= 8;
+ }
+
+ while (size-- > 0)
+ *optr++ = *iptr++ * d_k;
+
+ return noutput_items;
+ }
+
+template class multiply_const<std::int16_t>;
+template class multiply_const<std::int32_t>;
+template class multiply_const<float>;
+template class multiply_const<gr_complex>;
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_XX_impl.h.t b/gr-blocks/lib/multiply_const_impl.h
index ed33652a41..674fc66609 100644
--- a/gr-blocks/lib/multiply_const_XX_impl.h.t
+++ b/gr-blocks/lib/multiply_const_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,26 +20,26 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef MULTIPLY_CONST_IMPL_H
+#define MULTIPLY_CONST_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/multiply_const.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+ class BLOCKS_API multiply_const_impl : public multiply_const<T>
{
- @O_TYPE@ d_k;
+ T d_k;
size_t d_vlen;
public:
- @NAME_IMPL@(@O_TYPE@ k, size_t vlen);
+ multiply_const_impl (T k, size_t vlen);
- @O_TYPE@ k() const { return d_k; }
- void set_k(@O_TYPE@ k) { d_k = k; }
+ T k() const { return d_k; }
+ void set_k(T k) { d_k = k; }
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -49,4 +49,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* MULTIPLY_CONST_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_vXX_impl.cc.t b/gr-blocks/lib/multiply_const_vXX_impl.cc.t
deleted file mode 100644
index 2de0684144..0000000000
--- a/gr-blocks/lib/multiply_const_vXX_impl.cc.t
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(std::vector<@O_TYPE@> k)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(k));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(std::vector<@O_TYPE@> k)
- : sync_block ("@NAME@",
- io_signature::make (1, 1, sizeof (@I_TYPE@)*k.size()),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*k.size())),
- d_k(k)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0];
- @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
-
- int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@);
-
- for (int i = 0; i < noutput_items; i++)
- for (int j = 0; j < nitems_per_block; j++)
- *optr++ = *iptr++ * d_k[j];
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_vXX_impl.h.t b/gr-blocks/lib/multiply_const_vXX_impl.h.t
deleted file mode 100644
index 6c087d9461..0000000000
--- a/gr-blocks/lib/multiply_const_vXX_impl.h.t
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2010,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
- {
- std::vector<@O_TYPE@> d_k;
-
- public:
- @NAME_IMPL@(std::vector<@O_TYPE@> k);
-
- std::vector<@O_TYPE@> k() const { return d_k; }
- void set_k(std::vector<@O_TYPE@> k) { d_k = k; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/multiply_const_v_impl.cc b/gr-blocks/lib/multiply_const_v_impl.cc
new file mode 100644
index 0000000000..24c4a99b78
--- /dev/null
+++ b/gr-blocks/lib/multiply_const_v_impl.cc
@@ -0,0 +1,138 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <multiply_const_v_impl.h>
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ template <class T>
+ typename multiply_const_v<T>::sptr multiply_const_v<T>::make(std::vector<T> k)
+ {
+ return gnuradio::get_initial_sptr(new multiply_const_v_impl<T>(k));
+ }
+
+ template <>
+ multiply_const_v_impl<float>::multiply_const_v_impl(std::vector<float> k)
+ : sync_block("multiply_const_vff",
+ io_signature::make(1, 1, sizeof(float)*k.size()),
+ io_signature::make(1, 1, sizeof(float)*k.size())),
+ d_k(k)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1,alignment_multiple));
+ }
+
+ template <>
+ int
+ multiply_const_v_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float *iptr = (float*)input_items[0];
+ float *optr = (float*)output_items[0];
+
+ int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(float);
+
+ for(int i = 0; i < noutput_items; i++) {
+ for(int j = 0; j < nitems_per_block; j++) {
+ *optr++ = *iptr++ * d_k[j];
+ }
+ }
+
+ return noutput_items;
+ }
+
+ template <>
+ multiply_const_v_impl<gr_complex>::multiply_const_v_impl(std::vector<gr_complex> k)
+ : sync_block("multiply_const_vcc",
+ io_signature::make(1, 1, sizeof(gr_complex)*k.size()),
+ io_signature::make(1, 1, sizeof(gr_complex)*k.size())),
+ d_k(k)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
+ }
+
+ template <>
+ int
+ multiply_const_v_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gr_complex *iptr = (gr_complex*)input_items[0];
+ gr_complex *optr = (gr_complex*)output_items[0];
+
+ int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(gr_complex);
+
+ for(int i = 0; i < noutput_items; i++) {
+ for(int j = 0; j < nitems_per_block; j++) {
+ *optr++ = *iptr++ * d_k[j];
+ }
+ }
+
+ return noutput_items;
+ }
+
+
+
+ template <class T>
+ multiply_const_v_impl<T>::multiply_const_v_impl(std::vector<T> k)
+ : sync_block ("multiply_const_v<T>",
+ io_signature::make (1, 1, sizeof (T)*k.size()),
+ io_signature::make (1, 1, sizeof (T)*k.size())),
+ d_k(k)
+ {
+ }
+
+ template <class T>
+ int
+ multiply_const_v_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ T *iptr = (T *)input_items[0];
+ T *optr = (T *)output_items[0];
+
+ int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(T);
+
+ for (int i = 0; i < noutput_items; i++)
+ for (int j = 0; j < nitems_per_block; j++)
+ *optr++ = *iptr++ * d_k[j];
+
+ return noutput_items;
+ }
+
+ template class multiply_const_v<std::int16_t>;
+ template class multiply_const_v<std::int32_t>;
+ template class multiply_const_v<float>;
+ template class multiply_const_v<gr_complex>;
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_v_impl.h b/gr-blocks/lib/multiply_const_v_impl.h
new file mode 100644
index 0000000000..a329c12dd3
--- /dev/null
+++ b/gr-blocks/lib/multiply_const_v_impl.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2010,2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MULTIPLY_CONST_V_IMPL_H
+#define MULTIPLY_CONST_V_IMPL_H
+
+#include <gnuradio/blocks/multiply_const_v.h>
+
+namespace gr {
+ namespace blocks {
+
+ template <class T>
+ class BLOCKS_API multiply_const_v_impl : public multiply_const_v<T>
+ {
+ std::vector<T> d_k;
+
+ public:
+ multiply_const_v_impl(std::vector<T> k);
+
+ std::vector<T> k() const { return d_k; }
+ void set_k(std::vector<T> k) { d_k = k; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* MULTIPLY_CONST_V_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_vcc_impl.cc b/gr-blocks/lib/multiply_const_vcc_impl.cc
deleted file mode 100644
index b793ec7ddb..0000000000
--- a/gr-blocks/lib/multiply_const_vcc_impl.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014-2015 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <multiply_const_vcc_impl.h>
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- multiply_const_vcc::sptr
- multiply_const_vcc::make(std::vector<gr_complex> k)
- {
- return gnuradio::get_initial_sptr
- (new multiply_const_vcc_impl(k));
- }
-
- multiply_const_vcc_impl::multiply_const_vcc_impl(std::vector<gr_complex> k)
- : sync_block("multiply_const_vcc",
- io_signature::make(1, 1, sizeof(gr_complex)*k.size()),
- io_signature::make(1, 1, sizeof(gr_complex)*k.size())),
- d_k(k)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- multiply_const_vcc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *iptr = (gr_complex*)input_items[0];
- gr_complex *optr = (gr_complex*)output_items[0];
-
- int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(gr_complex);
-
- for(int i = 0; i < noutput_items; i++) {
- for(int j = 0; j < nitems_per_block; j++) {
- *optr++ = *iptr++ * d_k[j];
- }
- }
-
- return noutput_items;
- }
-
- void
- multiply_const_vcc_impl::setup_rpc()
- {
-#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<multiply_const_vcc,
- std::vector<gr_complex> >(
- alias(), "coefficient",
- &multiply_const_vcc::k,
- pmt::from_complex(-1024.0f),
- pmt::from_complex(1024.0f),
- pmt::from_complex(0.0f),
- "", "Coefficient", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTSTRIP)));
-
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<multiply_const_vcc,
- std::vector<gr_complex> >(
- alias(), "coefficient",
- &multiply_const_vcc::set_k,
- pmt::from_complex(-1024.0f),
- pmt::from_complex(1024.0f),
- pmt::from_complex(0.0f),
- "", "Coefficient",
- RPC_PRIVLVL_MIN, DISPNULL)));
-#endif /* GR_CTRLPORT */
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_vcc_impl.h b/gr-blocks/lib/multiply_const_vcc_impl.h
deleted file mode 100644
index c3fc5885b0..0000000000
--- a/gr-blocks/lib/multiply_const_vcc_impl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H
-#define INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_vcc.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API multiply_const_vcc_impl : public multiply_const_vcc
- {
- private:
- std::vector<gr_complex> d_k;
-
- public:
- multiply_const_vcc_impl(std::vector<gr_complex> k);
-
- void setup_rpc();
-
- std::vector<gr_complex> k() const { return d_k; }
- void set_k(std::vector<gr_complex> k) { d_k = k; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_vff_impl.cc b/gr-blocks/lib/multiply_const_vff_impl.cc
deleted file mode 100644
index 6a4719e5d3..0000000000
--- a/gr-blocks/lib/multiply_const_vff_impl.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014-2015 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <multiply_const_vff_impl.h>
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- multiply_const_vff::sptr
- multiply_const_vff::make(std::vector<float> k)
- {
- return gnuradio::get_initial_sptr
- (new multiply_const_vff_impl(k));
- }
-
- multiply_const_vff_impl::multiply_const_vff_impl(std::vector<float> k)
- : sync_block("multiply_const_vff",
- io_signature::make(1, 1, sizeof(float)*k.size()),
- io_signature::make(1, 1, sizeof(float)*k.size())),
- d_k(k)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- multiply_const_vff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *iptr = (float*)input_items[0];
- float *optr = (float*)output_items[0];
-
- int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(float);
-
- for(int i = 0; i < noutput_items; i++) {
- for(int j = 0; j < nitems_per_block; j++) {
- *optr++ = *iptr++ * d_k[j];
- }
- }
-
- return noutput_items;
- }
-
- void
- multiply_const_vff_impl::setup_rpc()
- {
-#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<multiply_const_vff,
- std::vector<float> >(
- alias(), "coefficient",
- &multiply_const_vff::k,
- pmt::mp(-1024.0f), pmt::mp(1024.0f), pmt::mp(0.0f),
- "", "Coefficient", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTSTRIP)));
-
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<multiply_const_vff,
- std::vector<float> >(
- alias(), "coefficient",
- &multiply_const_vff::set_k,
- pmt::mp(-1024.0f), pmt::mp(1024.0f), pmt::mp(0.0f),
- "", "Coefficient",
- RPC_PRIVLVL_MIN, DISPNULL)));
-#endif /* GR_CTRLPORT */
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_vff_impl.h b/gr-blocks/lib/multiply_const_vff_impl.h
deleted file mode 100644
index ca555669ed..0000000000
--- a/gr-blocks/lib/multiply_const_vff_impl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H
-#define INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_vff.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API multiply_const_vff_impl : public multiply_const_vff
- {
- private:
- std::vector<float> d_k;
-
- public:
- multiply_const_vff_impl(std::vector<float> k);
-
- void setup_rpc();
-
- std::vector<float> k() const { return d_k; }
- void set_k(std::vector<float> k) { d_k = k; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H */
diff --git a/gr-blocks/lib/multiply_ff_impl.cc b/gr-blocks/lib/multiply_ff_impl.cc
deleted file mode 100644
index edc0749f2c..0000000000
--- a/gr-blocks/lib/multiply_ff_impl.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <multiply_ff_impl.h>
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace blocks {
-
- multiply_ff::sptr multiply_ff::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_ff_impl(vlen));
- }
-
- multiply_ff_impl::multiply_ff_impl(size_t vlen)
- : sync_block("multiply_ff",
- io_signature::make (1, -1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- multiply_ff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *out = (float *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- memcpy(out, input_items[0], noi*sizeof(float));
- for(size_t i = 1; i < input_items.size(); i++)
- volk_32f_x2_multiply_32f(out, out, (float*)input_items[i], noi);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
diff --git a/gr-blocks/lib/multiply_ff_impl.h b/gr-blocks/lib/multiply_ff_impl.h
deleted file mode 100644
index 1213eef842..0000000000
--- a/gr-blocks/lib/multiply_ff_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_BLOCKS_MULTIPLY_FF_IMPL_H
-#define INCLUDED_BLOCKS_MULTIPLY_FF_IMPL_H
-
-#include <gnuradio/blocks/multiply_ff.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API multiply_ff_impl : public multiply_ff
- {
- size_t d_vlen;
-
- public:
- multiply_ff_impl(size_t vlen);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-
-#endif /* INCLUDED_BLOCKS_MULTIPLY_FF_IMPL_H */
diff --git a/gr-blocks/lib/multiply_impl.cc b/gr-blocks/lib/multiply_impl.cc
new file mode 100644
index 0000000000..22845251fb
--- /dev/null
+++ b/gr-blocks/lib/multiply_impl.cc
@@ -0,0 +1,132 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "multiply_impl.h"
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ template <class T>
+ typename multiply<T>::sptr multiply<T>::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr(new multiply_impl<T> (vlen));
+ }
+
+ template <>
+ multiply_impl<float>::multiply_impl(size_t vlen)
+ : sync_block("multiply_ff",
+ io_signature::make (1, -1, sizeof(float)*vlen),
+ io_signature::make (1, 1, sizeof(float)*vlen)),
+ d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+ }
+
+ template<>
+ int
+ multiply_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(float));
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_multiply_32f(out, out, (float*)input_items[i], noi);
+
+ return noutput_items;
+ }
+
+ template <>
+ multiply_impl<gr_complex>::multiply_impl(size_t vlen)
+ : sync_block("multiply_cc",
+ io_signature::make (1, -1, sizeof(gr_complex)*vlen),
+ io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
+ d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+ }
+
+ template <>
+ int
+ multiply_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(gr_complex));
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32fc_x2_multiply_32fc(out, out, (gr_complex*)input_items[i], noi);
+
+ return noutput_items;
+ }
+
+ template <class T>
+ multiply_impl<T> ::multiply_impl(size_t vlen)
+ : sync_block ("multiply",
+ io_signature::make (1, -1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ template <class T>
+ int
+ multiply_impl<T> ::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ T *optr = (T *) output_items[0];
+
+ int ninputs = input_items.size ();
+
+ for (size_t i = 0; i < noutput_items*d_vlen; i++){
+ T acc = ((T *) input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc *= ((T *) input_items[j])[i];
+
+ *optr++ = (T) acc;
+ }
+
+ return noutput_items;
+ }
+
+template class multiply<std::int16_t>;
+template class multiply<std::int32_t>;
+template class multiply<gr_complex>;
+template class multiply<float>;
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/add_ff_impl.h b/gr-blocks/lib/multiply_impl.h
index 4683688399..7f75f85f9f 100644
--- a/gr-blocks/lib/add_ff_impl.h
+++ b/gr-blocks/lib/multiply_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,28 +20,28 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_BLOCKS_ADD_FF_IMPL_H
-#define INCLUDED_BLOCKS_ADD_FF_IMPL_H
-#include <gnuradio/blocks/add_ff.h>
+#ifndef MULTIPLY_IMPL_H
+#define MULTIPLY_IMPL_H
+
+#include <gnuradio/blocks/multiply.h>
namespace gr {
namespace blocks {
- class BLOCKS_API add_ff_impl : public add_ff
+template<class T>
+ class BLOCKS_API multiply_impl : public multiply<T>
{
size_t d_vlen;
public:
- add_ff_impl(size_t vlen);
+ multiply_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
-
} /* namespace blocks */
} /* namespace gr */
-
-#endif /* INCLUDED_BLOCKS_ADD_FF_IMPL_H */
+#endif /* MULTIPLY_IMPL_H */
diff --git a/gr-blocks/lib/multiply_matrix_cc_impl.cc b/gr-blocks/lib/multiply_matrix_cc_impl.cc
deleted file mode 100644
index 15fc0fc814..0000000000
--- a/gr-blocks/lib/multiply_matrix_cc_impl.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014,2017 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-#include "multiply_matrix_cc_impl.h"
-
-namespace gr {
- namespace blocks {
-
- const std::string multiply_matrix_cc::MSG_PORT_NAME_SET_A = "set_A";
-
- multiply_matrix_cc::sptr
- multiply_matrix_cc::make(std::vector<std::vector<gr_complex> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- {
- if (A.empty() || A[0].size() == 0) {
- throw std::invalid_argument("matrix A has invalid dimensions.");
- }
- return gnuradio::get_initial_sptr
- (new multiply_matrix_cc_impl(A, tag_propagation_policy));
- }
-
- multiply_matrix_cc_impl::multiply_matrix_cc_impl(std::vector<std::vector<gr_complex> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- : gr::sync_block("multiply_matrix_cc",
- gr::io_signature::make(A[0].size(), A[0].size(), sizeof(gr_complex)),
- gr::io_signature::make(A.size(), A.size(), sizeof(gr_complex))),
- d_A(A)
- {
- this->set_tag_propagation_policy(tag_propagation_policy);
- const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
-
- pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
- message_port_register_in(port_name);
- set_msg_handler(
- port_name,
- boost::bind(&multiply_matrix_cc_impl::msg_handler_A, this, _1)
- );
- }
-
- multiply_matrix_cc_impl::~multiply_matrix_cc_impl()
- {
- }
-
- int
- multiply_matrix_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
- gr_complex *out = reinterpret_cast<gr_complex *>(output_items[out_idx]);
- // Do input 0 first, this saves a memset
- const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
- volk_32fc_s32fc_multiply_32fc(out, in, d_A[out_idx][0], noutput_items);
- // Then do inputs 1 through N
- for (size_t in_idx = 1; in_idx < input_items.size(); in_idx++) {
- in = reinterpret_cast<const gr_complex *>(input_items[in_idx]);
- // Yeah, this needs VOLK-ifying (TODO)
- for (int i = 0; i < noutput_items; i++) {
- out[i] += in[i] * d_A[out_idx][in_idx];
- }
- }
- }
- if (tag_propagation_policy() == TPP_CUSTOM) {
- propagate_tags_by_A(noutput_items, input_items.size(), output_items.size());
- }
- return noutput_items;
- }
-
-
- // Copy tags from input k to output l if A[l][k] is not zero
- void
- multiply_matrix_cc_impl::propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports)
- {
- std::vector<gr::tag_t> tags;
- for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
- get_tags_in_window(
- tags,
- in_idx,
- 0,
- noutput_items
- );
-
- for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
- if (d_A[out_idx][in_idx] == std::complex<float>(0, 0)) {
- continue;
- }
- for (size_t i = 0; i < tags.size(); i++) {
- add_item_tag(out_idx, tags[i]);
- }
- }
- }
- }
-
- // Check dimensions before copying
- bool
- multiply_matrix_cc_impl::set_A(const std::vector<std::vector<gr_complex> > &new_A)
- {
- if (d_A.size() != new_A.size()) {
- GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
- return false;
- }
- for (size_t i = 0; i < d_A.size(); i++) {
- if (d_A[i].size() != new_A[i].size()) {
- GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
- return false;
- }
- }
- d_A = new_A;
- return true;
- }
-
- void
- multiply_matrix_cc_impl::msg_handler_A(pmt::pmt_t A)
- {
- if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
- return;
- }
- if (pmt::length(A) != d_A.size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
- return;
- }
-
- std::vector<std::vector<gr_complex> > new_A(d_A);
- for (size_t i = 0; i < pmt::length(A); i++) {
- pmt::pmt_t row;
- if (pmt::is_vector(A)) {
- row = pmt::vector_ref(A, i);
- } else if (pmt::is_tuple(A)) {
- row = pmt::tuple_ref(A, i);
- }
- if (pmt::is_vector(row) || pmt::is_tuple(row)) {
- if (pmt::length(row) != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- for (size_t k = 0; k < pmt::length(row); k++) {
- new_A[i][k] = pmt::to_double(pmt::is_vector(row) ? pmt::vector_ref(row, k) : pmt::tuple_ref(row, k));
- }
- } else if (pmt::is_c32vector(row)) {
- size_t row_len = 0;
- const gr_complex *elements = pmt::c32vector_elements(row, row_len);
- if (row_len != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- new_A[i].assign(elements, elements + row_len);
- }
- }
-
- if (!set_A(new_A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A.");
- }
- }
-
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_matrix_cc_impl.h b/gr-blocks/lib/multiply_matrix_cc_impl.h
deleted file mode 100644
index f342817e26..0000000000
--- a/gr-blocks/lib/multiply_matrix_cc_impl.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014, 2017 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_BLOCKS_MULTIPLY_matrix_cc_IMPL_H
-#define INCLUDED_BLOCKS_MULTIPLY_matrix_cc_IMPL_H
-
-#include <gnuradio/blocks/multiply_matrix_cc.h>
-
-namespace gr {
- namespace blocks {
-
- class multiply_matrix_cc_impl : public multiply_matrix_cc
- {
- private:
- std::vector<std::vector<gr_complex> > d_A;
-
- void propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports);
-
- void msg_handler_A(pmt::pmt_t A);
-
- public:
- multiply_matrix_cc_impl(std::vector<std::vector<gr_complex> > A, gr::block::tag_propagation_policy_t tag_propagation_policy);
- ~multiply_matrix_cc_impl();
-
- const std::vector<std::vector<gr_complex> >& get_A() const { return d_A; };
- bool set_A(const std::vector<std::vector<gr_complex> > &new_A);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } // namespace blocks
-} // namespace gr
-
-#endif /* INCLUDED_BLOCKS_MULTIPLY_matrix_cc_IMPL_H */
-
diff --git a/gr-blocks/lib/multiply_matrix_ff_impl.cc b/gr-blocks/lib/multiply_matrix_ff_impl.cc
deleted file mode 100644
index a5eae4261e..0000000000
--- a/gr-blocks/lib/multiply_matrix_ff_impl.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/io_signature.h>
-#include <volk/volk.h>
-#include "multiply_matrix_ff_impl.h"
-
-namespace gr {
- namespace blocks {
-
- const std::string multiply_matrix_ff::MSG_PORT_NAME_SET_A = "set_A";
-
- multiply_matrix_ff::sptr
- multiply_matrix_ff::make(std::vector<std::vector<float> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- {
- if (A.empty() || A[0].size() == 0) {
- throw std::invalid_argument("matrix A has invalid dimensions.");
- }
- return gnuradio::get_initial_sptr
- (new multiply_matrix_ff_impl(A, tag_propagation_policy));
- }
-
- multiply_matrix_ff_impl::multiply_matrix_ff_impl(std::vector<std::vector<float> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- : gr::sync_block("multiply_matrix_ff",
- gr::io_signature::make(A[0].size(), A[0].size(), sizeof(float)),
- gr::io_signature::make(A.size(), A.size(), sizeof(float))),
- d_A(A)
- {
- this->set_tag_propagation_policy(tag_propagation_policy);
- const int alignment_multiple = volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
-
- pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
- message_port_register_in(port_name);
- set_msg_handler(
- port_name,
- boost::bind(&multiply_matrix_ff_impl::msg_handler_A, this, _1)
- );
- }
-
- multiply_matrix_ff_impl::~multiply_matrix_ff_impl()
- {
- }
-
- int
- multiply_matrix_ff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
- float *out = reinterpret_cast<float *>(output_items[out_idx]);
- // Do input 0 first, this saves a memset
- const float *in = reinterpret_cast<const float *>(input_items[0]);
- volk_32f_s32f_multiply_32f(out, in, d_A[out_idx][0], noutput_items);
- // Then do inputs 1 through N
- for (size_t in_idx = 1; in_idx < input_items.size(); in_idx++) {
- in = reinterpret_cast<const float *>(input_items[in_idx]);
- // Yeah, this needs VOLK-ifying (TODO)
- for (int i = 0; i < noutput_items; i++) {
- out[i] += in[i] * d_A[out_idx][in_idx];
- }
- }
- }
- if (tag_propagation_policy() == TPP_CUSTOM) {
- propagate_tags_by_A(noutput_items, input_items.size(), output_items.size());
- }
- return noutput_items;
- }
-
-
- // Copy tags from input k to output l if A[l][k] is not zero
- void
- multiply_matrix_ff_impl::propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports)
- {
- std::vector<gr::tag_t> tags;
- for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
- get_tags_in_window(
- tags,
- in_idx,
- 0,
- noutput_items
- );
-
- for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
- if (d_A[out_idx][in_idx] == 0) {
- continue;
- }
- for (size_t i = 0; i < tags.size(); i++) {
- add_item_tag(out_idx, tags[i]);
- }
- }
- }
- }
-
- // Check dimensions before copying
- bool
- multiply_matrix_ff_impl::set_A(const std::vector<std::vector<float> > &new_A)
- {
- if (d_A.size() != new_A.size()) {
- GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
- return false;
- }
- for (size_t i = 0; i < d_A.size(); i++) {
- if (d_A[i].size() != new_A[i].size()) {
- GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
- return false;
- }
- }
- d_A = new_A;
- return true;
- }
-
- void
- multiply_matrix_ff_impl::msg_handler_A(pmt::pmt_t A)
- {
- if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
- return;
- }
- if (pmt::length(A) != d_A.size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
- return;
- }
-
- std::vector<std::vector<float> > new_A(d_A);
- for (size_t i = 0; i < pmt::length(A); i++) {
- pmt::pmt_t row;
- if (pmt::is_vector(A)) {
- row = pmt::vector_ref(A, i);
- } else if (pmt::is_tuple(A)) {
- row = pmt::tuple_ref(A, i);
- }
- if (pmt::is_vector(row) || pmt::is_tuple(row)) {
- if (pmt::length(row) != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- for (size_t k = 0; k < pmt::length(row); k++) {
- new_A[i][k] = pmt::to_double(pmt::is_vector(row) ? pmt::vector_ref(row, k) : pmt::tuple_ref(row, k));
- }
- } else if (pmt::is_f32vector(row)) {
- size_t row_len = 0;
- const float *elements = pmt::f32vector_elements(row, row_len);
- if (row_len != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- new_A[i].assign(elements, elements + row_len);
- }
- }
-
- if (!set_A(new_A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A.");
- }
- }
-
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_matrix_impl.cc b/gr-blocks/lib/multiply_matrix_impl.cc
new file mode 100644
index 0000000000..4d7dbb3651
--- /dev/null
+++ b/gr-blocks/lib/multiply_matrix_impl.cc
@@ -0,0 +1,327 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014,2017,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+#include "multiply_matrix_impl.h"
+
+namespace gr {
+ namespace blocks {
+
+ // Copy tags from input k to output l if A[l][k] is not zero
+ template <>
+ void
+ multiply_matrix_impl<gr_complex>::propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports)
+ {
+ std::vector<gr::tag_t> tags;
+ for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
+ this->get_tags_in_window(
+ tags,
+ in_idx,
+ 0,
+ noutput_items
+ );
+
+ for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
+ if (d_A[out_idx][in_idx] == std::complex<float>(0, 0)) {
+ continue;
+ }
+ for (size_t i = 0; i < tags.size(); i++) {
+ this->add_item_tag(out_idx, tags[i]);
+ }
+ }
+ }
+ }
+
+ // Check dimensions before copying
+ template <>
+ bool
+ multiply_matrix_impl<gr_complex>::set_A(const std::vector<std::vector<gr_complex> > &new_A)
+ {
+ if (d_A.size() != new_A.size()) {
+ GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
+ return false;
+ }
+ for (size_t i = 0; i < d_A.size(); i++) {
+ if (d_A[i].size() != new_A[i].size()) {
+ GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
+ return false;
+ }
+ }
+ d_A = new_A;
+ return true;
+ }
+
+ template <>
+ void
+ multiply_matrix_impl<gr_complex>::msg_handler_A(pmt::pmt_t A)
+ {
+ if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
+ return;
+ }
+ if (pmt::length(A) != d_A.size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
+ return;
+ }
+
+ std::vector<std::vector<gr_complex> > new_A(d_A);
+ for (size_t i = 0; i < pmt::length(A); i++) {
+ pmt::pmt_t row;
+ if (pmt::is_vector(A)) {
+ row = pmt::vector_ref(A, i);
+ } else if (pmt::is_tuple(A)) {
+ row = pmt::tuple_ref(A, i);
+ }
+ if (pmt::is_vector(row) || pmt::is_tuple(row)) {
+ if (pmt::length(row) != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ for (size_t k = 0; k < pmt::length(row); k++) {
+ new_A[i][k] = pmt::to_double(pmt::is_vector(row) ? pmt::vector_ref(row, k) : pmt::tuple_ref(row, k));
+ }
+ } else if (pmt::is_c32vector(row)) {
+ size_t row_len = 0;
+ const gr_complex *elements = pmt::c32vector_elements(row, row_len);
+ if (row_len != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ new_A[i].assign(elements, elements + row_len);
+ }
+ }
+
+ if (!set_A(new_A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A.");
+ }
+ }
+
+ // Copy tags from input k to output l if A[l][k] is not zero
+ template <>
+ void
+ multiply_matrix_impl<float>::propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports)
+ {
+ std::vector<gr::tag_t> tags;
+ for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
+ get_tags_in_window(
+ tags,
+ in_idx,
+ 0,
+ noutput_items
+ );
+
+ for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
+ if (d_A[out_idx][in_idx] == 0) {
+ continue;
+ }
+ for (size_t i = 0; i < tags.size(); i++) {
+ add_item_tag(out_idx, tags[i]);
+ }
+ }
+ }
+ }
+
+ // Check dimensions before copying
+ template <>
+ bool
+ multiply_matrix_impl<float>::set_A(const std::vector<std::vector<float> > &new_A)
+ {
+ if (d_A.size() != new_A.size()) {
+ GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
+ return false;
+ }
+ for (size_t i = 0; i < d_A.size(); i++) {
+ if (d_A[i].size() != new_A[i].size()) {
+ GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
+ return false;
+ }
+ }
+ d_A = new_A;
+ return true;
+ }
+
+ template <>
+ void
+ multiply_matrix_impl<float>::msg_handler_A(pmt::pmt_t A)
+ {
+ if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
+ return;
+ }
+ if (pmt::length(A) != d_A.size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
+ return;
+ }
+
+ std::vector<std::vector<float> > new_A(d_A);
+ for (size_t i = 0; i < pmt::length(A); i++) {
+ pmt::pmt_t row;
+ if (pmt::is_vector(A)) {
+ row = pmt::vector_ref(A, i);
+ } else if (pmt::is_tuple(A)) {
+ row = pmt::tuple_ref(A, i);
+ }
+ if (pmt::is_vector(row) || pmt::is_tuple(row)) {
+ if (pmt::length(row) != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ for (size_t k = 0; k < pmt::length(row); k++) {
+ new_A[i][k] = pmt::to_double(pmt::is_vector(row) ? pmt::vector_ref(row, k) : pmt::tuple_ref(row, k));
+ }
+ } else if (pmt::is_f32vector(row)) {
+ size_t row_len = 0;
+ const float *elements = pmt::f32vector_elements(row, row_len);
+ if (row_len != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ new_A[i].assign(elements, elements + row_len);
+ }
+ }
+
+ if (!set_A(new_A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A.");
+ }
+ }
+
+
+
+ template <class T>
+ typename multiply_matrix<T>::sptr
+ multiply_matrix<T>::make(std::vector<std::vector<T> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
+ {
+ if (A.empty() || A[0].size() == 0) {
+ throw std::invalid_argument("matrix A has invalid dimensions.");
+ }
+ return gnuradio::get_initial_sptr
+ (new multiply_matrix_impl<T>(A, tag_propagation_policy));
+ }
+
+ template <>
+ multiply_matrix_impl<gr_complex>::multiply_matrix_impl(std::vector<std::vector<gr_complex> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
+ : gr::sync_block("multiply_matrix_cc",
+ gr::io_signature::make(A[0].size(), A[0].size(), sizeof(gr_complex)),
+ gr::io_signature::make(A.size(), A.size(), sizeof(gr_complex))),
+ d_A(A)
+ { this->MSG_PORT_NAME_SET_A = "set_A";
+ this->set_tag_propagation_policy(tag_propagation_policy);
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+
+ pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
+ message_port_register_in(port_name);
+ set_msg_handler(
+ port_name,
+ boost::bind(&multiply_matrix_impl<gr_complex>::msg_handler_A, this, _1)
+ );
+ }
+
+ template <>
+ multiply_matrix_impl<float>::multiply_matrix_impl(std::vector<std::vector<float> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
+ : gr::sync_block("multiply_matrix_ff",
+ gr::io_signature::make(A[0].size(), A[0].size(), sizeof(float)),
+ gr::io_signature::make(A.size(), A.size(), sizeof(float))),
+ d_A(A)
+ { this->MSG_PORT_NAME_SET_A = "set_A";
+ this->set_tag_propagation_policy(tag_propagation_policy);
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+
+ pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
+ message_port_register_in(port_name);
+ set_msg_handler(
+ port_name,
+ boost::bind(&multiply_matrix_impl<float>::msg_handler_A, this, _1)
+ );
+ }
+
+
+
+ template <class T>
+ multiply_matrix_impl<T>::~multiply_matrix_impl()
+ {
+ }
+
+ template <>
+ int
+ multiply_matrix_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
+ gr_complex *out = reinterpret_cast<gr_complex *>(output_items[out_idx]);
+ // Do input 0 first, this saves a memset
+ const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
+ volk_32fc_s32fc_multiply_32fc(out, in, d_A[out_idx][0], noutput_items);
+ // Then do inputs 1 through N
+ for (size_t in_idx = 1; in_idx < input_items.size(); in_idx++) {
+ in = reinterpret_cast<const gr_complex *>(input_items[in_idx]);
+ // Yeah, this needs VOLK-ifying (TODO)
+ for (int i = 0; i < noutput_items; i++) {
+ out[i] += in[i] * d_A[out_idx][in_idx];
+ }
+ }
+ }
+ if (tag_propagation_policy() == TPP_CUSTOM) {
+ propagate_tags_by_A(noutput_items, input_items.size(), output_items.size());
+ }
+ return noutput_items;
+ }
+
+ template <>
+ int
+ multiply_matrix_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
+ float *out = reinterpret_cast<float *>(output_items[out_idx]);
+ // Do input 0 first, this saves a memset
+ const float *in = reinterpret_cast<const float *>(input_items[0]);
+ volk_32f_s32f_multiply_32f(out, in, d_A[out_idx][0], noutput_items);
+ // Then do inputs 1 through N
+ for (size_t in_idx = 1; in_idx < input_items.size(); in_idx++) {
+ in = reinterpret_cast<const float *>(input_items[in_idx]);
+ // Yeah, this needs VOLK-ifying (TODO)
+ for (int i = 0; i < noutput_items; i++) {
+ out[i] += in[i] * d_A[out_idx][in_idx];
+ }
+ }
+ }
+ if (tag_propagation_policy() == TPP_CUSTOM) {
+ propagate_tags_by_A(noutput_items, input_items.size(), output_items.size());
+ }
+ return noutput_items;
+ }
+
+
+ template class multiply_matrix<float>;
+ template class multiply_matrix<gr_complex>;
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_matrix_ff_impl.h b/gr-blocks/lib/multiply_matrix_impl.h
index 93b2bebadd..bb5477e805 100644
--- a/gr-blocks/lib/multiply_matrix_ff_impl.h
+++ b/gr-blocks/lib/multiply_matrix_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014, 2017 Free Software Foundation, Inc.
+ * Copyright 2014,2017-2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,29 +20,30 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_BLOCKS_MULTIPLY_MATRIX_FF_IMPL_H
-#define INCLUDED_BLOCKS_MULTIPLY_MATRIX_FF_IMPL_H
+#ifndef INCLUDED_BLOCKS_MULTIPLY_MATRIX_IMPL_H
+#define INCLUDED_BLOCKS_MULTIPLY_MATRIX_IMPL_H
-#include <gnuradio/blocks/multiply_matrix_ff.h>
+#include <gnuradio/blocks/multiply_matrix.h>
namespace gr {
namespace blocks {
- class multiply_matrix_ff_impl : public multiply_matrix_ff
+ template <class T>
+ class multiply_matrix_impl : public multiply_matrix<T>
{
private:
- std::vector<std::vector<float> > d_A;
+ std::vector<std::vector<T> > d_A;
void propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports);
void msg_handler_A(pmt::pmt_t A);
public:
- multiply_matrix_ff_impl(std::vector<std::vector<float> > A, gr::block::tag_propagation_policy_t tag_propagation_policy);
- ~multiply_matrix_ff_impl();
+ multiply_matrix_impl(std::vector<std::vector<T> > A, gr::block::tag_propagation_policy_t tag_propagation_policy);
+ ~multiply_matrix_impl();
- const std::vector<std::vector<float> >& get_A() const { return d_A; };
- bool set_A(const std::vector<std::vector<float> > &new_A);
+ const std::vector<std::vector<T> >& get_A() const { return d_A; };
+ bool set_A(const std::vector<std::vector<T> > &new_A);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -52,5 +53,4 @@ namespace gr {
} // namespace blocks
} // namespace gr
-#endif /* INCLUDED_BLOCKS_MULTIPLY_MATRIX_FF_IMPL_H */
-
+#endif /* INCLUDED_BLOCKS_MULTIPLY_MATRIX_IMPL_H */
diff --git a/gr-blocks/lib/mute_XX_impl.cc.t b/gr-blocks/lib/mute_impl.cc
index e7c2c4398b..081dd81b35 100644
--- a/gr-blocks/lib/mute_XX_impl.cc.t
+++ b/gr-blocks/lib/mute_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,53 +20,56 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "mute_impl.h"
#include <gnuradio/io_signature.h>
#include <string.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(bool mute)
+ template <class T>
+ typename mute_blk<T>::sptr
+ mute_blk<T>::make(bool mute)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(mute));
+ (new mute_impl<T> (mute));
}
- @NAME_IMPL@::@NAME_IMPL@(bool mute)
- : sync_block("@BASE_NAME@",
- io_signature::make(1, 1, sizeof(@I_TYPE@)),
- io_signature::make(1, 1, sizeof(@O_TYPE@))),
+ template <class T>
+ mute_impl<T> ::mute_impl(bool mute)
+ : sync_block("mute",
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(1, 1, sizeof(T))),
d_mute(mute)
{
- message_port_register_in(pmt::intern("set_mute"));
- set_msg_handler(pmt::intern("set_mute"),
- boost::bind(&@NAME_IMPL@::set_mute_pmt, this, _1));
+ this->message_port_register_in(pmt::intern("set_mute"));
+ this->set_msg_handler(pmt::intern("set_mute"),
+ boost::bind(&mute_impl<T> ::set_mute_pmt, this, _1));
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ mute_impl<T> ::~mute_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ mute_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0];
- @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+ T *iptr = (T *)input_items[0];
+ T *optr = (T *)output_items[0];
int size = noutput_items;
if(d_mute) {
- memset(optr, 0, noutput_items * sizeof(@O_TYPE@));
+ memset(optr, 0, noutput_items * sizeof(T));
}
else {
while(size >= 8) {
@@ -88,5 +91,9 @@ namespace gr {
return noutput_items;
}
+template class mute_blk<std::int16_t>;
+template class mute_blk<std::int32_t>;
+template class mute_blk<float>;
+template class mute_blk<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/mute_XX_impl.h.t b/gr-blocks/lib/mute_impl.h
index 8234583bbf..6943e22739 100644
--- a/gr-blocks/lib/mute_XX_impl.h.t
+++ b/gr-blocks/lib/mute_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,24 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef MUTE_IMPL_H
+#define MUTE_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/mute.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class mute_impl : public mute_blk<T>
{
private:
bool d_mute;
public:
- @NAME_IMPL@(bool mute);
- ~@NAME_IMPL@();
+ mute_impl (bool mute);
+ ~mute_impl ();
bool mute() const { return d_mute; }
void set_mute(bool mute) { d_mute = mute; }
@@ -51,4 +51,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* MUTE_IMPL_H */
diff --git a/gr-blocks/lib/nlog10_ff_impl.cc b/gr-blocks/lib/nlog10_ff_impl.cc
index bed2da4d0d..5bc234f2cb 100644
--- a/gr-blocks/lib/nlog10_ff_impl.cc
+++ b/gr-blocks/lib/nlog10_ff_impl.cc
@@ -26,6 +26,7 @@
#include "nlog10_ff_impl.h"
#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
namespace gr {
namespace blocks {
@@ -39,8 +40,23 @@ namespace gr {
: sync_block("nlog10_ff",
io_signature::make (1, 1, sizeof(float)*vlen),
io_signature::make (1, 1, sizeof(float)*vlen)),
- d_n(n), d_vlen(vlen), d_k(k)
+ d_vlen(vlen)
{
+ setk(k);
+ setn(n);
+ //TODO message handlers
+ }
+
+ void
+ nlog10_ff_impl::setk(float k)
+ {
+ d_k = k;
+ }
+
+ void
+ nlog10_ff_impl::setn(float n)
+ {
+ d_prefactor = n / log2f(10.0f);
}
int
@@ -51,12 +67,14 @@ namespace gr {
const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
- float n = d_n;
- float k = d_k;
-
- for (int i = 0; i < noi; i++)
- out[i] = n * log10(std::max(in[i], (float) 1e-18)) + k;
+ volk_32f_log2_32f(out, in, noi);
+ volk_32f_s32f_multiply_32f(out, out, d_prefactor, noi);
+ if(d_k != 0.0f) {
+ for(int i = 0; i < noi; ++i) {
+ out[i] += d_k;
+ }
+ }
return noutput_items;
}
diff --git a/gr-blocks/lib/nlog10_ff_impl.h b/gr-blocks/lib/nlog10_ff_impl.h
index dd260bea1f..21c64d42f5 100644
--- a/gr-blocks/lib/nlog10_ff_impl.h
+++ b/gr-blocks/lib/nlog10_ff_impl.h
@@ -30,12 +30,14 @@ namespace gr {
class BLOCKS_API nlog10_ff_impl : public nlog10_ff
{
- float d_n;
+ float d_prefactor;
size_t d_vlen;
float d_k;
public:
nlog10_ff_impl(float n, size_t vlen, float k);
+ void setn(float n);
+ void setk(float k);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gr-blocks/lib/not_XX_impl.cc.t b/gr-blocks/lib/not_blk_impl.cc
index cb9be5cdb8..3c3dea5a15 100644
--- a/gr-blocks/lib/not_XX_impl.cc.t
+++ b/gr-blocks/lib/not_blk_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,38 +20,40 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "not_blk_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr @NAME@::make(size_t vlen)
+ template <class T>
+ typename not_blk<T>::sptr not_blk<T>::make(size_t vlen)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
+ return gnuradio::get_initial_sptr(new not_blk_impl<T> (vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, 1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
+ template <class T>
+ not_blk_impl<T> ::not_blk_impl(size_t vlen)
+ : sync_block ("not_blk",
+ io_signature::make (1, 1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
d_vlen(vlen)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ not_blk_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
- const @I_TYPE@ *inptr = (const @I_TYPE@ *) input_items[0];
+ T *optr = (T *) output_items[0];
+ const T *inptr = (const T *) input_items[0];
int noi = noutput_items*d_vlen;
@@ -61,5 +63,8 @@ namespace gr {
return noutput_items;
}
+template class not_blk<std::uint8_t>;
+template class not_blk<std::int16_t>;
+template class not_blk<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/divide_XX_impl.h.t b/gr-blocks/lib/not_blk_impl.h
index 2680ef7012..77050adee2 100644
--- a/gr-blocks/lib/divide_XX_impl.h.t
+++ b/gr-blocks/lib/not_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,22 +20,22 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef NOT_BLK_IMPL_H
+#define NOT_BLK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/not_blk.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+ class BLOCKS_API not_blk_impl : public not_blk<T>
{
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
+ not_blk_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -45,4 +45,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* NOT_BLK_IMPL_H */
diff --git a/gr-blocks/lib/or_XX_impl.cc.t b/gr-blocks/lib/or_XX_impl.cc.t
deleted file mode 100644
index 2782e1ee5f..0000000000
--- a/gr-blocks/lib/or_XX_impl.cc.t
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
-
- int ninputs = input_items.size ();
-
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc |= ((@I_TYPE@ *) input_items[j])[i];
-
- *optr++ = (@O_TYPE@) acc;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/or_blk_impl.cc b/gr-blocks/lib/or_blk_impl.cc
new file mode 100644
index 0000000000..1e9dab5ea5
--- /dev/null
+++ b/gr-blocks/lib/or_blk_impl.cc
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include <or_blk_impl.h>
+
+namespace gr {
+namespace blocks {
+
+template <class T> typename or_blk<T>::sptr or_blk<T>::make(size_t vlen) {
+ return gnuradio::get_initial_sptr(new or_blk_impl<T>(vlen));
+}
+
+template <class T>
+or_blk_impl<T>::or_blk_impl(size_t vlen)
+ : sync_block("or_blk", io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
+ d_vlen(vlen) {}
+
+template <class T>
+int or_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items) {
+ T *optr = (T *)output_items[0];
+
+ int ninputs = input_items.size();
+
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T *)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc |= ((T *)input_items[j])[i];
+
+ *optr++ = (T)acc;
+ }
+
+ return noutput_items;
+}
+
+template class or_blk<short>;
+template class or_blk<int>;
+template class or_blk<char>;
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/or_XX_impl.h.t b/gr-blocks/lib/or_blk_impl.h
index f7db3f2162..fbff19a24d 100644
--- a/gr-blocks/lib/or_XX_impl.h.t
+++ b/gr-blocks/lib/or_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,22 +20,21 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef OR_BLK_IMPL_H
+#define OR_BLK_IMPL_H
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/or_blk.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+ template<class T>
+ class BLOCKS_API or_blk_impl : public or_blk<T>
{
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
+ or_blk_impl(size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -45,4 +44,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* OR_BLK_IMPL_H */
diff --git a/gr-blocks/lib/packed_to_unpacked_XX_impl.cc.t b/gr-blocks/lib/packed_to_unpacked_impl.cc
index 9478ce25c0..ed84f7ecf0 100644
--- a/gr-blocks/lib/packed_to_unpacked_XX_impl.cc.t
+++ b/gr-blocks/lib/packed_to_unpacked_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,54 +20,53 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "@NAME_IMPL@.h"
+#include "packed_to_unpacked_impl.h"
#include <gnuradio/io_signature.h>
-#include <gnuradio/blocks/log2_const.h>
#include <assert.h>
namespace gr {
namespace blocks {
- static const unsigned int BITS_PER_TYPE = sizeof(@I_TYPE@) * 8;
- static const unsigned int LOG2_L_TYPE = log2_const<sizeof(@I_TYPE@) * 8>();
-
- @NAME@::sptr
- @NAME@::make(unsigned int bits_per_chunk,
+ template <class T>
+ typename packed_to_unpacked<T>::sptr
+ packed_to_unpacked<T>::make(unsigned int bits_per_chunk,
endianness_t endianness)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(bits_per_chunk, endianness));
+ (new packed_to_unpacked_impl<T> (bits_per_chunk, endianness));
}
- @NAME_IMPL@::@NAME_IMPL@(unsigned int bits_per_chunk,
+ template <class T>
+ packed_to_unpacked_impl<T> ::packed_to_unpacked_impl(unsigned int bits_per_chunk,
endianness_t endianness)
- : block("@NAME@",
- io_signature::make(1, -1, sizeof(@I_TYPE@)),
- io_signature::make(1, -1, sizeof(@O_TYPE@))),
+ : block("packed_to_unpacked",
+ io_signature::make(1, -1, sizeof(T)),
+ io_signature::make(1, -1, sizeof(T))),
d_bits_per_chunk(bits_per_chunk), d_endianness(endianness), d_index(0)
{
- assert(bits_per_chunk <= BITS_PER_TYPE);
+ assert(bits_per_chunk <= this->d_bits_per_type);
assert(bits_per_chunk > 0);
- set_relative_rate((uint64_t)BITS_PER_TYPE, (uint64_t)bits_per_chunk);
+ this->set_relative_rate((uint64_t)BITS_PER_TYPE, (uint64_t)bits_per_chunk);
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ packed_to_unpacked_impl<T> ::~packed_to_unpacked_impl()
{
}
+ template <class T>
void
- @NAME_IMPL@::forecast(int noutput_items,
+ packed_to_unpacked_impl<T> ::forecast(int noutput_items,
gr_vector_int &ninput_items_required)
{
int input_required = (int)ceil((d_index + noutput_items * d_bits_per_chunk)
- / (1.0 * BITS_PER_TYPE));
+ / (1.0 * this->d_bits_per_type));
unsigned ninputs = ninput_items_required.size();
for(unsigned int i = 0; i < ninputs; i++) {
ninput_items_required[i] = input_required;
@@ -75,22 +74,25 @@ namespace gr {
}
}
+ template <class T>
unsigned int
- get_bit_le(const @I_TYPE@ *in_vector, unsigned int bit_addr)
+ packed_to_unpacked_impl<T>::get_bit_le(const T *in_vector, unsigned int bit_addr)
{
- @I_TYPE@ x = in_vector[bit_addr >> LOG2_L_TYPE];
- return (x >> (bit_addr & (BITS_PER_TYPE-1))) & 1;
+ T x = in_vector[bit_addr >> this->d_log2_l_type];
+ return (x >> (bit_addr & (this->d_bits_per_type-1))) & 1;
}
+ template <class T>
unsigned int
- get_bit_be(const @I_TYPE@ *in_vector, unsigned int bit_addr)
+ packed_to_unpacked_impl<T>::get_bit_be(const T *in_vector, unsigned int bit_addr)
{
- @I_TYPE@ x = in_vector[bit_addr >> LOG2_L_TYPE];
- return (x >> ((BITS_PER_TYPE-1) - (bit_addr & (BITS_PER_TYPE-1)))) & 1;
+ T x = in_vector[bit_addr >> this->d_log2_l_type];
+ return (x >> ((this->d_bits_per_type-1) - (bit_addr & (this->d_bits_per_type-1)))) & 1;
}
+ template <class T>
int
- @NAME_IMPL@::general_work(int noutput_items,
+ packed_to_unpacked_impl<T> ::general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
@@ -101,8 +103,8 @@ namespace gr {
int nstreams = input_items.size();
for (int m=0; m < nstreams; m++){
- const @I_TYPE@ *in = (@I_TYPE@ *)input_items[m];
- @O_TYPE@ *out = (@O_TYPE@ *)output_items[m];
+ const T *in = (T *)input_items[m];
+ T *out = (T *)output_items[m];
index_tmp = d_index;
// per stream processing
@@ -111,7 +113,7 @@ namespace gr {
case GR_MSB_FIRST:
for(int i = 0; i < noutput_items; i++) {
//printf("here msb %d\n",i);
- @O_TYPE@ x = 0;
+ T x = 0;
for(unsigned int j = 0; j < d_bits_per_chunk; j++, index_tmp++)
x = (x<<1) | get_bit_be(in, index_tmp);
out[i] = x;
@@ -121,7 +123,7 @@ namespace gr {
case GR_LSB_FIRST:
for(int i = 0; i < noutput_items; i++) {
//printf("here lsb %d\n",i);
- @O_TYPE@ x = 0;
+ T x = 0;
for(unsigned int j = 0; j < d_bits_per_chunk; j++, index_tmp++)
x = (x<<1) | get_bit_le(in, index_tmp);
out[i] = x;
@@ -133,15 +135,18 @@ namespace gr {
}
//printf("almost got to end\n");
- assert(ninput_items[m] >= (int)((d_index+(BITS_PER_TYPE-1)) >> LOG2_L_TYPE));
+ assert(ninput_items[m] >= (int)((d_index+(this->d_bits_per_type-1)) >> this->d_log2_l_type));
}
d_index = index_tmp;
- consume_each(d_index >> LOG2_L_TYPE);
- d_index = d_index & (BITS_PER_TYPE-1);
+ this->consume_each(d_index >> this->d_log2_l_type);
+ d_index = d_index & (this->d_bits_per_type-1);
//printf("got to end\n");
return noutput_items;
}
+template class packed_to_unpacked<std::uint8_t>;
+template class packed_to_unpacked<std::int16_t>;
+template class packed_to_unpacked<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/unpacked_to_packed_XX_impl.h.t b/gr-blocks/lib/packed_to_unpacked_impl.h
index 2076c65e9b..fd65242478 100644
--- a/gr-blocks/lib/unpacked_to_packed_XX_impl.h.t
+++ b/gr-blocks/lib/packed_to_unpacked_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006.2013 Free Software Foundation, Inc.
+ * Copyright 2006,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,27 +20,32 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef PACKED_TO_UNPACKED_IMPL_H
+#define PACKED_TO_UNPACKED_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/packed_to_unpacked.h>
+#include <gnuradio/blocks/log2_const.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class packed_to_unpacked_impl : public packed_to_unpacked<T>
{
private:
unsigned int d_bits_per_chunk;
endianness_t d_endianness;
unsigned int d_index;
+ const unsigned int d_bits_per_type = sizeof(T) * 8;
+ const unsigned int d_log2_l_type = log2_const<sizeof(T) * 8>();
+ unsigned int get_bit_le(const T *in_vector, unsigned int bit_addr);
+ unsigned int get_bit_be(const T *in_vector, unsigned int bit_addr);
public:
- @NAME_IMPL@(unsigned int bits_per_chunk,
+ packed_to_unpacked_impl (unsigned int bits_per_chunk,
endianness_t endianness);
- ~@NAME_IMPL@();
+ ~packed_to_unpacked_impl ();
void forecast(int noutput_items,
gr_vector_int &ninput_items_required);
@@ -56,4 +61,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* PACKED_TO_UNPACKED_IMPL_H */
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
index a58f73c991..10232cd970 100644
--- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
@@ -43,7 +43,6 @@ namespace gr {
io_signature::make(1, 1, pdu::itemsize(type)),
tsb_tag_key),
d_itemsize(pdu::itemsize(type)),
- d_type(type),
d_curr_len(0)
{
message_port_register_in(pdu::pdu_port_id());
@@ -52,10 +51,7 @@ namespace gr {
int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
{
if (d_curr_len == 0) {
- /* FIXME: This blocking call is far from ideal but is the best we
- * can do at the moment
- */
- pmt::pmt_t msg(delete_head_blocking(pdu::pdu_port_id(), 100));
+ pmt::pmt_t msg(delete_head_nowait(pdu::pdu_port_id()));
if (msg.get() == NULL) {
return 0;
}
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.h b/gr-blocks/lib/pdu_to_tagged_stream_impl.h
index 99f68147c8..bce8122b13 100644
--- a/gr-blocks/lib/pdu_to_tagged_stream_impl.h
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.h
@@ -31,7 +31,6 @@ namespace gr {
class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream
{
size_t d_itemsize;
- pdu::vector_type d_type;
pmt::pmt_t d_curr_meta;
pmt::pmt_t d_curr_vect;
size_t d_curr_len;
diff --git a/gr-blocks/lib/peak_detector2_fb_impl.h b/gr-blocks/lib/peak_detector2_fb_impl.h
index 4e16c93dac..929e302d68 100644
--- a/gr-blocks/lib/peak_detector2_fb_impl.h
+++ b/gr-blocks/lib/peak_detector2_fb_impl.h
@@ -33,7 +33,6 @@ namespace gr {
private:
float d_threshold_factor_rise;
int d_look_ahead;
- int d_look_ahead_remaining;
int d_peak_ind;
float d_peak_val;
float d_alpha;
diff --git a/gr-blocks/lib/peak_detector_XX_impl.cc.t b/gr-blocks/lib/peak_detector_impl.cc
index 3ad5f3c8fe..cda1f6007b 100644
--- a/gr-blocks/lib/peak_detector_XX_impl.cc.t
+++ b/gr-blocks/lib/peak_detector_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2010,2013 Free Software Foundation, Inc.
+ * Copyright 2007,2010,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,13 +20,11 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "@NAME_IMPL@.h"
+#include "peak_detector_impl.h"
#include <gnuradio/io_signature.h>
#include <string.h>
#include <limits>
@@ -34,44 +32,48 @@
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(float threshold_factor_rise,
+ template <class T>
+ typename peak_detector<T>::sptr
+ peak_detector<T>::make(float threshold_factor_rise,
float threshold_factor_fall,
int look_ahead, float alpha)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(threshold_factor_rise,
+ (new peak_detector_impl<T>(threshold_factor_rise,
threshold_factor_fall,
look_ahead, alpha));
}
- @NAME_IMPL@::@NAME_IMPL@(float threshold_factor_rise,
+ template <class T>
+ peak_detector_impl<T>::peak_detector_impl(float threshold_factor_rise,
float threshold_factor_fall,
int look_ahead, float alpha)
- : sync_block("@BASE_NAME@",
- io_signature::make(1, 1, sizeof(@I_TYPE@)),
+ : sync_block("peak_detector",
+ io_signature::make(1, 1, sizeof(T)),
io_signature::make(1, 1, sizeof(char))),
d_threshold_factor_rise(threshold_factor_rise),
d_threshold_factor_fall(threshold_factor_fall),
- d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0), d_found(0)
+ d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0)
{
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ peak_detector_impl<T>::~peak_detector_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ peak_detector_impl<T>::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @I_TYPE@ *iptr = (@I_TYPE@*)input_items[0];
+ T *iptr = (T*)input_items[0];
char *optr = (char*)output_items[0];
memset(optr, 0, noutput_items*sizeof(char));
- @I_TYPE@ peak_val = std::numeric_limits<@I_TYPE@>::min();
+ T peak_val = std::numeric_limits<T>::min();
int peak_ind = 0;
unsigned char state = 0;
int i = 0;
@@ -102,7 +104,7 @@ namespace gr {
else {
optr[peak_ind] = 1;
state = 0;
- peak_val = -(@I_TYPE@)INFINITY;
+ peak_val = -(T)INFINITY;
//printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items: %d\n",
//peak_val, peak_ind, i, noutput_items);
}
@@ -119,5 +121,8 @@ namespace gr {
}
}
+ template class peak_detector<float>;
+ template class peak_detector<std::int16_t>;
+ template class peak_detector<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/peak_detector_XX_impl.h.t b/gr-blocks/lib/peak_detector_impl.h
index 22de961d32..5a70c1b060 100644
--- a/gr-blocks/lib/peak_detector_XX_impl.h.t
+++ b/gr-blocks/lib/peak_detector_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2013 Free Software Foundation, Inc.
+ * Copyright 2007,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,17 +20,16 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef PEAK_DETECTOR_IMPL_H
+#define PEAK_DETECTOR_IMPL_H
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/peak_detector.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+ template <class T>
+ class peak_detector_impl : public peak_detector<T>
{
private:
float d_threshold_factor_rise;
@@ -38,13 +37,12 @@ namespace gr {
int d_look_ahead;
float d_avg_alpha;
float d_avg;
- unsigned char d_found;
public:
- @NAME_IMPL@(float threshold_factor_rise,
+ peak_detector_impl(float threshold_factor_rise,
float threshold_factor_fall,
int look_ahead, float alpha);
- ~@NAME_IMPL@();
+ ~peak_detector_impl();
void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; }
@@ -63,4 +61,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* PEAK_DETECTOR_IMPL_H */
diff --git a/gr-blocks/lib/probe_rate_impl.cc b/gr-blocks/lib/probe_rate_impl.cc
index 898c20c515..24a736db4d 100644
--- a/gr-blocks/lib/probe_rate_impl.cc
+++ b/gr-blocks/lib/probe_rate_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2013 Free Software Foundation, Inc.
+ * Copyright 2005,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -46,7 +46,6 @@ namespace gr {
d_avg(0),
d_min_update_time(update_rate_ms),
d_lastthru(0),
- d_itemsize(itemsize),
d_port(pmt::mp("rate")),
d_dict_avg(pmt::mp("rate_avg")),
d_dict_now(pmt::mp("rate_now"))
diff --git a/gr-blocks/lib/probe_rate_impl.h b/gr-blocks/lib/probe_rate_impl.h
index 4153b336ae..42c3b13fe2 100644
--- a/gr-blocks/lib/probe_rate_impl.h
+++ b/gr-blocks/lib/probe_rate_impl.h
@@ -35,7 +35,6 @@ namespace gr {
double d_min_update_time;
boost::posix_time::ptime d_last_update;
uint64_t d_lastthru;
- size_t d_itemsize;
void setup_rpc();
const pmt::pmt_t d_port;
diff --git a/gr-blocks/lib/probe_signal_X_impl.cc.t b/gr-blocks/lib/probe_signal_impl.cc
index 1bc2793af2..1766464fc6 100644
--- a/gr-blocks/lib/probe_signal_X_impl.cc.t
+++ b/gr-blocks/lib/probe_signal_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2010,2012-2013 Free Software Foundation, Inc.
+ * Copyright 2005,2010,2012-2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,43 +20,46 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "probe_signal_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @BASE_NAME@::make()
+ template <class T>
+ typename probe_signal<T>::sptr
+ probe_signal<T>::make()
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@());
+ (new probe_signal_impl<T> ());
}
- @NAME_IMPL@::@NAME_IMPL@()
- : sync_block("@BASE_NAME@",
- io_signature::make(1, 1, sizeof(@TYPE@)),
+ template <class T>
+ probe_signal_impl<T> ::probe_signal_impl()
+ : sync_block("probe_signal",
+ io_signature::make(1, 1, sizeof(T)),
io_signature::make(0, 0, 0)),
d_level(0)
{
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ probe_signal_impl<T> ::~probe_signal_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ probe_signal_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const @TYPE@ *in = (const @TYPE@ *)input_items[0];
+ const T *in = (const T *)input_items[0];
if(noutput_items > 0)
d_level = in[noutput_items-1];
@@ -64,5 +67,10 @@ namespace gr {
return noutput_items;
}
+template class probe_signal<std::uint8_t>;
+template class probe_signal<std::int16_t>;
+template class probe_signal<std::int32_t>;
+template class probe_signal<float>;
+template class probe_signal<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_impl.h b/gr-blocks/lib/probe_signal_impl.h
new file mode 100644
index 0000000000..d86f6e6d75
--- /dev/null
+++ b/gr-blocks/lib/probe_signal_impl.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef PROBE_SIGNAL_IMPL_H
+#define PROBE_SIGNAL_IMPL_H
+
+#include <gnuradio/blocks/probe_signal.h>
+
+namespace gr {
+ namespace blocks {
+
+template<class T>
+ class probe_signal_impl : public probe_signal<T>
+ {
+ private:
+ T d_level;
+
+ public:
+ probe_signal_impl ();
+ ~probe_signal_impl ();
+
+ T level() const { return d_level; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* PROBE_SIGNAL_IMPL_H */
diff --git a/gr-blocks/lib/probe_signal_vX_impl.cc.t b/gr-blocks/lib/probe_signal_v_impl.cc
index 5865bde41b..e355fd030a 100644
--- a/gr-blocks/lib/probe_signal_vX_impl.cc.t
+++ b/gr-blocks/lib/probe_signal_v_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2010,2012-2013 Free Software Foundation, Inc.
+ * Copyright 2005,2010,2012-2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,50 +20,57 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include <probe_signal_v_impl.h>
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @BASE_NAME@::make(size_t size)
+ template <class T>
+ typename probe_signal_v<T>::sptr
+ probe_signal_v<T>::make(size_t size)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(size));
+ (new probe_signal_v_impl<T>(size));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t size)
- : sync_block("@BASE_NAME@",
- io_signature::make(1, 1, size*sizeof(@TYPE@)),
+ template <class T>
+ probe_signal_v_impl<T>::probe_signal_v_impl(size_t size)
+ : sync_block("probe_signal_v",
+ io_signature::make(1, 1, size*sizeof(T)),
io_signature::make(0, 0, 0)),
d_level(size, 0), d_size(size)
{
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ probe_signal_v_impl<T>::~probe_signal_v_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ probe_signal_v_impl<T>::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const @TYPE@ *in = (const @TYPE@ *)input_items[0];
+ const T *in = (const T *)input_items[0];
for(size_t i=0; i<d_size; i++)
d_level[i] = in[(noutput_items-1)*d_size+i];
return noutput_items;
}
+ template class probe_signal_v<std::uint8_t>;
+ template class probe_signal_v<std::int16_t>;
+ template class probe_signal_v<std::int32_t>;
+ template class probe_signal_v<float>;
+ template class probe_signal_v<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_vX_impl.h.t b/gr-blocks/lib/probe_signal_v_impl.h
index 434eb44ac1..dd36ebf741 100644
--- a/gr-blocks/lib/probe_signal_vX_impl.h.t
+++ b/gr-blocks/lib/probe_signal_v_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2012-2013 Free Software Foundation, Inc.
+ * Copyright 2005,2012-2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,28 +20,27 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef PROBE_SIGNAL_V_IMPL_H
+#define PROBE_SIGNAL_V_IMPL_H
#include <vector>
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/probe_signal_v.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+ template <class T>
+ class probe_signal_v_impl : public probe_signal_v<T>
{
private:
- std::vector<@TYPE@> d_level;
+ std::vector<T> d_level;
size_t d_size;
public:
- @NAME_IMPL@(size_t size);
- ~@NAME_IMPL@();
+ probe_signal_v_impl(size_t size);
+ ~probe_signal_v_impl();
- std::vector<@TYPE@> level() const { return d_level; }
+ std::vector<T> level() const { return d_level; }
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -51,4 +50,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* PROBE_SIGNAL_V_IMPL_H */
diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc
index 0e567aec8f..a39a2bd0fa 100644
--- a/gr-blocks/lib/qa_rotator.cc
+++ b/gr-blocks/lib/qa_rotator.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002,2013 Free Software Foundation, Inc.
+ * Copyright 2002,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -28,7 +28,8 @@
#include <gnuradio/attributes.h>
#include <gnuradio/blocks/rotator.h>
#include <gnuradio/expj.h>
-#include <stdio.h>
+#include <gnuradio/math.h>
+
#include <cmath>
// error vector magnitude
@@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE(t1)
gr::blocks::rotator r;
- double phase_incr = 2*M_PI / 1003;
+ double phase_incr = 2*GR_M_PI / 1003;
double phase = 0;
// Old code: We increment then return the rotated value, thus we
@@ -58,17 +59,11 @@ BOOST_AUTO_TEST_CASE(t1)
gr_complex expected = gr_expj(phase);
gr_complex actual = r.rotate(gr_complex(1, 0));
-#if 0
- float evm = error_vector_mag(expected, actual);
- printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n",
- i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm);
-#endif
-
BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
phase += phase_incr;
- if(phase >= 2*M_PI)
- phase -= 2*M_PI;
+ if(phase >= 2*GR_M_PI)
+ phase -= 2*GR_M_PI;
}
}
@@ -80,7 +75,7 @@ BOOST_AUTO_TEST_CASE(t2)
gr_complex *input = new gr_complex[N];
gr_complex *output = new gr_complex[N];
- double phase_incr = 2*M_PI / 1003;
+ double phase_incr = 2*GR_M_PI / 1003;
double phase = 0;
r.set_phase(gr_complex(1,0));
@@ -98,17 +93,11 @@ BOOST_AUTO_TEST_CASE(t2)
gr_complex expected = gr_expj(phase);
gr_complex actual = output[i];
-#if 0
- float evm = error_vector_mag(expected, actual);
- printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n",
- i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm);
-#endif
-
BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
phase += phase_incr;
- if(phase >= 2*M_PI)
- phase -= 2*M_PI;
+ if(phase >= 2*GR_M_PI)
+ phase -= 2*GR_M_PI;
}
delete[] output;
diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.h.t b/gr-blocks/lib/sample_and_hold_XX_impl.h.t
deleted file mode 100644
index ed7d6f4d40..0000000000
--- a/gr-blocks/lib/sample_and_hold_XX_impl.h.t
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
-
-namespace gr {
- namespace blocks {
-
- class @NAME_IMPL@ : public @NAME@
- {
- private:
- @O_TYPE@ d_data;
-
- public:
- @NAME_IMPL@();
- ~@NAME_IMPL@();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.cc.t b/gr-blocks/lib/sample_and_hold_impl.cc
index 27597b67dd..c5e25bca6c 100644
--- a/gr-blocks/lib/sample_and_hold_XX_impl.cc.t
+++ b/gr-blocks/lib/sample_and_hold_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2010,2013 Free Software Foundation, Inc.
+ * Copyright 2007,2010,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,45 +20,48 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "sample_and_hold_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make()
+ template <class T>
+ typename sample_and_hold<T>::sptr
+ sample_and_hold<T>::make()
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@());
+ (new sample_and_hold_impl<T> ());
}
- @NAME_IMPL@::@NAME_IMPL@()
- : sync_block("@BASE_NAME@",
- io_signature::make2(2, 2, sizeof(@I_TYPE@), sizeof(char)),
- io_signature::make(1, 1, sizeof(@O_TYPE@))),
+ template <class T>
+ sample_and_hold_impl<T> ::sample_and_hold_impl()
+ : sync_block("sample_and_hold",
+ io_signature::make2(2, 2, sizeof(T), sizeof(char)),
+ io_signature::make(1, 1, sizeof(T))),
d_data(0)
{
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ sample_and_hold_impl<T> ::~sample_and_hold_impl()
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ sample_and_hold_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0];
+ T *iptr = (T *)input_items[0];
const char *ctrl = (const char *)input_items[1];
- @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+ T *optr = (T *)output_items[0];
for(int i = 0; i < noutput_items; i++) {
if(ctrl[i]) {
@@ -69,5 +72,9 @@ namespace gr {
return noutput_items;
}
+template class sample_and_hold<std::uint8_t>;
+template class sample_and_hold<std::int16_t>;
+template class sample_and_hold<std::int32_t>;
+template class sample_and_hold<float>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_X_impl.h.t b/gr-blocks/lib/sample_and_hold_impl.h
index c20994877f..f2ba032073 100644
--- a/gr-blocks/lib/probe_signal_X_impl.h.t
+++ b/gr-blocks/lib/sample_and_hold_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2012-2013 Free Software Foundation, Inc.
+ * Copyright 2007,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,26 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef SAMPLE_AND_HOLD_IMPL_H
+#define SAMPLE_AND_HOLD_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/sample_and_hold.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class sample_and_hold_impl : public sample_and_hold<T>
{
private:
- @TYPE@ d_level;
+ T d_data;
public:
- @NAME_IMPL@();
- ~@NAME_IMPL@();
-
- @TYPE@ level() const { return d_level; }
+ sample_and_hold_impl ();
+ ~sample_and_hold_impl ();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -49,4 +47,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* SAMPLE_AND_HOLD_IMPL_H */
diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h
index 1df99fdeff..ad42996cd1 100644
--- a/gr-blocks/lib/socket_pdu_impl.h
+++ b/gr-blocks/lib/socket_pdu_impl.h
@@ -37,7 +37,6 @@ namespace gr {
void run_io_service() { d_io_service.run(); }
gr::thread::thread d_thread;
bool d_started;
- bool d_finished;
// TCP specific
boost::asio::ip::tcp::endpoint d_tcp_endpoint;
diff --git a/gr-blocks/lib/stream_pdu_base.h b/gr-blocks/lib/stream_pdu_base.h
index 6a2bf9b15e..e15aec1787 100644
--- a/gr-blocks/lib/stream_pdu_base.h
+++ b/gr-blocks/lib/stream_pdu_base.h
@@ -24,6 +24,7 @@
#define INCLUDED_STREAM_PDU_BASE_H
#include <gnuradio/thread/thread.h>
+#include <gnuradio/basic_block.h>
#include <pmt/pmt.h>
class basic_block;
diff --git a/gr-blocks/lib/sub_XX_impl.cc.t b/gr-blocks/lib/sub_XX_impl.cc.t
deleted file mode 100644
index 6c7484a5d4..0000000000
--- a/gr-blocks/lib/sub_XX_impl.cc.t
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
-
- int ninputs = input_items.size ();
-
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc -= ((@I_TYPE@ *) input_items[j])[i];
-
- *optr++ = (@O_TYPE@) acc;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/sub_XX_impl.h.t b/gr-blocks/lib/sub_XX_impl.h.t
deleted file mode 100644
index 2680ef7012..0000000000
--- a/gr-blocks/lib/sub_XX_impl.h.t
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
- {
- size_t d_vlen;
-
- public:
- @NAME_IMPL@(size_t vlen);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/sub_ff_impl.h b/gr-blocks/lib/sub_ff_impl.h
deleted file mode 100644
index b4eff66ae6..0000000000
--- a/gr-blocks/lib/sub_ff_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_BLOCKS_SUB_FF_IMPL_H
-#define INCLUDED_BLOCKS_SUB_FF_IMPL_H
-
-#include <gnuradio/blocks/sub_ff.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API sub_ff_impl : public sub_ff
- {
- private:
- size_t d_vlen;
-
- public:
- sub_ff_impl(size_t vlen);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* INCLUDED_BLOCKS_SUB_FF_IMPL_H */
diff --git a/gr-blocks/lib/sub_ff_impl.cc b/gr-blocks/lib/sub_impl.cc
index 8ea1a47c8b..ee4df1ed66 100644
--- a/gr-blocks/lib/sub_ff_impl.cc
+++ b/gr-blocks/lib/sub_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2010,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,25 +20,26 @@
* Boston, MA 02110-1301, USA.
*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <sub_ff_impl.h>
+#include "sub_impl.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
namespace gr {
namespace blocks {
- sub_ff::sptr
- sub_ff::make(size_t vlen)
+ template <class T>
+ typename sub<T>::sptr sub<T>::make(size_t vlen)
{
- return gnuradio::get_initial_sptr
- (new sub_ff_impl(vlen));
+ return gnuradio::get_initial_sptr(new sub_impl<T> (vlen));
}
- sub_ff_impl::sub_ff_impl(size_t vlen)
+ template <>
+ sub_impl<float>::sub_impl(size_t vlen)
: sync_block("@sub_ff",
io_signature::make(1, -1, sizeof(float)*vlen),
io_signature::make(1, 1, sizeof(float)*vlen)),
@@ -49,8 +50,9 @@ namespace gr {
set_alignment(std::max(1, alignment_multiple));
}
+ template <>
int
- sub_ff_impl::work(int noutput_items,
+ sub_impl<float>::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
@@ -59,14 +61,6 @@ namespace gr {
int ninputs = input_items.size();
int noi = noutput_items*d_vlen;
- //for(size_t i = 0; i < noutput_items*d_vlen; i++){
- // @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
- // for (int j = 1; j < ninputs; j++)
- // acc -= ((@I_TYPE@ *) input_items[j])[i];
- //
- // *optr++ = (@O_TYPE@) acc;
- //}
-
const float *in = (const float*)input_items[0];
memcpy(out, in, noi*sizeof(float));
for(int i = 1; i < ninputs; i++) {
@@ -77,5 +71,39 @@ namespace gr {
return noutput_items;
}
+ template <class T>
+ sub_impl<T> ::sub_impl(size_t vlen)
+ : sync_block ("sub",
+ io_signature::make (1, -1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ template <class T>
+ int
+ sub_impl<T> ::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ T *optr = (T *) output_items[0];
+
+ int ninputs = input_items.size ();
+
+ for (size_t i = 0; i < noutput_items*d_vlen; i++){
+ T acc = ((T *) input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc -= ((T *) input_items[j])[i];
+
+ *optr++ = (T) acc;
+ }
+
+ return noutput_items;
+ }
+
+template class sub<std::int16_t>;
+template class sub<std::int32_t>;
+template class sub<gr_complex>;
+template class sub<float>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/not_XX_impl.h.t b/gr-blocks/lib/sub_impl.h
index f7db3f2162..66e46995fd 100644
--- a/gr-blocks/lib/not_XX_impl.h.t
+++ b/gr-blocks/lib/sub_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,22 +20,22 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef SUB_IMPL_H
+#define SUB_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/sub.h>
namespace gr {
namespace blocks {
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
+template<class T>
+ class BLOCKS_API sub_impl : public sub<T>
{
size_t d_vlen;
public:
- @NAME_IMPL@(size_t vlen);
+ sub_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -45,4 +45,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* SUB_IMPL_H */
diff --git a/gr-blocks/lib/tcp_server_sink_impl.h b/gr-blocks/lib/tcp_server_sink_impl.h
index d10f3b95b8..ea1aa3e84a 100644
--- a/gr-blocks/lib/tcp_server_sink_impl.h
+++ b/gr-blocks/lib/tcp_server_sink_impl.h
@@ -39,7 +39,7 @@ namespace gr {
boost::asio::io_service d_io_service;
gr::thread::thread d_io_serv_thread;
boost::asio::ip::tcp::endpoint d_endpoint;
- std::auto_ptr<boost::asio::ip::tcp::socket> d_socket;
+ std::unique_ptr<boost::asio::ip::tcp::socket> d_socket;
std::set<boost::asio::ip::tcp::socket *> d_sockets;
boost::asio::ip::tcp::acceptor d_acceptor;
diff --git a/gr-blocks/lib/tsb_vector_sink_X_impl.cc.t b/gr-blocks/lib/tsb_vector_sink_impl.cc
index c5b79f94a4..e4a3474e96 100644
--- a/gr-blocks/lib/tsb_vector_sink_X_impl.cc.t
+++ b/gr-blocks/lib/tsb_vector_sink_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014 Free Software Foundation, Inc.
+ * Copyright 2014,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,66 +20,76 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "tsb_vector_sink_impl.h"
#include <gnuradio/io_signature.h>
-#include "@NAME_IMPL@.h"
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(int vlen, const std::string &tsb_key)
+ template <class T>
+ typename tsb_vector_sink<T>::sptr
+ tsb_vector_sink<T>::make(int vlen, const std::string &tsb_key)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(vlen, tsb_key));
+ (new tsb_vector_sink_impl<T> (vlen, tsb_key));
}
- @NAME_IMPL@::@NAME_IMPL@(int vlen, const std::string &tsb_key)
- : gr::tagged_stream_block("@NAME@",
- gr::io_signature::make(1, 1, vlen * sizeof(@TYPE@)),
+ template <class T>
+ tsb_vector_sink_impl<T> ::tsb_vector_sink_impl(int vlen, const std::string &tsb_key)
+ : gr::tagged_stream_block("tsb_vector_sink",
+ gr::io_signature::make(1, 1, vlen * sizeof(T)),
gr::io_signature::make(0, 0, 0), tsb_key),
d_vlen(vlen)
{}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ tsb_vector_sink_impl<T> ::~tsb_vector_sink_impl()
{
}
- std::vector<std::vector<@TYPE@> >
- @NAME_IMPL@::data() const
+ template <class T>
+ std::vector<std::vector<T> >
+ tsb_vector_sink_impl<T> ::data() const
{
return d_data;
}
+ template <class T>
std::vector<tag_t>
- @NAME_IMPL@::tags() const
+ tsb_vector_sink_impl<T> ::tags() const
{
return d_tags;
}
+ template <class T>
int
- @NAME_IMPL@::work (int noutput_items,
+ tsb_vector_sink_impl<T> ::work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const @TYPE@ *in = (const @TYPE@ *) input_items[0];
+ const T *in = (const T *) input_items[0];
- std::vector<@TYPE@> new_data(in, in + (ninput_items[0] * d_vlen));
+ std::vector<T> new_data(in, in + (ninput_items[0] * d_vlen));
d_data.push_back(new_data);
std::vector<tag_t> tags;
- get_tags_in_window(tags, 0, 0, ninput_items[0]);
+ this->get_tags_in_window(tags, 0, 0, ninput_items[0]);
d_tags.insert(d_tags.end(), tags.begin(), tags.end());
return ninput_items[0];
}
+template class tsb_vector_sink<std::uint8_t>;
+template class tsb_vector_sink<std::int16_t>;
+template class tsb_vector_sink<std::int32_t>;
+template class tsb_vector_sink<float>;
+template class tsb_vector_sink<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/tsb_vector_sink_X_impl.h.t b/gr-blocks/lib/tsb_vector_sink_impl.h
index 3bf5892cc2..555e80c7dd 100644
--- a/gr-blocks/lib/tsb_vector_sink_X_impl.h.t
+++ b/gr-blocks/lib/tsb_vector_sink_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2014 Free Software Foundation, Inc.
+ * Copyright 2014,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,29 +20,29 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef TSB_VECTOR_SINK_IMPL_H
+#define TSB_VECTOR_SINK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/tsb_vector_sink.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class tsb_vector_sink_impl : public tsb_vector_sink<T>
{
private:
- std::vector<std::vector<@TYPE@> > d_data;
+ std::vector<std::vector<T> > d_data;
std::vector<tag_t> d_tags;
int d_vlen;
public:
- @NAME_IMPL@(int vlen, const std::string &tsb_key);
- ~@NAME_IMPL@();
+ tsb_vector_sink_impl (int vlen, const std::string &tsb_key);
+ ~tsb_vector_sink_impl ();
void reset() { d_data.clear(); }
- std::vector<std::vector<@TYPE@> > data() const;
+ std::vector<std::vector<T> > data() const;
std::vector<tag_t> tags() const;
int work(int noutput_items,
@@ -54,5 +54,5 @@ namespace gr {
} // namespace blocks
} // namespace gr
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* TSB_VECTOR_SINK_IMPL_H */
diff --git a/gr-blocks/lib/udp_source_impl.cc b/gr-blocks/lib/udp_source_impl.cc
index ea2f2b60a0..6081690259 100644
--- a/gr-blocks/lib/udp_source_impl.cc
+++ b/gr-blocks/lib/udp_source_impl.cc
@@ -56,7 +56,7 @@ namespace gr {
io_signature::make(0, 0, 0),
io_signature::make(1, 1, itemsize)),
d_itemsize(itemsize), d_payload_size(payload_size),
- d_eof(eof), d_connected(false), d_residual(0), d_sent(0), d_offset(0)
+ d_eof(eof), d_connected(false), d_residual(0), d_sent(0)
{
// Give us some more room to play.
d_rxbuf = new char[4*d_payload_size];
diff --git a/gr-blocks/lib/udp_source_impl.h b/gr-blocks/lib/udp_source_impl.h
index 42cb64dabe..5b4b6996ab 100644
--- a/gr-blocks/lib/udp_source_impl.h
+++ b/gr-blocks/lib/udp_source_impl.h
@@ -42,7 +42,6 @@ namespace gr {
char *d_residbuf; // hold buffer between calls
ssize_t d_residual; // hold information about number of bytes stored in residbuf
ssize_t d_sent; // track how much of d_residbuf we've outputted
- size_t d_offset; // point to residbuf location offset
static const int BUF_SIZE_PAYLOADS; //!< The d_residbuf size in multiples of d_payload_size
diff --git a/gr-blocks/lib/unpacked_to_packed_XX_impl.cc.t b/gr-blocks/lib/unpacked_to_packed_impl.cc
index c4e385deea..54bcfd3c0b 100644
--- a/gr-blocks/lib/unpacked_to_packed_XX_impl.cc.t
+++ b/gr-blocks/lib/unpacked_to_packed_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2006,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2006,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,51 +20,53 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "@NAME_IMPL@.h"
+#include "unpacked_to_packed_impl.h"
#include <gnuradio/io_signature.h>
#include <assert.h>
namespace gr {
namespace blocks {
- static const unsigned int BITS_PER_TYPE = sizeof(@O_TYPE@) * 8;
- @NAME@::sptr
- @NAME@::make(unsigned int bits_per_chunk,
+ template <class T>
+ typename unpacked_to_packed<T>::sptr
+ unpacked_to_packed<T>::make(unsigned int bits_per_chunk,
endianness_t endianness)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(bits_per_chunk, endianness));
+ (new unpacked_to_packed_impl<T> (bits_per_chunk, endianness));
}
- @NAME_IMPL@::@NAME_IMPL@(unsigned int bits_per_chunk,
+ template <class T>
+ unpacked_to_packed_impl<T> ::unpacked_to_packed_impl(unsigned int bits_per_chunk,
endianness_t endianness)
- : block("@NAME@",
- io_signature::make(1, -1, sizeof(@I_TYPE@)),
- io_signature::make(1, -1, sizeof(@O_TYPE@))),
+ : block("unpacked_to_packed",
+ io_signature::make(1, -1, sizeof(T)),
+ io_signature::make(1, -1, sizeof(T))),
d_bits_per_chunk(bits_per_chunk), d_endianness(endianness), d_index(0)
{
- assert(bits_per_chunk <= BITS_PER_TYPE);
+ assert(bits_per_chunk <= d_bits_per_type);
assert(bits_per_chunk > 0);
- set_relative_rate((uint64_t)bits_per_chunk, (uint64_t)BITS_PER_TYPE);
+ this->set_relative_rate((uint64_t)bits_per_chunk, (uint64_t)BITS_PER_TYPE);
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ unpacked_to_packed_impl<T> ::~unpacked_to_packed_impl()
{
}
+ template <class T>
void
- @NAME_IMPL@::forecast(int noutput_items,
+ unpacked_to_packed_impl<T> ::forecast(int noutput_items,
gr_vector_int &ninput_items_required)
{
- int input_required = (int)ceil((d_index+noutput_items * 1.0 * BITS_PER_TYPE)
+ int input_required = (int)ceil((d_index+noutput_items * 1.0 * d_bits_per_type)
/ d_bits_per_chunk);
unsigned ninputs = ninput_items_required.size();
for(unsigned int i = 0; i < ninputs; i++) {
@@ -72,19 +74,21 @@ namespace gr {
}
}
+ template <class T>
unsigned int
- get_bit_be1(const @I_TYPE@ *in_vector, unsigned int bit_addr,
+ unpacked_to_packed_impl<T>::get_bit_be1(const T *in_vector, unsigned int bit_addr,
unsigned int bits_per_chunk)
{
unsigned int byte_addr = (int)bit_addr/bits_per_chunk;
- @I_TYPE@ x = in_vector[byte_addr];
+ T x = in_vector[byte_addr];
unsigned int residue = bit_addr - byte_addr * bits_per_chunk;
//printf("Bit addr %d byte addr %d residue %d val %d\n",bit_addr,byte_addr,residue,(x>>(bits_per_chunk-1-residue))&1);
return (x >> (bits_per_chunk-1-residue)) & 1;
}
+ template <class T>
int
- @NAME_IMPL@::general_work(int noutput_items,
+ unpacked_to_packed_impl<T> ::general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
@@ -95,20 +99,20 @@ namespace gr {
int nstreams = input_items.size();
for(int m=0; m< nstreams; m++) {
- const @I_TYPE@ *in = (@I_TYPE@ *)input_items[m];
- @O_TYPE@ *out = (@O_TYPE@ *)output_items[m];
+ const T *in = (T *)input_items[m];
+ T *out = (T *)output_items[m];
index_tmp=d_index;
// per stream processing
- //assert((ninput_items[m]-d_index)*d_bits_per_chunk >= noutput_items*BITS_PER_TYPE);
+ //assert((ninput_items[m]-d_index)*d_bits_per_chunk >= noutput_items*d_bits_per_type);
switch(d_endianness) {
case GR_MSB_FIRST:
for(int i = 0; i < noutput_items; i++) {
- @O_TYPE@ tmp=0;
- for(unsigned int j = 0; j < BITS_PER_TYPE; j++) {
+ T tmp=0;
+ for(unsigned int j = 0; j < d_bits_per_type; j++) {
tmp = (tmp<<1) | get_bit_be1(in, index_tmp, d_bits_per_chunk);
index_tmp++;
}
@@ -119,8 +123,8 @@ namespace gr {
case GR_LSB_FIRST:
for(int i = 0; i < noutput_items; i++) {
unsigned long tmp=0;
- for(unsigned int j = 0; j < BITS_PER_TYPE; j++) {
- tmp = (tmp>>1) | (get_bit_be1(in, index_tmp, d_bits_per_chunk) << (BITS_PER_TYPE-1));
+ for(unsigned int j = 0; j < d_bits_per_type; j++) {
+ tmp = (tmp>>1) | (get_bit_be1(in, index_tmp, d_bits_per_chunk) << (d_bits_per_type-1));
index_tmp++;
}
out[i] = tmp;
@@ -133,11 +137,14 @@ namespace gr {
}
d_index = index_tmp;
- consume_each((int)(d_index/d_bits_per_chunk));
+ this->consume_each((int)(d_index/d_bits_per_chunk));
d_index = d_index%d_bits_per_chunk;
return noutput_items;
}
+template class unpacked_to_packed<std::uint8_t>;
+template class unpacked_to_packed<std::int16_t>;
+template class unpacked_to_packed<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/packed_to_unpacked_XX_impl.h.t b/gr-blocks/lib/unpacked_to_packed_impl.h
index 3f8b15c1a6..78b39b0f2d 100644
--- a/gr-blocks/lib/packed_to_unpacked_XX_impl.h.t
+++ b/gr-blocks/lib/unpacked_to_packed_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2013 Free Software Foundation, Inc.
+ * Copyright 2006.2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,27 +20,29 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef UNPACKED_TO_PACKED_IMPL_H
+#define UNPACKED_TO_PACKED_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/unpacked_to_packed.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class unpacked_to_packed_impl : public unpacked_to_packed<T>
{
private:
unsigned int d_bits_per_chunk;
endianness_t d_endianness;
unsigned int d_index;
+ const unsigned int d_bits_per_type = sizeof(T) * 8;
+ unsigned int get_bit_be1(const T *in_vector, unsigned int bit_addr, unsigned int bits_per_chunk);
public:
- @NAME_IMPL@(unsigned int bits_per_chunk,
+ unpacked_to_packed_impl (unsigned int bits_per_chunk,
endianness_t endianness);
- ~@NAME_IMPL@();
+ ~unpacked_to_packed_impl ();
void forecast(int noutput_items,
gr_vector_int &ninput_items_required);
@@ -56,4 +58,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* UNPACKED_TO_PACKED_IMPL_H */
diff --git a/gr-blocks/lib/vector_insert_X_impl.cc.t b/gr-blocks/lib/vector_insert_impl.cc
index 6464a4aba3..a39b0779ac 100644
--- a/gr-blocks/lib/vector_insert_X_impl.cc.t
+++ b/gr-blocks/lib/vector_insert_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,56 +20,59 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <@NAME_IMPL@.h>
+#include "vector_insert_impl.h"
#include <algorithm>
#include <gnuradio/io_signature.h>
+#include <gnuradio/block.h>
#include <stdexcept>
#include <stdio.h>
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(const std::vector<@TYPE@> &data, int periodicity, int offset)
+ template <class T>
+ typename vector_insert<T>::sptr
+ vector_insert<T>::make(const std::vector<T> &data, int periodicity, int offset)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(data, periodicity, offset));
+ (new vector_insert_impl<T> (data, periodicity, offset));
}
- @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data,
+ template <class T>
+ vector_insert_impl<T>::vector_insert_impl(const std::vector<T> &data,
int periodicity, int offset)
- : block("@BASE_NAME@",
- io_signature::make(1, 1, sizeof(@TYPE@)),
- io_signature::make(1, 1, sizeof(@TYPE@))),
+ : block("vector_insert",
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(1, 1, sizeof(T))),
d_data(data),
d_offset(offset),
d_periodicity(periodicity)
{
- set_tag_propagation_policy(TPP_DONT); // handle tags manually
- //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset);
+ this->set_tag_propagation_policy(gr::block::TPP_DONT); // handle tags manually
// some sanity checks
assert(offset < periodicity);
assert(offset >= 0);
assert((size_t)periodicity > data.size());
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ vector_insert_impl<T>::~vector_insert_impl()
{}
+ template <class T>
int
- @NAME_IMPL@::general_work(int noutput_items,
+ vector_insert_impl<T> ::general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @TYPE@ *out = (@TYPE@ *)output_items[0];
- const @TYPE@ *in = (const @TYPE@ *)input_items[0];
+ T *out = (T *)output_items[0];
+ const T *in = (const T *)input_items[0];
int ii(0), oo(0);
@@ -81,14 +84,14 @@ namespace gr {
int max_copy = std::min(std::min(noutput_items - oo, ninput_items[0] - ii),
d_periodicity - d_offset);
std::vector<tag_t> tags;
- get_tags_in_range(tags, 0, nitems_read(0) + ii, nitems_read(0) + max_copy + ii);
+ this->get_tags_in_range(tags, 0, this->nitems_read(0) + ii, this->nitems_read(0) + max_copy + ii);
for(unsigned i = 0; i < tags.size(); i++)
{
//printf("copy tag from in@%d to out@%d\n", int(tags[i].offset), int(nitems_written(0) + oo + (tags[i].offset-nitems_read(0)-ii)));
- add_item_tag(0, nitems_written(0) + oo + (tags[i].offset-nitems_read(0)-ii), tags[i].key, tags[i].value, tags[i].srcid);
+ this->add_item_tag(0, this->nitems_written(0) + oo + (tags[i].offset-this->nitems_read(0)-ii), tags[i].key, tags[i].value, tags[i].srcid);
}
//printf("copy %d from input\n", max_copy);
- memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy );
+ memcpy( &out[oo], &in[ii], sizeof(T)*max_copy );
//printf(" * memcpy returned.\n");
ii += max_copy;
oo += max_copy;
@@ -97,7 +100,7 @@ namespace gr {
else { // if we are in the insertion region
int max_copy = std::min(noutput_items - oo, ((int)d_data.size()) - d_offset);
//printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo);
- memcpy(&out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy);
+ memcpy(&out[oo], &d_data[d_offset], sizeof(T)*max_copy);
//printf(" * memcpy returned.\n");
oo += max_copy;
d_offset = (d_offset + max_copy)%d_periodicity;
@@ -109,9 +112,14 @@ namespace gr {
//printf(" # got out of loop\n");
//printf("consume = %d, produce = %d\n", ii, oo);
- consume_each(ii);
+ this->consume_each(ii);
return oo;
}
+template class vector_insert<std::uint8_t>;
+template class vector_insert<std::int16_t>;
+template class vector_insert<std::int32_t>;
+template class vector_insert<float>;
+template class vector_insert<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_insert_X_impl.h.t b/gr-blocks/lib/vector_insert_impl.h
index fa03f52693..a24fe4fc43 100644
--- a/gr-blocks/lib/vector_insert_X_impl.h.t
+++ b/gr-blocks/lib/vector_insert_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012,2013 Free Software Foundation, Inc.
+ * Copyright 2012,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,30 +20,30 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef VECTOR_INSERT_IMPL_H
+#define VECTOR_INSERT_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/vector_insert.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class vector_insert_impl : public vector_insert<T>
{
private:
- std::vector<@TYPE@> d_data;
+ std::vector<T> d_data;
int d_offset;
int d_periodicity;
public:
- @NAME_IMPL@(const std::vector<@TYPE@> &data,
+ vector_insert_impl (const std::vector<T> &data,
int periodicity, int offset);
- ~@NAME_IMPL@();
+ ~vector_insert_impl ();
void rewind() { d_offset=0; }
- void set_data(const std::vector<@TYPE@> &data) {
+ void set_data(const std::vector<T> &data) {
d_data = data; rewind(); }
int general_work(int noutput_items,
@@ -55,4 +55,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* VECTOR_INSERT_IMPL_H */
diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_impl.cc
index 630ddb9165..f27ebd1668 100644
--- a/gr-blocks/lib/vector_sink_X_impl.cc.t
+++ b/gr-blocks/lib/vector_sink_impl.cc
@@ -20,13 +20,12 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <@NAME_IMPL@.h>
+#include "vector_sink_impl.h"
#include <gnuradio/io_signature.h>
#include <gnuradio/thread/thread.h>
#include <algorithm>
@@ -35,16 +34,18 @@
namespace gr {
namespace blocks {
- @NAME@::sptr
- @BASE_NAME@::make(const int vlen, const int reserve_items)
+ template <class T>
+ typename vector_sink<T>::sptr
+ vector_sink<T>::make(int vlen, const int reserve_items)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(vlen, reserve_items));
+ (new vector_sink_impl<T> (vlen, reserve_items));
}
- @NAME_IMPL@::@NAME_IMPL@(const int vlen, const int reserve_items)
- : sync_block("@NAME@",
- io_signature::make(1, 1, sizeof(@TYPE@) * vlen),
+ template <class T>
+ vector_sink_impl<T> ::vector_sink_impl(int vlen, const int reserve_items)
+ : sync_block("vector_sink",
+ io_signature::make(1, 1, sizeof(T) * vlen),
io_signature::make(0, 0, 0)),
d_vlen(vlen)
{
@@ -52,38 +53,43 @@ namespace gr {
d_data.reserve(d_vlen * reserve_items);
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ vector_sink_impl<T> ::~vector_sink_impl()
{}
- std::vector<@TYPE@>
- @NAME_IMPL@::data() const
+ template <class T>
+ std::vector<T>
+ vector_sink_impl<T> ::data() const
{
gr::thread::scoped_lock guard(d_data_mutex);
return d_data;
}
+ template <class T>
std::vector<tag_t>
- @NAME_IMPL@::tags() const
+ vector_sink_impl<T> ::tags() const
{
gr::thread::scoped_lock guard(d_data_mutex);
return d_tags;
}
+ template <class T>
void
- @NAME_IMPL@::reset()
+ vector_sink_impl<T> ::reset()
{
gr::thread::scoped_lock guard(d_data_mutex);
d_tags.clear();
d_data.clear();
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ vector_sink_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @TYPE@ *iptr = (@TYPE@*)input_items[0];
+ T *iptr = (T*)input_items[0];
// can't touch this (as long as work() is working, the accessors shall not
// read the data
@@ -91,10 +97,15 @@ namespace gr {
for(int i = 0; i < noutput_items * d_vlen; i++)
d_data.push_back (iptr[i]);
std::vector<tag_t> tags;
- get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items);
+ this->get_tags_in_range(tags, 0, this->nitems_read(0), this->nitems_read(0) + noutput_items);
d_tags.insert(d_tags.end(), tags.begin(), tags.end());
return noutput_items;
}
+template class vector_sink<std::uint8_t>;
+template class vector_sink<std::int16_t>;
+template class vector_sink<std::int32_t>;
+template class vector_sink<float>;
+template class vector_sink<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_sink_X_impl.h.t b/gr-blocks/lib/vector_sink_impl.h
index dfcb2ccc04..23d177eea5 100644
--- a/gr-blocks/lib/vector_sink_X_impl.h.t
+++ b/gr-blocks/lib/vector_sink_impl.h
@@ -20,31 +20,31 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef VECTOR_SINK_IMPL_H
+#define VECTOR_SINK_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/vector_sink.h>
#include <gnuradio/thread/thread.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class vector_sink_impl : public vector_sink<T>
{
private:
- std::vector<@TYPE@> d_data;
+ std::vector<T> d_data;
std::vector<tag_t> d_tags;
mutable gr::thread::mutex d_data_mutex; // protects internal data access.
int d_vlen;
public:
- @NAME_IMPL@(const int vlen, const int reserve_items);
- ~@NAME_IMPL@();
+ vector_sink_impl (int vlen, const int reserve_items);
+ ~vector_sink_impl ();
void reset();
- std::vector<@TYPE@> data() const;
+ std::vector<T> data() const;
std::vector<tag_t> tags() const;
int work(int noutput_items,
@@ -55,4 +55,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* VECTOR_SINK_IMPL_H */
diff --git a/gr-blocks/lib/vector_source_X_impl.cc.t b/gr-blocks/lib/vector_source_impl.cc
index 287864fcac..fd1ad16981 100644
--- a/gr-blocks/lib/vector_source_X_impl.cc.t
+++ b/gr-blocks/lib/vector_source_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2010,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2010,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,13 +20,12 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <@NAME_IMPL@.h>
+#include "vector_source_impl.h"
#include <algorithm>
#include <gnuradio/io_signature.h>
#include <stdexcept>
@@ -34,44 +33,47 @@
namespace gr {
namespace blocks {
- @NAME@::sptr
- @NAME@::make(const std::vector<@TYPE@> &data,
+ template <class T>
+ typename vector_source<T>::sptr
+ vector_source<T>::make(const std::vector<T> &data,
bool repeat, int vlen,
const std::vector<tag_t> &tags)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(data, repeat, vlen, tags));
+ (new vector_source_impl<T> (data, repeat, vlen, tags));
}
- @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data,
+ template <class T>
+ vector_source_impl<T> ::vector_source_impl(const std::vector<T> &data,
bool repeat, int vlen,
const std::vector<tag_t> &tags)
- : sync_block("@BASE_NAME@",
+ : sync_block("vector_source",
io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof(@TYPE@) * vlen)),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_data(data),
d_repeat(repeat),
d_offset(0),
d_vlen(vlen),
- d_tags(tags),
- d_tagpos(0)
+ d_tags(tags)
{
if(tags.size() == 0) {
d_settags = 0;
}
else {
d_settags = 1;
- set_output_multiple(data.size() / vlen);
+ this->set_output_multiple(data.size() / vlen);
}
if((data.size() % vlen) != 0)
throw std::invalid_argument("data length must be a multiple of vlen");
}
- @NAME_IMPL@::~@NAME_IMPL@()
+ template <class T>
+ vector_source_impl<T> ::~vector_source_impl()
{}
+ template <class T>
void
- @NAME_IMPL@::set_data (const std::vector<@TYPE@> &data,
+ vector_source_impl<T> ::set_data (const std::vector<T> &data,
const std::vector<tag_t> &tags)
{
d_data = data;
@@ -85,12 +87,13 @@ namespace gr {
}
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ vector_source_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @TYPE@ *optr = (@TYPE@ *) output_items[0];
+ T *optr = (T *) output_items[0];
if(d_repeat) {
unsigned int size = d_data.size ();
@@ -102,10 +105,10 @@ namespace gr {
int n_outputitems_per_vector = d_data.size() / d_vlen;
for(int i = 0; i < noutput_items; i += n_outputitems_per_vector) {
// FIXME do proper vector copy
- memcpy((void *) optr, (const void*)&d_data[0], size*sizeof (@TYPE@));
+ memcpy((void *) optr, (const void*)&d_data[0], size*sizeof (T));
optr += size;
for(unsigned t = 0; t < d_tags.size(); t++) {
- add_item_tag(0, nitems_written(0)+i+d_tags[t].offset,
+ this->add_item_tag(0, this->nitems_written(0)+i+d_tags[t].offset,
d_tags[t].key, d_tags[t].value, d_tags[t].srcid);
}
}
@@ -133,7 +136,7 @@ namespace gr {
}
for(unsigned t = 0; t < d_tags.size(); t++) {
if((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n))
- add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value,
+ this->add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value,
d_tags[t].srcid);
}
d_offset += n;
@@ -141,5 +144,10 @@ namespace gr {
}
}
+template class vector_source<std::uint8_t>;
+template class vector_source<std::int16_t>;
+template class vector_source<std::int32_t>;
+template class vector_source<float>;
+template class vector_source<gr_complex>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_source_X_impl.h.t b/gr-blocks/lib/vector_source_impl.h
index bc9b329d8f..b4161d68fc 100644
--- a/gr-blocks/lib/vector_source_X_impl.h.t
+++ b/gr-blocks/lib/vector_source_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2012-2013 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2012-2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,35 +20,34 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
+#ifndef VECTOR_SOURCE_IMPL_H
+#define VECTOR_SOURCE_IMPL_H
-#include <gnuradio/blocks/@NAME@.h>
+#include <gnuradio/blocks/vector_source.h>
namespace gr {
namespace blocks {
- class @NAME_IMPL@ : public @NAME@
+template<class T>
+ class vector_source_impl : public vector_source<T>
{
private:
- std::vector<@TYPE@> d_data;
+ std::vector<T> d_data;
bool d_repeat;
unsigned int d_offset;
int d_vlen;
bool d_settags;
std::vector<tag_t> d_tags;
- unsigned int d_tagpos;
public:
- @NAME_IMPL@(const std::vector<@TYPE@> &data,
+ vector_source_impl (const std::vector<T> &data,
bool repeat, int vlen,
const std::vector<tag_t> &tags);
- ~@NAME_IMPL@();
+ ~vector_source_impl ();
void rewind() { d_offset=0; }
- void set_data(const std::vector<@TYPE@> &data,
+ void set_data(const std::vector<T> &data,
const std::vector<tag_t> &tags);
void set_repeat(bool repeat) { d_repeat=repeat; };
@@ -60,4 +59,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* @GUARD_NAME_IMPL@ */
+#endif /* VECTOR_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/xor_XX_impl.cc.t b/gr-blocks/lib/xor_XX_impl.cc.t
deleted file mode 100644
index aa7a542ed9..0000000000
--- a/gr-blocks/lib/xor_XX_impl.cc.t
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <@NAME_IMPL@.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace blocks {
-
- @NAME@::sptr @NAME@::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
- }
-
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
- d_vlen(vlen)
- {
- }
-
- int
- @NAME_IMPL@::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
-
- int ninputs = input_items.size ();
-
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc ^= ((@I_TYPE@ *) input_items[j])[i];
-
- *optr++ = (@O_TYPE@) acc;
- }
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-} /* namespace gr */
diff --git a/gr-blocks/lib/xor_XX_impl.h.t b/gr-blocks/lib/xor_XX_impl.h.t
deleted file mode 100644
index f7db3f2162..0000000000
--- a/gr-blocks/lib/xor_XX_impl.h.t
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-// @WARNING@
-
-#ifndef @GUARD_NAME_IMPL@
-#define @GUARD_NAME_IMPL@
-
-#include <gnuradio/blocks/@NAME@.h>
-
-namespace gr {
- namespace blocks {
-
- class BLOCKS_API @NAME_IMPL@ : public @NAME@
- {
- size_t d_vlen;
-
- public:
- @NAME_IMPL@(size_t vlen);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
-} /* namespace gr */
-
-#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/divide_XX_impl.cc.t b/gr-blocks/lib/xor_blk_impl.cc
index 052b09217a..5180e6a600 100644
--- a/gr-blocks/lib/divide_XX_impl.cc.t
+++ b/gr-blocks/lib/xor_blk_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,50 +20,54 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <@NAME_IMPL@.h>
+#include "xor_blk_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace blocks {
-
- @NAME@::sptr @NAME@::make(size_t vlen)
+ template <class T>
+ typename xor_blk<T>::sptr xor_blk<T>::make(size_t vlen)
{
- return gnuradio::get_initial_sptr(new @NAME_IMPL@(vlen));
+ return gnuradio::get_initial_sptr(new xor_blk_impl<T> (vlen));
}
- @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
- : sync_block ("@NAME@",
- io_signature::make (1, -1, sizeof (@I_TYPE@)*vlen),
- io_signature::make (1, 1, sizeof (@O_TYPE@)*vlen)),
+ template <class T>
+ xor_blk_impl<T> ::xor_blk_impl(size_t vlen)
+ : sync_block ("xor_blk",
+ io_signature::make (1, -1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
d_vlen(vlen)
{
}
+ template <class T>
int
- @NAME_IMPL@::work(int noutput_items,
+ xor_blk_impl<T> ::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+ T *optr = (T *) output_items[0];
int ninputs = input_items.size ();
for (size_t i = 0; i < noutput_items*d_vlen; i++){
- @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
+ T acc = ((T *) input_items[0])[i];
for (int j = 1; j < ninputs; j++)
- acc /= ((@I_TYPE@ *) input_items[j])[i];
+ acc ^= ((T *) input_items[j])[i];
- *optr++ = (@O_TYPE@) acc;
+ *optr++ = (T) acc;
}
return noutput_items;
}
+template class xor_blk<std::uint8_t>;
+template class xor_blk<std::int16_t>;
+template class xor_blk<std::int32_t>;
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/divide_ff_impl.h b/gr-blocks/lib/xor_blk_impl.h
index efa099f93c..72caa0a799 100644
--- a/gr-blocks/lib/divide_ff_impl.h
+++ b/gr-blocks/lib/xor_blk_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004-2016 Free Software Foundation, Inc.
+ * Copyright 2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -21,20 +21,21 @@
*/
-#ifndef __DIVIDE_FF_IMPL_H__
-#define __DIVIDE_FF_IMPL_H__
+#ifndef XOR_BLK_IMPL_H
+#define XOR_BLK_IMPL_H
-#include <gnuradio/blocks/divide_ff.h>
+#include <gnuradio/blocks/xor_blk.h>
namespace gr {
namespace blocks {
- class BLOCKS_API divide_ff_impl : public divide_ff
+template<class T>
+ class BLOCKS_API xor_blk_impl : public xor_blk<T>
{
size_t d_vlen;
public:
- divide_ff_impl(size_t vlen);
+ xor_blk_impl (size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -44,4 +45,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* include guard */
+#endif /* XOR_BLK_IMPL_H */