//===-- deluxe/executionpolicies/Decimation.cpp -----------------*- C++ -*-===//
//
//                                 The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file deluxe/executionpolicies/Decimation.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2019
///
/// \brief Implementation for deluxe/executionpolicies/Decimation.h.
///
//===----------------------------------------------------------------------===//

#include "Decimation.h"

#include <algorithm>

namespace rosa {
namespace deluxe {

Decimation::Decimation(const size_t D)
    : Rate(std::max<size_t>(D, 1)), Cycle(0) {}

bool Decimation::canHandle(const AgentHandle, const DeluxeSystem &) const
    noexcept {
  return true;
}

bool Decimation::shouldProcess(const std::vector<bool> &) noexcept {
  return (Cycle++ % Rate) == 0;
}

std::string Decimation::dump(void) const noexcept {
  return "Decimation with rate " + std::to_string(Rate);
}

} // End namespace deluxe
} // End namespace rosa
