[Insight-developers] Get_vnl_vector deprecation

Lorensen, William E (Research) lorensen at crd.ge.com
Fri Jan 14 11:05:48 EST 2005


API stability will be discussed at the upcoming SPIE meeting. We can discuss
this issue then.

Bill

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com]
Sent: Friday, January 14, 2005 10:47 AM
To: Insight Developers
Subject: [Insight-developers] Get_vnl_vector deprecation


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
_______________________________________________
Insight-developers mailing list
Insight-developers at itk.org
http://www.itk.org/mailman/listinfo/insight-developers


More information about the Insight-developers mailing list