Imported Upstream version 3.2.2
[debian/gnuradio] / mblock / src / lib / mb_connection.h
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 3, 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 #ifndef INCLUDED_MB_CONNECTION_H
23 #define INCLUDED_MB_CONNECTION_H
24
25 #include <mb_endpoint.h>
26 #include <list>
27
28 /*!
29  * \brief Representation of a connection
30  */
31 struct mb_connection {
32   mb_endpoint   d_ep[2];
33
34   mb_connection(const mb_endpoint &ep0, const mb_endpoint &ep1){
35     d_ep[0] = ep0;
36     d_ep[1] = ep1;
37   }
38 };
39
40 typedef std::list<mb_connection>::iterator mb_conn_iter;
41 typedef std::list<mb_connection>::const_iterator mb_conn_const_iter;
42
43 /*!
44  * \brief data structure that keeps track of connections
45  */
46 class mb_conn_table {
47   std::list<mb_connection> d_connections;
48
49 public:
50   bool
51   lookup_conn_by_name(const std::string &component_name,
52                       const std::string &port_name,
53                       mb_conn_iter *it, int *which_ep);
54
55   bool
56   lookup_conn_by_port(const mb_port *port,
57                       mb_conn_iter *it, int *which_ep);
58
59   void
60   create_conn(const mb_endpoint &ep0, const mb_endpoint &ep1);
61
62
63   void
64   disconnect(const std::string &comp_name1, const std::string &port_name1,
65              const std::string &comp_name2, const std::string &port_name2);
66
67   void
68   disconnect_component(const std::string component_name);
69
70   void
71   disconnect_all();
72
73   int
74   nconnections() const;
75
76 };
77
78 #endif /* INCLUDED_MB_CONNECTION_H */