Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / filter / generate_gr_fir_sysconfig.py
1 #!/bin/env python
2 # -*- python -*-
3 #
4 # Copyright 2003,2009 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 3, 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     if not out:
32         return
33
34     out.write (copyright)
35
36     out.write (
37 '''
38 /*
39  * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py
40  * Any changes made to this file will be overwritten.
41  */
42
43 #ifndef INCLUDED_GR_FIR_SYSCONFIG_H
44 #define INCLUDED_GR_FIR_SYSCONFIG_H
45
46 #include <gr_types.h>
47
48 ''')
49
50     # for sig in fir_signatures:
51     #    out.write ('class gr_fir_' + sig + ';\n')
52
53     out.write ('#include <gr_fir_util.h>\n')
54
55     out.write (
56 '''
57 /*!
58  * \\brief abstract base class for configuring the automatic selection of the
59  * fastest gr_fir for your platform.
60  *
61  * This is used internally by gr_fir_util.
62  */
63
64 class gr_fir_sysconfig {
65 public:
66   virtual ~gr_fir_sysconfig ();
67
68 ''')
69     
70     for sig in fir_signatures:
71       out.write (('  virtual gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps) = 0;\n' %
72         (sig, sig, tap_type (sig))))
73
74     out.write ('\n')
75
76     for sig in fir_signatures:
77       out.write (('  virtual void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) = 0;\n' %
78         (sig, sig)))
79
80     out.write (
81 '''
82 };
83
84 /*
85  * This returns the single instance of the appropriate derived class.
86  * This function must be defined only once in the system, and should be defined 
87  * in the platform specific code.
88  */
89
90 gr_fir_sysconfig *gr_fir_sysconfig_singleton ();
91
92
93 #endif /* INCLUDED_GR_FIR_SYSCONFIG_H */
94 ''')
95     out.close ()
96     
97
98 # ----------------------------------------------------------------
99
100 def make_gr_fir_sysconfig_cc ():
101     out = open_and_log_name ('gr_fir_sysconfig.cc', 'w')
102     if not out:
103         return
104
105     out.write (copyright)
106
107     out.write (
108 '''
109 /*
110  * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py
111  * Any changes made to this file will be overwritten.
112  */
113
114 #ifdef HAVE_CONFIG_H
115 #include <config.h>
116 #endif
117 #include <gr_fir_sysconfig.h>
118
119 gr_fir_sysconfig::~gr_fir_sysconfig ()
120 {
121 }
122 ''')
123     out.close ()
124     
125
126 # ----------------------------------------------------------------
127
128 def generate ():
129     make_gr_fir_sysconfig_h ()
130     make_gr_fir_sysconfig_cc ()
131
132 if __name__ == '__main__':
133     generate ()