3 * Copyright 2006,2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <qa_gr_hier_block2_derived.h>
28 #include <gr_top_block.h>
29 #include <gr_io_signature.h>
30 #include <gr_null_source.h>
31 #include <gr_null_sink.h>
33 #include <gr_kludge_copy.h>
35 // Declare a test C++ hierarchical block
37 class gr_derived_block;
38 typedef boost::shared_ptr<gr_derived_block> gr_derived_block_sptr;
39 gr_derived_block_sptr gr_make_derived_block();
41 class gr_derived_block : public gr_hier_block2
44 friend gr_derived_block_sptr gr_make_derived_block();
53 gr_make_derived_block()
55 return gnuradio::get_initial_sptr(new gr_derived_block());
58 gr_derived_block::gr_derived_block()
59 : gr_hier_block2("gr_derived_block",
60 gr_make_io_signature(1, 1, sizeof(int)), // Input signature
61 gr_make_io_signature(1, 1, sizeof(int))) // Output signature
63 gr_block_sptr copy(gr_make_kludge_copy(sizeof(int)));
65 connect(self(), 0, copy, 0);
66 connect(copy, 0, self(), 0);
69 gr_derived_block::~gr_derived_block()
73 void qa_gr_hier_block2_derived::test_1()
75 gr_top_block_sptr tb(gr_make_top_block("test"));
77 gr_block_sptr src(gr_make_null_source(sizeof(int)));
78 gr_block_sptr head(gr_make_head(sizeof(int), 1000));
79 gr_derived_block_sptr blk(gr_make_derived_block());
80 gr_block_sptr dst(gr_make_null_sink(sizeof(int)));
82 tb->connect(src, 0, head, 0);
83 tb->connect(head, 0, blk, 0);
84 tb->connect(blk, 0, dst, 0);