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
|
/* -*- c++ -*- */
/*
* Copyright 2006,2007,2008 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 <gr_hier_block2.h>
#include <gr_io_signature.h>
#include <gr_hier_block2_detail.h>
#include <iostream>
#define GR_HIER_BLOCK2_DEBUG 0
gr_hier_block2_sptr
gr_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 gr_hier_block2(name, input_signature, output_signature));
}
gr_hier_block2::gr_hier_block2(const std::string &name,
gr_io_signature_sptr input_signature,
gr_io_signature_sptr output_signature)
: gr_basic_block(name, input_signature, output_signature),
d_detail(new gr_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);
}
gr_hier_block2::~gr_hier_block2()
{
delete d_detail;
}
gr_hier_block2::opaque_self
gr_hier_block2::self()
{
return shared_from_this();
}
gr_hier_block2_sptr
gr_hier_block2::to_hier_block2()
{
return cast_to_hier_block2_sptr(shared_from_this());
}
void
gr_hier_block2::connect(gr_basic_block_sptr block)
{
d_detail->connect(block);
}
void
gr_hier_block2::connect(gr_basic_block_sptr src, int src_port,
gr_basic_block_sptr dst, int dst_port)
{
d_detail->connect(src, src_port, dst, dst_port);
}
void
gr_hier_block2::msg_connect(gr_basic_block_sptr src, pmt::pmt_t srcport,
gr_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
gr_hier_block2::msg_connect(gr_basic_block_sptr src, std::string srcport,
gr_basic_block_sptr dst, std::string dstport)
{
d_detail->msg_connect(src, pmt::mp(srcport), dst, pmt::mp(dstport));
}
void
gr_hier_block2::msg_disconnect(gr_basic_block_sptr src, pmt::pmt_t srcport,
gr_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
gr_hier_block2::msg_disconnect(gr_basic_block_sptr src, std::string srcport,
gr_basic_block_sptr dst, std::string dstport)
{
d_detail->msg_disconnect(src, pmt::mp(srcport), dst, pmt::mp(dstport));
}
void
gr_hier_block2::disconnect(gr_basic_block_sptr block)
{
d_detail->disconnect(block);
}
void
gr_hier_block2::disconnect(gr_basic_block_sptr src, int src_port,
gr_basic_block_sptr dst, int dst_port)
{
d_detail->disconnect(src, src_port, dst, dst_port);
}
void
gr_hier_block2::disconnect_all()
{
d_detail->disconnect_all();
}
void
gr_hier_block2::lock()
{
d_detail->lock();
}
void
gr_hier_block2::unlock()
{
d_detail->unlock();
}
gr_flat_flowgraph_sptr
gr_hier_block2::flatten() const
{
gr_flat_flowgraph_sptr new_ffg = gr_make_flat_flowgraph();
d_detail->flatten_aux(new_ffg);
return new_ffg;
}
|