coding style
this document describes the coding style for pnpd code
language
pnpd is written in the c++ programming language. it makes use of most c++ language features such as polymorphism, runtime type information (rtti), templated programming (as well as template meta programming) and exception handling and is heavily relying on stl containers and algorithms. it also utilizes parts of the stl::tr1, mainly as part of the boost libraries. some dsp functions are written with sse instructions using c intrinsics and compile time loop unrolling.
coding style
The c++ coding style is based on the BSD/Allman style. indentations are 4 spaces, tabs should be converted to spaces, lines should fit within 120 spaces, function definitions should not be longer than 100 lines:
void foo(int i, my_class & t)
{
if (i > 0)
foo(i-1, t);
else
t.something();
}
classes, that are defined in header files, should be implemented there if they are used in a realtime thread to help the compiler generating inline code. class and function names should follow the foo_bar naming convention.
code documentation
every function or class should be documented with a doxygen documentation using javadoc style. external api functions should especially cover a detailed description of parameters, return value and side effects.
supported systems
pnpd is should compile on every modern and standard compliant c++ compiler. the reference system is gcc/linux, however icc/linux, gcc/osx and mingw/windos should be supported as well.
libraries
the code should make use of libraries under the following circumstances
- a feature is not trivial to implement
- the library is available on all supported platforms
- the library is assumed to be stable (used in other project, tested)
- the library is using a lgpl or compatible license
- the library is known to be threadsafe, lockfree or it's not called in a realtime thread
if a certain feature is available in the c++ stl, stl::tr1 or the boost c++ libraries, these should be prefered.
build system
the build system should be based on scons.
thread synchronization
the code should make use of lock-free data structures whenever reasonable. the realtime threads are not allowed to use any thread locks, if there are lock-free primitives available.
