3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
21 #ifndef INCLUDED_MB_MBLOCK_IMPL_H
22 #define INCLUDED_MB_MBLOCK_IMPL_H
24 #include <mb_mblock.h>
25 #include <mb_connection.h>
30 typedef std::map<std::string, mb_port_sptr> mb_port_map_t;
31 typedef std::map<std::string, mb_mblock_sptr> mb_comp_map_t;
35 * \brief The private implementation details of the mblock system.
37 class mb_mblock_impl : boost::noncopyable
39 mb_mblock *d_mb; // pointer to our associated mblock
41 mb_port_map_t d_port_map; // our ports
42 mb_comp_map_t d_comp_map; // our components
43 mb_conn_table d_conn_table; // our connections
46 mb_mblock_impl(mb_mblock *mb);
50 * \brief Define a port.
52 * EXTERNAL and RELAY ports are part of our peer interface.
53 * INTERNAL ports are used to talk to sub-components.
55 * \param port_name The name of the port (must be unique within this mblock).
56 * \param protocol_class_name The name of the protocol class associated with
57 * this port. It must already be defined.
58 * \param conjugated Are the incoming and outgoing message sets swapped?
59 * \param port_type INTERNAL, EXTERNAL or RELAY.
62 define_port(const std::string &port_name,
63 const std::string &protocol_class_name,
65 mb_port::port_type_t port_type);
68 * \brief Define a subcomponent by name.
70 * Called within the constructor to tell the system the
71 * names and identities of our sub-component mblocks.
73 * \param component_name The name of the sub-component (must be unique with this mblock).
74 * \param component The sub-component instance.
77 define_component(const std::string &component_name,
78 mb_mblock_sptr component);
81 * \brief connect endpoint_1 to endpoint_2
83 * \param comp_name1 component on one of the connection
84 * \param port_name1 the name of the port on comp1
85 * \param comp_name2 component on the other end the connection
86 * \param port_name2 the name of the port on comp2
88 * An endpoint is specified by the component's local name (given as
89 * component_name in the call to register_component) and the name of
90 * the port on that component.
92 * To connect an internal or relay port, use "self" as the component name.
95 connect(const std::string &comp_name1, const std::string &port_name1,
96 const std::string &comp_name2, const std::string &port_name2);
99 * \brief disconnect endpoint_1 from endpoint_2
101 * \param comp_name1 component on one of the connection
102 * \param port_name1 the name of the port on comp1
103 * \param comp_name2 component on the other end the connection
104 * \param port_name2 the name of the port on comp2
106 * An endpoint is specified by the component's local name (given as
107 * component_name in the call to register_component) and the name of
108 * the port on that component.
110 * To disconnect an internal or relay port, use "self" as the component name.
113 disconnect(const std::string &comp_name1, const std::string &port_name1,
114 const std::string &comp_name2, const std::string &port_name2);
117 * \brief disconnect all connections to specified component
118 * \param component_name component to disconnect
121 disconnect_component(const std::string component_name);
124 * \brief disconnect all connections to all components
130 * \brief Return number of connections (QA mostly)
133 nconnections() const;
136 walk_tree(mb_visitor *visitor, const std::string &path="");
139 * Our implementation methods
142 //bool port_is_defined(pmt_t name);
143 bool port_is_defined(const std::string &name);
144 //bool comp_is_defined(pmt_t name);
145 bool comp_is_defined(const std::string &name);
148 check_and_resolve_endpoint(const std::string &comp_name,
149 const std::string &port_name);
153 resolve_port(const std::string &comp_name,
154 const std::string &port_name);
157 ports_are_compatible(mb_port_sptr p0, mb_port_sptr p1);
162 #endif /* INCLUDED_MB_MBLOCK_IMPL_H */