Ignore:
File:
1 edited

Legend:

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

    ra483e4 rbe21fa  
    4747
    4848  // set the new default
    49   RandomNumberDistributionFactory::getInstance().setCurrentType(params.distribution_type.get());
     49  RandomNumberDistributionFactory::getInstance().setCurrentType(params.distribution_type);
    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   {
    58     std::stringstream input(params.parameters.get());
     57  if (!params.parameters.isDefault()) {
    5958    RandomNumberDistribution_Parameters *currentparameters =
    6059        RandomNumberDistributionFactory::getInstance().getPrototype().getParameterSet();
    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     }
     60    currentparameters->update(params.parameters);
     61    LOG(1, "INFO: Changing prototype's parameters to " << params.parameters << ".");
     62    RandomNumberDistributionFactory::getInstance().manipulatePrototype(*currentparameters);
    6663    delete currentparameters;
    6764  }
     
    7471  }
    7572
    76   std::stringstream output;
    77   output << *oldparameters;
    7873  CommandSetRandomNumbersDistributionState *newstate =
    79       new CommandSetRandomNumbersDistributionState(oldtype,output.str(),params);
     74      new CommandSetRandomNumbersDistributionState(oldtype,*oldparameters,params);
    8075  delete oldparameters;
    8176  return Action::state_ptr(newstate);
     
    9994
    10095  // set each parameter back (that is not -1);
    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;
     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);
    11199  }
    112100
     
    118106  }
    119107
    120   std::stringstream output;
    121   output << *newparameters;
    122108  CommandSetRandomNumbersDistributionState *newstate =
    123       new CommandSetRandomNumbersDistributionState(newtype,output.str(),params);
     109      new CommandSetRandomNumbersDistributionState(newtype,*newparameters,params);
    124110  delete newparameters;
    125111  return Action::state_ptr(newstate);
Note: See TracChangeset for help on using the changeset viewer.