[Insight-developers] Get_vnl_vector deprecation

Brad King brad.king at kitware.com
Fri Jan 14 10:46:55 EST 2005


Hello,

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:
#ifndef ITK_LEGACY_REMOVE
/*
  * 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",
                            Point::GetVnlVector);
   return vnl_vector_ref< T >( TPointDimension, this->GetDataPointer());
}
#endif

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.

Comments?
-Brad


More information about the Insight-developers mailing list