#include "Parameters.h"

#include <cstddef>

const Parameters * Parameters::instance = NULL;
const FloatType Parameters::default_mutationRate = static_cast<FloatType>( 0.1 );
const FloatType Parameters::default_penalty = static_cast<FloatType>( 1.0 / 1024.0 );
const FloatType Parameters::default_reward = static_cast<FloatType>( 1.0 / 1024.0 );
const FloatType Parameters::default_convergenceThreshold = static_cast<FloatType>( 0.95 );
const unsigned Parameters::default_pollingInterval = 10u;

const Parameters * const Parameters::getInstance() {
  if ( !instance )
    instance = new Parameters();
  return instance;
}

void Parameters::deleteInstance() {
  if ( instance )
    delete instance;
  instance = NULL;
}

Parameters::Parameters() :
    mutationRate( default_mutationRate ),
    reward( default_reward ),
    penalty( default_penalty ),
    convergenceThreshold( default_convergenceThreshold ),
    pollingInterval( default_pollingInterval ) {
  /* Empty. */
}

FloatType Parameters::getMutationRate() const {
  return mutationRate;
}
void Parameters::setMutationRate( const FloatType& value ) {
  mutationRate = value;
}

FloatType Parameters::getReward() const {
  return reward;
}
void Parameters::setReward( const FloatType& value ) {
  reward = value;
}

FloatType Parameters::getPenalty() const {
  return penalty;
}
void Parameters::setPenalty( const FloatType& value ) {
  penalty = value;
}

FloatType Parameters::getConvergenceThreshold() const {
  return convergenceThreshold;
}
void Parameters::setConvergenceThreshold( const FloatType& value ) {
  convergenceThreshold = value;
}

unsigned Parameters::getPollingInterval() const {
  return pollingInterval;
}
void Parameters::setPollingInterval( const unsigned& value ) {
  pollingInterval = value;
}
