Merge jcorgan/hier developer branch into trunk. Enables creation of true hierarchica...
[debian/gnuradio] / gnuradio-core / src / lib / runtime / gr_hier_block2_detail.h
1 /*
2  * Copyright 2006 Free Software Foundation, Inc.
3  * 
4  * This file is part of GNU Radio
5  * 
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  * 
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 #ifndef INCLUDED_GR_HIER_BLOCK2_DETAIL_H
22 #define INCLUDED_GR_HIER_BLOCK2_DETAIL_H
23
24 #include <gr_hier_block2.h>
25 #include <gr_simple_flowgraph_detail.h>
26 #include <boost/utility.hpp>
27
28 typedef std::map<std::string, gr_basic_block_sptr> gr_hier_component_map_t;
29 typedef std::map<std::string, gr_basic_block_sptr>::iterator gr_hier_component_miter_t;
30
31 class gr_hier_block2_detail : boost::noncopyable
32 {
33 private:
34     friend class gr_hier_block2;
35     friend class gr_runtime_impl;
36     
37     // Constructor--it's private, only friends can instantiate
38     gr_hier_block2_detail(gr_hier_block2 *owner);
39
40     // Private implementation data
41     gr_hier_block2 *d_owner;
42     gr_hier_component_map_t d_components;
43     gr_edge_vector_t d_edges;
44         
45     // Private implementation methods
46     void define_component(const std::string &name, gr_basic_block_sptr block);
47     gr_basic_block_sptr lookup_block(const std::string &name);
48     void connect(const std::string &src_name, int src_port, 
49                  const std::string &dst_name, int dst_port);
50     void check_valid_port(gr_io_signature_sptr sig, int port);
51     void check_dst_not_used(const std::string name, int port);
52     void check_type_match(gr_io_signature_sptr src_sig, int src_port,
53                           gr_io_signature_sptr dst_sig, int dst_port);
54     std::string prepend_prefix(const std::string &prefix, const std::string &str);
55     void flatten(gr_simple_flowgraph_sptr sfg, const std::string &prefix = "");
56     void flatten_components(gr_simple_flowgraph_sptr sfg, const std::string &prefix);
57     void flatten_edges(gr_simple_flowgraph_sptr sfg, const std::string &prefix);
58     gr_endpoint match_endpoint(const std::string &name, int port, bool is_input);
59     gr_endpoint resolve_endpoint(const std::string &name, int port, 
60                                  const std::string &prefix, bool is_input);
61     
62 public:
63     ~gr_hier_block2_detail();
64 };
65
66 #endif /* INCLUDED_GR_HIER_BLOCK2_DETAIL_H */