3 # Copyright 2004 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
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 2, or (at your option)
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.
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.
24 Random notes on coding conventions, some explanations about why things
25 aren't done differently, etc, etc,
30 GNU Radio is now a hybrid system. Some parts of the system are built
31 in C++ and some of it in Python. In general, prefer Python to C++.
32 Signal processing primitives are still built in C++ for performance.
34 It is no longer possible to build user applications entirely in C++.
35 Essential parts of the runtime system have been moved into Python.
40 In the cleanup process, I considered putting everything in the
41 gnuradio namespace and dropping the Gr|gr prefix. In fact, I think
42 it's probably the right idea, but when I tested it out, I ran into
43 problems with SWIG's handling of namespaces. Bottom line, SWIG
44 (1.3.21) got confused and generated bad code when I started playing
45 around with namespaces in a not particularly convoluted way. I saw
46 problems using the boost::shared_ptr template in combination with
47 classes defined in the gnuradio namespace. It wasn't pretty...
52 Death to CamelCaseNames! We've returned to a kinder, gentler era.
53 We're now using the "STL style" naming convention with a couple of
54 modifications since we're not using namespaces.
56 With the exception of macros and other constant values, all
57 identifiers shall be lower case with words_separated_like_this.
59 Macros and constant values (e.g., enumerated values,
60 static const int FOO = 23) shall be in UPPER_CASE.
65 All globally visible names (types, functions, variables, consts, etc)
66 shall begin with a "package prefix", followed by an '_'. The bulk of
67 the code in GNU Radio logically belongs to the "gr" package, hence
68 names look like gr_open_file (...).
70 Large coherent bodies of code may use other package prefixes, but
71 let's try to keep them to a well thought out list. See the list
76 These are the current package prefixes:
80 gri_ Implementation primitives. Sometimes we
81 have both a gr_<foo> and a gri_<foo>. In that case,
82 gr_<foo> would be derived from gr_block and gri_<foo>
83 would be the low level guts of the function.
85 atsc_ Code related to the Advanced Television
86 Standards Committee HDTV implementation
88 usrp_ Universal Software Radio Peripheral
90 qa_ Quality Assurance. Test code.
93 ** Class data members (instance variables)
95 All class data members shall begin with d_<foo>.
97 The big win is when you're staring at a block of code it's obvious
98 which of the things being assigned to persist outside of the block.
99 This also keeps you from having to be creative with parameter names
100 for methods and constructors. You just use the same name as the
101 instance variable, without the d_.
103 class gr_wonderfulness {
105 double d_wonderfulness_factor;
108 gr_wonderfulness (std::string name, double wonderfulness_factor)
109 : d_name (name), d_wonderfulness_factor (wonderfulness_factor)
117 ** Class static data members (class variables)
119 All class static data members shall begin with s_<foo>.
124 Each significant class shall be contained in it's own file. The
125 declaration of class gr_foo shall be in gr_foo.h, the definition in
132 Strongly consider using the boost smart pointer templates, scoped_ptr
133 and shared_ptr. scoped_ptr should be used for locals that contain
134 pointers to objects that we need to delete when we exit the current
135 scope. shared_ptr implements transparent reference counting and is a
136 major win. You never have to worry about calling delete. The right
139 See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
144 Build unit tests for everything non-trivial and run them after every
145 change. Check out Extreme Programming:
146 http://c2.com/cgi/wiki?ExtremeProgrammingRoadmap
148 Unit tests should also be written for all examples. This should kill
149 off the bit rot we've been plagued with.
153 For C++ we're using the cppunit framework. cppunit has its bad
154 smells, but it's mostly workable. http://cppunit.sf.net
156 Currently each directory <dirname> contains files qa_<dirname>.{h,cc}
157 that bring together all the qa_<foo> test suites in the directory.
158 We ought to be able to automate this without too much trouble.
160 The directory gnuradio-core/src/tests contains programs that run
161 the tests. test_all runs all of the registered C++ unit tests.
163 As far as I can tell, the cppunit TestFactoryRegistry maybe able to be
164 tricked into doing what we want. As is, I don't think it's enough by
165 itself, since there's nothing dragging the qa* files out of the
166 library and into the program. I haven't tested out this idea.
170 We use the standard unittest package for unit testing of Python code.
175 ccache, a compiler cache, can really speed up your builds.
176 See http://ccache.samba.org/
178 Be sure to create links for gcc and g++