Proposals:Refactoring Statistics Framework 2007 Transition Plan

From KitwarePublic
Jump to navigationJump to search

Option A

  1. Rename the existing Statistics/ directory in ITK to StatisticsDeprecated/
  2. Create a parallel directory Statistics/ containing the new classes.
  3. 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.
  4. 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 :

  1. ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK
 calculator = Statistics::CovarianceCalculator< ListSampleType >::New();
 calculator->SetInputSample(sample);
 calculator->Update();
  1. else
 filter = Statistics::CovarianceFilter< ListSampleType >::New();
 filter->SetInput( sampleGenerator->GetOutput() );
 filter->Update();
  1. endif