Proposals:Refactoring Statistics Framework 2007 Transition Plan
From KitwarePublic
Option A
- Rename the existing Statistics/ directory in ITK to StatisticsDeprecated/
- Create a parallel directory Statistics/ containing the new classes.
- Add an ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK option at configure time to toggle between the usage of the deprecated and the new framework. The option will cause (a) the right directory to be compiled (b) headers from there right directory to be installed (c) the right directory to be added to the include dirs.
- All existing code in the toolkit using the statistics framework will be ifdef'ed to work with both the new and the old framework. For instance :
#ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK calculator = Statistics::CovarianceCalculator< ListSampleType >::New(); calculator->SetInputSample(sample); calculator->Update(); #else filter = Statistics::CovarianceFilter< ListSampleType >::New(); filter->SetInput( sampleGenerator->GetOutput() ); filter->Update(); #endif
Option B
- Keep all files in a single directory but use two different namespaces.
For instance the file itkSample.h would look like :
namespace itk
{ namespace StatisticsDeprecated { class Sample : public Object { ... } }
namespace StatisticsNew { class Sample : public DataObject { ... } } }
- The ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK option redefines the unused namespace to be an anonymous namespace. The used namespace to "Statistics". For instance :
#ifdef ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK #define StatisticsDeprecated Statistics #define StatisticsNew #else #define StatisticsNew Statistics #define StatisticsDeprecated #endif
User code still looks the same :
- ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK
calculator = Statistics::CovarianceCalculator< ListSampleType >::New(); calculator->SetInputSample(sample); calculator->Update();
- else
filter = Statistics::CovarianceFilter< ListSampleType >::New(); filter->SetInput( sampleGenerator->GetOutput() ); filter->Update();
- endif