Xmipp program design - I2PC/xmipp GitHub Wiki

Xmipp program design

Typical Xmipp executable will be compiled from various source files. To keep good interoperability, reusability, testability, the small size of the shared library, and low compilation times, please follow these rules of thumb when designing your program:

  • your program should be divided into the 'core functionality' source files, responsible for the hard-core processing, and the 'main' source file, responsible for command line argument definition, parsing, and preprocessing.

  • the main() method must be in a cpp file in src/xmipp/applications/programs. Notice that each program is located in its own folder, from which it inherits the name. For example, compiling src/xmipp/applications/programs/myProgram/main.cpp will create xmipp_myProgram binary.

  • your program should inherit from XmippProgram. This class will provide you with basic functionality and command-line argument parsing:

class MyProgram final : public XmippProgram

  • command line argument definition and processing should be done in the main source file

  • the core of your program should be located in the respective folder (typically src/xmipp/libraries/reconstruction). It is recommended to define a specific class responsible for the functionality. An instance of this class will then be created in the main(), passing it already parsed and preprocessed arguments

  • remember to write (unit) tests for your class. Since you design your class so it can be easily instantiated, it should be relatively fast and straightforward.

Notice that majority of the existing code does not currently follow these rules. However, following them now will make our codebase better in the future.

Please refer to phantom_movie_main.cpp main source file and the phantom_movie.h (+ .cpp) files for a working example following these rules.