[2] | 1 | $Id: README.developer 2384 2010-12-22 14:03:36Z peter $ |
---|
| 2 | |
---|
[1674] | 3 | = Coding Style = |
---|
[1605] | 4 | |
---|
[1674] | 5 | We follow the coding style described in |
---|
| 6 | [http://cbbp.thep.lu.se/~jari/documents/c++_coding_guidelines/index.html C++ coding guidelines] |
---|
| 7 | [http://cbbp.thep.lu.se/~jari/documents/c++_coding_guidelines/c++_coding_guidelines.pdf pdf] |
---|
| 8 | [http://cbbp.thep.lu.se/~jari/documents/c++_coding_guidelines/c++_coding_guidelines.ps postscript] |
---|
| 9 | with the additions described here. |
---|
| 10 | |
---|
[1721] | 11 | === Subversion usage === |
---|
| 12 | |
---|
| 13 | Commits should be minimalistic and the project should always compile |
---|
| 14 | (`make` and `make check`) when someone makes a clean checkout. There |
---|
| 15 | is a short introduction to subversion and its usage available as |
---|
| 16 | [http://cbbp.thep.lu.se/~jari/documents/subversion_guidelines/index.html |
---|
| 17 | Subversion guidelines]. We follow these guidelines. |
---|
| 18 | |
---|
[1674] | 19 | === Testing === |
---|
| 20 | |
---|
[1721] | 21 | The test suite is run with `make check` at the project root directory |
---|
| 22 | level. |
---|
[1674] | 23 | |
---|
[1721] | 24 | The test suite should at minimum include creation of all classes (to |
---|
| 25 | catch linking errors) and calls to template functions (as template |
---|
| 26 | functions are not compiled until they are needed). There is a test |
---|
| 27 | that checks that minimum amount of documentation is written. |
---|
| 28 | |
---|
| 29 | For more details on writing and running tests, see file |
---|
| 30 | [source:trunk/test/README test/README]. |
---|
| 31 | |
---|
[1674] | 32 | === Interfacing [http://www.gnu.org/software/gsl/ Gnu Scientific Library, GSL] === |
---|
| 33 | |
---|
| 34 | The GSL documentation describes how |
---|
| 35 | [http://www.gnu.org/software/gsl/manual/html_node/Error-Handling.html#Error-Handling GSL error handling] |
---|
| 36 | works. The GSL library follows the thread-safe |
---|
| 37 | error reporting conventions of the posix Threads library. That is, |
---|
| 38 | functions return a non-zero error code to indicate an error. In most |
---|
| 39 | cases yat just returns whatever the underlying GSL library calls |
---|
| 40 | returns. If GSL errors occur in constructors yat handles them |
---|
| 41 | accordingly. If GSL reports errors that cannot be resolved by yat a |
---|
| 42 | [http://cbbp.thep.lu.se/~jari/documents/yat/classtheplu_1_1yat_1_1utility_1_1GSL__error.html GSL_error] |
---|
| 43 | exception will be thrown. However, the default behaviour of |
---|
| 44 | GSL library is to call abort() when unrecoverable errors occur and |
---|
| 45 | puts the yat (and any other) GSL error treatment out of play. For |
---|
[2067] | 46 | production environments, yat and GSL users should turn off the default |
---|
[1674] | 47 | GSL error treatment by calling gsl_set_error_handler_off(), but also |
---|
| 48 | when yat's GSL error treatment is preferred. |
---|
| 49 | |
---|
| 50 | When new GSL functionality is introduced to yat, it is the |
---|
[1721] | 51 | responsibility of the programmer to make sure that GSL errors are |
---|
[1674] | 52 | treated properly. Proper GSL error treatment is very important in |
---|
| 53 | cases when yat users turn off the default GSL error handler since: |
---|
| 54 | |
---|
| 55 | yat aims at treating GSL errors appropriately in an |
---|
| 56 | [http://www.gotw.ca/gotw/008.htm exception safe and neutral] |
---|
| 57 | way but there is still some work to do before we do exceptions in a neutral way. |
---|
| 58 | |
---|
| 59 | === Doxygen === |
---|
[2071] | 60 | We generate our documentation using [http://www.doxygen.org Doxygen] |
---|
| 61 | (version 1.5 or later). Doxygen allows several different styles. We |
---|
| 62 | try to use the following style as we have found this minimizes parsing |
---|
| 63 | problems: |
---|
[1674] | 64 | |
---|
| 65 | {{{ |
---|
| 66 | /** |
---|
| 67 | \brief My class |
---|
| 68 | |
---|
| 69 | Some text documenting the class MyClass |
---|
| 70 | */ |
---|
| 71 | class MyClass |
---|
| 72 | }}} |
---|
| 73 | |
---|
| 74 | or similarly |
---|
| 75 | |
---|
| 76 | {{{ |
---|
| 77 | /** |
---|
| 78 | \brief magic function |
---|
| 79 | |
---|
| 80 | Some text documenting my_function |
---|
| 81 | */ |
---|
| 82 | void my_function(void); |
---|
| 83 | }}} |
---|
| 84 | |
---|
[2071] | 85 | We use doxygen keywords preceded by `\` such as `\brief`, |
---|
| 86 | `\return`. All classes and functions have a brief description, which |
---|
| 87 | increases clarity on summary pages. |
---|
[1674] | 88 | |
---|
[2071] | 89 | Try to keep comment line lengths within the terminal character limit, |
---|
| 90 | in other words, less than 80 characters per line. This makes the |
---|
| 91 | comments more readable. |
---|
[1674] | 92 | |
---|
| 93 | '''Internal Interface''' |
---|
| 94 | |
---|
| 95 | Helper functions and classes that are not part of yat API should either be |
---|
| 96 | labeled with doxygen flag `\internal` or placed in sub-namespace `detail`. |
---|
| 97 | |
---|
| 98 | = Build = |
---|
| 99 | |
---|
| 100 | == Requirements == |
---|
| 101 | |
---|
[1605] | 102 | To build from a subversion checkout, you will need Autotools. More |
---|
[1674] | 103 | specifically |
---|
[2227] | 104 | * Automake 1.11 (or later) |
---|
[2088] | 105 | * Autoconf 2.63 (or later) |
---|
[1674] | 106 | * Libtool. |
---|
[1605] | 107 | |
---|
[1674] | 108 | == Disable shared library == |
---|
[573] | 109 | |
---|
[1368] | 110 | yat uses gnu Libtool in order to build shared libraries on a variety |
---|
| 111 | of systems. While this is very nice for making usable binaries, it |
---|
| 112 | can be a pain when trying to debug a program. For that reason, |
---|
| 113 | compilation of shared libraries can be turned off by specifying the |
---|
| 114 | `--disable-shared` option to configure. |
---|
| 115 | |
---|
[1674] | 116 | == Debugging using GDB == |
---|
[1372] | 117 | |
---|
| 118 | If shared library is enabled (default), libtool creates wrapper |
---|
[1638] | 119 | scripts in directory test/ that call the test programs located in |
---|
| 120 | directory test/.libs/. While this allows us to dynamically link against |
---|
| 121 | the temporary library in yat/, it makes straightforward usage of GDB |
---|
[1372] | 122 | impossible. For that reason libtool provides a wrapper: |
---|
| 123 | |
---|
| 124 | `#> libtool --mode=execute gdb foo_test` |
---|
| 125 | |
---|
| 126 | that sets the necessary environment variables. For more detailed |
---|
| 127 | discussion, please refer to the libtool manual: |
---|
| 128 | |
---|
| 129 | http://www.gnu.org/software/libtool/manual/libtool.html#Debugging-executables |
---|
| 130 | |
---|
[1674] | 131 | = Versioning = |
---|
| 132 | |
---|
| 133 | We use a softened version of [http://apr.apache.org/versioning.html APR guidelines] which |
---|
| 134 | in short implies |
---|
| 135 | |
---|
| 136 | ''"The basic intent is that '''`MAJOR`''' versions are incompatible, |
---|
| 137 | large-scale upgrades of the API. '''`MINOR`''' versions retain compatibility with older minor versions, and changes in the |
---|
| 138 | '''`PATCH`''' level are perfectly compatible, forwards and backwards."'' |
---|
| 139 | |
---|
| 140 | == '''`MAJOR`''' Releases == |
---|
| 141 | |
---|
| 142 | No compatibility is guaranteed between '''`MAJOR`''' versions. |
---|
| 143 | |
---|
| 144 | == '''`MINOR`''' Releases == |
---|
| 145 | |
---|
| 146 | '''`MINOR`''' versions should be compatible with earlier minor |
---|
| 147 | versions. However, in the `0.x` line we may allow exceptions to this |
---|
| 148 | rule, if developers agree the gain of change is sufficient. Binary compatibility is typically not guaranteed between '''`MINOR`''' versions. The `YAT_LT_VERSION` in [source:trunk/build_support/version.m4 version.m4] should reflect which versions are binary compatible. |
---|
| 149 | |
---|
| 150 | == '''`PATCH`''' Releases == |
---|
| 151 | |
---|
| 152 | Versions with same '''`MAJOR.MINOR`''' are perfectly compatible, |
---|
| 153 | forwards and backwards. |
---|
| 154 | |
---|
| 155 | This implies that only implementations can be modified in a `PATCH` |
---|
| 156 | release. You cannot change the API, not even add functions or |
---|
| 157 | classes because it will break forward compatibility for the previous |
---|
| 158 | `PATCH` version. A `PATCH` release is a pure bug fix release |
---|
| 159 | |
---|
| 160 | === Backward Source Compatibility === |
---|
| 161 | |
---|
| 162 | Backward Source Compatibility means that an application that could build |
---|
| 163 | against version `x.y` shall also build without error against |
---|
| 164 | `x.y+1`. An application that compiled against header files from |
---|
| 165 | previous `MINOR` version shall also compile without errors against the |
---|
| 166 | header files of the new version. |
---|
| 167 | |
---|
| 168 | Specifically this implies: |
---|
| 169 | - Do not remove any public, protected, or free functions. |
---|
| 170 | - If you modify a function, its signature must be compatible with |
---|
| 171 | previous signature, e.g., new parameters with default values may |
---|
[1721] | 172 | be added to signature. |
---|
[1674] | 173 | - Do not remove any class or inheritance for a class. |
---|
| 174 | |
---|
| 175 | === Backward Binary Compatibility === |
---|
| 176 | |
---|
| 177 | Backward Binary Compatibility means that an application that has been |
---|
| 178 | compiled against version `x.y` can be linked against version |
---|
| 179 | `x.y+1`. |
---|
| 180 | |
---|
| 181 | Specifically this implies: |
---|
| 182 | |
---|
| 183 | - Do not remove or modify any function (except private), not even |
---|
| 184 | add a parameter with default value because it will make the |
---|
| 185 | function incompatible with earlier header files. |
---|
| 186 | |
---|
| 187 | - Do not add, remove, or modify member variables, because that will |
---|
| 188 | change the allocated size of the class. Therefore, to allow |
---|
| 189 | modifications of the internal representation, it is preferable to |
---|
| 190 | hold member variable is a ''pimpl'' that is allocated privately. |
---|
| 191 | http://developer.gnome.org/doc/guides/programming-guidelines/binary.html |
---|
| 192 | |
---|
| 193 | - Do not add or change order among virtual functions because it will |
---|
| 194 | change the layout of the virtual table. |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | |
---|
[1262] | 199 | ---------------------------------------------------------------------- |
---|
| 200 | {{{ |
---|
[2119] | 201 | Copyright (C) 2003 Jari Häkkinen, Peter Johansson |
---|
| 202 | Copyright (C) 2004 Jari Häkkinen |
---|
| 203 | Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson |
---|
[2384] | 204 | Copyright (C) 2010 Peter Johansson |
---|
[1262] | 205 | |
---|
[1469] | 206 | This file is part of yat library, http://dev.thep.lu.se/yat |
---|
[1262] | 207 | |
---|
| 208 | The yat library is free software; you can redistribute it and/or |
---|
| 209 | modify it under the terms of the GNU General Public License as |
---|
[1486] | 210 | published by the Free Software Foundation; either version 3 of the |
---|
[1262] | 211 | License, or (at your option) any later version. |
---|
| 212 | |
---|
| 213 | The yat library is distributed in the hope that it will be useful, but |
---|
| 214 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 215 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 216 | General Public License for more details. |
---|
| 217 | |
---|
| 218 | You should have received a copy of the GNU General Public License |
---|
[1487] | 219 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
[1262] | 220 | }}} |
---|