Tomato
OxFactoryOfCalculators.hxx
Go to the documentation of this file.
1 
7 #ifndef Tomato_OXFACTORYOFCalculators_HXX
8 #define Tomato_OXFACTORYOFCalculators_HXX
9 
11 #include "OxCalculatorT1Shmolli.h"
12 #ifdef USE_PRIVATE_NR2
13 #include "OxCalculatorT1ShmolliOriginal.h"
14 #include "OxCalculatorT2.h"
15 #include "OxCalculatorT2Truncation.h"
16 #include "OxCalculatorT2TruncationNoise.h"
17 #include "OxCalculatorT2Linear.h"
18 #endif
19 #include "TomatoOptions.h"
20 #include "OxFactoryOfCalculators.h"
21 
22 
23 namespace Ox {
24 
25  template < typename TYPE >
26  Calculator<TYPE>*
27  FactoryOfCalculators<TYPE>
28  ::newByFactory(TomatoOptions<TYPE> *opts){
29  Calculator<TYPE> *calculator = 0; //nullpointer
30  switch (opts->parameter_to_map){
31  case T1_MOLLI: {
32  calculator = new CalculatorT1WithSignCheck<TYPE>();
33  break;
34  }
35  case T1_SHMOLLI: {
36  calculator = new CalculatorT1Shmolli<TYPE>();
37  break;
38  }
39 #ifdef USE_PRIVATE_NR2
40  case T1_SHMOLLI_original: {
41  calculator = new CalculatorT1ShmolliOriginal<TYPE>();
42  break;
43  }
44  case T2_basic: {
45  calculator = new CalculatorT2<TYPE>();
46  break;
47  }
48  case T2_truncation: {
49  calculator = new CalculatorT2Truncation<TYPE>();
50  break;
51  }
52  case T2_truncation_noise: {
53  calculator = new CalculatorT2TruncationNoise<TYPE>();
54  break;
55  }
56  case T2_linear: {
57  calculator = new CalculatorT2Linear<TYPE>();
58  break;
59  }
60 #endif
61  default:
62  throw std::runtime_error("parameter_to_map not available");
63 
64  }
65 
66  calculator->setMeanCutOff(opts->mean_cut_off);
67 
68  return calculator;
69  }
70 
71  template < typename TYPE >
72  void
73  FactoryOfCalculators<TYPE>
74  ::disp(int parameter_to_map){
75 
76  if (parameter_to_map >= 0) {
77  printf("%-28s%-22s", " parameter_to_map: ", calculatorsTypeNames[parameter_to_map]);
78  }
79 
80  printf("options: [ ");
81 
82  for (int i = 0; i < lastCalculatorType+1; i++){
83  if(calculatorsAvailability[i]){
84  printf("%s ", calculatorsTypeNames[i]);
85  }
86  }
87 
88  printf("] \n");
89  }
90 
91 } // namespace Ox
92 
93 #endif //Tomato_OXFACTORYOFCalculators_HXX
Definition: OxCalculator.h:19