root / gnuradio-core / src / lib / runtime / qa_gr_hier_block2_derived.cc @ d65ae424
History | View | Annotate | Download (2.3 kB)
| 1 | 395e1fa6 | eb | /* -*- c++ -*- */
|
|---|---|---|---|
| 2 | 395e1fa6 | eb | /*
|
| 3 | 395e1fa6 | eb | * Copyright 2006,2008 Free Software Foundation, Inc. |
| 4 | 395e1fa6 | eb | * |
| 5 | 395e1fa6 | eb | * This file is part of GNU Radio |
| 6 | 395e1fa6 | eb | * |
| 7 | 395e1fa6 | eb | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | 395e1fa6 | eb | * it under the terms of the GNU General Public License as published by |
| 9 | 395e1fa6 | eb | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | 395e1fa6 | eb | * any later version. |
| 11 | 395e1fa6 | eb | * |
| 12 | 395e1fa6 | eb | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | 395e1fa6 | eb | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | 395e1fa6 | eb | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | 395e1fa6 | eb | * GNU General Public License for more details. |
| 16 | 395e1fa6 | eb | * |
| 17 | 395e1fa6 | eb | * You should have received a copy of the GNU General Public License |
| 18 | 395e1fa6 | eb | * along with GNU Radio; see the file COPYING. If not, write to |
| 19 | 395e1fa6 | eb | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | 395e1fa6 | eb | * Boston, MA 02110-1301, USA. |
| 21 | 395e1fa6 | eb | */ |
| 22 | 395e1fa6 | eb | |
| 23 | 395e1fa6 | eb | #ifdef HAVE_CONFIG_H
|
| 24 | 395e1fa6 | eb | #include <config.h> |
| 25 | 395e1fa6 | eb | #endif
|
| 26 | 395e1fa6 | eb | |
| 27 | 395e1fa6 | eb | #include <qa_gr_hier_block2_derived.h> |
| 28 | 395e1fa6 | eb | #include <gr_top_block.h> |
| 29 | 395e1fa6 | eb | #include <gr_io_signature.h> |
| 30 | 395e1fa6 | eb | #include <gr_null_source.h> |
| 31 | 395e1fa6 | eb | #include <gr_null_sink.h> |
| 32 | 395e1fa6 | eb | #include <gr_head.h> |
| 33 | 395e1fa6 | eb | #include <gr_kludge_copy.h> |
| 34 | 395e1fa6 | eb | |
| 35 | 395e1fa6 | eb | // Declare a test C++ hierarchical block
|
| 36 | 395e1fa6 | eb | |
| 37 | 395e1fa6 | eb | class gr_derived_block; |
| 38 | 395e1fa6 | eb | typedef boost::shared_ptr<gr_derived_block> gr_derived_block_sptr;
|
| 39 | 395e1fa6 | eb | gr_derived_block_sptr gr_make_derived_block(); |
| 40 | 395e1fa6 | eb | |
| 41 | 395e1fa6 | eb | class gr_derived_block : public gr_hier_block2 |
| 42 | 395e1fa6 | eb | {
|
| 43 | 395e1fa6 | eb | private:
|
| 44 | 395e1fa6 | eb | friend gr_derived_block_sptr gr_make_derived_block();
|
| 45 | 395e1fa6 | eb | gr_derived_block(); |
| 46 | 395e1fa6 | eb | |
| 47 | 395e1fa6 | eb | public:
|
| 48 | 395e1fa6 | eb | ~gr_derived_block(); |
| 49 | 395e1fa6 | eb | }; |
| 50 | 395e1fa6 | eb | |
| 51 | 395e1fa6 | eb | |
| 52 | 395e1fa6 | eb | gr_derived_block_sptr |
| 53 | 395e1fa6 | eb | gr_make_derived_block() |
| 54 | 395e1fa6 | eb | {
|
| 55 | 395e1fa6 | eb | return gnuradio::get_initial_sptr(new gr_derived_block()); |
| 56 | 395e1fa6 | eb | } |
| 57 | 395e1fa6 | eb | |
| 58 | 395e1fa6 | eb | gr_derived_block::gr_derived_block() |
| 59 | 395e1fa6 | eb | : gr_hier_block2("gr_derived_block",
|
| 60 | 395e1fa6 | eb | gr_make_io_signature(1, 1, sizeof(int)), // Input signature |
| 61 | 395e1fa6 | eb | gr_make_io_signature(1, 1, sizeof(int))) // Output signature |
| 62 | 395e1fa6 | eb | {
|
| 63 | 395e1fa6 | eb | gr_block_sptr copy(gr_make_kludge_copy(sizeof(int))); |
| 64 | 395e1fa6 | eb | |
| 65 | 395e1fa6 | eb | connect(self(), 0, copy, 0); |
| 66 | 395e1fa6 | eb | connect(copy, 0, self(), 0); |
| 67 | 395e1fa6 | eb | } |
| 68 | 395e1fa6 | eb | |
| 69 | 395e1fa6 | eb | gr_derived_block::~gr_derived_block() |
| 70 | 395e1fa6 | eb | {
|
| 71 | 395e1fa6 | eb | } |
| 72 | 395e1fa6 | eb | |
| 73 | 395e1fa6 | eb | void qa_gr_hier_block2_derived::test_1()
|
| 74 | 395e1fa6 | eb | {
|
| 75 | 395e1fa6 | eb | gr_top_block_sptr tb(gr_make_top_block("test"));
|
| 76 | 395e1fa6 | eb | |
| 77 | 395e1fa6 | eb | gr_block_sptr src(gr_make_null_source(sizeof(int))); |
| 78 | 395e1fa6 | eb | gr_block_sptr head(gr_make_head(sizeof(int), 1000)); |
| 79 | 395e1fa6 | eb | gr_derived_block_sptr blk(gr_make_derived_block()); |
| 80 | 395e1fa6 | eb | gr_block_sptr dst(gr_make_null_sink(sizeof(int))); |
| 81 | 395e1fa6 | eb | |
| 82 | 395e1fa6 | eb | tb->connect(src, 0, head, 0); |
| 83 | 395e1fa6 | eb | tb->connect(head, 0, blk, 0); |
| 84 | 395e1fa6 | eb | tb->connect(blk, 0, dst, 0); |
| 85 | 395e1fa6 | eb | |
| 86 | 395e1fa6 | eb | tb->run(); |
| 87 | 395e1fa6 | eb | } |