Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::DataStorageCompare Class Reference

#include <mitkDataStorageCompare.h>

Public Types

enum  Tests {
  CMP_Nothing, CMP_Hierarchy, CMP_Data, CMP_Properties,
  CMP_Mappers, CMP_Interactors, CMP_All
}
 Flag describing the aspects of comparing two DataStorages. More...
 

Public Member Functions

 DataStorageCompare (const DataStorage *reference, const DataStorage *test, Tests flags=CMP_All, double eps=mitk::eps)
 Constructor taking reference and test DataStorage. More...
 
bool CompareVerbose ()
 Shorthand for Compare(true). More...
 
bool Compare (bool verbose=false)
 Execute the comparison. More...
 
void Report ()
 Prints a small summary of what tests have been executed and which ones failed or passed. More...
 

Detailed Description

Helper class to compare two DataStorages.

This is purposely not a mitk::Equal() function because the main intention is to use this class for I/O testing, and because the definition of equal is really not clear for two DataStorages.

In the context of I/O tests, one could want to verify (given two storages "reference" and "test") that all nodes from reference are in test (identification of nodes is difficult) all nodes from test are in reference all property lists are identical (types and values) all data is identical (types, values) all mappers are identical (types, not state) all interactors are identical (type) ... ?

This class offers a number of flags that describe one of those aspects. These flags can be combined by the OR operator ("|"). The Compare() method will only test those aspects.

Once Compare() has been executed there are a couple of methods to query the results or print a small report.

Finding nodes: Identifying nodes to be compares poses a problem. This is because we don't have node identifiers but only names. Names are not unique and are not even required to exist or to be non-empty.

This class does not solve this problem completely. It identifies nodes by constructing an "identifier" that includes the node name and the BaseData class name of the node itself and all its direct and indirect parents.

This leaves certain cases where two nodes in the hierarchy would get the same identifier. For the use in test cases (

See also
SceneIOTestScenarioProvider) this is sufficient, however, since we can make sure that each node gets an individual name.

Definition at line 66 of file mitkDataStorageCompare.h.

Member Enumeration Documentation

Flag describing the aspects of comparing two DataStorages.

Flag values can be combined by the "|" operator (bitwise or).

Enumerator
CMP_Nothing 

No tests.

CMP_Hierarchy 

Compare hierarchy.

CMP_Data 

Compare BaseData.

CMP_Properties 

Compare PropertyLists.

CMP_Mappers 

Compare Mapper types.

CMP_Interactors 

Compare interactors.

CMP_All 

Compare all known aspects.

Definition at line 74 of file mitkDataStorageCompare.h.

Constructor & Destructor Documentation

mitk::DataStorageCompare::DataStorageCompare ( const DataStorage reference,
const DataStorage test,
Tests  flags = CMP_All,
double  eps = mitk::eps 
)

Constructor taking reference and test DataStorage.

Parameters
referenceReference DataStorage object.
testTest DataStorage object.
flagsFlags describing the desired test aspects (
See also
Tests).
Parameters
epsprecision for floating point comparisons.

Definition at line 27 of file mitkDataStorageCompare.cpp.

References mitk::BaseDataCompare::RegisterCoreEquals().

Member Function Documentation

bool mitk::DataStorageCompare::Compare ( bool  verbose = false)

Execute the comparison.

Parameters
verboseif true, the comparison will output messages for all differences found and Report() will be called at the end.
Returns
true if reference and test are judged equal regarding all flags provided in constructor.

Definition at line 50 of file mitkDataStorageCompare.cpp.

bool mitk::DataStorageCompare::CompareVerbose ( )

Shorthand for Compare(true).

Definition at line 45 of file mitkDataStorageCompare.cpp.

void mitk::DataStorageCompare::Report ( )

Prints a small summary of what tests have been executed and which ones failed or passed.

Called automatically by Compare() when that method is called with the verbose flag.

Definition at line 83 of file mitkDataStorageCompare.cpp.

References MITK_INFO.


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