Merged latest pmt and mblock into trunk (eb/wip -r4262:4268)
[debian/gnuradio] / mblock / src / lib / mb_mblock.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 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 2, 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 along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <mb_mblock.h>
27 #include <mb_mblock_impl.h>
28
29
30 mb_mblock::mb_mblock()
31   : d_impl(mb_mblock_impl_sptr(new mb_mblock_impl(this)))
32 {
33 }
34
35 mb_mblock::~mb_mblock()
36 {
37   disconnect_all();
38
39   // FIXME more?
40 }
41
42
43 void
44 mb_mblock::init_fsm()
45 {
46   // default implementation does nothing
47 }
48
49 void
50 mb_mblock::handle_message(mb_message_sptr msg)
51 {
52   // default implementation does nothing
53 }
54
55 ////////////////////////////////////////////////////////////////////////
56 //           Forward other methods to implementation class            //
57 ////////////////////////////////////////////////////////////////////////
58
59 mb_port_sptr
60 mb_mblock::define_port(const std::string &port_name_string,
61                        const std::string &protocol_class_name,
62                        bool conjugated,
63                        mb_port::port_type_t port_type)
64 {
65   return d_impl->define_port(port_name_string, protocol_class_name,
66                              conjugated, port_type);
67 }
68
69 void
70 mb_mblock::define_component(const std::string &component_name,
71                             mb_mblock_sptr component)
72 {
73   d_impl->define_component(component_name, component);
74 }
75
76 void
77 mb_mblock::connect(const std::string &comp_name1, const std::string &port_name1,
78                    const std::string &comp_name2, const std::string &port_name2)
79 {
80   d_impl->connect(comp_name1, port_name1,
81                   comp_name2, port_name2);
82 }                               
83
84
85 void
86 mb_mblock::disconnect(const std::string &comp_name1, const std::string &port_name1,
87                       const std::string &comp_name2, const std::string &port_name2)
88 {
89   d_impl->disconnect(comp_name1, port_name1,
90                      comp_name2, port_name2);
91 }
92
93 void
94 mb_mblock::disconnect_component(const std::string component_name)
95 {
96   d_impl->disconnect_component(component_name);
97 }
98
99 void
100 mb_mblock::disconnect_all()
101 {
102   d_impl->disconnect_all();
103 }
104
105 int
106 mb_mblock::nconnections() const
107 {
108   return d_impl->nconnections();
109 }
110
111 bool
112 mb_mblock::walk_tree(mb_visitor *visitor, const std::string &path)
113 {
114   return d_impl->walk_tree(visitor, path);
115 }