MantisBT - ITK
View Issue Details
0001485ITKpublic2005-01-14 13:352009-04-07 06:44
Lydia Ng 
Bill Lorensen 
0001485: Need a standard deprecation mechansim
We need a standard deprecation mechanism to remove/update old API and classes.

This issue is table for the SPIE'05 ISC meeting.

Possible options from Brad's email:
The use of itkWarningMacro to deprecate the Get_vnl_vector methods in Point, Vector, and CovariantVector will not work. Using the warning macro requires there to be a TypeMacro in the class definition. The type macro is intended only for subclasses of LightObject. It adds virtual functions (and therefore a vtable pointer), which is something we don't want for these small classes.

While it is easy to rip out this code we need a different deprecation mechanism. We could do something similar to what was recently done in VTK. This would mean adding two CMake options: ITK_LEGACY_SILENT and ITK_LEGACY_REMOVE. By default we would setup some kind of warnings (compile time and/or runtime) for deprecated methods. If the user builds ITK with ITK_LEGACY_SILENT set to ON it would silence the warnings. If the user builds itk with ITK_LEGACY_REMOVE then the legacy code will be removed completely resulting in errors in code trying to call it. Deprecating a method would look like this:

// In itkPoint.h:
ITK_LEGACY(vnl_vector_ref<TCoordRep> Get_vnl_vector());

// In itkPoint.txx:
* Return a vnl_vector_ref
template<class T, unsigned int TPointDimension >
vnl_vector_ref< T >
Point<T, TPointDimension>
::Get_vnl_vector( void )
  ITK_LEGACY_REPLACED_BODY(Point::Get_vnl_vector, "1.10",
  return vnl_vector_ref< T >( TPointDimension, this->GetDataPointer());

The ITK_LEGACY and ITK_LEGACY_REPLACED_BODY methods would be defined appropriately depending on the settings of ITK_LEGACY_SILENT and ITK_LEGACY_REMOVE. The ITK_LEGACY_REPLACED_BODY macro would use itkGenericOutputMacro to print a deprecation message. There would also be a macro called ITK_LEGACY_BODY to print a message when the method was removed but not replaced. I prefer to make these macros uppercase instead of itkXXXMacro format because it makes the code stick out as legacy rather than implemented by a macro.
No tags attached.
Issue History
2007-09-18 11:45Luis IbanezNote Added: 0009082
2009-04-07 06:44Marius StaringNote Added: 0015945
2009-04-07 06:44Marius StaringStatusassigned => closed
2009-04-07 06:44Marius StaringResolutionopen => fixed

Lydia Ng   
2005-08-05 15:33   
Triaged 8/5/05 tcon. Assigned to Bill L.
Luis Ibanez   
2007-09-18 11:45   
needs more thinking.

To be addressed during WA10
Marius Staring   
2009-04-07 06:44 [^]