Basic text
- Use an Unix/Linux or Windows compliant text editor, not MAC,
- Don't use tab characters but spaces,
- Write code in English language.
Regression
- Check that sdkV2, testAstro and eLynx app compile without error on your platform.
- Run sdkV2 with all tests actived and check there is not runtime regression (core dump at least).
- Check that generated images with test on modified code are still ok.
Class naming
- interface = class with only pure virtual methods, no data + virtual destructor,
naming convention: name start with I, ex: IImageGeometry.
- abstract class = base class with at least one abstract method.
could have datas and method implementations
naming convention: name start with Abstract, ex: AbstractImage.
- Have files .h and .cpp named with inside class name.
Method prototypes
Follow rules with i,o, io prefixes with parameters:
- i input method/function parameter, const should be welcome here,
- o output only method/function parameter,
- io input and output method/function parameter.
ex: bool Add(AbstractImage& ioImage1, const AbstractImage& iImage2, bool ibClamp, bool& oOverflow);
Variables naming
- Do not prefix variables with i, o, io as it is reserved for parameters.
- Prefix data member of class or struct with _ (underscore),
- Prefix static data member of class or struct with _s (static),
- Prefix global variable with g_ but try not to have globals,
- Prefix singleton object (specific global) with the_ (the only one),
- Prefix module static variable (cpp) with s_ (static),
- Prefix method static variable with ms_ (method's static),
- Prefix smart pointers with sp: boost::shared_ptr< ImageRGB > spImage;
- Prefix pointer on reference with pr: PixelRGB * prPixel = image.GetPixel();
In resume :
Prefix
|
Meaning
|
_? | class/struct data member (normal _, or static _s) |
?_ | data out of a class/struct (global g_, local s_, singleton the_, method/function static ms_) |
i,o,io | method or function parameter |
(nothing) | method or function local variable |
Shared image processing patterns
- While accessing image's pixels use: x or i to loop over horizontal axis, y or j to loop over vertical axis:
for (uint y=0; y<h; y++)
for (uint x=0, x<w; x++)
process pixel(x,y)
for (uint j=0; j<h; j++)
for (uint i=0, i<w; i++)
process pixel(i,j)
- While accessing pixel's channels use variable c:
const uint nChannel = Pixel::GetChannelCount();
for (uint c=0, c<nChannel; c++)
p._channel[c] = ?;
- Looping over all pixels without location:
with template pixel: Pixel * prDst = image.GetPixel();
Pixel * prEnd = image.GetPixelEnd();
do
{
}
while (++prDst != prEnd);
with iterators: PixelIterator<Pixel> dst = elxDowncast<Pixel>(image.Begin());
PixelIterator<Pixel> end = elxDowncast<Pixel>(image.End());
do
{
}
while (++dst != end);