//===-- deluxe/executionpolicies/Decimation.h -------------------*- C++ -*-===//
//
//                                 The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file deluxe/executionpolicies/Decimation.h
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2019
///
/// \brief Declaration of the *execution policy* *decimation*.
///
//===----------------------------------------------------------------------===//

#ifndef ROSA_LIB_DELUXE_EXECUTIONPOLICIES_DECIMATION_H
#define ROSA_LIB_DELUXE_EXECUTIONPOLICIES_DECIMATION_H

#include "rosa/deluxe/DeluxeExecutionPolicy.h"

namespace rosa {
namespace deluxe {

/// Implementation of the *execution policy* *decimation*.
///
/// \see \c rosa::deluxe::DeluxeExecutionPolicy::decimation()
class Decimation : public DeluxeExecutionPolicy {

  /// The rate of *decimation*.
  const size_t Rate;

  /// Counter of triggerings.
  size_t Cycle;

public:
  /// Constructor.
  ///
  /// \param D the rate of *decimation*
  Decimation(const size_t D);

  /// Tells if \p this object can handle the deluxe *unit* referred by \p H.
  ///
  /// *Decimation* can handle any *units*.
  ///
  /// \param H reference to the *unit* to check
  /// \param S the system owning the *unit* referred by \p H
  ///
  /// \return if \p this object can handle the *unit* referred by \p H
  bool canHandle(const AgentHandle H, const DeluxeSystem &S) const
      noexcept override;

  /// Tells if processing function should be executed on the current triggering.
  ///
  /// *Decimation* allows execution on each \c rosa::deluxe::Decimation::Rate
  /// <sup>th</sup> triggering (i.e., calling of the function), which is counted
  /// by \p this object in \c rosa::deluxe::Decimation::Cycle.
  ///
  /// \param InputChanged *ignored*
  ///
  /// \return if to execute processing function
  bool shouldProcess(const std::vector<bool> &InputChanged) noexcept override;

  /// Dumps \p this object into textual representation.
  ///
  /// \return textual representation of \p this object
  std::string dump(void) const noexcept override;
};

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

#endif // ROSA_LIB_DELUXE_EXECUTIONPOLICIES_DECIMATION_H
