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

From KitwarePublic
Jump to navigationJump to search
Line 19: Line 19:
= Option B =
= Option B =


- Keep all files in a single directory but use two different namespaces.
== Keep all files in a single directory but use two different namespaces ==


For instance the file itkSample.h would look like :
For instance the file itkSample.h would look like :


namespace itk
  namespace itk
   {
   {
   namespace StatisticsDeprecated
   namespace StatisticsDeprecated
Line 38: Line 38:
- The ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK option redefines the unused namespace to be an anonymous namespace. The used namespace to "Statistics". For instance :
- 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
    #ifdef ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK
    #define StatisticsDeprecated Statistics
      #define StatisticsDeprecated Statisticshow to put code in a wiki
    #define StatisticsNew
      #define StatisticsNew
  #else
    #else
    #define StatisticsNew Statistics
      #define StatisticsNew Statistics
    #define StatisticsDeprecated
      #define StatisticsDeprecated
  #endif
    #endif


User code still looks the same :
User code still looks the same :


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

Revision as of 20:37, 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 Statisticshow to put code in a wiki 
     #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