Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
Bial macros

Macros

#define COMMENT(exp, num)   { }
 Use COMMENT to write comments throughout your code, in order to keep it self explanatory.
Use instead of C or C++ default comments in the begining of code blocks to describe what the block is expected to do.
If you want to make a small comment in the end of a line, then, do not use COMMENT.
COMMENT was designed to both describe the code and for debugging purposes. Therefore, use it strictly according to the instructions here to avoid having a code that is unclear or too verbose.
More...
 
#define BIAL_WARNING(exp)   std::cerr << __FILE__ << ": " << __LINE__ << ": " << __FUNCTION__ << " Warning: " << exp << std::endl;
 Use BIAL_WARNING to print a message to the output stream warn the user that something bad may have happend, but the program will continue to be executed. More...
 
#define BIAL_ERROR(exp)   std::string( __FILE__ ) + ": " + std::to_string( __LINE__ ) + ": " + std::string( __FUNCTION__ ) + ": Error: " + exp
 Use BIAL_ERROR to compose runtime error messages. Note that ERROR generates a string, instead of a stream, because it is better to throw an exception, rather than exiting the program.
This way, the exception may be threated by a higher level program, like an user IDE. More...
 

Detailed Description

Macro Definition Documentation

#define BIAL_ERROR (   exp)    std::string( __FILE__ ) + ": " + std::to_string( __LINE__ ) + ": " + std::string( __FUNCTION__ ) + ": Error: " + exp

Use BIAL_ERROR to compose runtime error messages. Note that ERROR generates a string, instead of a stream, because it is better to throw an exception, rather than exiting the program.
This way, the exception may be threated by a higher level program, like an user IDE.

Definition at line 161 of file Common.hpp.

#define BIAL_WARNING (   exp)    std::cerr << __FILE__ << ": " << __LINE__ << ": " << __FUNCTION__ << " Warning: " << exp << std::endl;

Use BIAL_WARNING to print a message to the output stream warn the user that something bad may have happend, but the program will continue to be executed.

Definition at line 158 of file Common.hpp.

#define COMMENT (   exp,
  num 
)    { }

Use COMMENT to write comments throughout your code, in order to keep it self explanatory.
Use instead of C or C++ default comments in the begining of code blocks to describe what the block is expected to do.
If you want to make a small comment in the end of a line, then, do not use COMMENT.
COMMENT was designed to both describe the code and for debugging purposes. Therefore, use it strictly according to the instructions here to avoid having a code that is unclear or too verbose.

COMMENT has two parameters. The first is a stream containg the comment describing what the block does, and possibly print variable's values for debugging. The second parameter is the verbosity level. Level 0, means that the comment will always be printed in debugging mode. Higher levels may or may not be printed, depending on the verbosity level selected during code compilation.

Therefore, follow the instructions to select the level of verbosity of your comment:

  • Level 0 -> Basically a comment that you would make in your code describing high level blocks, that are not often repeated (less than 5 times) for the main purpuses of your code.
  • Level 1 -> Also comments describing blocks that may repeaty a few times (less than 20). This level may also contain debugging information as the value of a variable or a small container that can be written in few lines (less than 5). Exception handling comments should be set to this verbosity level.
  • Level 2 -> Comments that may be repeated several times (less than 100). This verbosity level helps to identify bugs that happen in some loops without blocking the std::out for too long. Ou may also print variables or containers that use several lines (less than 20);
  • Level 3 -> Comments that are exausted repeated or data with possibly more than 20 lines. The output for this verbosity level might require to be piped to a file.
    If you are not sure between two verbosity levels, pick the greater. If you have no idea about what the verbosity level is, please select 3 or 4, indicating that you postponed the decision.
  • Level 4 -> Comments that mostly no one would like to print. They will generate thousands of debuging lines with enabled. Use it also if this comment is merely descriptive of less important part of the code.

Here follow some examples. Note that they are hypothetical, because this depends on the context.

1 COMMENT( "Segmenting brain tissues.", 0 );
2 COMMENT( "Computing the median value of feature vector.", 1 ); // Supposing you have 4 or less feature vectors.
3 COMMENT( "Tissue mean value." << mean, 1 ); // Mean value is computed a few times.
4 COMMENT( "Printing the patient's information.", 2 );
5 COMMENT( "Starting clustering with k neighbors.", 2 ); //k varies from 10 to 30.
6 COMMENT( "pxl: " << plx, 3 ); // inside triple for loop or printing all pixel of 3D image.
7 COMMENT( "Computing sum of intensities of each pixel." <<, 4 ); // inside loop for all pixel of an image.

To get verbose results while compiling your code, compile it setting BIAL_DEBUG with a non-negative value. If you are using makefile in tst subfolder, type: make <your_program> verbose=<level> where <your_program> is the name of the program, and <level> is the verbosity level you want to print. If you want to use a debugger of sanity checker along with BIAL comments, than compile with make <your_program> debug=<level> where again <your_program> is the name of the program, and <level> is the verbosity level you want to print.

Parameters
expExplanatory
numVerbosity level

Definition at line 154 of file Common.hpp.