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