Proposals:Refactoring Statistics Framework 2007 Transition Plan: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
= Option A =
= Option A =


- Rename the existing Statistics/ directory in ITK to StatisticsDeprecated/
# 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.


- Create a parallel directory Statistics/ containing the new classes.
For instance :


- 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();
#ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK
    calculator->SetInputSample(sample);
  calculator = Statistics::CovarianceCalculator< ListSampleType >::New();
    calculator->Update();
  calculator->SetInputSample(sample);
  #else
  calculator->Update();
    filter = Statistics::CovarianceFilter< ListSampleType >::New();
#else
    filter->SetInput( sampleGenerator->GetOutput() );
  filter = Statistics::CovarianceFilter< ListSampleType >::New();
    filter->Update();
  filter->SetInput( sampleGenerator->GetOutput() );
  #endif
  filter->Update();
#endif


= Option B =
= Option B =

Revision as of 20:36, 4 April 2009

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