Imported Upstream version 3.2.2
[debian/gnuradio] / grc / gui / Platform.py
1 """
2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
4
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 GNU Radio Companion is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18 """
19
20 from FlowGraph import FlowGraph
21 from Connection import Connection
22 from Block import Block
23 from Port import Port
24 from Param import Param
25
26 def conjoin_classes(name, c1, c2):
27         exec("""
28 class %s(c1, c2):
29         def __init__(self, *args, **kwargs):
30                 c1.__init__(self, *args, **kwargs)
31                 c2.__init__(self, *args, **kwargs)
32 """%name, locals())
33         return locals()[name]
34
35 def Platform(platform):
36         #combine with gui class
37         for attr, value in (
38                 ('FlowGraph', FlowGraph),
39                 ('Connection', Connection),
40                 ('Block', Block),
41                 ('Source', Port),
42                 ('Sink', Port),
43                 ('Param', Param),
44         ):
45                 old_value = getattr(platform, attr)
46                 c = conjoin_classes(attr, old_value, value)
47                 setattr(platform, attr, c)
48         return platform