Summary of bug description
- actual behaviour
Properties with specializations of mitk::GenericLookupTable can not be compared for equality, because the current implementation will only compare pointers to the lookup table objects, not the objects themselves
- expected behaviour
the == operator should compare the objects, as it does with all other properties
Cause of the bug
The current implementation is this:
mitkSpecializeGenericProperty(FloatLookupTableProperty, FloatLookupTable::Pointer , FloatLookupTable::New());
mitk::GenericProperty is used with a smartpointer to a lookup table as data type. The == operator of GenericProperty is calling == of the smartpointer class, which only checks if the pointer are equal, not if the objects that the pointers point at are equal.
Proposed solution
Therefore another solution is needed: We can not use a (smart)pointer to a lookup table as template paramter, we have to use the lookup table itself:
mitkSpecializeGenericProperty(FloatLookupTableProperty, FloatLookupTable , FloatLookupTable());
To allow this, mitk::GenericLookupTable may not derive from itk::Object. It must define =, ==, != operators and must define a global ostream& << operator. Because the ostream& << operator has to be a global function, it must be defined in a cpp file. Therefore the mitkSpecializeGenericLookupTable must be splitted into one that declares the new lookup table and is called in a header file (mitkLookupTables.h), and a second macro mitkSpecializeGenericLookupTableOperator that is called for each specialized lookup table in a cpp file (mitkLookupTables.cpp) and defines the << operator function
Affected classes
mitkGenericLookupTable.h mitk::GenericLookupTable: not derived from itk::Object, define =, ==, != operators and define a global ostream& << operator
- mitkGenericLookupTable.cpp: add calls to mitkSpecializeGenericLookupTableOperator for all lookup tables
- mitkProperties.h: change the declaration of the the properties that hold the lookup tables to use the lookup tables directly instead of a smartpointer
- mitkProperties.cpp: change template instantiation of the properties that hold the lookup tables to use the lookup tables directly instead of a smartpointer
mitkPropertyList.cpp: add template instantiations for mitk::PropertyList::GetPropertyValue<>() method for the new properties.
- other classes outside mitkCore need to be adapted for the interface changes.
How will the bugfix get tested?
- a unit test will be written for the generic lookup tables and the respective properties.
The lookup tables and their properties are used in SceneSerialization. The PropertyListSerialization unit test uses them too.
