- Introduction
- This document summarizes the basic coding and naming style in
EMAN2. The intended audiences are EMAN2 developers.
- This document is not a programming tutorial. You may refer the
references at the end of document for good books.
- Overview
Coding:
- EMAN2 follows the GNU coding style with minor changes. We use indent at
http://www.gnu.org/software/indent/indent.html
for beautifying EMAN2 code.
Naming:
- All source code files use lower cases;
- All classes and data types use uppercase in the first letter;
- All functions use lower cases with '_' if necessary;
- All parameter names use lower case with '_' if necessary.
- indent HowTo
- install indent. (for linux, rpm is available from standard distribution.)
- save file .indent.pro to your home directory.
- say you have a file called "foo.C", run indent like this:
indent foo.C
- because indent is designed for C code, it is not perfect for
C++ code. Read your new source and fix the following possible errors:
- change 'const const' to 'const'
- Comments
Use Doxygen JavaDoc style:
/** Brief description which ends at this dot. Details follow here.
*/
class Test
{
public:
/** The constructor's brief description in one line.
* A more elaborate description of the constructor.
*/
Test();
/** do some test.
* @author Liwei Peng <lpeng@bcm.tmc.edu>
* @date 1/20/2005
* @param low the low threshold.
* @param high the high threshold.
* @return 0 if do_test succeeds; 1 if do_test fails.
* @exception ImageDimensionException If the image is 3D.
*/
int do_test(float low, float high);
/** Calculate the sum of an array.
* @param[in] data Data array
* @param[in] nitems Number of items in the array.
* @param[out] sum The sum of the array.
*/
void calc_sum(int[] data, int nitems, int *sum);
private:
int count;
}
- References