Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.cpp

    rbe21fa ra483e4  
    4747
    4848  // set the new default
    49   RandomNumberDistributionFactory::getInstance().setCurrentType(params.distribution_type);
     49  RandomNumberDistributionFactory::getInstance().setCurrentType(params.distribution_type.get());
    5050  LOG(0, "STATUS: Distribution of random number generator is now: "
    5151      << RandomNumberDistributionFactory::getInstance().getCurrentTypeName());
     
    5555      RandomNumberDistributionFactory::getInstance().getPrototype().getParameterSet();
    5656  // set each parameter (that is not -1);
    57   if (!params.parameters.isDefault()) {
     57  {
     58    std::stringstream input(params.parameters.get());
    5859    RandomNumberDistribution_Parameters *currentparameters =
    5960        RandomNumberDistributionFactory::getInstance().getPrototype().getParameterSet();
    60     currentparameters->update(params.parameters);
    61     LOG(1, "INFO: Changing prototype's parameters to " << params.parameters << ".");
    62     RandomNumberDistributionFactory::getInstance().manipulatePrototype(*currentparameters);
     61    input >> *currentparameters;  // add new values on top
     62    if (!currentparameters->isDefault()) {
     63      LOG(1, "Changing prototype's parameters.");
     64      RandomNumberDistributionFactory::getInstance().manipulatePrototype(*currentparameters);
     65    }
    6366    delete currentparameters;
    6467  }
     
    7174  }
    7275
     76  std::stringstream output;
     77  output << *oldparameters;
    7378  CommandSetRandomNumbersDistributionState *newstate =
    74       new CommandSetRandomNumbersDistributionState(oldtype,*oldparameters,params);
     79      new CommandSetRandomNumbersDistributionState(oldtype,output.str(),params);
    7580  delete oldparameters;
    7681  return Action::state_ptr(newstate);
     
    9499
    95100  // set each parameter back (that is not -1);
    96   if (!state->old_parameters.isDefault()) {
    97     LOG(1, "INFO: Changing back prototype's parameters to " << state->old_parameters << ".");
    98     RandomNumberDistributionFactory::getInstance().manipulatePrototype(state->old_parameters);
     101  {
     102    std::stringstream input(state->old_parameters);
     103    RandomNumberDistribution_Parameters *currentparameters =
     104        RandomNumberDistributionFactory::getInstance().getPrototype().getParameterSet();
     105    input >> *currentparameters;
     106    if (!currentparameters->isDefault()) {
     107      LOG(1, "Changing prototype's parameters.");
     108      RandomNumberDistributionFactory::getInstance().manipulatePrototype(*currentparameters);
     109    }
     110    delete currentparameters;
    99111  }
    100112
     
    106118  }
    107119
     120  std::stringstream output;
     121  output << *newparameters;
    108122  CommandSetRandomNumbersDistributionState *newstate =
    109       new CommandSetRandomNumbersDistributionState(newtype,*newparameters,params);
     123      new CommandSetRandomNumbersDistributionState(newtype,output.str(),params);
    110124  delete newparameters;
    111125  return Action::state_ptr(newstate);
Note: See TracChangeset for help on using the changeset viewer.