Commit 9e7f1f63a6f78174326f79463075d3485b7a8fb6

Authored by Menouard AZIB
1 parent fe6b6521

Remplacer les strings par un enum

src/ParamOutputImpl/Plot/SpectroNode.hh
... ... @@ -100,7 +100,17 @@ namespace plot
100 100 value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_TYPE);
101 101 if (value)
102 102 {
103   - spectroPropsPtr->setBackgroundSubType((const char *)value);
  103 + const char *valueString = (const char *)value;
  104 +
  105 + if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_CHANNEL) == 0)
  106 + {
  107 + spectroPropsPtr->setBackgroundSubType(SpectroProperties::BackgroundSubType::BYCHANNEL);
  108 + }
  109 + else if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_FIXED_VALUE) == 0)
  110 + {
  111 + spectroPropsPtr->setBackgroundSubType(SpectroProperties::BackgroundSubType::FIXEDVALUE);
  112 + }
  113 +
104 114 xmlFree(value);
105 115 }
106 116  
... ...
src/ParamOutputImpl/Plot/SpectroProperties.hh
... ... @@ -29,6 +29,15 @@ namespace plot
29 29 class SpectroProperties : public DrawingProperties
30 30 {
31 31 public:
  32 + /**
  33 + * @brief An enum to represent different possible values of the background subtraction type
  34 + *
  35 + */
  36 + enum BackgroundSubType
  37 + {
  38 + BYCHANNEL,
  39 + FIXEDVALUE
  40 + };
32 41 friend std::ostream &operator<<(std::ostream &out_,
33 42 const SpectroProperties &lprop_);
34 43  
... ... @@ -89,7 +98,7 @@ namespace plot
89 98 * @brief the type of the background subtraction : By channel, Fixed value
90 99 *
91 100 */
92   - std::string backgroundSubType;
  101 + BackgroundSubType backgroundSubType;
93 102 /**
94 103 * @brief the value of the background subtraction
95 104 *
... ... @@ -206,12 +215,12 @@ namespace plot
206 215 _normalization = normalization;
207 216 }
208 217  
209   - void setBackgroundSubType(std::string backgroundSubType1)
  218 + void setBackgroundSubType(BackgroundSubType backgroundSubType1)
210 219 {
211 220 backgroundSubType = backgroundSubType1;
212 221 }
213 222  
214   - std::string getBackgroundSubType()
  223 + BackgroundSubType getBackgroundSubType()
215 224 {
216 225 return backgroundSubType;
217 226 }
... ...
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... ... @@ -1140,12 +1140,13 @@ namespace plot
1140 1140 //We get the background subtraction value given by the user
1141 1141 const double backgroundSubValue = pSpectro.getBackgroundSubValue();
1142 1142  
1143   - //If negative value then quit and do nothing
1144   - if (backgroundSubValue < 0) return;
  1143 + //If negative value then quit and do nothing
  1144 + if (backgroundSubValue < 0)
  1145 + return;
1145 1146  
1146 1147 const int len = matrixGrid.size();
1147 1148 //Channel subtraction
1148   - if (pSpectro.getBackgroundSubType().compare(BACKGROUND_SUB_TYPE_BY_CHANNEL) == 0)
  1149 + if (pSpectro.getBackgroundSubType() == SpectroProperties::BackgroundSubType::BYCHANNEL)
1149 1150 {
1150 1151 int indexChannelDim1 = -1;
1151 1152 int indexChannelDim2 = -1;
... ... @@ -1163,7 +1164,7 @@ namespace plot
1163 1164 matrixGrid[i].value -= values[i];
1164 1165 }
1165 1166 //Fixed value substraction
1166   - else if (pSpectro.getBackgroundSubType().compare(BACKGROUND_SUB_TYPE_BY_FIXED_VALUE) == 0)
  1167 + else if (pSpectro.getBackgroundSubType() == SpectroProperties::BackgroundSubType::FIXEDVALUE)
1167 1168 {
1168 1169 for (int i = 0; i < len; i++)
1169 1170 matrixGrid[i].value -= backgroundSubValue;
... ... @@ -1172,7 +1173,7 @@ namespace plot
1172 1173 {
1173 1174 std::stringstream lError;
1174 1175 lError << "Unknown background substracion type "
1175   - << pSpectro.getBackgroundSubType();
  1176 + << pSpectro.getBackgroundSubType();
1176 1177 BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
1177 1178 }
1178 1179  
... ...