So, the trick is that the different types of the add_XX
blocks are actually different classes, and the dropdown menu actually makes the GNU Radio companion set a few variables, which in turn are used to decide which block is used; this is all relatively ugly code in the XML file that describes the add_xx:
<?xml version="1.0"?>
...
<block>
<name>Add</name>
<key>blocks_add_xx</key>
<import>from gnuradio import blocks</import>
<make>blocks.add_v$(type.fcn)($vlen)</make>
<param>
<name>IO Type</name>
<key>type</key>
<type>enum</type>
<option>
<name>Complex</name>
<key>complex</key>
<opt>fcn:cc</opt>
</option>
<option>
<name>Float</name>
<key>float</key>
<opt>fcn:ff</opt>
</option>
...
</param>
<param>
<name>Num Inputs</name>
<key>num_inputs</key>
<value>2</value>
<type>int</type>
</param>
<param>
<name>Vec Length</name>
<key>vlen</key>
<value>1</value>
<type>int</type>
</param>
<check>$num_inputs > 1</check>
<check>$vlen > 0</check>
<sink>
<name>in</name>
<type>$type</type>
<vlen>$vlen</vlen>
<nports>$num_inputs</nports>
</sink>
<source>
<name>out</name>
<type>$type</type>
<vlen>$vlen</vlen>
</source>
</block>
So, there's an add_cc
class for complex, an add_ff
for float and so on. In fact, GNU Radio's build system generates these implementations from a single text template.
So, whilst I do think it's a very good idea to recreate a simple block like add_cc
, the type variability is as much a feature seldom necessary when implementing new stuff, as hard to do right for a beginner.
So: start with a single type, and follow the official GNU Radio Guided Tutorials from 1 to 5. They were made especially for people like you, and they cover C++ blocks!