1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/* -*- c++ -*- */
/*
* Copyright 2006-2008,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 <gnuradio/hier_block2.h>
#include <gnuradio/io_signature.h>
#include "hier_block2_detail.h"
#include <iostream>
namespace gr {
#define GR_HIER_BLOCK2_DEBUG 0
hier_block2_sptr
make_hier_block2(const std::string &name,
gr::io_signature::sptr input_signature,
gr::io_signature::sptr output_signature)
{
return gnuradio::get_initial_sptr
(new hier_block2(name, input_signature, output_signature));
}
hier_block2::hier_block2(const std::string &name,
gr::io_signature::sptr input_signature,
gr::io_signature::sptr output_signature)
: basic_block(name, input_signature, output_signature),
d_detail(new hier_block2_detail(this)),
hier_message_ports_in(pmt::PMT_NIL),
hier_message_ports_out(pmt::PMT_NIL)
{
// This bit of magic ensures that self() works in the constructors of derived classes.
gnuradio::detail::sptr_magic::create_and_stash_initial_sptr(this);
}
hier_block2::~hier_block2()
{
delete d_detail;
}
hier_block2::opaque_self
hier_block2::self()
{
return shared_from_this();
}
hier_block2_sptr
hier_block2::to_hier_block2()
{
return cast_to_hier_block2_sptr(shared_from_this());
}
void
hier_block2::connect(basic_block_sptr block)
{
d_detail->connect(block);
}
void
hier_block2::connect(basic_block_sptr src, int src_port,
basic_block_sptr dst, int dst_port)
{
d_detail->connect(src, src_port, dst, dst_port);
}
void
hier_block2::msg_connect(basic_block_sptr src, pmt::pmt_t srcport,
basic_block_sptr dst, pmt::pmt_t dstport)
{
if(!pmt::is_symbol(srcport)) {
throw std::runtime_error("bad port id");
}
d_detail->msg_connect(src, srcport, dst, dstport);
}
void
hier_block2::msg_connect(basic_block_sptr src, std::string srcport,
basic_block_sptr dst, std::string dstport)
{
d_detail->msg_connect(src, pmt::mp(srcport), dst, pmt::mp(dstport));
}
void
hier_block2::msg_disconnect(basic_block_sptr src, pmt::pmt_t srcport,
basic_block_sptr dst, pmt::pmt_t dstport)
{
if(!pmt::is_symbol(srcport)) {
throw std::runtime_error("bad port id");
}
d_detail->msg_disconnect(src, srcport, dst, dstport);
}
void
hier_block2::msg_disconnect(basic_block_sptr src, std::string srcport,
basic_block_sptr dst, std::string dstport)
{
d_detail->msg_disconnect(src, pmt::mp(srcport), dst, pmt::mp(dstport));
}
void
hier_block2::disconnect(basic_block_sptr block)
{
d_detail->disconnect(block);
}
void
hier_block2::disconnect(basic_block_sptr src, int src_port,
basic_block_sptr dst, int dst_port)
{
d_detail->disconnect(src, src_port, dst, dst_port);
}
void
hier_block2::disconnect_all()
{
d_detail->disconnect_all();
}
void
hier_block2::lock()
{
d_detail->lock();
}
void
hier_block2::unlock()
{
d_detail->unlock();
}
flat_flowgraph_sptr
hier_block2::flatten() const
{
flat_flowgraph_sptr new_ffg = make_flat_flowgraph();
d_detail->flatten_aux(new_ffg);
return new_ffg;
}
} /* namespace gr */
|