Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / filter / generate_gr_fir_sysconfig.py
1 #!/bin/env python
2 # -*- python -*-
3 #
4 # Copyright 2003 Free Software Foundation, Inc.
5
6 # This file is part of GNU Radio
7
8 # GNU Radio is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12
13 # GNU Radio is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Radio; see the file COPYING.  If not, write to
20 # the Free Software Foundation, Inc., 51 Franklin Street,
21 # Boston, MA 02110-1301, USA.
22
23
24 from generate_utils import *
25
26
27 # ----------------------------------------------------------------
28
29 def make_gr_fir_sysconfig_h ():
30     out = open_and_log_name ('gr_fir_sysconfig.h', 'w')
31     out.write (copyright)
32
33     out.write (
34 '''
35 /*
36  * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py
37  * Any changes made to this file will be overwritten.
38  */
39
40 #ifndef INCLUDED_GR_FIR_SYSCONFIG_H
41 #define INCLUDED_GR_FIR_SYSCONFIG_H
42
43 #include <gr_types.h>
44
45 ''')
46
47     # for sig in fir_signatures:
48     #    out.write ('class gr_fir_' + sig + ';\n')
49
50     out.write ('#include <gr_fir_util.h>\n')
51
52     out.write (
53 '''
54 /*!
55  * \\brief abstract base class for configuring the automatic selection of the
56  * fastest gr_fir for your platform.
57  *
58  * This is used internally by gr_fir_util.
59  */
60
61 class gr_fir_sysconfig {
62 public:
63   virtual ~gr_fir_sysconfig ();
64
65 ''')
66     
67     for sig in fir_signatures:
68       out.write (('  virtual gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps) = 0;\n' %
69         (sig, sig, tap_type (sig))))
70
71     out.write ('\n')
72
73     for sig in fir_signatures:
74       out.write (('  virtual void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) = 0;\n' %
75         (sig, sig)))
76
77     out.write (
78 '''
79 };
80
81 /*
82  * This returns the single instance of the appropriate derived class.
83  * This function must be defined only once in the system, and should be defined 
84  * in the platform specific code.
85  */
86
87 gr_fir_sysconfig *gr_fir_sysconfig_singleton ();
88
89
90 #endif /* INCLUDED_GR_FIR_SYSCONFIG_H */
91 ''')
92     out.close ()
93     
94
95 # ----------------------------------------------------------------
96
97 def make_gr_fir_sysconfig_cc ():
98     out = open_and_log_name ('gr_fir_sysconfig.cc', 'w')
99     out.write (copyright)
100
101     out.write (
102 '''
103 /*
104  * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py
105  * Any changes made to this file will be overwritten.
106  */
107
108 #ifdef HAVE_CONFIG_H
109 #include <config.h>
110 #endif
111 #include <gr_fir_sysconfig.h>
112
113 gr_fir_sysconfig::~gr_fir_sysconfig ()
114 {
115 }
116 ''')
117     out.close ()
118     
119
120 # ----------------------------------------------------------------
121
122 def generate ():
123     make_gr_fir_sysconfig_h ()
124     make_gr_fir_sysconfig_cc ()
125
126 if __name__ == '__main__':
127     generate ()