MLAlgorithmModule
AlgorithmModule Class Referenceabstract

ML-Module base class to simplify development of modules encapsulating an algorithm with dedicated input and output interface. More...

#include <mlAlgorithmModule.h>

Inheritance diagram for AlgorithmModule:
AlgorithmModuleExample AlgorithmModuleExampleWithOutputImage

Classes

class  Error
 Data structure to indicate an error within an AlgorithmModule derivative's implementation of interface methods. More...
 
class  InputObjectError
 Data structure indicating an error because of an invalid input object. More...
 
class  InputParameterError
 Data structure indicating an error because of an invalid input parameter. More...
 
class  InternalError
 Data structure indicating an internally caused error. More...
 

Public Member Functions

 AlgorithmModule (int numInputImages, int numOutputImages)
 Forwards given parameters to base class constructor. More...
 
 ~AlgorithmModule () override
 
void handleNotification (Field *field) override
 Never overwrite this method in derivative! More...
 
void activateAttachments () override
 Never overwrite this method in derivative! More...
 
void calculateOutputImageProperties (int outputIndex, PagedImage *outputImage) override
 Never overwrite this method in derivative! More...
 

Protected Types

enum  EStatusCode { SC_OK = 0 , SC_ERROR_INPUT_OBJECT , SC_ERROR_INPUT_PARAMETER , SC_ERROR_INTERNAL }
 Contains possible values of field statusCode. More...
 

Protected Member Functions

virtual void validateInput ()=0
 Validates the values of module's input fields (object and parameter fields). More...
 
virtual void update ()=0
 Executes the algorithm and updates the values of module's output fields with results. More...
 
virtual void clear ()=0
 Clears the values of module's output fields (object and parameter fields). More...
 
virtual void setOutputImageProperties (int outputIndex, PagedImage *outputImage)
 Sets properties of the output image at output outputIndex. More...
 

Detailed Description

ML-Module base class to simplify development of modules encapsulating an algorithm with dedicated input and output interface.

The class AlgorithmModule already implements an update behavior and status feedback mechanism including a field interface. A developer of a derivative class has to declare module's input and output fields: The name of an input field has to start with prefix "in" followed by an uppercase letter. The name of an output field has to start with prefix "out" followed by an uppercase letter. Beside this the developer has to overwrite interface methods of base class:

  • to validate values of the input fields: validateInput(),
  • to update values of the output fields: update(),
  • to clear values of the output fields: clear(), and if the module owns output image field(s):
  • the interface method to set the properties of the output image(s): setOutputImageProperties().

Member Enumeration Documentation

◆ EStatusCode

Contains possible values of field statusCode.

Enumerator
SC_OK 

No error occurred.

SC_ERROR_INPUT_OBJECT 

An invalid input object caused abort of update.

SC_ERROR_INPUT_PARAMETER 

An invalid input parameter caused abort of update.

SC_ERROR_INTERNAL 

An internal error caused abort of update.

Constructor & Destructor Documentation

◆ AlgorithmModule()

AlgorithmModule::AlgorithmModule ( int  numInputImages,
int  numOutputImages 
)

Forwards given parameters to base class constructor.

Creates fields of update control and status feedback interface.

Parameters
numInputImagesNumber of input images.
numOutputImagesNumber of output images.

◆ ~AlgorithmModule()

AlgorithmModule::~AlgorithmModule ( )
override

Member Function Documentation

◆ activateAttachments()

void AlgorithmModule::activateAttachments ( )
override

Never overwrite this method in derivative!

Updates the internal module state after loading or cloning the module, and enables notification handling again. Related to current value of field onInputChangeBehavior an update or clear is initiated.

◆ calculateOutputImageProperties()

void AlgorithmModule::calculateOutputImageProperties ( int  outputIndex,
PagedImage *  outputImage 
)
override

Never overwrite this method in derivative!

Makes sure to call derivative's implementation of setOutputImageProperties() only if update succeeded. Otherwise the output image is invalidated. Handles occurring AlgorithmModule::Error or invalidated output image as result of setOutputImageProperties() and sets status fields accordingly.

Parameters
outputIndexIndex of affected output image field.
outputImageAffected output image.

◆ clear()

virtual void AlgorithmModule::clear ( )
protectedpure virtual

Clears the values of module's output fields (object and parameter fields).

Implemented in AlgorithmModuleExampleWithOutputImage, and AlgorithmModuleExample.

◆ handleNotification()

void AlgorithmModule::handleNotification ( Field *  field)
override

Never overwrite this method in derivative!

Handles field changes. When affected field is identified as an input field than update or clear of module's output fields related to current value of field onInputChangeBehavior is initiated. Interface fields are also considered:

  • update: Initiates update.
  • clear: Initiates clear.
  • onInputChangeBehavior: Initiates update if value is "Update".
    Parameters
    fieldAffected field whose value was changed.

◆ setOutputImageProperties()

void AlgorithmModule::setOutputImageProperties ( int  outputIndex,
PagedImage *  outputImage 
)
protectedvirtual

Sets properties of the output image at output outputIndex.

Parameters
outputIndexIndex of affected output image field.
outputImageAffected output image.
Exceptions
Throwsan exception of type AlgorithmModule::Error on failure.

Reimplemented in AlgorithmModuleExampleWithOutputImage.

◆ update()

virtual void AlgorithmModule::update ( )
protectedpure virtual

Executes the algorithm and updates the values of module's output fields with results.

Exceptions
Throwsan exception of type AlgorithmModule::Error on failure.

Implemented in AlgorithmModuleExampleWithOutputImage, and AlgorithmModuleExample.

◆ validateInput()

virtual void AlgorithmModule::validateInput ( )
protectedpure virtual

Validates the values of module's input fields (object and parameter fields).

Exceptions
Throwsan exception of type AlgorithmModule::Error on failure.

Implemented in AlgorithmModuleExampleWithOutputImage, and AlgorithmModuleExample.


The documentation for this class was generated from the following files: