Updated license from GPL version 2 or later to GPL version 3 or later.
[debian/gnuradio] / gnuradio-core / src / lib / runtime / gr_simple_flowgraph.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,2007 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
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef INCLUDED_GR_SIMPLE_FLOWGRAPH_H
24 #define INCLUDED_GR_SIMPLE_FLOWGRAPH_H
25
26 #include <gr_block.h>
27 #include <boost/shared_ptr.hpp>
28 #include <string>
29
30 gr_simple_flowgraph_sptr gr_make_simple_flowgraph();
31
32 class gr_simple_flowgraph_detail;
33
34 class gr_endpoint
35 {
36 private:
37   friend class gr_hier_block2_detail;
38   gr_basic_block_sptr d_block;
39   int d_port;
40
41 public:
42   gr_endpoint() : d_block(), d_port(0) { } // Internal use only
43   gr_endpoint(gr_basic_block_sptr block, int port) { d_block = block; d_port = port; }
44   gr_basic_block_sptr block() const { return d_block; }
45   int port() const { return d_port; }
46 };    
47
48 typedef std::vector<gr_endpoint> gr_endpoint_vector_t;
49
50 /*!
51  *\brief Class representing a low-level, "flattened" flow graph
52  *
53  * This class holds the results of the call to gr.hier_block2.flatten(),
54  * which is a graph that has only the connected blocks and edges of
55  * the original hier_block2, with all the hierarchy removed.
56  *
57  * While this class is exported to Python via SWIG for ease of QA
58  * testing, it is not used by application developers, and there is
59  * no way to feed this to a gr.runtime() instance.
60  */
61 class gr_simple_flowgraph
62 {
63 private:
64   friend class gr_runtime_impl;
65   friend class gr_simple_flowgraph_detail;
66   friend class gr_hier_block2_detail;
67   friend gr_simple_flowgraph_sptr gr_make_simple_flowgraph();
68   gr_simple_flowgraph();
69
70   gr_simple_flowgraph_detail *d_detail;
71             
72 public:
73   ~gr_simple_flowgraph();
74
75   void connect(gr_basic_block_sptr src_block, int src_port,
76                gr_basic_block_sptr dst_block, int dst_port);
77   void connect(const gr_endpoint &src, const gr_endpoint &dst);
78   void disconnect(gr_basic_block_sptr src_block, int src_port,
79                   gr_basic_block_sptr dst_block, int dst_port);
80   void validate();
81 };
82
83 #endif /* INCLUDED_GR_SIMPLE_FLOWGRAPH_H */