Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / lib / runtime / qa_gr_hier_block2_derived.cc @ 395e1fa6

History | View | Annotate | Download (2.3 kB)

1
/* -*- c++ -*- */
2
/*
3
 * Copyright 2006,2008 Free Software Foundation, Inc.
4
 * 
5
 * This file is part of GNU Radio
6
 * 
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)
10
 * any later version.
11
 * 
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.
16
 * 
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.
21
 */
22
23
#ifdef HAVE_CONFIG_H
24
#include <config.h>
25
#endif
26
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>
32
#include <gr_head.h>
33
#include <gr_kludge_copy.h>
34
35
// Declare a test C++ hierarchical block
36
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();
40
41
class gr_derived_block : public gr_hier_block2
42
{
43
private:
44
  friend gr_derived_block_sptr gr_make_derived_block();
45
  gr_derived_block();
46
47
public:
48
  ~gr_derived_block();
49
};
50
51
52
gr_derived_block_sptr
53
gr_make_derived_block()
54
{
55
  return gnuradio::get_initial_sptr(new gr_derived_block());
56
}
57
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
62
{
63
  gr_block_sptr copy(gr_make_kludge_copy(sizeof(int)));
64
65
  connect(self(), 0, copy, 0);
66
  connect(copy, 0, self(), 0);
67
}
68
69
gr_derived_block::~gr_derived_block()
70
{
71
}
72
73
void qa_gr_hier_block2_derived::test_1()
74
{
75
  gr_top_block_sptr     tb(gr_make_top_block("test"));
76
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)));
81
  
82
  tb->connect(src,  0, head, 0);
83
  tb->connect(head, 0, blk,  0);
84
  tb->connect(blk,  0, dst,  0);
85
86
  tb->run();
87
}