bf9f5b0ce1c09de3266965564da3e8b8a7cf7c55
[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_visitor::~mb_visitor()
31 {
32   // nop base case for virtual destructor.
33 }
34
35
36 mb_mblock::mb_mblock()
37   : d_impl(mb_mblock_impl_sptr(new mb_mblock_impl(this)))
38 {
39 }
40
41 mb_mblock::~mb_mblock()
42 {
43   disconnect_all();
44
45   // FIXME more?
46 }
47
48
49 void
50 mb_mblock::init_fsm()
51 {
52   // default implementation does nothing
53 }
54
55 void
56 mb_mblock::handle_message(mb_message_sptr msg)
57 {
58   // default implementation does nothing
59 }
60
61 ////////////////////////////////////////////////////////////////////////
62 //           Forward other methods to implementation class            //
63 ////////////////////////////////////////////////////////////////////////
64
65 mb_port_sptr
66 mb_mblock::define_port(const std::string &port_name_string,
67                        const std::string &protocol_class_name,
68                        bool conjugated,
69                        mb_port::port_type_t port_type)
70 {
71   return d_impl->define_port(port_name_string, protocol_class_name,
72                              conjugated, port_type);
73 }
74
75 void
76 mb_mblock::define_component(const std::string &component_name,
77                             mb_mblock_sptr component)
78 {
79   d_impl->define_component(component_name, component);
80 }
81
82 void
83 mb_mblock::connect(const std::string &comp_name1, const std::string &port_name1,
84                    const std::string &comp_name2, const std::string &port_name2)
85 {
86   d_impl->connect(comp_name1, port_name1,
87                   comp_name2, port_name2);
88 }                               
89
90
91 void
92 mb_mblock::disconnect(const std::string &comp_name1, const std::string &port_name1,
93                       const std::string &comp_name2, const std::string &port_name2)
94 {
95   d_impl->disconnect(comp_name1, port_name1,
96                      comp_name2, port_name2);
97 }
98
99 void
100 mb_mblock::disconnect_component(const std::string component_name)
101 {
102   d_impl->disconnect_component(component_name);
103 }
104
105 void
106 mb_mblock::disconnect_all()
107 {
108   d_impl->disconnect_all();
109 }
110
111 int
112 mb_mblock::nconnections() const
113 {
114   return d_impl->nconnections();
115 }
116
117 bool
118 mb_mblock::walk_tree(mb_visitor *visitor, const std::string &path)
119 {
120   return d_impl->walk_tree(visitor, path);
121 }
122
123 std::string
124 mb_mblock::fullname() const
125 {
126   return d_impl->fullname();
127 }
128
129 void
130 mb_mblock::set_fullname(const std::string name)
131 {
132   d_impl->set_fullname(name);
133 }
134
135 mb_mblock *
136 mb_mblock::parent() const
137 {
138   return d_impl->mblock_parent();
139 }